@cat-factory/cli 0.10.4 → 0.11.0
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/README.md +8 -0
- package/dist/args.d.ts +16 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +44 -14
- package/dist/args.js.map +1 -1
- package/dist/bin.js +7 -1
- package/dist/bin.js.map +1 -1
- package/dist/errorText.d.ts +6 -0
- package/dist/errorText.d.ts.map +1 -0
- package/dist/errorText.js +175 -0
- package/dist/errorText.js.map +1 -0
- package/dist/host-shell.d.ts +26 -0
- package/dist/host-shell.d.ts.map +1 -1
- package/dist/host-shell.js +19 -0
- package/dist/host-shell.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/k3s-handler.d.ts +35 -20
- package/dist/k3s-handler.d.ts.map +1 -1
- package/dist/k3s-handler.js +54 -26
- package/dist/k3s-handler.js.map +1 -1
- package/dist/k3s-ingress.d.ts +259 -0
- package/dist/k3s-ingress.d.ts.map +1 -0
- package/dist/k3s-ingress.js +372 -0
- package/dist/k3s-ingress.js.map +1 -0
- package/dist/k3s-probe.d.ts +38 -3
- package/dist/k3s-probe.d.ts.map +1 -1
- package/dist/k3s-probe.js +93 -5
- package/dist/k3s-probe.js.map +1 -1
- package/dist/k3s-provision.d.ts +92 -18
- package/dist/k3s-provision.d.ts.map +1 -1
- package/dist/k3s-provision.js +280 -28
- package/dist/k3s-provision.js.map +1 -1
- package/dist/k3s.d.ts +3 -0
- package/dist/k3s.d.ts.map +1 -1
- package/dist/k3s.js +149 -24
- package/dist/k3s.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -45,6 +45,14 @@ It does the fiddly setup for you:
|
|
|
45
45
|
is **not** needed to boot; add providers/keys through the UI after sign-in (the `.env` leaves
|
|
46
46
|
them as commented hints), so the generated file runs local mode with no manual edits.
|
|
47
47
|
- **`cat-factory k3s`**: guided local Kubernetes setup for ephemeral environments (see `--help`).
|
|
48
|
+
It probes the host, creates or reuses a cluster, applies a least-privilege ServiceAccount, mints a
|
|
49
|
+
token, and hands the values to the SPA's connect form. It also CHECKS, rather than assumes, whether
|
|
50
|
+
the cluster can serve an ingress-derived environment URL: that needs an ingress controller inside
|
|
51
|
+
the cluster and a host port published into it (`--ingress-port`, default 80). When either is
|
|
52
|
+
missing the summary says so and names the fix instead of printing a host template that resolves to
|
|
53
|
+
nothing. A published host port is fixed when the cluster is created, so `--recreate` destroys the
|
|
54
|
+
named k3d/kind cluster and builds it again from the current flags. It names what is on the cluster
|
|
55
|
+
before deleting it, and `-y` on its own never selects it.
|
|
48
56
|
- **`cat-factory supervise`**: run a dev command under a self-healing watchdog (see
|
|
49
57
|
[Supervising local dev](#supervising-local-dev)).
|
|
50
58
|
|
package/dist/args.d.ts
CHANGED
|
@@ -32,6 +32,21 @@ export interface CliOptions {
|
|
|
32
32
|
clusterName?: string;
|
|
33
33
|
/** `k3s` command: the Kubernetes distribution to provision/target. */
|
|
34
34
|
k3sRuntime?: K3sRuntime;
|
|
35
|
+
/**
|
|
36
|
+
* `k3s` command: host port published into the cluster's ingress controller, so an
|
|
37
|
+
* ingress-template environment URL resolves to something. Fixed at cluster-create time.
|
|
38
|
+
*/
|
|
39
|
+
ingressPort?: number;
|
|
40
|
+
/**
|
|
41
|
+
* `k3s` command: DESTROY the named local cluster and build it again from the current flags.
|
|
42
|
+
*
|
|
43
|
+
* A flag rather than a subcommand because everything a recreate needs (`--cluster-name`,
|
|
44
|
+
* `--runtime`, `--ingress-port`) is already `k3s`'s own option surface, and the flow around it
|
|
45
|
+
* (probe, RBAC, token, hand-off) is byte-for-byte the create path's: a subcommand would be the
|
|
46
|
+
* same command with one step in front of it. It is also what makes destructive intent EXPLICIT
|
|
47
|
+
* rather than inferred, since `--yes` alone can never select a recreate.
|
|
48
|
+
*/
|
|
49
|
+
recreate?: boolean;
|
|
35
50
|
/** `k3s` command: base URL of the running SPA, opened (deep-linked) to wire the handler. */
|
|
36
51
|
appUrl?: string;
|
|
37
52
|
/** `supervise` command: the command to run and keep alive — everything after `--`. */
|
|
@@ -75,5 +90,5 @@ export declare const OPTION_DEFAULTS: {
|
|
|
75
90
|
readonly appUrl: 'http://localhost:3000';
|
|
76
91
|
readonly healthPath: '/health';
|
|
77
92
|
};
|
|
78
|
-
export declare const HELP_TEXT = "cat-factory \u2014 bootstrap a local cat-factory deployment\n\nUsage:\n cat-factory [init] [options]\n cat-factory env [options]\n cat-factory k3s [options]\n cat-factory supervise [options] -- <command...>\n\nCommands:\n init Scaffold a local-mode backend (local/) + frontend SPA (frontend/): generate the\n crypto secrets, mint a GitHub/GitLab PAT (opens your browser), write gitignored .env.\n env Generate ONLY a ready-to-run local-mode .env in the current dir (or --dir): all three\n crypto secrets, a minted GitHub/GitLab PAT, and the execution mode \u2014 so local mode\n boots with no manual edits. Use it in an existing deployment dir (e.g. deploy/local).\n k3s Guided local Kubernetes setup: probe the host for a usable cluster, then create (or\n reuse) one + a least-privilege ServiceAccount and print the values to wire the\n Local k3s environment handler. A k3s install needs sudo, so it is only ever printed.\n supervise Run a dev command under a self-healing watchdog. 'node --watch' PARKS on crash\n (it restarts only on a file change), so a laptop sleep leaves the server dead with\n the port unbound and the SPA showing only \"can't reach backend\" \u2014 indefinitely. This\n probes the real signal (port listening AND /health 200), notices a resume, brings the\n database/cluster back, and restarts the command.\n\nOptions (init):\n -d, --dir <path> Target directory (default: ./<name>)\n --name <name> Project name slug (default: cat-factory)\n --title <title> Frontend app title (default: Agent Architecture Board)\n --provider <p> Source control: github | gitlab (default: github)\n --token <token> PAT value (skips the browser/paste flow)\n --db-url <url> Postgres DATABASE_URL\n --api-base <url> Backend API base for the SPA (default: http://localhost:<port>)\n --port <n> Backend HTTP port (default: 8787; also sets the SPA's api-base)\n --harness-image <ref> Pin the executor-harness image (default: unset \u2014 the backend runs the version it was built against)\n --container-runtime <r> Agent container runtime: docker | podman | orbstack | colima | apple\n --execution-mode <m> How agents run: pool (Docker container pool) | native (host CLI)\n --native-harnesses <l> Native mode: harnesses to run natively (claude-code,codex)\n --harness-entry <p> Native mode: path to the executor-harness server entry\n --no-open Don't open the browser (just print the token URL)\n -y, --yes Non-interactive: use defaults/flags, never prompt\n -f, --force Overwrite existing files\n -h, --help Show this help\n -v, --version Show the CLI version\n\nOptions (env):\n -d, --dir <path> Directory to write .env into (default: current directory)\n --provider <p> Source control: github | gitlab (default: github)\n --token <token> PAT value (skips the browser/paste flow)\n --db-url <url> Postgres DATABASE_URL\n --port <n> Backend HTTP port (default: 8787)\n --harness-image <ref> Pin the executor-harness image (default: unset \u2014 the backend runs the version it was built against)\n --container-runtime <r> Agent container runtime: docker | podman | orbstack | colima | apple\n --execution-mode <m> How agents run: pool (Docker container pool) | native (host CLI)\n --native-harnesses <l> Native mode: harnesses to run natively (claude-code,codex)\n --harness-entry <p> Native mode: path to the executor-harness server entry\n --no-open Don't open the browser (just print the token URL)\n -y, --yes Non-interactive: use defaults/flags, never prompt\n -f, --force Overwrite an existing .env\n\nOptions (k3s):\n --cluster-name <n> Name for a provisioned local cluster (default: cat-factory)\n --runtime <r> Kubernetes distribution: k3d | kind | k3s (default: k3d)\n --app-url <url> SPA base URL to deep-link for wiring (default: http://localhost:3000)\n --no-open Don't open the browser at the pre-filled connect form (still prints it)\n -y, --yes Non-interactive: pick the recommended path + skip confirms\n\n After provisioning, the values are printed and the SPA's Local k3s connect form is opened\n pre-filled (paste the token, then Test -> Save). A hands-free --register flag that POSTs the\n handler to the local API directly is a planned follow-up.\n\nOptions (supervise):\n --port <n> Port the supervised server binds (default: 8787)\n --health-path <p> Health endpoint probed on that port (default: /health)\n -d, --dir <path> Working directory for the command (default: current directory)\n --compose-service <s> docker compose service to keep up (e.g. postgres)\n --compose-dir <path> Directory holding docker-compose.yml (default: --dir)\n --k3s-cluster <name> Local k3d/kind cluster to keep running (started if stopped)\n --runtime <r> Cluster distribution for --k3s-cluster: k3d | kind (default: k3d).\n 'k3s' is refused: a host service has no cluster to start from here.\n --poll <seconds> Health probe interval, whole seconds (default: 10)\n --boot-grace <seconds> Ignore failures for this long after a (re)start (default: 60)\n --failures <n> Consecutive failed probes before repairing (default: 3)\n\n Everything after `--` is the supervised command, passed through untouched:\n cat-factory supervise --compose-service postgres -- pnpm dev\n\n A cluster that is merely STOPPED is started automatically. A cluster whose restart is blocked\n by a stale cgroup (\"device or resource busy\" \u2014 a state a suspend can leave behind) cannot be\n fixed from here: clearing it needs the container ENGINE restarted, which would kill every other\n container. That case is reported once, with the fix, instead of retried forever.\n\n The same rule applies to the supervised command itself: restarts that never reach a serving\n state are capped, and hitting the cap reports why and exits NON-ZERO rather than looping. A\n command that is simply broken cannot be repaired by killing it again.\n";
|
|
93
|
+
export declare const HELP_TEXT = "cat-factory \u2014 bootstrap a local cat-factory deployment\n\nUsage:\n cat-factory [init] [options]\n cat-factory env [options]\n cat-factory k3s [options]\n cat-factory supervise [options] -- <command...>\n\nCommands:\n init Scaffold a local-mode backend (local/) + frontend SPA (frontend/): generate the\n crypto secrets, mint a GitHub/GitLab PAT (opens your browser), write gitignored .env.\n env Generate ONLY a ready-to-run local-mode .env in the current dir (or --dir): all three\n crypto secrets, a minted GitHub/GitLab PAT, and the execution mode \u2014 so local mode\n boots with no manual edits. Use it in an existing deployment dir (e.g. deploy/local).\n k3s Guided local Kubernetes setup: probe the host for a usable cluster, then create (or\n reuse) one + a least-privilege ServiceAccount and print the values to wire the\n Local k3s environment handler. A k3s install needs sudo, so it is only ever printed.\n supervise Run a dev command under a self-healing watchdog. 'node --watch' PARKS on crash\n (it restarts only on a file change), so a laptop sleep leaves the server dead with\n the port unbound and the SPA showing only \"can't reach backend\" \u2014 indefinitely. This\n probes the real signal (port listening AND /health 200), notices a resume, brings the\n database/cluster back, and restarts the command.\n\nOptions (init):\n -d, --dir <path> Target directory (default: ./<name>)\n --name <name> Project name slug (default: cat-factory)\n --title <title> Frontend app title (default: Agent Architecture Board)\n --provider <p> Source control: github | gitlab (default: github)\n --token <token> PAT value (skips the browser/paste flow)\n --db-url <url> Postgres DATABASE_URL\n --api-base <url> Backend API base for the SPA (default: http://localhost:<port>)\n --port <n> Backend HTTP port (default: 8787; also sets the SPA's api-base)\n --harness-image <ref> Pin the executor-harness image (default: unset \u2014 the backend runs the version it was built against)\n --container-runtime <r> Agent container runtime: docker | podman | orbstack | colima | apple\n --execution-mode <m> How agents run: pool (Docker container pool) | native (host CLI)\n --native-harnesses <l> Native mode: harnesses to run natively (claude-code,codex)\n --harness-entry <p> Native mode: path to the executor-harness server entry\n --no-open Don't open the browser (just print the token URL)\n -y, --yes Non-interactive: use defaults/flags, never prompt\n -f, --force Overwrite existing files\n -h, --help Show this help\n -v, --version Show the CLI version\n\nOptions (env):\n -d, --dir <path> Directory to write .env into (default: current directory)\n --provider <p> Source control: github | gitlab (default: github)\n --token <token> PAT value (skips the browser/paste flow)\n --db-url <url> Postgres DATABASE_URL\n --port <n> Backend HTTP port (default: 8787)\n --harness-image <ref> Pin the executor-harness image (default: unset \u2014 the backend runs the version it was built against)\n --container-runtime <r> Agent container runtime: docker | podman | orbstack | colima | apple\n --execution-mode <m> How agents run: pool (Docker container pool) | native (host CLI)\n --native-harnesses <l> Native mode: harnesses to run natively (claude-code,codex)\n --harness-entry <p> Native mode: path to the executor-harness server entry\n --no-open Don't open the browser (just print the token URL)\n -y, --yes Non-interactive: use defaults/flags, never prompt\n -f, --force Overwrite an existing .env\n\nOptions (k3s):\n --cluster-name <n> Name for a provisioned local cluster (default: cat-factory)\n --runtime <r> Kubernetes distribution: k3d | kind | k3s (default: k3d)\n --ingress-port <n> Host port published into the cluster's ingress controller (default: 80).\n Fixed when the cluster is created: changing it needs --recreate.\n --recreate DESTROY the named k3d/kind cluster and build it again from these flags.\n Names what is on it first and asks before deleting. Never selected for\n you: -y alone cannot pick this path.\n --app-url <url> SPA base URL to deep-link for wiring (default: http://localhost:3000)\n --no-open Don't open the browser at the pre-filled connect form (still prints it)\n -y, --yes Non-interactive: pick the recommended path + skip confirms\n\n After provisioning, the values are printed and the SPA's Local k3s connect form is opened\n pre-filled (paste the token, then Test -> Save). A hands-free --register flag that POSTs the\n handler to the local API directly is a planned follow-up.\n\n Ingress-derived environment URLs need TWO things, and both are checked rather than assumed: an\n ingress controller in the cluster, and a host port published into it. A published host port\n cannot be added to a running k3d/kind cluster, which is what --recreate is for.\n\nOptions (supervise):\n --port <n> Port the supervised server binds (default: 8787)\n --health-path <p> Health endpoint probed on that port (default: /health)\n -d, --dir <path> Working directory for the command (default: current directory)\n --compose-service <s> docker compose service to keep up (e.g. postgres)\n --compose-dir <path> Directory holding docker-compose.yml (default: --dir)\n --k3s-cluster <name> Local k3d/kind cluster to keep running (started if stopped)\n --runtime <r> Cluster distribution for --k3s-cluster: k3d | kind (default: k3d).\n 'k3s' is refused: a host service has no cluster to start from here.\n --poll <seconds> Health probe interval, whole seconds (default: 10)\n --boot-grace <seconds> Ignore failures for this long after a (re)start (default: 60)\n --failures <n> Consecutive failed probes before repairing (default: 3)\n\n Everything after `--` is the supervised command, passed through untouched:\n cat-factory supervise --compose-service postgres -- pnpm dev\n\n A cluster that is merely STOPPED is started automatically. A cluster whose restart is blocked\n by a stale cgroup (\"device or resource busy\" \u2014 a state a suspend can leave behind) cannot be\n fixed from here: clearing it needs the container ENGINE restarted, which would kill every other\n container. That case is reported once, with the fix, instead of retried forever.\n\n The same rule applies to the supervised command itself: restarts that never reach a serving\n state are capped, and hitting the cap reports why and exits NON-ZERO rather than looping. A\n command that is simply broken cannot be repaired by killing it again.\n";
|
|
79
94
|
//# sourceMappingURL=args.d.ts.map
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAA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mGAAmG;AACnG,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAiCpD;AA6SD,qEAAqE;AACrE,eAAO,MAAM,eAAe;aAC1B,WAAW,EAAE,aAAa;aAC1B,QAAQ,EAAE,0BAA0B;aACpC,QAAQ,EAAc,WAAW;aACjC,WAAW,EAAE,8CAA8C;aAI3D,IAAI,EAAE,IAAI;aAGV,gBAAgB,EAAc,gBAAgB;aAC9C,aAAa,EAAY,aAAa;aAEtC,cAAc,EAAE,aAAa;aAC7B,UAAU,EAAW,UAAU;aAG/B,MAAM,EAAE,uBAAuB;aAE/B,UAAU,EAAE,SAAS;CACb,CAAA;AAEV,eAAO,MAAM,SAAS,o9NAsGrB,CAAA"}
|
package/dist/args.js
CHANGED
|
@@ -104,11 +104,44 @@ function applyCommandToken(flag, opts, commandSet) {
|
|
|
104
104
|
return { handled: false, commandSet };
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* The flags that name a local Kubernetes CLUSTER: which one, how it is built, and how the SPA is
|
|
109
|
+
* reached to wire it. Split out of {@link applyOptionFlag} so the one table stays under the
|
|
110
|
+
* complexity ratchet, and because they are the group that grows together (`--ingress-port` and
|
|
111
|
+
* `--recreate` arrived as a pair with the ingress work). Returns `false` for anything not its own.
|
|
112
|
+
*/
|
|
113
|
+
function applyClusterFlag(flag, opts, take) {
|
|
114
|
+
switch (flag) {
|
|
115
|
+
case '--cluster-name':
|
|
116
|
+
opts.clusterName = take(flag);
|
|
117
|
+
break;
|
|
118
|
+
case '--runtime':
|
|
119
|
+
opts.k3sRuntime = parseK3sRuntime(take(flag));
|
|
120
|
+
break;
|
|
121
|
+
case '--ingress-port':
|
|
122
|
+
opts.ingressPort = parsePort(take(flag), flag);
|
|
123
|
+
break;
|
|
124
|
+
case '--recreate':
|
|
125
|
+
opts.recreate = true;
|
|
126
|
+
break;
|
|
127
|
+
case '--app-url':
|
|
128
|
+
opts.appUrl = parseAppUrl(take(flag));
|
|
129
|
+
break;
|
|
130
|
+
case '--k3s-cluster':
|
|
131
|
+
opts.k3sCluster = take(flag);
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
107
138
|
/**
|
|
108
139
|
* Apply a single option flag, consuming its value from the queue (via `take`) where one is
|
|
109
140
|
* required. Returns `false` for an unrecognised flag so the caller can raise the error.
|
|
110
141
|
*/
|
|
111
142
|
function applyOptionFlag(flag, opts, take) {
|
|
143
|
+
if (applyClusterFlag(flag, opts, take))
|
|
144
|
+
return true;
|
|
112
145
|
switch (flag) {
|
|
113
146
|
case '--dir':
|
|
114
147
|
case '-d':
|
|
@@ -150,15 +183,6 @@ function applyOptionFlag(flag, opts, take) {
|
|
|
150
183
|
case '--harness-entry':
|
|
151
184
|
opts.harnessEntry = take(flag);
|
|
152
185
|
break;
|
|
153
|
-
case '--cluster-name':
|
|
154
|
-
opts.clusterName = take(flag);
|
|
155
|
-
break;
|
|
156
|
-
case '--runtime':
|
|
157
|
-
opts.k3sRuntime = parseK3sRuntime(take(flag));
|
|
158
|
-
break;
|
|
159
|
-
case '--app-url':
|
|
160
|
-
opts.appUrl = parseAppUrl(take(flag));
|
|
161
|
-
break;
|
|
162
186
|
case '--health-path':
|
|
163
187
|
opts.healthPath = parseHealthPath(take(flag));
|
|
164
188
|
break;
|
|
@@ -168,9 +192,6 @@ function applyOptionFlag(flag, opts, take) {
|
|
|
168
192
|
case '--compose-service':
|
|
169
193
|
opts.composeService = take(flag);
|
|
170
194
|
break;
|
|
171
|
-
case '--k3s-cluster':
|
|
172
|
-
opts.k3sCluster = take(flag);
|
|
173
|
-
break;
|
|
174
195
|
case '--poll':
|
|
175
196
|
opts.pollSeconds = parseWholeSeconds(flag, take(flag), 1);
|
|
176
197
|
break;
|
|
@@ -270,10 +291,10 @@ function parseFailures(value) {
|
|
|
270
291
|
}
|
|
271
292
|
return n;
|
|
272
293
|
}
|
|
273
|
-
function parsePort(value) {
|
|
294
|
+
function parsePort(value, flag = '--port') {
|
|
274
295
|
const n = Number(value);
|
|
275
296
|
if (!Number.isInteger(n) || n < 1 || n > 65535) {
|
|
276
|
-
throw new ArgError(`Invalid
|
|
297
|
+
throw new ArgError(`Invalid ${flag} "${value}" (expected an integer 1-65535)`);
|
|
277
298
|
}
|
|
278
299
|
return n;
|
|
279
300
|
}
|
|
@@ -380,6 +401,11 @@ Options (env):
|
|
|
380
401
|
Options (k3s):
|
|
381
402
|
--cluster-name <n> Name for a provisioned local cluster (default: cat-factory)
|
|
382
403
|
--runtime <r> Kubernetes distribution: k3d | kind | k3s (default: k3d)
|
|
404
|
+
--ingress-port <n> Host port published into the cluster's ingress controller (default: 80).
|
|
405
|
+
Fixed when the cluster is created: changing it needs --recreate.
|
|
406
|
+
--recreate DESTROY the named k3d/kind cluster and build it again from these flags.
|
|
407
|
+
Names what is on it first and asks before deleting. Never selected for
|
|
408
|
+
you: -y alone cannot pick this path.
|
|
383
409
|
--app-url <url> SPA base URL to deep-link for wiring (default: http://localhost:3000)
|
|
384
410
|
--no-open Don't open the browser at the pre-filled connect form (still prints it)
|
|
385
411
|
-y, --yes Non-interactive: pick the recommended path + skip confirms
|
|
@@ -388,6 +414,10 @@ Options (k3s):
|
|
|
388
414
|
pre-filled (paste the token, then Test -> Save). A hands-free --register flag that POSTs the
|
|
389
415
|
handler to the local API directly is a planned follow-up.
|
|
390
416
|
|
|
417
|
+
Ingress-derived environment URLs need TWO things, and both are checked rather than assumed: an
|
|
418
|
+
ingress controller in the cluster, and a host port published into it. A published host port
|
|
419
|
+
cannot be added to a running k3d/kind cluster, which is what --recreate is for.
|
|
420
|
+
|
|
391
421
|
Options (supervise):
|
|
392
422
|
--port <n> Port the supervised server binds (default: 8787)
|
|
393
423
|
--health-path <p> Health endpoint probed on that port (default: /health)
|
package/dist/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sour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a;IAC1B,QAAQ,EAAE,0BAA0B;IACpC,QAAQ,EAAE,QAAuB;IACjC,WAAW,EAAE,8CAA8C;IAC3D,0EAA0E;IAC1E,0FAA0F;IAC1F,gCAAgC;IAChC,IAAI,EAAE,IAAI;IACV,gGAAgG;IAChG,0FAA0F;IAC1F,gBAAgB,EAAE,QAA4B;IAC9C,aAAa,EAAE,MAAuB;IACtC,0BAA0B;IAC1B,cAAc,EAAE,aAAa;IAC7B,UAAU,EAAE,KAAmB;IAC/B,iGAAiG;IACjG,oEAAoE;IACpE,MAAM,EAAE,uBAAuB;IAC/B,8DAA8D;IAC9D,UAAU,EAAE,SAAS;CACb,CAAA;AAEV,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsGxB,CAAA"}
|
package/dist/bin.js
CHANGED
|
@@ -4,6 +4,10 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import { ArgError, HELP_TEXT, parseArgs } from './args.js';
|
|
5
5
|
import { bootstrap } from './bootstrap.js';
|
|
6
6
|
import { generateEnv } from './envCommand.js';
|
|
7
|
+
// Kernel's describer, COPIED into this package rather than imported: `@cat-factory/kernel` is a
|
|
8
|
+
// devDependency here and this file is the published `bin`, so a runtime import would resolve
|
|
9
|
+
// through pnpm's workspace link locally and fail with ERR_MODULE_NOT_FOUND off the registry.
|
|
10
|
+
import { getErrorMessage } from './errorText.js';
|
|
7
11
|
import { setupK3s } from './k3s.js';
|
|
8
12
|
import { supervise } from './superviseCommand.js';
|
|
9
13
|
function readVersion() {
|
|
@@ -51,7 +55,9 @@ async function main() {
|
|
|
51
55
|
await bootstrap(options);
|
|
52
56
|
}
|
|
53
57
|
main().catch((err) => {
|
|
54
|
-
|
|
58
|
+
// An error that describes itself as nothing (an empty message with no cause) says so as an
|
|
59
|
+
// empty string, so the fallback is what stops the last line of a failed run being a bare prefix.
|
|
60
|
+
process.stderr.write(`\ncat-factory: ${getErrorMessage(err) || 'failed for an unreported reason'}\n`);
|
|
55
61
|
process.exit(1);
|
|
56
62
|
});
|
|
57
63
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,SAAS,WAAW;IAClB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;QAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAyB,CAAA;QAC3F,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAA;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAA;IAChB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,IAAI,OAAO,CAAA;IACX,IAAI,CAAC;QACH,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,G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AAS,CAAC,CAAA;QAC/B,OAAM;IACR,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,EAAE,IAAI,CAAC,CAAA;QAC1C,OAAM;IACR,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC9B,MAAM,WAAW,CAAC,OAAO,CAAC,CAAA;QAC1B,OAAM;IACR,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC9B,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAA;QACvB,OAAM;IACR,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACpC,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;QACxB,OAAM;IACR,CAAC;IAED,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;AAC1B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,2FAA2F;IAC3F,iGAAiG;IACjG,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,kBAAkB,eAAe,CAAC,GAAG,CAAC,IAAI,iCAAiC,IAAI,CAChF,CAAA;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A thrown value as ONE line: its own message, then each cause beneath it, scrubbed and capped.
|
|
3
|
+
* Byte-for-byte kernel's `getErrorMessage` — see the header, and the conformity test beside it.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
6
|
+
//# sourceMappingURL=errorText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorText.d.ts","sourceRoot":"","sources":["../src/errorText.ts"],"names":[],"mappings":"AA4KA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQtD"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// How the CLI turns a THROWN VALUE into the one line it writes to stderr before exiting.
|
|
2
|
+
//
|
|
3
|
+
// This is a deliberate COPY of `getErrorMessage` in `@cat-factory/kernel`
|
|
4
|
+
// (`src/shared/error-chain.logic.ts` over `src/shared/redact-secrets.logic.ts`), for the same
|
|
5
|
+
// reason the executor-harness copies `hostMarkdown`: this package is PUBLISHED and stays runtime
|
|
6
|
+
// dependency-free (its only `dependencies` entry is `@clack/prompts`), so a `workspace:*` package
|
|
7
|
+
// it imports at runtime would resolve locally through pnpm's link and be missing the moment
|
|
8
|
+
// someone runs `npx cat-factory` off the registry. `errorText.conformity.test.ts` pins the two to
|
|
9
|
+
// byte-identical output over a shared corpus, so the copy cannot drift: change one, change the
|
|
10
|
+
// other. Kernel stays a devDependency, which is what lets that test import it.
|
|
11
|
+
//
|
|
12
|
+
// Why the CLI wants the chain at all: on Node a transport failure IS a bare `TypeError: fetch
|
|
13
|
+
// failed`, and what actually happened (`connect ECONNREFUSED`, `self-signed certificate`,
|
|
14
|
+
// `getaddrinfo ENOTFOUND`) hangs off `.cause`. `cat-factory` bootstraps against GitHub, a Docker
|
|
15
|
+
// daemon and a k3s cluster, so "fetch failed" as the last thing a failed bootstrap prints is the
|
|
16
|
+
// least useful sentence available.
|
|
17
|
+
const REPLACEMENT = '[REDACTED]';
|
|
18
|
+
const PEM_PRIVATE_KEY_BEGIN = /-----BEGIN[ A-Z0-9]*PRIVATE KEY[ A-Z0-9]*-----/g;
|
|
19
|
+
const PEM_PRIVATE_KEY_END = /-----END[ A-Z0-9]*PRIVATE KEY[ A-Z0-9]*-----/g;
|
|
20
|
+
/** Drop PEM-armored private keys pasted verbatim, block and all (kernel's `redactPrivateKeyBlocks`). */
|
|
21
|
+
function redactPrivateKeyBlocks(value) {
|
|
22
|
+
PEM_PRIVATE_KEY_BEGIN.lastIndex = 0;
|
|
23
|
+
let begin = PEM_PRIVATE_KEY_BEGIN.exec(value);
|
|
24
|
+
if (begin === null)
|
|
25
|
+
return value;
|
|
26
|
+
let out = '';
|
|
27
|
+
let copiedTo = 0;
|
|
28
|
+
while (begin !== null) {
|
|
29
|
+
PEM_PRIVATE_KEY_END.lastIndex = begin.index + begin[0].length;
|
|
30
|
+
const end = PEM_PRIVATE_KEY_END.exec(value);
|
|
31
|
+
if (end === null)
|
|
32
|
+
break;
|
|
33
|
+
out += value.slice(copiedTo, begin.index) + REPLACEMENT;
|
|
34
|
+
copiedTo = end.index + end[0].length;
|
|
35
|
+
PEM_PRIVATE_KEY_BEGIN.lastIndex = copiedTo;
|
|
36
|
+
begin = PEM_PRIVATE_KEY_BEGIN.exec(value);
|
|
37
|
+
}
|
|
38
|
+
return copiedTo === 0 ? value : out + value.slice(copiedTo);
|
|
39
|
+
}
|
|
40
|
+
const ENV_VAR_NAME = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/;
|
|
41
|
+
const PROSE_WORD = /^(?:[a-z]+|[A-Z]+|[A-Z][a-z]+)$/;
|
|
42
|
+
const MIN_ALPHABETIC_SECRET_CHARS = 16;
|
|
43
|
+
/** Whether a field-name rule's captured value is a credential rather than the next word of a sentence. */
|
|
44
|
+
function looksLikeSecretValue(value) {
|
|
45
|
+
if (ENV_VAR_NAME.test(value))
|
|
46
|
+
return false;
|
|
47
|
+
return !(value.length < MIN_ALPHABETIC_SECRET_CHARS && PROSE_WORD.test(value));
|
|
48
|
+
}
|
|
49
|
+
const RULES = [
|
|
50
|
+
{
|
|
51
|
+
pattern: /\b(bearer|basic|token)\s+([A-Za-z0-9._+/=~-]{8,})/gi,
|
|
52
|
+
replace: (m) => (looksLikeSecretValue(m[2] ?? '') ? `${m[1]} ${REPLACEMENT}` : (m[0] ?? '')),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
pattern: /\b(authorization|x-api-key|x-auth-token|proxy-authorization)(["']?\s*[:=]\s*["']?)([^\s"',}]+)/gi,
|
|
56
|
+
replace: (m) => `${m[1]}${m[2]}${REPLACEMENT}`,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
pattern: /(?<=[a-z][a-z0-9+.-]{0,39}:\/\/)([^/\s:@]+):([^/\s@]+)@/gi,
|
|
60
|
+
replace: (m) => `${m[1]}:${REPLACEMENT}@`,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
pattern: /\b((?:access[_-]?)?(?:api[_-]?)?(?:client[_-]?)?(?:token|secret|password|passwd|pwd|sig|signature|key|apikey|auth))(["']?\s*[:=]\s*["']?)([^\s"',&}@/]{4,})/gi,
|
|
64
|
+
replace: (m) => looksLikeSecretValue(m[3] ?? '') ? `${m[1]}${m[2]}${REPLACEMENT}` : (m[0] ?? ''),
|
|
65
|
+
},
|
|
66
|
+
{ pattern: /\b(sk|rk|pk)-[A-Za-z0-9_-]{16,}/g, replace: () => REPLACEMENT },
|
|
67
|
+
{ pattern: /\bgh[pousr]_[A-Za-z0-9]{20,}/g, replace: () => REPLACEMENT },
|
|
68
|
+
{ pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g, replace: () => REPLACEMENT },
|
|
69
|
+
{ pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}/g, replace: () => REPLACEMENT },
|
|
70
|
+
{ pattern: /\bAKIA[0-9A-Z]{16}\b/g, replace: () => REPLACEMENT },
|
|
71
|
+
{
|
|
72
|
+
pattern: /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,
|
|
73
|
+
replace: () => REPLACEMENT,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
/** Best-effort scrub of credentials from a string (kernel's `redactSecrets`, non-null input only). */
|
|
77
|
+
function redactSecrets(value) {
|
|
78
|
+
let out = redactPrivateKeyBlocks(value);
|
|
79
|
+
for (const rule of RULES) {
|
|
80
|
+
out = out.replace(rule.pattern, (...args) => {
|
|
81
|
+
const groups = args.slice(0, -2);
|
|
82
|
+
return rule.replace(groups);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
const MAX_ERROR_CHAIN_CHARS = 400;
|
|
88
|
+
const MAX_CHAIN_DEPTH = 6;
|
|
89
|
+
const MAX_AGGREGATE_BRANCHES = 8;
|
|
90
|
+
const TRANSPORT_CODE = /^[A-Z][A-Z0-9_]*$/;
|
|
91
|
+
function readProperty(value, key) {
|
|
92
|
+
if (value === null || (typeof value !== 'object' && typeof value !== 'function'))
|
|
93
|
+
return undefined;
|
|
94
|
+
try {
|
|
95
|
+
return value[key];
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function safeText(value) {
|
|
102
|
+
try {
|
|
103
|
+
return String(value);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function errorCode(error) {
|
|
110
|
+
const code = readProperty(error, 'code');
|
|
111
|
+
return typeof code === 'string' && code ? code : undefined;
|
|
112
|
+
}
|
|
113
|
+
function aggregated(error) {
|
|
114
|
+
const errors = readProperty(error, 'errors');
|
|
115
|
+
return Array.isArray(errors) ? errors : [];
|
|
116
|
+
}
|
|
117
|
+
function flattenErrorChain(error, depth = 0, out = [], seen = new Set()) {
|
|
118
|
+
if (error === null || error === undefined || depth > MAX_CHAIN_DEPTH)
|
|
119
|
+
return out;
|
|
120
|
+
if (typeof error === 'object') {
|
|
121
|
+
if (seen.has(error))
|
|
122
|
+
return out;
|
|
123
|
+
seen.add(error);
|
|
124
|
+
}
|
|
125
|
+
out.push(error);
|
|
126
|
+
const branches = aggregated(error);
|
|
127
|
+
for (const branch of branches.slice(0, MAX_AGGREGATE_BRANCHES))
|
|
128
|
+
flattenErrorChain(branch, depth + 1, out, seen);
|
|
129
|
+
if (branches.length > MAX_AGGREGATE_BRANCHES)
|
|
130
|
+
out.push(`[…${branches.length - MAX_AGGREGATE_BRANCHES} more branches not read]`);
|
|
131
|
+
flattenErrorChain(readProperty(error, 'cause'), depth + 1, out, seen);
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
function describeErrorLink(link) {
|
|
135
|
+
const message = link instanceof Error ? readProperty(link, 'message') : link;
|
|
136
|
+
const code = errorCode(link);
|
|
137
|
+
const text = safeText(message ?? '').trim();
|
|
138
|
+
if (!code || !TRANSPORT_CODE.test(code))
|
|
139
|
+
return text || code || '';
|
|
140
|
+
if (!text)
|
|
141
|
+
return code;
|
|
142
|
+
return text.includes(code) ? text : `${text} (${code})`;
|
|
143
|
+
}
|
|
144
|
+
function renderErrorChainLinks(links) {
|
|
145
|
+
const counts = new Map();
|
|
146
|
+
for (const link of links) {
|
|
147
|
+
const text = describeErrorLink(link);
|
|
148
|
+
if (!text)
|
|
149
|
+
continue;
|
|
150
|
+
counts.set(text, (counts.get(text) ?? 0) + 1);
|
|
151
|
+
}
|
|
152
|
+
return [...counts].map(([text, count]) => (count > 1 ? `${text} (x${count})` : text));
|
|
153
|
+
}
|
|
154
|
+
function joinErrorChain(parts) {
|
|
155
|
+
const text = redactSecrets(parts.join(': '));
|
|
156
|
+
if (text.length <= MAX_ERROR_CHAIN_CHARS)
|
|
157
|
+
return text;
|
|
158
|
+
const dropped = text.length - MAX_ERROR_CHAIN_CHARS;
|
|
159
|
+
return `${text.slice(0, MAX_ERROR_CHAIN_CHARS)} […${dropped} more characters of the cause chain]`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* A thrown value as ONE line: its own message, then each cause beneath it, scrubbed and capped.
|
|
163
|
+
* Byte-for-byte kernel's `getErrorMessage` — see the header, and the conformity test beside it.
|
|
164
|
+
*/
|
|
165
|
+
export function getErrorMessage(error) {
|
|
166
|
+
const parts = renderErrorChainLinks(flattenErrorChain(error));
|
|
167
|
+
if (parts.length > 0)
|
|
168
|
+
return joinErrorChain(parts);
|
|
169
|
+
if (error instanceof Error) {
|
|
170
|
+
const name = readProperty(error, 'name');
|
|
171
|
+
return typeof name === 'string' && name && name !== Error.name ? joinErrorChain([name]) : '';
|
|
172
|
+
}
|
|
173
|
+
return joinErrorChain([safeText(error)]);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=errorText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorText.js","sourceRoot":"","sources":["../src/errorText.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,EAAE;AACF,0EAA0E;AAC1E,8FAA8F;AAC9F,iGAAiG;AACjG,kGAAkG;AAClG,4FAA4F;AAC5F,kGAAkG;AAClG,+FAA+F;AAC/F,+EAA+E;AAC/E,EAAE;AACF,8FAA8F;AAC9F,0FAA0F;AAC1F,iGAAiG;AACjG,iGAAiG;AACjG,mCAAmC;AAEnC,MAAM,WAAW,GAAG,YAAY,CAAA;AAChC,MAAM,qBAAqB,GAAG,iDAAiD,CAAA;AAC/E,MAAM,mBAAmB,GAAG,+CAA+C,CAAA;AAE3E,wGAAwG;AACxG,SAAS,sBAAsB,CAAC,KAAa;IAC3C,qBAAqB,CAAC,SAAS,GAAG,CAAC,CAAA;IACnC,IAAI,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC7C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAChC,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,OAAO,KAAK,KAAK,IAAI,EAAE,CAAC;QACtB,mBAAmB,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAC7D,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC3C,IAAI,GAAG,KAAK,IAAI;YAAE,MAAK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AAI,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC,MAAM,OAAO,sCAAsC,CAAA;AACnG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,MAAM,KAAK,GAAG,qBAAqB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,cAAc,CAAC,KAAK,CAAC,CAAA;IAClD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QACxC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9F,CAAC;IACD,OAAO,cAAc,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC1C,CAAC"}
|
package/dist/host-shell.d.ts
CHANGED
|
@@ -10,6 +10,20 @@ export interface ShellResult {
|
|
|
10
10
|
}
|
|
11
11
|
/** Conventional exit code for a missing binary — returned by {@link HostShell.run} on `ENOENT`. */
|
|
12
12
|
export declare const COMMAND_NOT_FOUND = 127;
|
|
13
|
+
/**
|
|
14
|
+
* A single command to run through the {@link HostShell}, optionally with stdin `input`.
|
|
15
|
+
*
|
|
16
|
+
* Lives here rather than beside one of its planners because several modules now plan commands
|
|
17
|
+
* (provisioning, the ingress probe) and a shared type in either of them would make the pair
|
|
18
|
+
* import each other.
|
|
19
|
+
*/
|
|
20
|
+
export interface Command {
|
|
21
|
+
cmd: string;
|
|
22
|
+
args: string[];
|
|
23
|
+
input?: string;
|
|
24
|
+
/** Per-command watchdog override (ms). Absent ⇒ the {@link HostShell} default applies. */
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
}
|
|
13
27
|
/** Conventional exit code for a command killed by the watchdog timeout (mirrors `timeout(1)`). */
|
|
14
28
|
export declare const COMMAND_TIMED_OUT = 124;
|
|
15
29
|
/**
|
|
@@ -47,6 +61,18 @@ export interface HostShell {
|
|
|
47
61
|
cwd?: string;
|
|
48
62
|
}): Promise<ShellResult>;
|
|
49
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Run a planned {@link Command} through a shell, honouring every field it carries.
|
|
66
|
+
*
|
|
67
|
+
* Use this for a READ whose non-zero exit is data rather than a failure (a probe, a best-effort
|
|
68
|
+
* list). `shell.run(command.cmd, command.args)` at a call site looks equivalent and is not: it
|
|
69
|
+
* silently drops `input` and the per-command `timeoutMs`, and hard-codes the binary the planner
|
|
70
|
+
* was there to name, so changing `cmd` keeps invoking the old one and the read gets the 10s
|
|
71
|
+
* default watchdog instead of its own.
|
|
72
|
+
*/
|
|
73
|
+
export declare function runCommand(shell: HostShell, command: Command): Promise<ShellResult>;
|
|
74
|
+
/** A planned command rendered as the shell line a human would type, for printed guidance. */
|
|
75
|
+
export declare function renderCommandLine(command: Command): string;
|
|
50
76
|
/** The real, process-backed {@link HostShell}. */
|
|
51
77
|
export declare function createNodeShell(): HostShell;
|
|
52
78
|
//# sourceMappingURL=host-shell.d.ts.map
|
package/dist/host-shell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-shell.d.ts","sourceRoot":"","sources":["../src/host-shell.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,mGAAmG;AACnG,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAS,CAAA;AAEhD;;;;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;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAKnF;AAED,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAE1D;AAED,kDAAkD;AAClD,wBAAgB,eAAe,IAAI,SAAS,CA2D3C"}
|
package/dist/host-shell.js
CHANGED
|
@@ -10,6 +10,25 @@ export const COMMAND_TIMED_OUT = 124;
|
|
|
10
10
|
* {@link COMMAND_TIMED_OUT} so the probe treats it as "ran but failed" (not reachable), never hangs.
|
|
11
11
|
*/
|
|
12
12
|
export const DEFAULT_COMMAND_TIMEOUT_MS = 10_000;
|
|
13
|
+
/**
|
|
14
|
+
* Run a planned {@link Command} through a shell, honouring every field it carries.
|
|
15
|
+
*
|
|
16
|
+
* Use this for a READ whose non-zero exit is data rather than a failure (a probe, a best-effort
|
|
17
|
+
* list). `shell.run(command.cmd, command.args)` at a call site looks equivalent and is not: it
|
|
18
|
+
* silently drops `input` and the per-command `timeoutMs`, and hard-codes the binary the planner
|
|
19
|
+
* was there to name, so changing `cmd` keeps invoking the old one and the read gets the 10s
|
|
20
|
+
* default watchdog instead of its own.
|
|
21
|
+
*/
|
|
22
|
+
export function runCommand(shell, command) {
|
|
23
|
+
return shell.run(command.cmd, command.args, {
|
|
24
|
+
input: command.input,
|
|
25
|
+
timeoutMs: command.timeoutMs,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** A planned command rendered as the shell line a human would type, for printed guidance. */
|
|
29
|
+
export function renderCommandLine(command) {
|
|
30
|
+
return [command.cmd, ...command.args].join(' ');
|
|
31
|
+
}
|
|
13
32
|
/** The real, process-backed {@link HostShell}. */
|
|
14
33
|
export function createNodeShell() {
|
|
15
34
|
return {
|
package/dist/host-shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-shell.js","sourceRoot":"","sources":["../src/host-shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAa1C,mGAAmG;AACnG,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"host-shell.js","sourceRoot":"","sources":["../src/host-shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAa1C,mGAAmG;AACnG,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAiBpC,kGAAkG;AAClG,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAA;AA+BhD;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgB,EAAE,OAAgB;IAC3D,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE;QAC1C,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAA;AACJ,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI;YACjB,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,0BAA0B,CAAA;YAC/D,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,EAAE;gBAC1C,IAAI,MAAM,GAAG,EAAE,CAAA;gBACf,IAAI,MAAM,GAAG,EAAE,CAAA;gBACf,IAAI,OAA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rapDeps, BootstrapError } from './bootstrap.js';
|
|
3
3
|
export { type EnvCommandDeps, EnvCommandError, generateEnv } from './envCommand.js';
|
|
4
4
|
export { type FileSystem } from './fs.js';
|
|
5
|
-
export { COMMAND_NOT_FOUND, COMMAND_TIMED_OUT, createNodeShell, DEFAULT_COMMAND_TIMEOUT_MS, type HostShell, type ShellResult, } from './host-shell.js';
|
|
5
|
+
export { type Command, COMMAND_NOT_FOUND, COMMAND_TIMED_OUT, createNodeShell, DEFAULT_COMMAND_TIMEOUT_MS, type HostShell, renderCommandLine, runCommand, type ShellResult, } from './host-shell.js';
|
|
6
6
|
export { K3S_INSTALL_COMMAND, type K3sDeps, type K3sResult, setupK3s } from './k3s.js';
|
|
7
|
-
export { buildK3sHandler, buildK3sSetupUrl,
|
|
8
|
-
export {
|
|
7
|
+
export { buildK3sHandler, buildK3sSetupUrl, DEFAULT_NAMESPACE_TEMPLATE, handlerLabel, type K3sHandlerInput, KUBERNETES_ENV_TOKEN_SECRET_KEY, } from './k3s-handler.js';
|
|
8
|
+
export { DEFAULT_INGRESS_PORT, INGRESS_HOST_TEMPLATE, type IngressReadiness, ingressHostTemplate, ingressUrlPort, } from './k3s-ingress.js';
|
|
9
|
+
export { classifyHost, hasServerVersion, type HostDetections, type HostState, isRecreateOffer, type Offer, type OfferId, parseK3dClusters, parseKindClusters, probeHost, RECREATE_OFFERS, recreateOfferFor, recreateTargetForContext, type ToolDetection, } from './k3s-probe.js';
|
|
9
10
|
export { buildFrontendEnv, buildLocalEnv, type EnvEntry, type FrontendEnvInput, type LocalEnvInput, renderEnvFile, } from './env.js';
|
|
10
11
|
export { buildGitignore, mergeGitignore, REQUIRED_GITIGNORE_RULES } from './gitignore.js';
|
|
11
12
|
export { type Io, createConsoleIo } from './io.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,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mB,EACnB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,aAAa,EACb,eAAe,EACf,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,SAAS,EACT,aAAa,EACb,aAAa,EACb,KAAK,WAAW,GACjB,MAAM,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,11 @@ export { HELP_TEXT, K3S_RUNTIMES, OPTION_DEFAULTS, parseArgs, ArgError, } from '
|
|
|
4
4
|
export { bootstrap, BootstrapError } from './bootstrap.js';
|
|
5
5
|
export { EnvCommandError, generateEnv } from './envCommand.js';
|
|
6
6
|
export {} from './fs.js';
|
|
7
|
-
export { COMMAND_NOT_FOUND, COMMAND_TIMED_OUT, createNodeShell, DEFAULT_COMMAND_TIMEOUT_MS, } from './host-shell.js';
|
|
7
|
+
export { COMMAND_NOT_FOUND, COMMAND_TIMED_OUT, createNodeShell, DEFAULT_COMMAND_TIMEOUT_MS, renderCommandLine, runCommand, } from './host-shell.js';
|
|
8
8
|
export { K3S_INSTALL_COMMAND, setupK3s } from './k3s.js';
|
|
9
|
-
export { buildK3sHandler, buildK3sSetupUrl,
|
|
10
|
-
export {
|
|
9
|
+
export { buildK3sHandler, buildK3sSetupUrl, DEFAULT_NAMESPACE_TEMPLATE, handlerLabel, KUBERNETES_ENV_TOKEN_SECRET_KEY, } from './k3s-handler.js';
|
|
10
|
+
export { DEFAULT_INGRESS_PORT, INGRESS_HOST_TEMPLATE, ingressHostTemplate, ingressUrlPort, } from './k3s-ingress.js';
|
|
11
|
+
export { classifyHost, hasServerVersion, isRecreateOffer, parseK3dClusters, parseKindClusters, probeHost, RECREATE_OFFERS, recreateOfferFor, recreateTargetForContext, } from './k3s-probe.js';
|
|
11
12
|
export { buildFrontendEnv, buildLocalEnv, renderEnvFile, } from './env.js';
|
|
12
13
|
export { buildGitignore, mergeGitignore, REQUIRED_GITIGNORE_RULES } from './gitignore.js';
|
|
13
14
|
export { createConsoleIo } from './io.js';
|