Files
yishentu--claudian/scripts/check-release-version.mjs
wehub-resource-sync 2771cff92b
CI / lint (push) Failing after 1s
CI / typecheck (push) Failing after 2s
CI / build (push) Has been skipped
CI / test (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 12:22:56 +08:00

38 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
export function validateReleaseVersions({ tag, packageVersion, manifestVersion }) {
if (typeof tag !== 'string' || !/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(tag)) {
throw new Error(`Invalid or missing release tag: ${JSON.stringify(tag)}`);
}
if (tag !== packageVersion || tag !== manifestVersion) {
throw new Error(
`Release version mismatch: tag=${tag}, package.json=${packageVersion}, manifest.json=${manifestVersion}`,
);
}
}
function run() {
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(scriptDir, '..');
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf8'));
const manifestJson = JSON.parse(fs.readFileSync(path.join(rootDir, 'manifest.json'), 'utf8'));
validateReleaseVersions({
tag: process.argv[2],
packageVersion: packageJson.version,
manifestVersion: manifestJson.version,
});
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
try {
run();
} catch (error) {
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
process.exitCode = 1;
}
}