@saacms/cli 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/main.js +64 -41
- package/dist/util/proc.d.ts +50 -0
- package/dist/util/proc.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA8EH,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAA;AAEzC,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;2CAEuC;IACvC,KAAK,CAAC,EAAE,QAAQ,CAAA;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACtB;AAOD,wBAAsB,QAAQ,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAiH7E;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;EAwBrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"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AG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AA0ED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAOrE;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CASvD;AAID;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CA8KpD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAIlE;AAmBD,eAAO,MAAM,aAAa;;;;;;;;;;;EA+BxB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAuMH,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;EA8JtB,CAAA;AAIF,UAAU,UAAU;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,CACd,GAAG,EAAE,MAAM,EAAE,EACb,GAAG,EAAE,MAAM,KACR,OAAO,CAAC,UAAU,CAAC,CAAA;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CACvB;AAiCD;;;;;;GAMG;AACH,iBAAe,aAAa,CAC1B,IAAI,EAAE,cAAc,EACpB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,MAAM,CAAC,CAiFjB;AAED,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;EAsCjB,CAAA;AAEF,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;EAsInB,CAAA;AAEF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,CAAA;AAE5E,eAAO,MAAM,cAAc,qDAUzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AA+DH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD;AA8ID,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;EA8MzB,CAAA"}
|
package/dist/main.js
CHANGED
|
@@ -355,6 +355,55 @@ var codegenCommand = defineCommand2({
|
|
|
355
355
|
import { defineCommand as defineCommand3 } from "citty";
|
|
356
356
|
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
357
357
|
import { join as join2 } from "node:path";
|
|
358
|
+
|
|
359
|
+
// src/util/proc.ts
|
|
360
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
361
|
+
import { Readable } from "node:stream";
|
|
362
|
+
async function spawnCapture(cmd, opts = {}) {
|
|
363
|
+
const [bin, ...args] = cmd;
|
|
364
|
+
const r = spawnSync(bin, args, {
|
|
365
|
+
cwd: opts.cwd,
|
|
366
|
+
env: opts.env ?? process.env,
|
|
367
|
+
encoding: "utf8",
|
|
368
|
+
maxBuffer: 64 * 1024 * 1024
|
|
369
|
+
});
|
|
370
|
+
if (r.error) {
|
|
371
|
+
return {
|
|
372
|
+
code: 127,
|
|
373
|
+
stdout: "",
|
|
374
|
+
stderr: String(r.error.message ?? r.error)
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
code: r.status ?? (r.signal ? 1 : 0),
|
|
379
|
+
stdout: r.stdout ?? "",
|
|
380
|
+
stderr: r.stderr ?? ""
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function spawnLong(cmd, opts) {
|
|
384
|
+
const [bin, ...args] = cmd;
|
|
385
|
+
const piped = opts.stdio === "pipe";
|
|
386
|
+
const child = spawn(bin, args, {
|
|
387
|
+
cwd: opts.cwd,
|
|
388
|
+
stdio: ["inherit", piped ? "pipe" : "inherit", piped ? "pipe" : "inherit"]
|
|
389
|
+
});
|
|
390
|
+
const exited = new Promise((resolveExit) => {
|
|
391
|
+
child.on("exit", (code, signal) => resolveExit(code ?? (signal ? 1 : 0)));
|
|
392
|
+
child.on("error", () => resolveExit(127));
|
|
393
|
+
});
|
|
394
|
+
return {
|
|
395
|
+
stdout: piped && child.stdout ? Readable.toWeb(child.stdout) : null,
|
|
396
|
+
stderr: piped && child.stderr ? Readable.toWeb(child.stderr) : null,
|
|
397
|
+
exited,
|
|
398
|
+
kill: (sig) => {
|
|
399
|
+
try {
|
|
400
|
+
child.kill(sig);
|
|
401
|
+
} catch {}
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/commands/dev.ts
|
|
358
407
|
var ASTRO_CONFIG_FILES2 = [
|
|
359
408
|
"astro.config.ts",
|
|
360
409
|
"astro.config.mjs",
|
|
@@ -418,23 +467,11 @@ async function startDev(opts = {}) {
|
|
|
418
467
|
const host = detectHost2(cwd);
|
|
419
468
|
const hostCmd = resolveHostCommand(host);
|
|
420
469
|
console.log(`[saacms dev] starting host: ${hostCmd.join(" ")} | codegen watcher: ${codegenEnabled ? "enabled" : "disabled"}`);
|
|
421
|
-
const hostProc =
|
|
422
|
-
cmd: [...hostCmd],
|
|
423
|
-
cwd,
|
|
424
|
-
stdin: "inherit",
|
|
425
|
-
stdout: stdio === "pipe" ? "pipe" : "inherit",
|
|
426
|
-
stderr: stdio === "pipe" ? "pipe" : "inherit"
|
|
427
|
-
});
|
|
470
|
+
const hostProc = spawnLong([...hostCmd], { cwd, stdio });
|
|
428
471
|
let codegenProc = null;
|
|
429
472
|
if (codegenEnabled) {
|
|
430
473
|
const cliPath = process.argv[1] ?? "";
|
|
431
|
-
codegenProc =
|
|
432
|
-
cmd: ["bun", "run", cliPath, "codegen", "--watch", "--cwd", cwd],
|
|
433
|
-
cwd,
|
|
434
|
-
stdin: "inherit",
|
|
435
|
-
stdout: stdio === "pipe" ? "pipe" : "inherit",
|
|
436
|
-
stderr: stdio === "pipe" ? "pipe" : "inherit"
|
|
437
|
-
});
|
|
474
|
+
codegenProc = spawnLong(["bun", "run", cliPath, "codegen", "--watch", "--cwd", cwd], { cwd, stdio });
|
|
438
475
|
}
|
|
439
476
|
let signalReceived = false;
|
|
440
477
|
let hostExitedFirst = false;
|
|
@@ -722,20 +759,8 @@ ${currentDdl}
|
|
|
722
759
|
});
|
|
723
760
|
var RUN_PREFIX = "[saacms migrate run]";
|
|
724
761
|
async function defaultExec(cmd, cwd) {
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
cmd: [bin, ...rest],
|
|
728
|
-
cwd,
|
|
729
|
-
env: { ...process.env },
|
|
730
|
-
stdout: "pipe",
|
|
731
|
-
stderr: "pipe"
|
|
732
|
-
});
|
|
733
|
-
const [stdout, stderr, code] = await Promise.all([
|
|
734
|
-
new Response(proc.stdout).text(),
|
|
735
|
-
new Response(proc.stderr).text(),
|
|
736
|
-
proc.exited
|
|
737
|
-
]);
|
|
738
|
-
return { code, stdout, stderr };
|
|
762
|
+
const r = await spawnCapture(cmd, { cwd, env: { ...process.env } });
|
|
763
|
+
return { code: r.code, stdout: r.stdout, stderr: r.stderr };
|
|
739
764
|
}
|
|
740
765
|
function ledgerPath(cwd) {
|
|
741
766
|
return resolve3(cwd, ".saacms/migrations/applied.json");
|
|
@@ -997,18 +1022,10 @@ function isSaacmsOwned(path, manifestWritten) {
|
|
|
997
1022
|
return manifestWritten.includes(path);
|
|
998
1023
|
}
|
|
999
1024
|
async function git(cwd, args) {
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
env: { ...process.env },
|
|
1003
|
-
stdout: "pipe",
|
|
1004
|
-
stderr: "pipe"
|
|
1025
|
+
const r = await spawnCapture(["git", "-C", cwd, ...args], {
|
|
1026
|
+
env: { ...process.env }
|
|
1005
1027
|
});
|
|
1006
|
-
|
|
1007
|
-
new Response(proc.stdout).text(),
|
|
1008
|
-
new Response(proc.stderr).text(),
|
|
1009
|
-
proc.exited
|
|
1010
|
-
]);
|
|
1011
|
-
return { code, stdout, stderr };
|
|
1028
|
+
return { code: r.code, stdout: r.stdout, stderr: r.stderr };
|
|
1012
1029
|
}
|
|
1013
1030
|
function parsePorcelain(out) {
|
|
1014
1031
|
const entries = [];
|
|
@@ -1424,8 +1441,14 @@ function isBunVersionOk(version) {
|
|
|
1424
1441
|
var MIN_BUN_STR = MIN_BUN.join(".");
|
|
1425
1442
|
function runChecks(cwd) {
|
|
1426
1443
|
const results = [];
|
|
1427
|
-
const bunVersion = Bun
|
|
1428
|
-
if (
|
|
1444
|
+
const bunVersion = globalThis.Bun?.version;
|
|
1445
|
+
if (bunVersion === undefined) {
|
|
1446
|
+
results.push({
|
|
1447
|
+
name: "runtime-version",
|
|
1448
|
+
status: "info",
|
|
1449
|
+
message: `Running under Node ${process.version} (bun not detected). The ` + `saacms cli is runtime-agnostic; bun >= ${MIN_BUN_STR} is only ` + `required to run the saacms workspace test suite.`
|
|
1450
|
+
});
|
|
1451
|
+
} else if (isBunVersionOk(bunVersion)) {
|
|
1429
1452
|
results.push({
|
|
1430
1453
|
name: "bun-version",
|
|
1431
1454
|
status: "pass",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-runtime process spawning for the @saacms/cli.
|
|
3
|
+
*
|
|
4
|
+
* The published cli bin is shebang'd `#!/usr/bin/env node` (npm requires a
|
|
5
|
+
* node-resolvable bin), so every command must run under BOTH node and bun.
|
|
6
|
+
* `Bun.spawn` / `Bun.version` are bun-only globals — referencing them from a
|
|
7
|
+
* node-launched bin throws `Bun is not defined` (publish-boundary defect #4).
|
|
8
|
+
*
|
|
9
|
+
* `node:child_process` is available under node AND bun, so this module is the
|
|
10
|
+
* single runtime-agnostic spawn surface the cli uses. It deliberately mirrors
|
|
11
|
+
* the small slice of the `Bun.spawn` shape `saacms dev` already depends on
|
|
12
|
+
* (`.stdout`/`.stderr` as Web ReadableStreams, `.exited`, `.kill`) so the dev
|
|
13
|
+
* supervision logic is unchanged — only the spawn primitive swaps.
|
|
14
|
+
*/
|
|
15
|
+
export interface CaptureResult {
|
|
16
|
+
code: number;
|
|
17
|
+
stdout: string;
|
|
18
|
+
stderr: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Run `cmd` to completion, capturing stdout/stderr/exit code. Never throws —
|
|
22
|
+
* a spawn failure (ENOENT etc.) comes back as `code: 127` with the error text
|
|
23
|
+
* on `stderr`, so callers can render a clear message rather than crash. This
|
|
24
|
+
* is the runtime-agnostic replacement for the old `Bun.spawn(...)` +
|
|
25
|
+
* `new Response(proc.stdout).text()` + `await proc.exited` idiom used by
|
|
26
|
+
* publish.ts's `git()` and migrate.ts's `defaultExec()`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function spawnCapture(cmd: string[], opts?: {
|
|
29
|
+
cwd?: string;
|
|
30
|
+
env?: NodeJS.ProcessEnv;
|
|
31
|
+
}): Promise<CaptureResult>;
|
|
32
|
+
export interface LongProc {
|
|
33
|
+
/** Web ReadableStream of stdout when spawned `stdio:"pipe"`, else null. */
|
|
34
|
+
stdout: ReadableStream<Uint8Array> | null;
|
|
35
|
+
stderr: ReadableStream<Uint8Array> | null;
|
|
36
|
+
/** Resolves with the exit code (or 1 if terminated by a signal). */
|
|
37
|
+
exited: Promise<number>;
|
|
38
|
+
kill(sig?: NodeJS.Signals): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Spawn a long-running child, presenting the small `Bun.spawn`-shaped surface
|
|
42
|
+
* `saacms dev` relies on. `stdio:"inherit"` hands the child the parent's tty;
|
|
43
|
+
* `stdio:"pipe"` exposes Web ReadableStreams the existing `readStream`
|
|
44
|
+
* (`new Response(stream).text()`) drains unchanged.
|
|
45
|
+
*/
|
|
46
|
+
export declare function spawnLong(cmd: string[], opts: {
|
|
47
|
+
cwd?: string;
|
|
48
|
+
stdio: "inherit" | "pipe";
|
|
49
|
+
}): LongProc;
|
|
50
|
+
//# sourceMappingURL=proc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proc.d.ts","sourceRoot":"","sources":["../../src/util/proc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EAAE,EACb,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAO,GACnD,OAAO,CAAC,aAAa,CAAC,CAsBxB;AAED,MAAM,WAAW,QAAQ;IACvB,2EAA2E;IAC3E,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IACzC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IACzC,oEAAoE;IACpE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACvB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EAAE,EACb,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAAA;CAAE,GAChD,QAAQ,CA6BV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saacms/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@saacms/core": "0.1.
|
|
24
|
+
"@saacms/core": "0.1.5",
|
|
25
25
|
"citty": "^0.1.6"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|