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
|
|
@ -21,6 +21,7 @@ import { CONFIG_NAMES } from './config';
|
|||
import { PROFILE_RE } from './credentials';
|
||||
import type { StoreApp } from './desktop-protocol';
|
||||
import { type IdProject, NO_OVERRIDES, type Overrides, type Pair } from './identity';
|
||||
import * as rt from './rt';
|
||||
|
||||
export const WORKSPACE_NAMES = ['storebound.workspace.json', 'storebound.workspace.ts', 'storebound.workspace.js'];
|
||||
/** Colours a studio can carry: the desktop's set (workspace.rs STUDIO_COLORS). */
|
||||
|
|
@ -94,7 +95,7 @@ export async function loadWorkspace(from: string, explicit?: string): Promise<Lo
|
|||
let raw: unknown;
|
||||
if (file.endsWith('.json')) {
|
||||
try { raw = JSON.parse(readFileSync(file, 'utf8')); } catch (e) { throw new Error(`${file}: ${(e as Error).message}`); }
|
||||
} else raw = ((await import(file)) as { default?: unknown }).default;
|
||||
} else raw = ((await rt.importConfigModule(file)) as { default?: unknown }).default;
|
||||
const problems = checkWorkspace(raw);
|
||||
if (problems.length) throw new Error(`${file}:\n ${problems.join('\n ')}`);
|
||||
return { file, root: resolve(file, '..'), ws: raw as Workspace };
|
||||
|
|
@ -162,7 +163,7 @@ export const studiosOf = (ws: Workspace): Studio[] =>
|
|||
(ws.studios ?? []).map((s, i) => ({ id: studioId(s), name: s.name, color: s.color ?? STUDIO_COLORS[i % STUDIO_COLORS.length]! }));
|
||||
|
||||
const isGlob = (p: string): boolean => /[*?[{]/.test(p);
|
||||
const matchAny = (globs: string[], rel: string): boolean => globs.some(g => new Bun.Glob(g.replace(/\/+$/, '')).match(rel));
|
||||
const matchAny = (globs: string[], rel: string): boolean => globs.some(g => new rt.Glob(g.replace(/\/+$/, '')).match(rel));
|
||||
const hasConfig = (dir: string): boolean => CONFIG_NAMES.some(n => existsSync(join(dir, n)));
|
||||
|
||||
/**
|
||||
|
|
@ -182,7 +183,7 @@ export function resolveApps(l: LoadedWorkspace): { apps: AppFolder[]; warnings:
|
|||
const base = isAbsolute(p) ? '/' : root;
|
||||
const pattern = isAbsolute(p) ? p.slice(1) : p;
|
||||
let hits = 0;
|
||||
for (const m of new Bun.Glob(pattern.replace(/\/+$/, '')).scanSync({ cwd: base, onlyFiles: false, dot: false })) {
|
||||
for (const m of new rt.Glob(pattern.replace(/\/+$/, '')).scanSync({ cwd: base, onlyFiles: false, dot: false })) {
|
||||
if (/(^|\/)(node_modules|\.git)(\/|$)/.test(m)) continue;
|
||||
const dir = resolve(base, m);
|
||||
try { if (!statSync(dir).isDirectory()) continue; } catch { continue; }
|
||||
|
|
@ -249,7 +250,7 @@ export function selectApps<T extends { rel: string; name: string }>(apps: T[], n
|
|||
const picked = new Set<T>();
|
||||
for (const n of names) {
|
||||
const lc = n.toLowerCase();
|
||||
const hits = apps.filter(a => a.rel.toLowerCase() === lc || basename(a.rel).toLowerCase() === lc || a.name.toLowerCase() === lc || (isGlob(n) && new Bun.Glob(n).match(a.rel)));
|
||||
const hits = apps.filter(a => a.rel.toLowerCase() === lc || basename(a.rel).toLowerCase() === lc || a.name.toLowerCase() === lc || (isGlob(n) && new rt.Glob(n).match(a.rel)));
|
||||
if (!hits.length) unknown.push(n);
|
||||
hits.forEach(h => picked.add(h));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue