mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
* refactor(tooling): organize test runtime and maintenance owners * test(tooling): preserve relocated runtime fixture dependency edges * refactor(tooling): preserve xterm routing owner checks * ci(tooling): include routing owner in sparse checkout * test(tooling): preserve copied workflow dependency closures * fix(tooling): normalize hashed JSON assets in release parity * fix(tooling): distinguish asset aliases from literal references * fix(tooling): frame normalized asset reference payloads * fix(tooling): normalize decoded JSON asset references * refactor(tooling): organize build, CI and release owners * fix(tooling): align moved generator and workflow path contracts * fix(tooling): update generated plugin bundle owner banners * test(tooling): create relocated mobile verifier fixture directories * test(tooling): copy headless detector dependency closure * test(tooling): align native batch policy fixtures with owner path * fix(tooling): link moved reliability command to historical evidence * fix(tooling): preserve nested sandbox owners and canonical guide source * fix(tooling): target release version owners in checkout fixture
90 lines
2.7 KiB
JavaScript
90 lines
2.7 KiB
JavaScript
import { availableParallelism } from 'node:os'
|
|
import { createRequire } from 'node:module'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { runProcess } from '@orca/process-host'
|
|
import { describeProcessFailure } from '../tool-invocation/process-failure-message.mjs'
|
|
import { isDirectInvocation } from '../tool-invocation/script-entry-detection.mjs'
|
|
import { supportsTsrs } from '../typecheck/project-execution/tsrs-typecheck-compiler.mjs'
|
|
import {
|
|
resolveProjectCompiler,
|
|
resolveTypecheckBunExecutable,
|
|
runTypecheckProjects,
|
|
selectTypecheckCompiler
|
|
} from '../typecheck/project-execution/run-typecheck-projects-in-parallel.mjs'
|
|
|
|
const ROOT = fileURLToPath(new URL('../../..', import.meta.url))
|
|
const CONFIG = 'config/tsconfig.build.cli.json'
|
|
|
|
export async function buildCli({
|
|
root = ROOT,
|
|
outDir = 'out',
|
|
check = runTypecheckProjects,
|
|
execute = runProcess,
|
|
compiler = process.env.ORCA_CLI_BUILD_COMPILER ?? 'bun',
|
|
resolveBunExecutable = resolveTypecheckBunExecutable
|
|
} = {}) {
|
|
if (compiler !== 'bun' && compiler !== 'tsrs') {
|
|
throw new Error(`Invalid ORCA_CLI_BUILD_COMPILER: ${compiler}`)
|
|
}
|
|
const emitArguments = [
|
|
'-p',
|
|
CONFIG,
|
|
'--outDir',
|
|
outDir,
|
|
'--composite',
|
|
'false',
|
|
'--incremental',
|
|
'false'
|
|
]
|
|
if (compiler === 'tsrs') {
|
|
const manifest = createRequire(join(root, 'package.json')).resolve('tsrs/package.json')
|
|
const result = await execute({
|
|
program: process.execPath,
|
|
args: [join(dirname(manifest), 'bin', 'tsrs'), ...emitArguments, '--noEmitOnError'],
|
|
cwd: root,
|
|
stdio: 'inherit',
|
|
timeoutMs: null
|
|
})
|
|
if (result.code !== 0) {
|
|
throw new Error(`CLI compilation failed: ${describeProcessFailure(result)}`)
|
|
}
|
|
return
|
|
}
|
|
const selection = selectTypecheckCompiler('bun', {
|
|
root,
|
|
resolveBunExecutable,
|
|
fallbackHint: supportsTsrs() ? 'set ORCA_CLI_BUILD_COMPILER=tsrs' : null
|
|
})
|
|
const failures = await check({
|
|
...selection,
|
|
root,
|
|
projects: [{ config: CONFIG, heapGib: 2 }],
|
|
bunThreads: availableParallelism()
|
|
})
|
|
if (failures.length > 0) {
|
|
throw failures[0]
|
|
}
|
|
|
|
// Bun has checked this exact project; retain TypeScript's emitter without checking it twice.
|
|
const result = await execute({
|
|
program: process.execPath,
|
|
args: [resolveProjectCompiler(CONFIG, root), ...emitArguments, '--noCheck'],
|
|
cwd: root,
|
|
stdio: 'inherit',
|
|
timeoutMs: null
|
|
})
|
|
if (result.code !== 0) {
|
|
throw new Error(`CLI emission failed: ${describeProcessFailure(result)}`)
|
|
}
|
|
}
|
|
|
|
if (isDirectInvocation(import.meta.url, process.argv[1])) {
|
|
try {
|
|
await buildCli()
|
|
} catch (error) {
|
|
console.error(error.message)
|
|
process.exitCode = 1
|
|
}
|
|
}
|