Clean up cross-package build coupling

This commit is contained in:
weishu
2026-05-20 19:29:43 +08:00
parent 6759cf4657
commit 83795c0630
22 changed files with 557 additions and 343 deletions
+18
View File
@@ -16,6 +16,7 @@ import { join } from 'node:path';
const scriptDir = import.meta.dir;
const projectRoot = join(scriptDir, '..');
const repoRoot = join(projectRoot, '..');
const buildInfoPath = join(repoRoot, 'shared', 'src', 'buildInfo.ts');
// 解析参数
const args = process.argv.slice(2);
@@ -41,6 +42,22 @@ function run(cmd: string, cwd = projectRoot): void {
}
}
function updateBuildInfoVersion(nextVersion: string): void {
const content = readFileSync(buildInfoPath, 'utf-8');
const updated = content.replace(
/export const APP_VERSION = ['"][^'"]+['"]/,
`export const APP_VERSION = '${nextVersion}'`
);
if (updated === content) {
throw new Error(`Could not update APP_VERSION in ${buildInfoPath}`);
}
if (!dryRun) {
writeFileSync(buildInfoPath, updated);
}
}
async function runWithTimeoutRetry(cmd: string, cwd = projectRoot): Promise<void> {
const timeoutCmd = `timeout 60s ${cmd}`;
while (true) {
@@ -93,6 +110,7 @@ async function main(): Promise<void> {
if (!dryRun) {
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
}
updateBuildInfoVersion(version);
console.log(` ${oldVersion}${version}`);
// Step 2: Build all platform binaries (with embedded web assets)