fix(cli): build release-runtime before packaging#127
fix(cli): build release-runtime before packaging#127quanru wants to merge 3 commits intohappier-dev:devfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughAdds a workspace bundle manifest and refactors CLI build scripts to use it; introduces resolveBundledWorkspaceBuildEntry and reworks buildSharedDeps to iterate bundled packages; adds a contract test validating bundle metadata, entry resolution, and dist sync behavior with filesystem mocks. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a real packaging regression:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| apps/cli/scripts/buildSharedDeps.mjs | Core fix: exports bundledWorkspacePackages constant that now includes release-runtime, updates syncBundledWorkspaceDist default and main() build+verify loops to use it. All four packages confirmed to produce dist/index.js, so the new hardcoded verification path works today — but the assumption is implicit and undocumented. |
| apps/cli/scripts/buildSharedDeps.contract.test.mjs | New contract test that guards the bundledWorkspacePackages list value and verifies syncBundledWorkspaceDist correctly copies and writes package.json for release-runtime when its destination directories exist. Test logic is sound: existsSync mock returns true only for release-runtime paths, so deepEqual on copyCalls implicitly asserts no other packages are incorrectly synced. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[main called] --> B[Build loop: for each pkg in bundledWorkspacePackages]
B --> C1[runTsc agents/tsconfig.json]
C1 --> C2[runTsc cli-common/tsconfig.json]
C2 --> C3[runTsc protocol/tsconfig.json]
C3 --> C4[runTsc release-runtime/tsconfig.json]
C4 --> D[Verify loop: for each pkg in bundledWorkspacePackages]
D --> E1{packages/agents/dist/index.js exists?}
E1 -- No --> ERR[throw Error]
E1 -- Yes --> E2{packages/cli-common/dist/index.js exists?}
E2 -- No --> ERR
E2 -- Yes --> E3{packages/protocol/dist/index.js exists?}
E3 -- No --> ERR
E3 -- Yes --> E4{packages/release-runtime/dist/index.js exists?}
E4 -- No --> ERR
E4 -- Yes --> F[syncBundledWorkspaceDist]
F --> G[For each pkg: if dest dist exists, cpSync src→dest]
G --> H[For each pkg: if dest package.json exists, sanitize & write]
H --> I[Done]
Last reviewed commit: b6fa3ca
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/cli/scripts/buildSharedDeps.mjs (1)
8-8: Unify this package list withbundleWorkspaceDeps.mjs.
bundledWorkspacePackagesis now the build-time source of truth, butapps/cli/scripts/bundleWorkspaceDeps.mjs:15-37still keeps a separate hard-coded bundle manifest. A future bundled package addition can update one script and miss the other, which recreates the same packaging drift this PR is fixing. Consider extracting a shared manifest and deriving both build and bundle behavior from it.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/cli/scripts/buildSharedDeps.mjs` at line 8, The hard-coded package list in bundledWorkspacePackages is diverging from the list in bundleWorkspaceDeps.mjs; consolidate by extracting a single shared manifest (e.g., export a constant like bundledWorkspacePackages or workspaceBundleManifest) and have both apps/cli/scripts/buildSharedDeps.mjs and apps/cli/scripts/bundleWorkspaceDeps.mjs import/require that shared manifest so both derive their behavior from the same source; update references in both scripts to use the shared symbol (bundledWorkspacePackages or new workspaceBundleManifest) and remove the duplicate hard-coded array in bundleWorkspaceDeps.mjs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/cli/scripts/buildSharedDeps.contract.test.mjs`:
- Around line 15-20: The test currently hard-codes POSIX paths in the fake
existsSync check (using repoRoot and existsSync) which breaks on Windows; update
the expectations to be platform-neutral by constructing/normalizing the expected
paths with node's path utilities (e.g., use path.resolve or path.join and/or
path.normalize) instead of string literals, and apply the same change to both
occurrences (the existsSync arrays around repoRoot and the other block at lines
36–46) so the candidate comparison uses normalized paths on both sides.
---
Nitpick comments:
In `@apps/cli/scripts/buildSharedDeps.mjs`:
- Line 8: The hard-coded package list in bundledWorkspacePackages is diverging
from the list in bundleWorkspaceDeps.mjs; consolidate by extracting a single
shared manifest (e.g., export a constant like bundledWorkspacePackages or
workspaceBundleManifest) and have both apps/cli/scripts/buildSharedDeps.mjs and
apps/cli/scripts/bundleWorkspaceDeps.mjs import/require that shared manifest so
both derive their behavior from the same source; update references in both
scripts to use the shared symbol (bundledWorkspacePackages or new
workspaceBundleManifest) and remove the duplicate hard-coded array in
bundleWorkspaceDeps.mjs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1e48c178-9f0c-4af6-9fab-b6ea06a3deea
📒 Files selected for processing (2)
apps/cli/scripts/buildSharedDeps.contract.test.mjsapps/cli/scripts/buildSharedDeps.mjs
Summary
release-runtimein the shared workspace build list used byapps/cliWhy
@happier-dev/cliimports@happier-dev/release-runtimeat runtime and declares it as a bundled dependency, butapps/cli/scripts/buildSharedDeps.mjsonly builtagents,cli-common, andprotocol.That made CLI packaging depend on pre-existing local
packages/release-runtime/diststate. In practice this can make npm release artifacts nondeterministic and matches theERR_MODULE_NOT_FOUNDfailure reported in#103.Testing
node --test apps/cli/scripts/buildSharedDeps.contract.test.mjsnode --test apps/cli/scripts/prepack-script.test.mjsRefs #103
Summary by CodeRabbit
Tests
Chores