forked from google-gemini/gemini-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare-npm-release.js
More file actions
67 lines (54 loc) · 1.85 KB
/
prepare-npm-release.js
File metadata and controls
67 lines (54 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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.');