mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
feat: add version consistency check to prepublish script
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@
|
|||||||
"publish:sandbox": "node scripts/publish-sandbox.js",
|
"publish:sandbox": "node scripts/publish-sandbox.js",
|
||||||
"publish:npm": "npm publish --workspaces ${NPM_PUBLISH_TAG:+--tag=$NPM_PUBLISH_TAG} ${NPM_DRY_RUN:+--dry-run}",
|
"publish:npm": "npm publish --workspaces ${NPM_PUBLISH_TAG:+--tag=$NPM_PUBLISH_TAG} ${NPM_DRY_RUN:+--dry-run}",
|
||||||
"publish:release": "npm run prepare:package && npm run build:packages && npm run build:sandbox:fast && npm run publish:sandbox && npm run publish:npm",
|
"publish:release": "npm run prepare:package && npm run build:packages && npm run build:sandbox:fast && npm run publish:sandbox && npm run publish:npm",
|
||||||
"prepublishOnly": "node scripts/prepublish.js",
|
"prepublishOnly": "node scripts/check-versions.js && node scripts/prepublish.js",
|
||||||
"release:version": "node scripts/version.js",
|
"release:version": "node scripts/version.js",
|
||||||
"push-release": "git push && git push --tags"
|
"push-release": "git push && git push --tags"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2025 Google LLC
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
function readPackageJson(dir) {
|
||||||
|
const p = path.join(dir, 'package.json');
|
||||||
|
return JSON.parse(readFileSync(p, 'utf-8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const root = readPackageJson('.');
|
||||||
|
const cli = readPackageJson('packages/cli');
|
||||||
|
const core = readPackageJson('packages/core');
|
||||||
|
|
||||||
|
const errors = [];
|
||||||
|
|
||||||
|
console.log('Checking version consistency...');
|
||||||
|
|
||||||
|
// 1. Check that all package versions are the same.
|
||||||
|
if (root.version !== cli.version || root.version !== core.version) {
|
||||||
|
errors.push(
|
||||||
|
`Version mismatch: root (${root.version}), cli (${cli.version}), core (${core.version})`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(`- All packages are at version ${root.version}.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Check that the cli's dependency on core matches the core version.
|
||||||
|
const coreDepVersion = cli.dependencies['@google/gemini-core'];
|
||||||
|
if (coreDepVersion !== `^${core.version}`) {
|
||||||
|
errors.push(
|
||||||
|
`CLI dependency on core is wrong: expected ^${core.version}, got ${coreDepVersion}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`- CLI dependency on core (${coreDepVersion}) is correct.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Check that the sandbox image tag matches the root version.
|
||||||
|
const imageUri = root.config.sandboxImageUri;
|
||||||
|
const imageTag = imageUri.split(':').pop();
|
||||||
|
if (imageTag !== root.version) {
|
||||||
|
errors.push(
|
||||||
|
`Sandbox image tag mismatch: expected ${root.version}, got ${imageTag}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(`- Sandbox image tag (${imageTag}) is correct.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.length > 0) {
|
||||||
|
console.error('\nVersion consistency checks failed:');
|
||||||
|
for (const error of errors) {
|
||||||
|
console.error(`- ${error}`);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('\nAll version checks passed!');
|
||||||
Reference in New Issue
Block a user