fix(build): guard packaged renderer bundles
This commit is contained in:
parent
33463d3479
commit
320cee2d29
2 changed files with 28 additions and 2 deletions
|
|
@ -7,7 +7,12 @@ const rendererBundles = readdirSync(assetsDir)
|
|||
.sort();
|
||||
|
||||
if (rendererBundles.length === 0) {
|
||||
console.error('No renderer JavaScript bundles found under out/renderer/assets.');
|
||||
console.error(
|
||||
[
|
||||
'No renderer JavaScript bundles found under out/renderer/assets.',
|
||||
'Run `pnpm build` before packaging production artifacts.',
|
||||
].join('\n')
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,32 @@
|
|||
#!/usr/bin/env node
|
||||
import { spawn } from 'node:child_process';
|
||||
import { createRequire } from 'node:module';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { buildElectronBuilderInvocations } = require('./dist-invocations.cjs');
|
||||
|
||||
export { buildElectronBuilderInvocations };
|
||||
|
||||
async function runRendererBundleGuard() {
|
||||
const guardPath = fileURLToPath(new URL('../ci/verify-radix-renderer-bundle.mjs', import.meta.url));
|
||||
await new Promise((resolve, reject) => {
|
||||
const child = spawn(process.execPath, [guardPath], {
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
child.on('error', reject);
|
||||
child.on('exit', (code, signal) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
reject(new Error(`renderer bundle guard failed with ${signal ?? `exit code ${code}`}`));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function runElectronBuilder(args) {
|
||||
const cliPath = require.resolve('electron-builder/cli.js');
|
||||
await new Promise((resolve, reject) => {
|
||||
|
|
@ -41,6 +60,8 @@ async function main(argv) {
|
|||
return;
|
||||
}
|
||||
|
||||
await runRendererBundleGuard();
|
||||
|
||||
for (const invocation of invocations) {
|
||||
await runElectronBuilder(invocation.args);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue