mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
feat: add prepublishOnly checks (#2052)
This commit is contained in:
@@ -46,12 +46,6 @@ if (!cliPackageJson.config) {
|
||||
}
|
||||
cliPackageJson.config.sandboxImageUri = containerImageUri;
|
||||
|
||||
// Remove 'prepublishOnly' from scripts if it exists
|
||||
if (cliPackageJson.scripts && cliPackageJson.scripts.prepublishOnly) {
|
||||
delete cliPackageJson.scripts.prepublishOnly;
|
||||
console.log('Removed prepublishOnly script from packages/cli/package.json');
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
cliPackageJsonPath,
|
||||
JSON.stringify(cliPackageJson, null, 2) + '\n',
|
||||
|
||||
45
scripts/prepublish.js
Normal file
45
scripts/prepublish.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
||||
const readmePath = path.resolve(process.cwd(), 'README.md');
|
||||
const licensePath = path.resolve(process.cwd(), 'LICENSE');
|
||||
|
||||
const errors = [];
|
||||
|
||||
// 1. Check for package.json and the 'repository' field
|
||||
// Required for publishing through wombat-dressing-room
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
errors.push(`Error: package.json not found in ${process.cwd()}`);
|
||||
} else {
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
if (packageJson.repository !== 'google-gemini/gemini-cli') {
|
||||
errors.push(
|
||||
`Error: The "repository" field in ${packageJsonPath} must be "google-gemini/gemini-cli".`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Check for README.md
|
||||
if (!fs.existsSync(readmePath)) {
|
||||
errors.push(`Error: README.md not found in ${process.cwd()}`);
|
||||
}
|
||||
|
||||
// 3. Check for LICENSE
|
||||
if (!fs.existsSync(licensePath)) {
|
||||
errors.push(`Error: LICENSE file not found in ${process.cwd()}`);
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
console.error('Pre-publish checks failed:');
|
||||
errors.forEach((error) => console.error(`- ${error}`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('Pre-publish checks passed.');
|
||||
Reference in New Issue
Block a user