Files
page-agent/scripts/build-libs.js
Simon 9af3a3f73e chore(scripts): add parallel build scripts
Replace sequential `npm run build --workspaces --if-present` with
concurrent execution via a reusable `parallelTask` utility. Full
`npm run build` now runs cleanup then all 7 build tasks in parallel.
2026-04-15 17:44:37 +08:00

26 lines
864 B
JavaScript

#!/usr/bin/env node
/**
* Equivalent to: npm run build --workspaces --if-present
*
* Reads the workspace list from root package.json, filters to those with a
* "build" script, and runs them all concurrently via parallelTask.
*/
import { readFileSync } from 'fs'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
import { parallelTask } from './parallel-task.js'
const rootDir = join(dirname(fileURLToPath(import.meta.url)), '..')
const rootPkg = JSON.parse(readFileSync(join(rootDir, 'package.json'), 'utf-8'))
const tasks = rootPkg.workspaces
.map((ws) => {
const dir = join(rootDir, ws)
const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8'))
return pkg.scripts?.build ? { label: pkg.name, command: 'npm run build', cwd: dir } : null
})
.filter(Boolean)
await parallelTask(tasks, { timeoutMs: 120_000 })