fwdloop 0.26.0 → 0.26.1
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 +1 -1
- package/bin/fwdloop +3 -3
- package/package.json +1 -1
- package/src/launcher.js +75 -8
- package/src/registry.js +3 -0
- package/types/launcher.d.ts +44 -5
- package/types/registry.d.ts +1 -0
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ standalone.
|
|
|
67
67
|
|
|
68
68
|
## Status
|
|
69
69
|
|
|
70
|
-
Work in progress, on npm as `fwdloop` (`npm install -g fwdloop`); expect changes between versions. `fwdloop` with no arguments opens a menu to start the panel. All jobs live in `~/.config/fwdloop/flows`, next to the settings; `--root <folder>` points a command somewhere else.
|
|
70
|
+
Work in progress, on npm as `fwdloop` (`npm install -g fwdloop`); expect changes between versions. `fwdloop` with no arguments opens a menu to start the panel; the menu also checks for a newer fwdloop on `6 update` (online only when pressed). All jobs live in `~/.config/fwdloop/flows`, next to the settings; `--root <folder>` points a command somewhere else.
|
|
71
71
|
|
|
72
72
|
The in-run `impact` tool needs ripgrep (`rg`) on PATH; without it the tool is refused with a message, never a wrong answer.
|
|
73
73
|
|
package/bin/fwdloop
CHANGED
|
@@ -1008,7 +1008,7 @@ function cmdLearn(rest) {
|
|
|
1008
1008
|
// ---------------------------------------------------------------------------
|
|
1009
1009
|
|
|
1010
1010
|
/**
|
|
1011
|
-
* M4b am4/am5 (the launcher): a bare `fwdloop` shows the menu; `start | stop | restart | status | install` are its
|
|
1011
|
+
* M4b am4/am5 (the launcher): a bare `fwdloop` shows the menu; `start | stop | restart | status | install | update` are its six choices as verbs. All logic is src/launcher.js.
|
|
1012
1012
|
* `--root <flows folder>` (default <config home>/flows, M4b am7) is the folder the runs line reads and `start` hands the panel; the config home is the real ~/.config/fwdloop.
|
|
1013
1013
|
*/
|
|
1014
1014
|
async function cmdLauncher(cmd, rest) {
|
|
@@ -1033,8 +1033,8 @@ async function main() {
|
|
|
1033
1033
|
if (verb === 'continue') return cmdContinue(rest);
|
|
1034
1034
|
if (verb === 'panel') return cmdPanel(rest);
|
|
1035
1035
|
if (verb === 'learn') return cmdLearn(rest);
|
|
1036
|
-
if (verb === 'start' || verb === 'stop' || verb === 'restart' || verb === 'status' || verb === 'install') return cmdLauncher(verb, rest);
|
|
1037
|
-
fail(`unknown verb "${verb}" — expected draft | sign | run | inbox | show | answer | resume | continue | panel | learn | start | stop | restart | status | install (or none, for the menu)`);
|
|
1036
|
+
if (verb === 'start' || verb === 'stop' || verb === 'restart' || verb === 'status' || verb === 'install' || verb === 'update') return cmdLauncher(verb, rest);
|
|
1037
|
+
fail(`unknown verb "${verb}" — expected draft | sign | run | inbox | show | answer | resume | continue | panel | learn | start | stop | restart | status | install | update (or none, for the menu)`);
|
|
1038
1038
|
return undefined;
|
|
1039
1039
|
}
|
|
1040
1040
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fwdloop",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "Describe a job as steps and guardrails; an agent builds the workflow, pauses for humans where you said, checks every step happened, and reruns it under budgets it cannot touch.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/launcher.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
// `readOwnVersion`; `start` spawns through src/panel/spawn.js `spawnDetached` (detached = its own session, log opened 0600 and appended) with `--root <flows folder>`;
|
|
5
5
|
// install creates the keys file with `createKeysFile`; the silent-port words are M4b am5 item 3's (bareloop 6d10023, unreleased); `launcherMain` is the entry bin/fwdloop calls
|
|
6
6
|
// (bareloop's runLauncher in cli.js). M4b am4 + am5.
|
|
7
|
+
// M4b am8 (built from the signed text): `6 update` / `fwdloop update` - the only online touch in this file, and only when pressed: node's own fetch of
|
|
8
|
+
// registry.npmjs.org/fwdloop/latest (`.version`, 5 s), a plain X.Y.Z compare, a y/n, then `npm install -g fwdloop@latest` (no shell, npm's output shown, a 5-minute
|
|
9
|
+
// deadline that kills only its own child; the number is the builder's, not signed). Piped input (no terminal) never asks and never installs.
|
|
7
10
|
//
|
|
8
11
|
// M4b am4/am5 (bareloop PANEL-BUILD.md addendum 2026-10-24, L) - the `fwdloop` launcher: the bare-`fwdloop` menu and `fwdloop start | stop | restart | status | install`.
|
|
9
12
|
//
|
|
@@ -17,6 +20,7 @@ import {
|
|
|
17
20
|
existsSync, statSync, mkdirSync, chmodSync,
|
|
18
21
|
} from 'node:fs';
|
|
19
22
|
import { createServer } from 'node:net';
|
|
23
|
+
import { spawn as realSpawn } from 'node:child_process';
|
|
20
24
|
import { openAsker } from './prompts.js';
|
|
21
25
|
import { dirname, join } from 'node:path';
|
|
22
26
|
import { fileURLToPath } from 'node:url';
|
|
@@ -25,6 +29,7 @@ import { keysHome, keysFilePath, createKeysFile } from './keysfile.js';
|
|
|
25
29
|
import { openInOs } from './opener.js';
|
|
26
30
|
import { PLAIN, makePaint } from './tty-colour.js';
|
|
27
31
|
import { readOwnVersion } from './version.js';
|
|
32
|
+
import { REGISTRY_URL } from './registry.js';
|
|
28
33
|
import { spawnDetached } from './panel/spawn.js';
|
|
29
34
|
import { runsListForCount, panelUrl } from './panel/server.js';
|
|
30
35
|
|
|
@@ -39,6 +44,11 @@ const SILENT_PORT_WAIT_MS = 10_000;
|
|
|
39
44
|
const POLL_MS = 100;
|
|
40
45
|
const MIN_NODE_MAJOR = 22;
|
|
41
46
|
const RULE_WIDTH = 56;
|
|
47
|
+
const REGISTRY_TIMEOUT_MS = 5000;
|
|
48
|
+
/** not in the signed text: how long `npm install -g` may run before its own child is killed */
|
|
49
|
+
const NPM_DEADLINE_MS = 300_000;
|
|
50
|
+
const NPM_ARGS = ['install', '-g', 'fwdloop@latest'];
|
|
51
|
+
const UPDATE_LATER = 'Not updated. To update later: npm install -g fwdloop@latest';
|
|
42
52
|
|
|
43
53
|
/**
|
|
44
54
|
* @typedef {object} Panel one answered probe
|
|
@@ -57,6 +67,9 @@ const RULE_WIDTH = 56;
|
|
|
57
67
|
* @property {number} [silentWaitMs] how long start keeps asking a taken, silent port (default 10 s)
|
|
58
68
|
* @property {string} [nodeVersion] default process.versions.node
|
|
59
69
|
* @property {typeof fetch} [fetchImpl]
|
|
70
|
+
* @property {typeof fetch} [registryFetch] the registry read of `update` (default global fetch); tests never go online
|
|
71
|
+
* @property {(args: string[]) => Promise<number>} [spawnNpm] runs npm with these args, resolves its exit code (non-zero = failed, deadline included); default {@link runNpm}
|
|
72
|
+
* @property {boolean} [isTTY] stdin is a terminal (launcherMain sets it); false/absent = `update` never asks and never installs
|
|
60
73
|
* @property {(a: {bin: string, argv: string[], env: Record<string, string|undefined>, logPath: string}) => any} [spawnFn] default src/panel/spawn.js `spawnDetached`
|
|
61
74
|
* @property {(pid: number, sig: string|number) => void} [kill] default process.kill
|
|
62
75
|
* @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
|
|
@@ -244,7 +257,7 @@ function bindFree(port) {
|
|
|
244
257
|
}
|
|
245
258
|
|
|
246
259
|
/**
|
|
247
|
-
* `fwdloop install` — creates only what is missing, never reads a key value.
|
|
260
|
+
* `fwdloop install` (menu 5) — creates only what is missing, never reads a key value.
|
|
248
261
|
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
|
|
249
262
|
* @returns {Promise<number>}
|
|
250
263
|
*/
|
|
@@ -279,12 +292,64 @@ export async function installCmd(io, d, shown) {
|
|
|
279
292
|
return 1;
|
|
280
293
|
}
|
|
281
294
|
}
|
|
282
|
-
if (made.length === 0) { io.out('Already
|
|
295
|
+
if (made.length === 0) { io.out('Already set up. This does not update fwdloop. Pick 6 update for that.'); return 0; }
|
|
283
296
|
io.out('Installed. Created:');
|
|
284
297
|
for (const m of made) io.out(` ${m}`);
|
|
285
298
|
return 0;
|
|
286
299
|
}
|
|
287
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Run `npm install -g fwdloop@latest`: no shell, npm's output on the terminal, killed by its own child handle at the deadline.
|
|
303
|
+
* @param {string[]} args @param {{spawnImpl?: typeof realSpawn, deadlineMs?: number}} [o]
|
|
304
|
+
* @returns {Promise<number>} npm's exit code; 1 when it could not start, was killed by a signal, or hit the deadline
|
|
305
|
+
*/
|
|
306
|
+
export function runNpm(args, o = {}) {
|
|
307
|
+
const spawnImpl = o.spawnImpl ?? realSpawn;
|
|
308
|
+
return new Promise((resolve) => {
|
|
309
|
+
let child;
|
|
310
|
+
try { child = spawnImpl('npm', args, { shell: false, stdio: 'inherit' }); } catch { resolve(1); return; }
|
|
311
|
+
let done = false;
|
|
312
|
+
const end = (/** @type {number} */ code) => { if (done) return; done = true; clearTimeout(timer); resolve(code); };
|
|
313
|
+
const timer = setTimeout(() => { try { child.kill('SIGTERM'); } catch { /* already gone */ } end(1); }, o.deadlineMs ?? NPM_DEADLINE_MS);
|
|
314
|
+
child.once('error', () => end(1));
|
|
315
|
+
child.once('close', (/** @type {number|null} */ code) => end(code === 0 ? 0 : 1));
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** @param {string} v @returns {number[]|null} X.Y.Z as numbers, nothing else counts */
|
|
320
|
+
const semverOf = (v) => { const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v); return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null; };
|
|
321
|
+
/** @param {number[]} a @param {number[]} b @returns {boolean} a is newer than b */
|
|
322
|
+
const isNewer = (a, b) => { for (let i = 0; i < 3; i += 1) if (a[i] !== b[i]) return a[i] > b[i]; return false; };
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* `fwdloop update` (menu 6, M4b am8) - the one online press. Exit 0: newest / updated / not updated; 1: could not reach npm, update failed.
|
|
326
|
+
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
|
|
327
|
+
* @returns {Promise<number>}
|
|
328
|
+
*/
|
|
329
|
+
export async function updateCmd(io, d, shown) {
|
|
330
|
+
await headerOnce(io, d, shown);
|
|
331
|
+
const mine = d.version ?? readOwnVersion() ?? 'unknown';
|
|
332
|
+
/** @type {string|null} */
|
|
333
|
+
let latest = null;
|
|
334
|
+
try {
|
|
335
|
+
const res = await (d.registryFetch ?? fetch)(REGISTRY_URL, { signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS) });
|
|
336
|
+
if (res.ok) { const v = /** @type {any} */ (await res.json())?.version; if (typeof v === 'string' && semverOf(v)) latest = v; }
|
|
337
|
+
} catch { /* offline, timeout or bad JSON: the same answer */ }
|
|
338
|
+
if (latest === null) { fail(io, d, 'Could not reach npm to check. Try again later.'); return 1; }
|
|
339
|
+
const a = /** @type {number[]} */ (semverOf(latest));
|
|
340
|
+
const b = semverOf(mine) ?? [0, 0, 0];
|
|
341
|
+
if (!isNewer(a, b)) { io.out(`You have the newest fwdloop (${mine}).`); return 0; }
|
|
342
|
+
io.out(`fwdloop ${latest} is out. You have ${mine}.`);
|
|
343
|
+
if (!d.isTTY || !d.ask) { io.out(UPDATE_LATER); return 0; }
|
|
344
|
+
let answer = (await d.ask('Update now? (y/n) ')).trim().toLowerCase();
|
|
345
|
+
if (answer === '') answer = (await d.ask('Update now? (y/n) ')).trim().toLowerCase();
|
|
346
|
+
if (answer !== 'y' && answer !== 'yes') { io.out(UPDATE_LATER); return 0; }
|
|
347
|
+
const code = await (d.spawnNpm ?? runNpm)(NPM_ARGS);
|
|
348
|
+
if (code !== 0) { fail(io, d, 'The update did not finish. Run it yourself: npm install -g fwdloop@latest'); return 1; }
|
|
349
|
+
io.out(`Updated to ${latest}. Then pick 3 restart.`);
|
|
350
|
+
return 0;
|
|
351
|
+
}
|
|
352
|
+
|
|
288
353
|
/**
|
|
289
354
|
* `fwdloop status` — the header, then one line per panel (or `Panel not running.`). Exit 0 running, 3 not running; 0 when the menu ran it.
|
|
290
355
|
* @param {{out: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown] header the menu already printed
|
|
@@ -497,7 +562,7 @@ export async function restartCmd(args, io, d, shown) {
|
|
|
497
562
|
}
|
|
498
563
|
|
|
499
564
|
/**
|
|
500
|
-
* The bare `fwdloop` menu: header, the
|
|
565
|
+
* The bare `fwdloop` menu: header, the six choices, one question. Runs the chosen command and returns its exit code.
|
|
501
566
|
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d
|
|
502
567
|
* @returns {Promise<number>}
|
|
503
568
|
*/
|
|
@@ -508,7 +573,7 @@ export async function menuCmd(io, d) {
|
|
|
508
573
|
const P = d.paint ?? PLAIN;
|
|
509
574
|
if (!P.on) io.out('');
|
|
510
575
|
const n = (/** @type {string} */ k) => P.boldCyan(k);
|
|
511
|
-
const items = `${n('1')} start ${n('2')} stop ${n('3')} restart ${n('4')} status ${n('5')} install ${n('q')} quit`;
|
|
576
|
+
const items = `${n('1')} start ${n('2')} stop ${n('3')} restart ${n('4')} status ${n('5')} install ${n('6')} update ${n('q')} quit`;
|
|
512
577
|
io.out(P.on ? ` ${items}` : items);
|
|
513
578
|
const choice = ask ? (await ask(`${P.cyan('>')} `)).trim().toLowerCase() : 'q';
|
|
514
579
|
// the header is already on screen: the chosen command reuses it instead of printing it a second time
|
|
@@ -517,15 +582,16 @@ export async function menuCmd(io, d) {
|
|
|
517
582
|
if (choice === '3' || choice === 'restart') return restartCmd([], io, d, h);
|
|
518
583
|
if (choice === '4' || choice === 'status') return statusCmd(io, d, h);
|
|
519
584
|
if (choice === '5' || choice === 'install') return installCmd(io, d, h);
|
|
585
|
+
if (choice === '6' || choice === 'update') return updateCmd(io, d, h);
|
|
520
586
|
if (choice === '' || choice === 'q' || choice === 'quit') return 0;
|
|
521
|
-
fail(io, d, `unknown choice ${JSON.stringify(choice)} — one of: 1, 2, 3, 4, 5, q`);
|
|
587
|
+
fail(io, d, `unknown choice ${JSON.stringify(choice)} — one of: 1, 2, 3, 4, 5, 6, q`);
|
|
522
588
|
return 1;
|
|
523
589
|
}
|
|
524
590
|
|
|
525
591
|
/**
|
|
526
|
-
* The launcher doors: the bare `fwdloop` menu and `start | stop | restart | status | install` (bin/fwdloop calls this; bareloop's runLauncher in src/cli.js). All logic is above;
|
|
592
|
+
* The launcher doors: the bare `fwdloop` menu and `start | stop | restart | status | install | update` (bin/fwdloop calls this; bareloop's runLauncher in src/cli.js). All logic is above;
|
|
527
593
|
* this only supplies the line reader and the colour. `deps.launcher` is the test seam for every OS touch (ports, spawn, kill, opener, clock).
|
|
528
|
-
* @param {'menu'|'start'|'stop'|'restart'|'status'|'install'} cmd @param {string[]} rest
|
|
594
|
+
* @param {'menu'|'start'|'stop'|'restart'|'status'|'install'|'update'} cmd @param {string[]} rest
|
|
529
595
|
* @param {{ stdin?: any, stdout?: any, stderr?: any, home?: string, root?: string, processEnv?: Record<string, string|undefined>, launcher?: LauncherDeps & {version?: string} }} deps
|
|
530
596
|
* @returns {Promise<number>}
|
|
531
597
|
*/
|
|
@@ -537,7 +603,7 @@ export async function launcherMain(cmd, rest, deps) {
|
|
|
537
603
|
const { ask, close } = openAsker({ stdin: deps.stdin, stdout });
|
|
538
604
|
const rawEnv = deps.processEnv ?? process.env;
|
|
539
605
|
const d = {
|
|
540
|
-
home: deps.home, root: deps.root, ask, paint: makePaint(stdout, rawEnv), paintErr: makePaint(stderr, rawEnv), ...(deps.launcher ?? {}),
|
|
606
|
+
home: deps.home, root: deps.root, ask, isTTY: Boolean((deps.stdin ?? process.stdin).isTTY), paint: makePaint(stdout, rawEnv), paintErr: makePaint(stderr, rawEnv), ...(deps.launcher ?? {}),
|
|
541
607
|
};
|
|
542
608
|
try {
|
|
543
609
|
if (cmd === 'start') return await startCmd(io, d);
|
|
@@ -545,6 +611,7 @@ export async function launcherMain(cmd, rest, deps) {
|
|
|
545
611
|
if (cmd === 'restart') return await restartCmd(rest, io, d);
|
|
546
612
|
if (cmd === 'status') return await statusCmd(io, d);
|
|
547
613
|
if (cmd === 'install') return await installCmd(io, d);
|
|
614
|
+
if (cmd === 'update') return await updateCmd(io, d);
|
|
548
615
|
return await menuCmd(io, d);
|
|
549
616
|
} finally {
|
|
550
617
|
close();
|
package/src/registry.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// M4b am8: the one address `fwdloop update` asks, and only when the human presses update. Kept out of src/launcher.js, whose test (launcher-header.test.js)
|
|
2
|
+
// pins "no address but panelUrl" for the PANEL's address.
|
|
3
|
+
export const REGISTRY_URL = 'https://registry.npmjs.org/fwdloop/latest';
|
package/types/launcher.d.ts
CHANGED
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* @property {number} [silentWaitMs] how long start keeps asking a taken, silent port (default 10 s)
|
|
15
15
|
* @property {string} [nodeVersion] default process.versions.node
|
|
16
16
|
* @property {typeof fetch} [fetchImpl]
|
|
17
|
+
* @property {typeof fetch} [registryFetch] the registry read of `update` (default global fetch); tests never go online
|
|
18
|
+
* @property {(args: string[]) => Promise<number>} [spawnNpm] runs npm with these args, resolves its exit code (non-zero = failed, deadline included); default {@link runNpm}
|
|
19
|
+
* @property {boolean} [isTTY] stdin is a terminal (launcherMain sets it); false/absent = `update` never asks and never installs
|
|
17
20
|
* @property {(a: {bin: string, argv: string[], env: Record<string, string|undefined>, logPath: string}) => any} [spawnFn] default src/panel/spawn.js `spawnDetached`
|
|
18
21
|
* @property {(pid: number, sig: string|number) => void} [kill] default process.kill
|
|
19
22
|
* @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
|
|
@@ -103,7 +106,7 @@ export function headerLines(d: LauncherDeps & {
|
|
|
103
106
|
version?: string;
|
|
104
107
|
}): Promise<string[]>;
|
|
105
108
|
/**
|
|
106
|
-
* `fwdloop install` — creates only what is missing, never reads a key value.
|
|
109
|
+
* `fwdloop install` (menu 5) — creates only what is missing, never reads a key value.
|
|
107
110
|
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
|
|
108
111
|
* @returns {Promise<number>}
|
|
109
112
|
*/
|
|
@@ -116,6 +119,29 @@ export function installCmd(io: {
|
|
|
116
119
|
lines: string[];
|
|
117
120
|
panels: Panel[];
|
|
118
121
|
}): Promise<number>;
|
|
122
|
+
/**
|
|
123
|
+
* Run `npm install -g fwdloop@latest`: no shell, npm's output on the terminal, killed by its own child handle at the deadline.
|
|
124
|
+
* @param {string[]} args @param {{spawnImpl?: typeof realSpawn, deadlineMs?: number}} [o]
|
|
125
|
+
* @returns {Promise<number>} npm's exit code; 1 when it could not start, was killed by a signal, or hit the deadline
|
|
126
|
+
*/
|
|
127
|
+
export function runNpm(args: string[], o?: {
|
|
128
|
+
spawnImpl?: typeof realSpawn;
|
|
129
|
+
deadlineMs?: number;
|
|
130
|
+
}): Promise<number>;
|
|
131
|
+
/**
|
|
132
|
+
* `fwdloop update` (menu 6, M4b am8) - the one online press. Exit 0: newest / updated / not updated; 1: could not reach npm, update failed.
|
|
133
|
+
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
|
|
134
|
+
* @returns {Promise<number>}
|
|
135
|
+
*/
|
|
136
|
+
export function updateCmd(io: {
|
|
137
|
+
out: (s: string) => void;
|
|
138
|
+
err: (s: string) => void;
|
|
139
|
+
}, d: LauncherDeps & {
|
|
140
|
+
version?: string;
|
|
141
|
+
}, shown?: {
|
|
142
|
+
lines: string[];
|
|
143
|
+
panels: Panel[];
|
|
144
|
+
}): Promise<number>;
|
|
119
145
|
/**
|
|
120
146
|
* `fwdloop status` — the header, then one line per panel (or `Panel not running.`). Exit 0 running, 3 not running; 0 when the menu ran it.
|
|
121
147
|
* @param {{out: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown] header the menu already printed
|
|
@@ -177,7 +203,7 @@ export function restartCmd(args: string[], io: {
|
|
|
177
203
|
panels: Panel[];
|
|
178
204
|
}): Promise<number>;
|
|
179
205
|
/**
|
|
180
|
-
* The bare `fwdloop` menu: header, the
|
|
206
|
+
* The bare `fwdloop` menu: header, the six choices, one question. Runs the chosen command and returns its exit code.
|
|
181
207
|
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d
|
|
182
208
|
* @returns {Promise<number>}
|
|
183
209
|
*/
|
|
@@ -188,13 +214,13 @@ export function menuCmd(io: {
|
|
|
188
214
|
version?: string;
|
|
189
215
|
}): Promise<number>;
|
|
190
216
|
/**
|
|
191
|
-
* The launcher doors: the bare `fwdloop` menu and `start | stop | restart | status | install` (bin/fwdloop calls this; bareloop's runLauncher in src/cli.js). All logic is above;
|
|
217
|
+
* The launcher doors: the bare `fwdloop` menu and `start | stop | restart | status | install | update` (bin/fwdloop calls this; bareloop's runLauncher in src/cli.js). All logic is above;
|
|
192
218
|
* this only supplies the line reader and the colour. `deps.launcher` is the test seam for every OS touch (ports, spawn, kill, opener, clock).
|
|
193
|
-
* @param {'menu'|'start'|'stop'|'restart'|'status'|'install'} cmd @param {string[]} rest
|
|
219
|
+
* @param {'menu'|'start'|'stop'|'restart'|'status'|'install'|'update'} cmd @param {string[]} rest
|
|
194
220
|
* @param {{ stdin?: any, stdout?: any, stderr?: any, home?: string, root?: string, processEnv?: Record<string, string|undefined>, launcher?: LauncherDeps & {version?: string} }} deps
|
|
195
221
|
* @returns {Promise<number>}
|
|
196
222
|
*/
|
|
197
|
-
export function launcherMain(cmd: "menu" | "start" | "stop" | "restart" | "status" | "install", rest: string[], deps: {
|
|
223
|
+
export function launcherMain(cmd: "menu" | "start" | "stop" | "restart" | "status" | "install" | "update", rest: string[], deps: {
|
|
198
224
|
stdin?: any;
|
|
199
225
|
stdout?: any;
|
|
200
226
|
stderr?: any;
|
|
@@ -258,6 +284,18 @@ export type LauncherDeps = {
|
|
|
258
284
|
*/
|
|
259
285
|
nodeVersion?: string | undefined;
|
|
260
286
|
fetchImpl?: typeof fetch | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* the registry read of `update` (default global fetch); tests never go online
|
|
289
|
+
*/
|
|
290
|
+
registryFetch?: typeof fetch | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* runs npm with these args, resolves its exit code (non-zero = failed, deadline included); default {@link runNpm}
|
|
293
|
+
*/
|
|
294
|
+
spawnNpm?: ((args: string[]) => Promise<number>) | undefined;
|
|
295
|
+
/**
|
|
296
|
+
* stdin is a terminal (launcherMain sets it); false/absent = `update` never asks and never installs
|
|
297
|
+
*/
|
|
298
|
+
isTTY?: boolean | undefined;
|
|
261
299
|
/**
|
|
262
300
|
* default src/panel/spawn.js `spawnDetached`
|
|
263
301
|
*/
|
|
@@ -305,3 +343,4 @@ export type LauncherDeps = {
|
|
|
305
343
|
*/
|
|
306
344
|
env?: Record<string, string | undefined> | undefined;
|
|
307
345
|
};
|
|
346
|
+
import { spawn as realSpawn } from 'node:child_process';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const REGISTRY_URL: "https://registry.npmjs.org/fwdloop/latest";
|