Repository navigation
chore(scripts): add cross-platform clean:build and clean:build:full - #768
Conversation
|
Warning Review limit reached
Next review available in: 31 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdded cross-platform ChangesBuild cleanup workflow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Developer
participant clean-build.mjs
participant Filesystem
participant RestorationCommands
Developer->>clean-build.mjs: Run cleanup command
clean-build.mjs->>Filesystem: Resolve and detect cleanup targets
clean-build.mjs->>Developer: Show plan and request confirmation
Developer->>clean-build.mjs: Confirm or use --yes
clean-build.mjs->>Filesystem: Remove selected targets
clean-build.mjs->>RestorationCommands: Reinstall dependencies and rebuild sidecar
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (2)
scripts/clean-build.mjs-88-100 (1)
88-100: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winRoute the plan through the supplied
stdout.
runCleanacceptsio.stdout, butprintPlanwrites to the global console. Callers cannot capture the plan through the injected stream, and the tests still emit plan output despite passingsilent.Pass
stdouttoprintPlanand usestdout.write. As per path instructions, useconsole.debug/warn/errorrather than bareconsole.log.Also applies to: 163-163
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/clean-build.mjs` around lines 88 - 100, Update printPlan to accept the supplied stdout stream and write all plan messages through stdout.write instead of the global console, then pass runClean’s io.stdout when invoking printPlan. Preserve the existing plan content and use console.debug/warn/error only where console output remains necessary, avoiding bare console.log.Source: Path instructions
scripts/clean-build.mjs-83-84 (1)
83-84: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCheck allowlisted paths without following broken symlinks.
existsSyncresolves symlink targets, so a dangling allowlisted link is skipped by the cleanup even though the script should remove symlinks as links. Use anlstatSynchelper atscripts/clean-build.mjs83, 141, and 172 that returns false only forENOENT.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/clean-build.mjs` around lines 83 - 84, Replace existsSync checks in the tier2Present logic and the corresponding checks around cleanup paths with an lstatSync-based helper that treats existing symlinks, including dangling links, as present and returns false only for ENOENT. Reuse this helper at the locations associated with tier2Present and the cleanup checks rather than following symlink targets.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/clean-build.mjs`:
- Around line 55-70: Update resolvePaths to inspect each existing path component
between rootDir and entry.abs with lstatSync, rejecting any symbolic-link
ancestor before returning resolved entries for deletion; retain the existing
lexical repository-boundary check. Add a regression test covering a symlinked
reticulum-sidecar directory that points outside rootDir and verifies resolution
is rejected.
- Around line 178-192: The restoration branch in runClean must signal failure
when either pnpm install or the sidecar rebuild fails. After logging the
failure, throw or otherwise return a failure that makes the direct CLI exit
nonzero, while preserving the removed state for rollback; add tests covering
each failed restoration command.
- Around line 133-137: Update runCmd to resolve pnpm to a Windows-compatible
executable before calling spawnSync with shell: false, or route Windows commands
through cmd.exe /c while preserving existing behavior on other platforms. Ensure
restore commands remain runnable after node_modules removal, and add a Windows
smoke test covering pnpm invocation.
---
Other comments:
In `@scripts/clean-build.mjs`:
- Around line 88-100: Update printPlan to accept the supplied stdout stream and
write all plan messages through stdout.write instead of the global console, then
pass runClean’s io.stdout when invoking printPlan. Preserve the existing plan
content and use console.debug/warn/error only where console output remains
necessary, avoiding bare console.log.
- Around line 83-84: Replace existsSync checks in the tier2Present logic and the
corresponding checks around cleanup paths with an lstatSync-based helper that
treats existing symlinks, including dangling links, as present and returns false
only for ENOENT. Reuse this helper at the locations associated with tier2Present
and the cleanup checks rather than following symlink targets.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Pro Plus
Run ID: 4b38ff69-a712-4e55-a992-91ec16239b34
📒 Files selected for processing (4)
docs/development-environment.mdpackage.jsonscripts/clean-build.mjsscripts/clean-build.test.mjs
| if (reinstall.install && removed.length > 0) { | ||
| stdout.write('Restoring working environment…\n'); | ||
| const installOk = run(['pnpm', 'install'], rootDir) === 0; | ||
| let sidecarOk = true; | ||
| if (installOk && reinstall.sidecar) { | ||
| sidecarOk = run(['pnpm', 'run', 'reticulum:sidecar:build'], rootDir) === 0; | ||
| } | ||
| if (!installOk) { | ||
| stderr.write('clean-build: `pnpm install` failed — dependencies not restored.\n'); | ||
| } else if (!sidecarOk) { | ||
| stderr.write( | ||
| 'clean-build: sidecar rebuild failed (is cargo installed?) — Reticulum may be unavailable.\n', | ||
| ); | ||
| } | ||
| return { removed, reinstalled: installOk && sidecarOk }; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Return a failure status when restoration fails.
When pnpm install or the sidecar build fails, runClean returns normally. The direct CLI path exits with status 0 even though node_modules was removed and the environment was not restored.
Throw after logging the restoration failure. Preserve the removed state for rollback, or document and implement an explicit recovery path. Add failure-path tests.
As per path instructions, preserve state on command failure.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/clean-build.mjs` around lines 178 - 192, The restoration branch in
runClean must signal failure when either pnpm install or the sidecar rebuild
fails. After logging the failure, throw or otherwise return a failure that makes
the direct CLI exit nonzero, while preserving the removed state for rollback;
add tests covering each failed restoration command.
Source: Path instructions
Summary
Adds a cross-platform build-artifact cleanup helper (
scripts/clean-build.mjs) for linux / darwin / win32, wired as two pnpm commands, replacing the ad-hoc habit of manuallyrm -rf-ing build output.pnpm run clean:build— shallow: removes build dists, test output, and caches (dist,dist-electron,release,coverage,.vitest-reports,test-results,playwright-report,.eslintcache) while keepingnode_modules/and the Reticulum sidecar, sopnpm run dev/pnpm startand Reticulum remain functional.pnpm run clean:build:full— full: additionally removesnode_modules,reticulum-sidecar/target/(~22G), and the bundled sidecar binary, then restores a working environment viapnpm install+pnpm run reticulum:sidecar:build.Safety features
Proceed? [y/N](default N) before deleting;-y/--yesskips the prompt but still echoes the plan.-yaborts instead of hanging.Testing (verified manually)
pnpm run clean:build -- -yremoved only the 8 tier-1 artifacts and preservednode_modules/+reticulum-sidecar/target/.pnpm run clean:build:full -- -yremovednode_modules/+target/, thenpnpm install(native modules rebuilt for Electron 41.10.3) and a fresh sidecar build (40.3s) restored the working env. Dev resolves the sidecar fromreticulum-sidecar/target/debug(reticulum-sidecar-path.ts), so Reticulum works.scripts/clean-build.test.mjs: 10/10 PASS; ESLintno issues; Prettier + markdownlint clean.Files
scripts/clean-build.mjs,scripts/clean-build.test.mjs(new)package.json(addsclean:build,clean:build:full)docs/development-environment.md(Maintenance block, Setup/helpers table, explainer prose)Summary by CodeRabbit
New Features
--yesoption for automation.Documentation
Tests