在 Makelore 构建并预检静态发布产物
This commit is contained in:
29
scripts/verify-publish-runtime.mjs
Normal file
29
scripts/verify-publish-runtime.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { existsSync } from 'node:fs';
|
||||
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const prepare = spawnSync(process.execPath, [join(root, 'scripts', 'prepare-publish-runtime.mjs')], {
|
||||
cwd: root,
|
||||
encoding: 'utf8',
|
||||
shell: false,
|
||||
});
|
||||
if (prepare.status !== 0) {
|
||||
throw new Error(`Unable to stage fixed publish runtime: ${prepare.stderr || prepare.stdout}`);
|
||||
}
|
||||
const npmCli = join(root, 'build', 'publish-runtime', 'bin', 'npm-cli.js');
|
||||
const procLogPackage = join(root, 'build', 'publish-runtime', 'node_modules', 'proc-log', 'package.json');
|
||||
if (!existsSync(procLogPackage)) {
|
||||
throw new Error(`Staged publish runtime is missing proc-log: ${procLogPackage}`);
|
||||
}
|
||||
const result = spawnSync(process.execPath, [npmCli, '--version'], {
|
||||
cwd: root,
|
||||
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
|
||||
shell: false,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (result.status !== 0 || !/^11\.6\.2\s*$/.test(result.stdout)) {
|
||||
throw new Error(`Fixed publish npm runtime unavailable: ${result.stderr || result.stdout}`);
|
||||
}
|
||||
console.log(`publish npm runtime OK: ${result.stdout.trim()}`);
|
||||
Reference in New Issue
Block a user