mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
feat(release): ship esbuild bundle in npm package (#19171)
Co-authored-by: Yuna Seol <yunaseol@gmail.com>
This commit is contained in:
7
.github/actions/publish-release/action.yml
vendored
7
.github/actions/publish-release/action.yml
vendored
@@ -192,6 +192,13 @@ runs:
|
|||||||
INPUTS_CLI_PACKAGE_NAME: '${{ inputs.cli-package-name }}'
|
INPUTS_CLI_PACKAGE_NAME: '${{ inputs.cli-package-name }}'
|
||||||
INPUTS_A2A_PACKAGE_NAME: '${{ inputs.a2a-package-name }}'
|
INPUTS_A2A_PACKAGE_NAME: '${{ inputs.a2a-package-name }}'
|
||||||
|
|
||||||
|
- name: '📦 Prepare bundled CLI for npm release'
|
||||||
|
if: "inputs.npm-registry-url != 'https://npm.pkg.github.com/'"
|
||||||
|
working-directory: '${{ inputs.working-directory }}'
|
||||||
|
shell: 'bash'
|
||||||
|
run: |
|
||||||
|
node ${{ github.workspace }}/scripts/prepare-npm-release.js
|
||||||
|
|
||||||
- name: 'Get CLI Token'
|
- name: 'Get CLI Token'
|
||||||
uses: './.github/actions/npm-auth-token'
|
uses: './.github/actions/npm-auth-token'
|
||||||
id: 'cli-token'
|
id: 'cli-token'
|
||||||
|
|||||||
67
scripts/prepare-npm-release.js
Normal file
67
scripts/prepare-npm-release.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2025 Google LLC
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
|
const rootDir = process.cwd();
|
||||||
|
|
||||||
|
function readJson(filePath) {
|
||||||
|
return JSON.parse(fs.readFileSync(path.resolve(rootDir, filePath), 'utf-8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeJson(filePath, data) {
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.resolve(rootDir, filePath),
|
||||||
|
JSON.stringify(data, null, 2),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy bundle directory into packages/cli
|
||||||
|
const sourceBundleDir = path.resolve(rootDir, 'bundle');
|
||||||
|
const destBundleDir = path.resolve(rootDir, 'packages/cli/bundle');
|
||||||
|
|
||||||
|
if (fs.existsSync(sourceBundleDir)) {
|
||||||
|
fs.rmSync(destBundleDir, { recursive: true, force: true });
|
||||||
|
fs.cpSync(sourceBundleDir, destBundleDir, { recursive: true });
|
||||||
|
console.log('Copied bundle/ directory to packages/cli/');
|
||||||
|
} else {
|
||||||
|
console.error(
|
||||||
|
'Error: bundle/ directory not found at project root. Please run `npm run bundle` first.',
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inherit optionalDependencies from root package.json, excluding dev-only packages.
|
||||||
|
const rootPkg = readJson('package.json');
|
||||||
|
const optionalDependencies = { ...(rootPkg.optionalDependencies || {}) };
|
||||||
|
delete optionalDependencies['gemini-cli-devtools'];
|
||||||
|
|
||||||
|
// Update @google/gemini-cli package.json for bundled npm release
|
||||||
|
const cliPkgPath = 'packages/cli/package.json';
|
||||||
|
const cliPkg = readJson(cliPkgPath);
|
||||||
|
|
||||||
|
cliPkg.files = ['bundle/'];
|
||||||
|
cliPkg.bin = {
|
||||||
|
gemini: 'bundle/gemini.js',
|
||||||
|
};
|
||||||
|
|
||||||
|
delete cliPkg.dependencies;
|
||||||
|
delete cliPkg.devDependencies;
|
||||||
|
delete cliPkg.scripts;
|
||||||
|
delete cliPkg.main;
|
||||||
|
delete cliPkg.config;
|
||||||
|
|
||||||
|
cliPkg.optionalDependencies = optionalDependencies;
|
||||||
|
|
||||||
|
writeJson(cliPkgPath, cliPkg);
|
||||||
|
|
||||||
|
console.log('Updated packages/cli/package.json for bundled npm release.');
|
||||||
|
console.log(
|
||||||
|
'optionalDependencies:',
|
||||||
|
JSON.stringify(optionalDependencies, null, 2),
|
||||||
|
);
|
||||||
|
console.log('Successfully prepared packages for npm release.');
|
||||||
Reference in New Issue
Block a user