This commit modifies the packaging setup to allow the CLI to be
executed directly from its GitHub URL using `npx`, for example:
`npx https://github.com/google-gemini/gemini-cli` (once merged to main).
This is achieved without requiring the bundle to be checked into
the repository.
Key changes and motivations:
- Modify `scripts.prepare` to run `npm run bundle`:
Ensures the CLI bundle is generated automatically when `npx`
installs the package from a git URL. This replaces previous
approaches (e.g., using `prepack`) which were not consistently
triggered in the `npx` environment.
- Update `scripts.bundle` to use a direct path for `esbuild`
and externalize `sqlite3`:
Using `node_modules/.bin/esbuild` provides a more reliable way
to invoke the bundler. Externalizing `sqlite3` is crucial for
correctly handling its native addon, preventing runtime errors.
- Add `bin`, `files`, and root `sqlite3` dependency:
- The `bin` field defines the `gemini` command.
- The `files` array ensures the generated `bundle/` directory is
recognized by npm.
- `sqlite3` is added as a root dependency to ensure it's
installed by `npx` when `gemini-code` is fetched, allowing the
externalized module to be resolved.
These changes collectively ensure that the necessary build artifacts
are created on-the-fly during `npx` installation, providing a
seamless execution experience directly from the GitHub repository URL.
- Converted scripts/copy_files.cjs to use ES module syntax (renaming to copy_files.js).
- This change aligns with the project's preference for ES modules over CommonJS for better modernity and future-proofing.
- Updated eslint.config.js to remove the .cjs override.
- Adjusted scripts/build_package.sh to call the new .js file.
- Replaces the rsync command in the build_package.sh script with a
Node.js script (copy_files.cjs) to handle copying necessary files
(e.g., .md, .json, .sb) during the build process.
- Addresses an issue where the build would fail on systems
that do not have rsync installed (e.g., some Windows environments or
minimal Linux distributions) by using a Node.js script, providing a
cross-platform solution as Node.js is already a project dependency.
- Updates the ESLint configuration to correctly lint .cjs files as
CommonJS modules.
Fixes https://github.com/google-gemini/gemini-cli/issues/387
* Starting to move a lot of code into packages/server
* More of the massive refactor, builds and runs, some issues though.
* Fixing outstanding issue with double messages.
* Fixing a minor UI issue.
* Fixing the build post-merge.
* Running formatting.
* Addressing comments.
- This is based on existing expectations for TS code in Google-esc repos.
- First part of the change (we have not run any linter or formatting commands). After this changeset goes in I'll do a mass changeset push.
Fixes https://b.corp.google.com/issues/411384603