feat(core): add staged self-updates and unify application version

This commit is contained in:
手瓜一十雪 committed 2026-10-18 12:50:11 +08:00
1 parent c54aeffc77
commit 5032cbb8c0
45 files changed
+1860 -165

No files matched your search

+2 -6
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env node
// Sync the `version` field across the monorepo root and every workspace package.
// Usage: pnpm bump <version> (e.g. pnpm bump 0.2.0)
// Usage: pnpm bump [version]; without an argument, sync the root version.
import { readFile, writeFile, readdir } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import path from 'node:path';
@@ -9,11 +9,7 @@ import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(__dirname, '..');
const nextVersion = process.argv[2];
if (!nextVersion) {
console.error('Usage: pnpm bump <version> (e.g. pnpm bump 0.2.0)');
process.exit(1);
}
const nextVersion = process.argv[2] ?? JSON.parse(await readFile(path.join(repoRoot, 'package.json'), 'utf8')).version;
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(nextVersion)) {
console.error(`Invalid semver: "${nextVersion}"`);
process.exit(1);
+13
View File
@@ -11,8 +11,21 @@ if (!fs.statSync(entryPoint, { throwIfNoEntry: false })?.isFile()) {
throw new Error(`release entry point must be at the archive root: ${entryPoint}`);
}
const release = JSON.parse(fs.readFileSync(path.join(root, 'release.json'), 'utf8'));
const runtimePackage = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
if (release.version !== runtimePackage.version) {
throw new Error('release version does not match its runtime package');
}
const actualEntries = fs.readdirSync(root).filter(name => !['node', 'node.exe'].includes(name));
if (JSON.stringify([...release.entries].sort()) !== JSON.stringify(actualEntries.sort())) {
throw new Error('release file manifest does not match the packaged files');
}
const sqliteRoot = path.join(root, 'native', 'sqlite');
const sqlite = JSON.parse(fs.readFileSync(path.join(sqliteRoot, 'manifest.json'), 'utf8'));
if (release.target !== sqlite.target) {
throw new Error('release target does not match its native artifacts');
}
if (sqlite.package !== '@appthreat/sqlite3' || sqlite.version !== '9.1.0' || sqlite.nativeInterface !== 1
|| !/^(win32|linux|darwin)-(x64|arm64)$/.test(sqlite.target)) {
throw new Error('release has an invalid SQLite native manifest');