Skip to content

feat(build): Add prepare script for GitHub-based npm install#1053

Merged
yamadashy merged 2 commits intomainfrom
feat/add-prepare-script
Dec 31, 2025
Merged

feat(build): Add prepare script for GitHub-based npm install#1053
yamadashy merged 2 commits intomainfrom
feat/add-prepare-script

Conversation

@yamadashy
Copy link
Copy Markdown
Owner

Enable building repomix when installed directly from GitHub repository.

Changes

  • Add prepare script that runs npm run build

Why

This allows the website server (and other projects) to install repomix directly from GitHub's main branch:

"repomix": "github:yamadashy/repomix#main"

The prepare script is triggered when:

  • Installing from GitHub (e.g., npm install github:yamadashy/repomix#main)
  • Running npm install locally for development
  • Before npm publish (ensures fresh build)

This does not affect npm registry installs since the published tarball already includes the pre-built lib/ directory.

Checklist

  • Run npm run test
  • Run npm run lint

Enable building repomix when installed directly from GitHub repository.
The prepare script runs `npm run build` which is triggered when:
- Installing from GitHub (e.g., `npm install github:yamadashy/repomix#main`)
- Running `npm install` locally for development

This does not affect npm registry installs since the published tarball
already includes the pre-built lib/ directory.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 31, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Added a prepare npm script to package.json that automatically invokes the existing build script during npm lifecycle phases, such as before publishing or packing operations.

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Added "prepare": "npm run build" script entry to execute build automatically during npm preparation phases

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a prepare script to enable GitHub-based npm installations. It is specific, concise, and clearly conveys the primary purpose of the changeset.
Description check ✅ Passed The description is comprehensive and well-structured. It includes a clear explanation of changes, rationale, and when the prepare script is triggered. Both required checklist items are marked as completed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @yamadashy, 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 introduces a prepare script to the project's package.json file. The primary motivation is to facilitate seamless installation and building of the repomix package when it's referenced directly from its GitHub repository. This ensures that consumers installing the package from source always receive a pre-built version, improving developer experience and consistency across different installation methods.

Highlights

  • New prepare script: A prepare script has been added to the scripts section of package.json, which executes npm run build.
  • GitHub-based installation support: This change enables repomix to be automatically built when installed directly from its GitHub repository (e.g., npm install github:yamadashy/repomix#main).
  • Improved build consistency: The prepare script also ensures a fresh build during local development (npm install) and before npm publish, without affecting npm registry installs.

🧠 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a prepare script to package.json to enable building the project when installed directly from a GitHub repository. This is a well-reasoned change that correctly uses the prepare npm lifecycle script to improve the developer experience for users who need to install the package from a git source. The implementation is simple, correct, and I have no suggestions for improvement.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.34%. Comparing base (f66a5f3) to head (5e194e1).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1053   +/-   ##
=======================================
  Coverage   90.34%   90.34%           
=======================================
  Files         123      123           
  Lines        9457     9457           
  Branches     1709     1709           
=======================================
  Hits         8544     8544           
  Misses        913      913           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Dec 31, 2025

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5e194e1
Status: ✅  Deploy successful!
Preview URL: https://06ceeee7.repomix.pages.dev
Branch Preview URL: https://feat-add-prepare-script.repomix.pages.dev

View logs

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Dec 31, 2025

Code Review Summary

Overall Assessment: ✅ This PR looks good and is ready to merge.

Changes Reviewed

The PR adds a single line to package.json:

"prepare": "npm run build"

Analysis

Purpose & Correctness:

  • The prepare npm lifecycle script runs automatically during npm install when installing from a Git repository (GitHub)
  • This enables users to install repomix directly from GitHub: npm install github:yamadashy/repomix#main
  • The build step is necessary because the lib/ directory is in .gitignore and not committed to the repository

Why this is safe:

  1. npm registry installs unaffected: Published tarballs already include the pre-built lib/ directory via the files field in package.json, and prepare doesn't run when installing from the registry
  2. Development workflow: Running npm ci in CI already handles the build step - the CI workflow at .github/workflows/ci.yml explicitly runs the build command separately (line 228: ./node_modules/.bin/rimraf lib && ./node_modules/.bin/tsc ...)
  3. Clean builds: The build script includes rimraf lib which ensures a fresh build each time
Premortem Analysis
Scenario Risk Level Mitigation
Slower npm install for local dev Low Build runs on every fresh npm install, but this is standard behavior and expected by developers. The TypeScript build is fast.
CI failures due to double build None CI workflows use npm ci followed by explicit build commands. Having both is redundant but harmless - the second build simply overwrites the first.
Circular dependency during install None npm run build depends only on rimraf and tsc which are dev dependencies installed before prepare runs.
Fresh clone without lib/ None This is exactly what the PR solves - the prepare script ensures build happens automatically.

Recommendations

None - this is a clean, minimal change that follows npm best practices.

Checklist

  • Code follows project conventions
  • No security concerns
  • No performance issues
  • CI should pass (prepare script doesn't interfere with existing workflows)

🤖 Generated with Claude Code

Add --ignore-scripts to npm ci --omit=dev to prevent prepare script
from running, which would fail due to missing devDependencies (rimraf).
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Dec 31, 2025

Code Review Summary

Overall Assessment: ✅ This PR is well-implemented and ready to merge.

Changes Overview

File Change
package.json Added "prepare": "npm run build" script
.github/workflows/ci.yml Added --ignore-scripts flag to production dependencies install

Analysis

1. The prepare Script (package.json:22)

The prepare npm lifecycle script is the correct hook for this use case:

  • Runs automatically when installing from Git repositories (e.g., npm install github:yamadashy/repomix#main)
  • Runs before npm publish ensuring a fresh build
  • Does NOT run when installing from npm registry (published tarball already includes lib/)

2. CI Fix (ci.yml:230)

The --ignore-scripts flag is essential:

- run: npm ci --omit=dev
+ run: npm ci --omit=dev --ignore-scripts

Without this flag, npm ci --omit=dev would trigger the prepare script, which calls npm run build, which requires rimraf - a dev dependency that was just omitted. This would cause CI to fail.

Code Quality

  • ✅ Minimal, focused change
  • ✅ Follows npm best practices for lifecycle scripts
  • ✅ Well-documented PR description explaining the rationale
  • ✅ CI fix demonstrates thorough testing
Premortem Analysis
Scenario Risk Assessment
Double build during CI Low CI runs npm ci (triggers prepare) then explicit build. Second build overwrites first - harmless redundancy
Local dev slower Minimal Build runs on fresh npm install, but TypeScript builds are fast and this is expected behavior
Breaking existing installs None npm registry installs are unaffected since the tarball includes pre-built lib/
Circular dependency None Dev dependencies are installed before prepare runs

Verdict

No issues found. The implementation correctly uses npm lifecycle hooks and the CI fix properly handles the edge case with production-only installs.


🤖 Generated with Claude Code

@yamadashy yamadashy merged commit 5b02cb5 into main Dec 31, 2025
54 checks passed
@yamadashy yamadashy deleted the feat/add-prepare-script branch December 31, 2025 10:01
yamadashy added a commit that referenced this pull request Mar 8, 2026
The `prepare` script (`npm run build`) added in #1053 causes the Docker
build to fail because `npm ci --omit=dev` triggers it without
devDependencies (`rimraf`, `tsc`) being available. Adding
`--ignore-scripts` skips the unnecessary rebuild since the build output
already exists from the prior step.

Docker builds have been broken since 2025-12-31 (PR #1053).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant