refactor(config): Replace prepare with prepack lifecycle script#1215
refactor(config): Replace prepare with prepack lifecycle script#1215
Conversation
The `prepare` script runs on `npm ci` and `npm install`, which caused Docker and CI failures when devDeps (rimraf, tsc) were unavailable. `prepack` only runs on `npm pack`, `npm publish`, and git dependency install — avoiding the issue while still supporting the website/server git dependency requirement. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue causing Docker and CI build failures by refactoring the project's npm lifecycle scripts. By switching from the "prepare" script to "prepack", the build process is now correctly aligned with dependency installation phases, preventing premature execution of build steps that rely on development dependencies. This ensures a more robust and reliable build environment across various deployment scenarios without impacting other essential workflows. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
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 (1)
📝 WalkthroughWalkthroughThe "prepare" npm lifecycle script in package.json has been replaced with a "prepack" script. Both execute the same "npm run build" command but are triggered at different stages in the npm lifecycle—prepare runs during install, while prepack runs before package creation. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
Deploying repomix with
|
| Latest commit: |
e27f719
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f6fa9ae9.repomix.pages.dev |
| Branch Preview URL: | https://refactor-prepare-to-prepack.repomix.pages.dev |
There was a problem hiding this comment.
Code Review
This pull request replaces the prepare npm lifecycle script with prepack. This is a well-reasoned change to fix build failures in CI and Docker environments by preventing the build script from running during a standard npm install. The prepack script is the appropriate choice here, as it correctly triggers the build for publishing and git dependency installations without affecting production installs. The change is correct and effectively resolves the issue described.
Note: Security Review has been skipped due to the limited scope of the PR.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1215 +/- ##
=======================================
Coverage 87.14% 87.14%
=======================================
Files 115 115
Lines 4310 4310
Branches 998 998
=======================================
Hits 3756 3756
Misses 554 554 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR Review:
|
| Claim | Verified |
|---|---|
Dockerfiles have explicit npm run build |
Yes — Dockerfile line 15 |
| CI workflows have explicit build steps | Yes — npm-publish.yml, ci.yml all have explicit npm run build |
website/server uses git dependency github:yamadashy/repomix#main |
Yes — website/server/package.json |
No downstream consumers rely on prepare auto-build |
Yes — all paths have explicit builds |
The lifecycle behavior table in the PR description is accurate. For git dependencies, npm internally uses npm pack after cloning, so prepack correctly fires during that flow.
Minor Observations
Developer workflow change (informational, no action needed)
With prepare, running npm install after cloning the repo would automatically trigger npm run build. With prepack, developers will need to run npm run build explicitly after npm install.
This is a minor change to the local development setup flow documented in CONTRIBUTING.md (which shows git clone → npm install → npm run repomix). However, since npm run repomix already includes an explicit npm run build step ("repomix": "node --run build && ..."), this doesn't actually break the documented workflow. The only case affected would be developers who expected the project to be pre-built after npm install and tried to run tests or import from lib/ directly — but this is uncommon enough that it doesn't warrant concern.
Premortem Analysis
Potential failure scenarios and mitigations
-
Git dependency install for
website/server: Thewebsite/server/package.jsonuses"repomix": "github:yamadashy/repomix#main". When npm installs this git dependency, it clones the repo, runsnpm ci, then runsnpm pack— which triggersprepack. This flow is correct and the build will run. Risk: Low. -
CI regression: All CI workflows (
ci.yml,npm-publish.yml,docker.yml) have explicitnpm run buildsteps before any actions that depend on built artifacts. Risk: None. -
Docker build regression: The main
Dockerfilerunsnpm ci && npm run build && npm link && npm prune --omit=dev. The explicitnpm run buildensures this works regardless of lifecycle hooks. Risk: None. -
npm publishregression: Thenpm-publish.ymlworkflow has an explicitnpm run buildstep, andprepackwould also fire beforenpm pack/npm publish. Risk: None — double-covered. -
Third-party consumers using
npm install github:yamadashy/repomix: These consumers rely on npm's git dependency flow which triggersprepackvia the internalnpm packstep. Risk: None.
Verdict
Clean change, well-documented rationale, no risks identified. This properly addresses the root cause that PR #1213 worked around.
Review by Claude
Replace
preparewithprepacklifecycle script in package.json to fix the root cause of Docker and CI build failures.Background
The
preparescript (npm run build) runs onnpm installandnpm ci, which caused failures when devDependencies (rimraf, tsc) were unavailable — notably during Docker builds and CI production dependency steps. PR #1213 worked around this by switching tonpm prune --omit=dev, but the root cause remained.Why
prepackprepareprepacknpm install/npm cinpm pack/npm publishprepackdoes NOT run onnpm ci→ Docker/CI issue resolved at the rootprepackDOES run on git dependency install →website/serverrequirement ("repomix": "github:yamadashy/repomix#main") still satisfiedprepackDOES run onnpm pack/npm publish→ release workflow unaffectednpm run buildsteps, so no downstream changes neededChecklist
npm run testnpm run lint🤖 Generated with Claude Code