CLI runs on Node 20+: npx storebound (bunx keeps working)
- cli/lib/rt.ts: the runtime layer on node: modules (spawn / spawnSync with Bun's defaults, exit codes and "Executable not found", which with PATHEXT, sleep, serve, Glob, hasher, gunzip, stdin, SQLite, packageRoot, config imports with a type-stripping fallback for Node 20); every Bun.* use in cli/ goes through it - tools/gen-embedded.ts -> cli/lib/embedded.ts: templates/, cli/shots/*.html and Play's Data safety form embedded (replaces Bun text imports; the bundle and the compiled sidecar carry them), checked fresh by bun run ci - package.json: bin dist/storebound.mjs (Node ESM bundle, tools/build-node.ts, prepack), engines node >=20 - bun run ci: node bundle + node smoke (real node: --version, help, check same as Bun, scan, release plan --help, init, MCP handshake + tool call); Forgejo CI sets up Node 20; tests/node-compat.test.ts guards cli/ - install writes npx MCP commands when run with Node; bin/storebound falls back to Node - docs: npx storebound init (Node 20+) or bunx storebound init
This commit is contained in:
parent
614c32bcba
commit
36a8bf9625
73 changed files with 1195 additions and 251 deletions
|
|
@ -1,16 +1,21 @@
|
|||
// Runs one storebound command as a child process: the shared core of `storebound mcp` and `storebound serve --stdio`.
|
||||
// Works from source (`bun cli/index.ts ...`) and from a `bun build --compile` binary (the desktop sidecar), where the
|
||||
// binary re-executes itself. Output is streamed line by line (progress) and the `--json` result line is picked out.
|
||||
import { join } from 'node:path';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { RESULT_MARK } from './log';
|
||||
import { toolPath } from './tools';
|
||||
import * as rt from './rt';
|
||||
|
||||
/** True inside a `bun build --compile` executable (the entry module lives in Bun's embedded file system). */
|
||||
export const compiled = (): boolean => /^(\/\$bunfs\/|[A-Z]:[\\/]~BUN[\\/])/.test(Bun.main);
|
||||
export const compiled = (): boolean => /^(\/\$bunfs\/|[A-Z]:[\\/]~BUN[\\/])/.test(rt.mainPath());
|
||||
|
||||
/** Command prefix that starts this storebound: the compiled binary itself, or bun + cli/index.ts. */
|
||||
export function selfCommand(): string[] {
|
||||
return compiled() ? [process.execPath] : [process.execPath, join(import.meta.dir, '..', 'index.ts')];
|
||||
if (compiled()) return [process.execPath];
|
||||
// from the sources (cli/lib/runner.ts): bun cli/index.ts; from the npm bundle (dist/storebound.mjs): node <bundle>
|
||||
const self = fileURLToPath(import.meta.url);
|
||||
return [process.execPath, /\.ts$/.test(self) ? join(dirname(self), '..', 'index.ts') : self];
|
||||
}
|
||||
|
||||
export interface RunOptions {
|
||||
|
|
@ -62,7 +67,7 @@ export async function pump(stream: ReadableStream<Uint8Array>, kind: 'stdout' |
|
|||
}
|
||||
|
||||
export function runCommand(argv: string[], o: RunOptions): Running {
|
||||
const p = Bun.spawn([...selfCommand(), ...argv], { cwd: o.cwd, stdin: 'ignore', stdout: 'pipe', stderr: 'pipe', env: childEnv(o.env, o.machine) });
|
||||
const p = rt.spawn([...selfCommand(), ...argv], { cwd: o.cwd, stdin: 'ignore', stdout: 'pipe', stderr: 'pipe', env: childEnv(o.env, o.machine) });
|
||||
let cancelled = false;
|
||||
const lines: string[] = [];
|
||||
let data: unknown;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue