Files
realmroot[bot]andjarvis b78dedd576 feat: migrate branch deployments to Worker Previews (#577)
* feat: migrate branch deployments to Worker Previews

* fix: keep preview links local and refresh audited dependencies

* fix: pair Preview instances using their current origin

* fix(dev): default to Workers and isolate Node state

* fix(previews): report the current preview instance origin

* refactor(previews): preserve instance origin fallback coverage

---------

Co-authored-by: jarvis <jarvis@agents.realmroot.dev>
2026-09-22 17:27:22 +00:00

28 lines
941 B
JavaScript

import { spawn } from 'node:child_process'
// Explicit Node development starts both the API and its Vite frontend proxy.
const apiPort = process.env.E2E_API_PORT ?? '8222'
const children = [
spawn(process.execPath, ['node_modules/tsx/dist/cli.mjs', 'watch', 'server/entry-node.ts'], {
stdio: 'inherit',
env: { ...process.env, PORT: apiPort },
}),
spawn(process.execPath, ['node_modules/vite/bin/vite.js', 'dev', '--mode', 'node', ...process.argv.slice(2)], {
stdio: 'inherit',
env: { ...process.env, E2E_API_PORT: apiPort },
}),
]
let stopping = false
function stop(code) {
if (stopping) return
stopping = true
process.exitCode = code
for (const child of children) child.kill('SIGTERM')
}
for (const child of children) {
child.on('error', (error) => { console.error(error); stop(1) })
child.on('exit', (code) => stop(code ?? 1))
}
process.on('SIGINT', () => stop(0))
process.on('SIGTERM', () => stop(0))