chore(cli): bundle with bun target node and publish from staged dir#2637
chore(cli): bundle with bun target node and publish from staged dir#2637RomanHotsiy wants to merge 12 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 4077b74 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
📦 A new experimental 🧪 version v0.0.0-snapshot.1772635755 of Redocly CLI has been published for testing. Install with NPM: npm install @redocly/cli@0.0.0-snapshot.1772635755
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1772635755
# or
npm install @redocly/respect-core@0.0.0-snapshot.1772635755 |
tatomyr
left a comment
There was a problem hiding this comment.
Had a brief look. Will give it another pass later.
| import { performance } from 'node:perf_hooks'; | ||
| import { default as redoc } from 'redoc'; | ||
|
|
||
| import packageJson from '../../../package.json' with { type: 'json' }; |
There was a problem hiding this comment.
It probably makes more sense to import it from utils/package.js.
tests/e2e/helpers.ts
Outdated
| } | ||
|
|
||
| function cleanUpStyledComponentWarnings(str: string): string { | ||
| return str.replace(/^styled-components: it looks like an unknown prop .*?(?:\r?\n|$)/gm, ''); |
There was a problem hiding this comment.
I don't see the message anywhere. Why do wee need this?
scripts/release-publish.mjs
Outdated
| const result = spawnSync(command, args, { | ||
| cwd: rootDir, | ||
| stdio: 'inherit', | ||
| shell: process.platform === 'win32', |
There was a problem hiding this comment.
Are we going to publish from Win?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1b232c3. Configure here.
tatomyr
left a comment
There was a problem hiding this comment.
Left a minor comment. Please also check this comment: #2637 (comment).
Otherwise LGTM.
Co-authored-by: Roman Hotsiy <gotsijroman@gmail.com>

What/Why/How?
bun build --target node) instead of the previous TypeScript-only compile flow.createRequire('../../package.json')patterns with static JSON imports in CLI runtime paths.build-docstemplate fallback so bundled artifacts do not depend ontemplate.hbsbeing present as a filesystem asset.package.jsonmutation/restore with a staged publish directory (packages/cli/.publish) andpublishConfig.directorysochangeset publishpublishes from the staged manifest/artifacts.bin/cli.js, bundledlib/index.js,README.md,LICENSE, and a strippedpackage.json(no deps/devDeps/scripts).Reference
Testing
npm --workspace packages/cli run compilenode packages/cli/lib/index.js --helpnpm run typechecknpm run pack:preparenpm run release(no unpublished packages in this run; verified publish-dir prepare/cleanup path)Screenshots (optional)
Check yourself
Security
Note
Medium Risk
Changes the CLI build and release/publish pipeline (bundling + staged publish directory), which could impact install/runtime behavior and npm publish correctness, but does not alter security-sensitive logic.
Overview
CLI distribution is reworked to ship as a Bun-bundled Node target:
packages/clinow buildslib/index.jsviabun build(with annpx bunfallback), and CI/e2e workflows install Bun and run a bundle step before tests.Publishing/packing now happens from a staged directory: a new
prepare-publish-dirscript generatespackages/cli/.publishwith only the bin entrypoint, bundled output, README/LICENSE, and a minimalpackage.json; release, snapshot publish, and local pack scripts are updated to publish/pack that directory and then clean it up.Bundling compatibility fixes: runtime
package.jsonaccess is switched to a static JSON import (exposingredocVersion), andbuild-docsembeds a default Handlebars template fallback whentemplate.hbsisn’t available as a file. Docker build no longer manually copies the template, and smoke fixtures are updated accordingly.Reviewed by Cursor Bugbot for commit 4077b74. Bugbot is set up for automated code reviews on this repo. Configure here.