Files
orca/config/scripts/orcad-windows-process-tree.mjs
T
OrcaWin 6fc3cdcad6 Bundle Bun for headless Orca and profile persistence (#22635)
Bundle a pinned, verified Bun runtime for headless Orca so existing Node launch commands can hand off before opening a profile. Keep desktop execution on Electron.

Add the Bun SQLite adapter and terminal backend, bounded shutdown, process inspection and cross-platform artifact qualification. Keep future managed SSH deployment separate from current production launch paths.
2026-09-25 22:49:06 -07:00

49 lines
1.6 KiB
JavaScript

import { copyFileSync, lstatSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join } from 'node:path'
import { ORCAD_WINDOWS_PROCESS_TREE_FILENAME } from '../../src/shared/orcad-artifacts.ts'
import {
inspectWindowsProcessTreeAddon,
windowsProcessTreeAddonPath
} from './windows-process-tree-gyp-rebuild.mjs'
const { PE_MACHINE, describePeMachine, readPeMachine } = createRequire(import.meta.url)(
'./windows-pe-machine.cjs'
)
export function stageOrcadWindowsProcessTree(
root,
outputDir,
target,
host = { platform: process.platform, arch: process.arch }
) {
if (!target.startsWith('win32-')) {
return
}
const arch = target.slice('win32-'.length)
let source = join(
root,
'.build',
'windows-process-tree',
arch,
ORCAD_WINDOWS_PROCESS_TREE_FILENAME
)
// Ordinary Windows installs already compile this N-API addon for the host.
if (target === `${host.platform}-${host.arch}` && !lstatSync(source, { throwIfNoEntry: false })) {
source = windowsProcessTreeAddonPath(
join(root, 'node_modules', '@vscode', 'windows-process-tree')
)
}
if (inspectWindowsProcessTreeAddon(source) !== 'clean') {
throw new Error(
`Orcad ${target} requires a patched process reader. On Windows, run: ` +
`node config/scripts/build-windows-process-tree-relay-addon.mjs --arch=${arch}`
)
}
const machine = readPeMachine(source)
if (machine !== PE_MACHINE[arch]) {
throw new Error(`Orcad ${target} process reader has ${describePeMachine(machine)}`)
}
copyFileSync(source, join(outputDir, ORCAD_WINDOWS_PROCESS_TREE_FILENAME))
}