feat(cli): build infra and plugins before dev-core (#3470)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import type { ChildProcess } from 'node:child_process';
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import { existsSync } from 'node:fs';
|
import { existsSync } from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
@@ -93,6 +94,51 @@ flags.channel = buildFlags.channel as any;
|
|||||||
flags.coverage = buildFlags.coverage;
|
flags.coverage = buildFlags.coverage;
|
||||||
|
|
||||||
watchI18N();
|
watchI18N();
|
||||||
|
|
||||||
|
function awaitChildProcess(child: ChildProcess): Promise<number> {
|
||||||
|
return new Promise<number>((resolve, reject) => {
|
||||||
|
const handleExitCode = (code: number | null) => {
|
||||||
|
if (code) {
|
||||||
|
reject(
|
||||||
|
new Error(
|
||||||
|
`Child process at ${
|
||||||
|
(child as any).cwd
|
||||||
|
} fails: ${child.spawnargs.join(' ')}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
resolve(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
child.on('error', () => handleExitCode(child.exitCode));
|
||||||
|
child.on('exit', code => handleExitCode(code));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Build:infra
|
||||||
|
await awaitChildProcess(
|
||||||
|
spawn('yarn', ['build:infra'], {
|
||||||
|
cwd,
|
||||||
|
stdio: 'inherit',
|
||||||
|
shell: true,
|
||||||
|
env: process.env,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Build:plugins
|
||||||
|
await awaitChildProcess(
|
||||||
|
spawn('yarn', ['build:plugins'], {
|
||||||
|
cwd,
|
||||||
|
stdio: 'inherit',
|
||||||
|
shell: true,
|
||||||
|
env: process.env,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Start webpack
|
||||||
|
await awaitChildProcess(
|
||||||
spawn(
|
spawn(
|
||||||
'node',
|
'node',
|
||||||
[
|
[
|
||||||
@@ -111,4 +157,9 @@ spawn(
|
|||||||
shell: true,
|
shell: true,
|
||||||
env: process.env,
|
env: process.env,
|
||||||
}
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error during build:', error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user