refactor: derive optionalDependencies from root instead of hardcoding

Instead of maintaining a hardcoded allowlist of native modules,
copy all optionalDependencies from the root package.json and
exclude only gemini-cli-devtools. Less brittle if new native
deps are added in the future.
This commit is contained in:
Gen Zhang
2026-02-15 20:14:26 +00:00
committed by Yuna Seol
parent 5cc2c27e7b
commit f88dc839e5
+3 -20
View File
@@ -35,27 +35,10 @@ if (fs.existsSync(sourceBundleDir)) {
process.exit(1);
}
// Read native module versions from root package.json
// Inherit optionalDependencies from root package.json, excluding dev-only packages.
const rootPkg = readJson('package.json');
const rootOptional = rootPkg.optionalDependencies || {};
const nativeModules = [
'@lydell/node-pty',
'@lydell/node-pty-darwin-arm64',
'@lydell/node-pty-darwin-x64',
'@lydell/node-pty-linux-x64',
'@lydell/node-pty-win32-arm64',
'@lydell/node-pty-win32-x64',
'keytar',
'node-pty',
];
const optionalDependencies = {};
for (const mod of nativeModules) {
if (rootOptional[mod]) {
optionalDependencies[mod] = rootOptional[mod];
}
}
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';