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
|
|
@ -28,6 +28,7 @@ import { done, log, printJson, step, warn } from './lib/log';
|
|||
import { childEnv, pump, selfCommand } from './lib/runner';
|
||||
import { PREBUILD_DONE_ENV, prebuildFor, prebuildsDone } from './lib/web-assets';
|
||||
import { parseYaml } from './lib/yaml';
|
||||
import * as rt from './lib/rt';
|
||||
|
||||
const TAG = 'flow';
|
||||
const EXT = ['.yml', '.yaml', '.json', '.ts'];
|
||||
|
|
@ -41,7 +42,7 @@ export function projectRoot(start = process.cwd()): string {
|
|||
}
|
||||
|
||||
async function readData(path: string): Promise<unknown> {
|
||||
if (path.endsWith('.ts')) { const m = await import(path) as { default?: unknown }; return m.default; }
|
||||
if (path.endsWith('.ts')) { const m = await rt.importConfigModule(path) as { default?: unknown }; return m.default; }
|
||||
const text = readFileSync(path, 'utf8');
|
||||
if (path.endsWith('.json')) return JSON.parse(text);
|
||||
return parseYaml(text);
|
||||
|
|
@ -64,7 +65,7 @@ export async function loadFlows(root: string): Promise<{ flows: Flow[]; errors:
|
|||
|
||||
/** Command names of this storebound (from `storebound help`), for `flow validate`. */
|
||||
function commandNames(): Set<string> {
|
||||
const r = Bun.spawnSync([...selfCommand(), 'help'], { stdout: 'pipe', stderr: 'pipe' });
|
||||
const r = rt.spawnSync([...selfCommand(), 'help'], { stdout: 'pipe', stderr: 'pipe' });
|
||||
const names = new Set<string>(['help', 'version']);
|
||||
for (const l of r.stdout.toString().split('\n')) if (/^ {2}[a-z]/.test(l)) { const n = l.slice(2, 27).trim(); if (n && !n.includes(':')) names.add(n); }
|
||||
return names;
|
||||
|
|
@ -106,7 +107,7 @@ function describe(p: PlannedStep): string {
|
|||
/** Runs one storebound step (or shell line) with stdin attached, so the command's own confirmation works; output indented. */
|
||||
async function exec(p: PlannedStep, root: string, quiet: boolean, extraEnv: Record<string, string> = {}): Promise<{ code: number; last: string; out: string }> {
|
||||
const cmd = p.shell !== undefined ? ['sh', '-c', p.shell] : [...selfCommand(), ...p.argv!];
|
||||
const proc = Bun.spawn(cmd, { cwd: root, stdin: 'inherit', stdout: 'pipe', stderr: 'pipe', env: childEnv(extraEnv) });
|
||||
const proc = rt.spawn(cmd, { cwd: root, stdin: 'inherit', stdout: 'pipe', stderr: 'pipe', env: childEnv(extraEnv) });
|
||||
const lines: string[] = [];
|
||||
let last = '';
|
||||
const each = (line: string, kind: 'stdout' | 'stderr') => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue