@nice-code/commander 0.95.0 → 0.97.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 +13 -9
- package/build/cli.cjs +900 -398
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +894 -399
- package/build/cli.mjs.map +1 -1
- package/build/client/assets/index-BEawHnvQ.css +1 -0
- package/build/client/assets/index-eogxmN5c.js +23 -0
- package/build/client/assets/index-eogxmN5c.js.map +1 -0
- package/build/client/index.html +2 -2
- package/build/config.cjs.map +1 -1
- package/build/config.d.cts +30 -12
- package/build/config.d.mts +30 -12
- package/build/config.mjs.map +1 -1
- package/build/{main-BlAdEbVt.mjs → main-BBH2T2OI.mjs} +219 -10
- package/build/main-BBH2T2OI.mjs.map +1 -0
- package/build/{main-B7EwREFQ.cjs → main-Xo-6rWk6.cjs} +218 -9
- package/build/main-Xo-6rWk6.cjs.map +1 -0
- package/build/types-B3WIUo4S.mjs.map +1 -1
- package/build/types-CIdWQGjF.cjs.map +1 -1
- package/package.json +6 -6
- package/build/client/assets/index-0MrLSa7o.css +0 -1
- package/build/client/assets/index-DvDRKmj5.js +0 -23
- package/build/client/assets/index-DvDRKmj5.js.map +0 -1
- package/build/main-B7EwREFQ.cjs.map +0 -1
- package/build/main-BlAdEbVt.mjs.map +0 -1
package/build/client/index.html
CHANGED
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
}
|
|
25
25
|
* { box-sizing: border-box; }
|
|
26
26
|
</style>
|
|
27
|
-
<script type="module" crossorigin src="/assets/index-
|
|
28
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
27
|
+
<script type="module" crossorigin src="/assets/index-eogxmN5c.js"></script>
|
|
28
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BEawHnvQ.css">
|
|
29
29
|
</head>
|
|
30
30
|
<body>
|
|
31
31
|
<div id="root"></div>
|
package/build/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["// The `./config` subpath — what a `commander.config.ts` imports. Lightweight by contract:\n// types + the identity helper only (the loader, validation and their deps stay daemon-side).\n\nimport type { ICommanderConfig } from \"./config/types\";\n\nexport {\n COMMANDER_ID_PATTERN,\n type ICommanderConfig,\n type ICommanderDefaults,\n type ICommanderEndpoint,\n type ICommanderEndpointHealth,\n type ICommanderEnvVar,\n type
|
|
1
|
+
{"version":3,"file":"config.cjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["// The `./config` subpath — what a `commander.config.ts` imports. Lightweight by contract:\n// types + the identity helper only (the loader, validation and their deps stay daemon-side).\n\nimport type { ICommanderConfig } from \"./config/types\";\n\nexport {\n COMMANDER_ID_PATTERN,\n type ICommanderConfig,\n type ICommanderDefaults,\n type ICommanderEndpoint,\n type ICommanderEndpointHealth,\n type ICommanderEnvVar,\n type ICommanderProcessDefinition,\n type ICommanderSuiteDefinition,\n type TCommanderEndpointOwnership,\n type TCommanderEndpointProtocol,\n type TCommanderReady,\n type TCommanderTagQuery,\n type TCommanderTagQueryOr,\n} from \"./config/types\";\n\n/** Identity helper so `commander.config.ts` files are typed end to end. */\nexport function defineCommanderConfig<T extends ICommanderConfig>(config: T): T {\n return config;\n}\n"],"mappings":";;;;AAsBA,SAAgB,sBAAkD,QAAc;CAC9E,OAAO;AACT"}
|
package/build/config.d.cts
CHANGED
|
@@ -75,8 +75,16 @@ interface ICommanderProcessDefinition {
|
|
|
75
75
|
envVars?: readonly ICommanderEnvVar[];
|
|
76
76
|
/** Default "pipe" (held open until stop); "ignore" is an instant EOF. */
|
|
77
77
|
stdin?: "pipe" | "ignore";
|
|
78
|
-
/**
|
|
79
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Free-form; `role` and `project` are the house convention. A key may carry several values —
|
|
80
|
+
* `project: ["api", "billing"]` matches both `project=api` and `project=billing`.
|
|
81
|
+
*/
|
|
82
|
+
tags?: Record<string, string | readonly string[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Never swept up in bulk: a tag selection, a suite's `where` and `all` all skip it. It starts
|
|
85
|
+
* only by exact id, by a suite's explicit `include`, or as a declared dependency.
|
|
86
|
+
*/
|
|
87
|
+
optIn?: boolean;
|
|
80
88
|
/**
|
|
81
89
|
* Transitive: starting this starts each dependency first and waits for it — service
|
|
82
90
|
* dependencies until ready, task dependencies until succeeded. Acyclic, validated at load.
|
|
@@ -95,20 +103,30 @@ interface ICommanderProcessDefinition {
|
|
|
95
103
|
ringBytes?: number;
|
|
96
104
|
lineBytes?: number;
|
|
97
105
|
};
|
|
98
|
-
/** Tasks only: hard cap on run time so a hung check can't hang a
|
|
106
|
+
/** Tasks only: hard cap on run time so a hung check can't hang a suite run forever. */
|
|
99
107
|
timeoutMs?: number;
|
|
100
108
|
}
|
|
101
109
|
/** Tag query: every entry must match (AND). An array of queries is OR'd. */
|
|
102
110
|
type TCommanderTagQuery = Record<string, string>;
|
|
103
111
|
type TCommanderTagQueryOr = TCommanderTagQuery | readonly TCommanderTagQuery[];
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
/**
|
|
113
|
+
* A named run-unit: several processes you mean to run as ONE thing (`verify`, `dev`). A label is
|
|
114
|
+
* a tag — a suite must resolve to at least two members.
|
|
115
|
+
*/
|
|
116
|
+
interface ICommanderSuiteDefinition {
|
|
117
|
+
/** One line — shown on the suite's card and in `list`. */
|
|
118
|
+
description?: string;
|
|
119
|
+
/** Tag-equality selection: OR of AND-maps. Skips `optIn` processes. */
|
|
106
120
|
where?: TCommanderTagQueryOr;
|
|
107
|
-
/** Process ids and/or other
|
|
121
|
+
/** Process ids and/or other suite names. Suite references must be acyclic. */
|
|
108
122
|
include?: readonly string[];
|
|
109
123
|
/** Excluded ids and/or tag queries, applied last. */
|
|
110
124
|
exclude?: readonly (string | TCommanderTagQuery)[] | TCommanderTagQuery;
|
|
111
|
-
/**
|
|
125
|
+
/** How many tasks run at once. Default 4. */
|
|
126
|
+
parallel?: number;
|
|
127
|
+
/** Stop scheduling tasks after the first failure. Default false. */
|
|
128
|
+
failFast?: boolean;
|
|
129
|
+
/** Delay between service spawns (no thundering herd of 17 tsc watchers). Default 100. */
|
|
112
130
|
staggerMs?: number;
|
|
113
131
|
}
|
|
114
132
|
interface ICommanderDefaults {
|
|
@@ -120,17 +138,17 @@ interface ICommanderDefaults {
|
|
|
120
138
|
ringBytes?: number;
|
|
121
139
|
lineBytes?: number;
|
|
122
140
|
};
|
|
123
|
-
tags?: Record<string, string>;
|
|
141
|
+
tags?: Record<string, string | readonly string[]>;
|
|
124
142
|
}
|
|
125
143
|
interface ICommanderConfig {
|
|
126
144
|
/** Config name — also the data-dir slug seed (D6). Same charset as ids. */
|
|
127
145
|
name: string;
|
|
128
146
|
defaults?: ICommanderDefaults;
|
|
129
147
|
processes: ICommanderProcessDefinition[];
|
|
130
|
-
|
|
148
|
+
suites?: Record<string, ICommanderSuiteDefinition>;
|
|
131
149
|
/**
|
|
132
|
-
* Selection used by a bare `up`
|
|
133
|
-
* available
|
|
150
|
+
* Selection used by a bare `up` — a suite name, a process id, or one `tag=value` term. Without
|
|
151
|
+
* it, bare `up` prints the available suites and exits without mutating anything.
|
|
134
152
|
*/
|
|
135
153
|
defaultSelection?: string;
|
|
136
154
|
/** Local config helpers the D2 loader cannot discover automatically (repo-relative). */
|
|
@@ -144,5 +162,5 @@ interface ICommanderConfig {
|
|
|
144
162
|
/** Identity helper so `commander.config.ts` files are typed end to end. */
|
|
145
163
|
declare function defineCommanderConfig<T extends ICommanderConfig>(config: T): T;
|
|
146
164
|
//#endregion
|
|
147
|
-
export { COMMANDER_ID_PATTERN, type ICommanderConfig, type ICommanderDefaults, type ICommanderEndpoint, type ICommanderEndpointHealth, type ICommanderEnvVar, type
|
|
165
|
+
export { COMMANDER_ID_PATTERN, type ICommanderConfig, type ICommanderDefaults, type ICommanderEndpoint, type ICommanderEndpointHealth, type ICommanderEnvVar, type ICommanderProcessDefinition, type ICommanderSuiteDefinition, type TCommanderEndpointOwnership, type TCommanderEndpointProtocol, type TCommanderReady, type TCommanderTagQuery, type TCommanderTagQueryOr, defineCommanderConfig };
|
|
148
166
|
//# sourceMappingURL=config.d.cts.map
|
package/build/config.d.mts
CHANGED
|
@@ -75,8 +75,16 @@ interface ICommanderProcessDefinition {
|
|
|
75
75
|
envVars?: readonly ICommanderEnvVar[];
|
|
76
76
|
/** Default "pipe" (held open until stop); "ignore" is an instant EOF. */
|
|
77
77
|
stdin?: "pipe" | "ignore";
|
|
78
|
-
/**
|
|
79
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Free-form; `role` and `project` are the house convention. A key may carry several values —
|
|
80
|
+
* `project: ["api", "billing"]` matches both `project=api` and `project=billing`.
|
|
81
|
+
*/
|
|
82
|
+
tags?: Record<string, string | readonly string[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Never swept up in bulk: a tag selection, a suite's `where` and `all` all skip it. It starts
|
|
85
|
+
* only by exact id, by a suite's explicit `include`, or as a declared dependency.
|
|
86
|
+
*/
|
|
87
|
+
optIn?: boolean;
|
|
80
88
|
/**
|
|
81
89
|
* Transitive: starting this starts each dependency first and waits for it — service
|
|
82
90
|
* dependencies until ready, task dependencies until succeeded. Acyclic, validated at load.
|
|
@@ -95,20 +103,30 @@ interface ICommanderProcessDefinition {
|
|
|
95
103
|
ringBytes?: number;
|
|
96
104
|
lineBytes?: number;
|
|
97
105
|
};
|
|
98
|
-
/** Tasks only: hard cap on run time so a hung check can't hang a
|
|
106
|
+
/** Tasks only: hard cap on run time so a hung check can't hang a suite run forever. */
|
|
99
107
|
timeoutMs?: number;
|
|
100
108
|
}
|
|
101
109
|
/** Tag query: every entry must match (AND). An array of queries is OR'd. */
|
|
102
110
|
type TCommanderTagQuery = Record<string, string>;
|
|
103
111
|
type TCommanderTagQueryOr = TCommanderTagQuery | readonly TCommanderTagQuery[];
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
/**
|
|
113
|
+
* A named run-unit: several processes you mean to run as ONE thing (`verify`, `dev`). A label is
|
|
114
|
+
* a tag — a suite must resolve to at least two members.
|
|
115
|
+
*/
|
|
116
|
+
interface ICommanderSuiteDefinition {
|
|
117
|
+
/** One line — shown on the suite's card and in `list`. */
|
|
118
|
+
description?: string;
|
|
119
|
+
/** Tag-equality selection: OR of AND-maps. Skips `optIn` processes. */
|
|
106
120
|
where?: TCommanderTagQueryOr;
|
|
107
|
-
/** Process ids and/or other
|
|
121
|
+
/** Process ids and/or other suite names. Suite references must be acyclic. */
|
|
108
122
|
include?: readonly string[];
|
|
109
123
|
/** Excluded ids and/or tag queries, applied last. */
|
|
110
124
|
exclude?: readonly (string | TCommanderTagQuery)[] | TCommanderTagQuery;
|
|
111
|
-
/**
|
|
125
|
+
/** How many tasks run at once. Default 4. */
|
|
126
|
+
parallel?: number;
|
|
127
|
+
/** Stop scheduling tasks after the first failure. Default false. */
|
|
128
|
+
failFast?: boolean;
|
|
129
|
+
/** Delay between service spawns (no thundering herd of 17 tsc watchers). Default 100. */
|
|
112
130
|
staggerMs?: number;
|
|
113
131
|
}
|
|
114
132
|
interface ICommanderDefaults {
|
|
@@ -120,17 +138,17 @@ interface ICommanderDefaults {
|
|
|
120
138
|
ringBytes?: number;
|
|
121
139
|
lineBytes?: number;
|
|
122
140
|
};
|
|
123
|
-
tags?: Record<string, string>;
|
|
141
|
+
tags?: Record<string, string | readonly string[]>;
|
|
124
142
|
}
|
|
125
143
|
interface ICommanderConfig {
|
|
126
144
|
/** Config name — also the data-dir slug seed (D6). Same charset as ids. */
|
|
127
145
|
name: string;
|
|
128
146
|
defaults?: ICommanderDefaults;
|
|
129
147
|
processes: ICommanderProcessDefinition[];
|
|
130
|
-
|
|
148
|
+
suites?: Record<string, ICommanderSuiteDefinition>;
|
|
131
149
|
/**
|
|
132
|
-
* Selection used by a bare `up`
|
|
133
|
-
* available
|
|
150
|
+
* Selection used by a bare `up` — a suite name, a process id, or one `tag=value` term. Without
|
|
151
|
+
* it, bare `up` prints the available suites and exits without mutating anything.
|
|
134
152
|
*/
|
|
135
153
|
defaultSelection?: string;
|
|
136
154
|
/** Local config helpers the D2 loader cannot discover automatically (repo-relative). */
|
|
@@ -144,5 +162,5 @@ interface ICommanderConfig {
|
|
|
144
162
|
/** Identity helper so `commander.config.ts` files are typed end to end. */
|
|
145
163
|
declare function defineCommanderConfig<T extends ICommanderConfig>(config: T): T;
|
|
146
164
|
//#endregion
|
|
147
|
-
export { COMMANDER_ID_PATTERN, type ICommanderConfig, type ICommanderDefaults, type ICommanderEndpoint, type ICommanderEndpointHealth, type ICommanderEnvVar, type
|
|
165
|
+
export { COMMANDER_ID_PATTERN, type ICommanderConfig, type ICommanderDefaults, type ICommanderEndpoint, type ICommanderEndpointHealth, type ICommanderEnvVar, type ICommanderProcessDefinition, type ICommanderSuiteDefinition, type TCommanderEndpointOwnership, type TCommanderEndpointProtocol, type TCommanderReady, type TCommanderTagQuery, type TCommanderTagQueryOr, defineCommanderConfig };
|
|
148
166
|
//# sourceMappingURL=config.d.mts.map
|
package/build/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["// The `./config` subpath — what a `commander.config.ts` imports. Lightweight by contract:\n// types + the identity helper only (the loader, validation and their deps stay daemon-side).\n\nimport type { ICommanderConfig } from \"./config/types\";\n\nexport {\n COMMANDER_ID_PATTERN,\n type ICommanderConfig,\n type ICommanderDefaults,\n type ICommanderEndpoint,\n type ICommanderEndpointHealth,\n type ICommanderEnvVar,\n type
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["// The `./config` subpath — what a `commander.config.ts` imports. Lightweight by contract:\n// types + the identity helper only (the loader, validation and their deps stay daemon-side).\n\nimport type { ICommanderConfig } from \"./config/types\";\n\nexport {\n COMMANDER_ID_PATTERN,\n type ICommanderConfig,\n type ICommanderDefaults,\n type ICommanderEndpoint,\n type ICommanderEndpointHealth,\n type ICommanderEnvVar,\n type ICommanderProcessDefinition,\n type ICommanderSuiteDefinition,\n type TCommanderEndpointOwnership,\n type TCommanderEndpointProtocol,\n type TCommanderReady,\n type TCommanderTagQuery,\n type TCommanderTagQueryOr,\n} from \"./config/types\";\n\n/** Identity helper so `commander.config.ts` files are typed end to end. */\nexport function defineCommanderConfig<T extends ICommanderConfig>(config: T): T {\n return config;\n}\n"],"mappings":";;;AAsBA,SAAgB,sBAAkD,QAAc;CAC9E,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ActionRuntime, B as stopSetWithDependencies, C as resolveCommanderDataDir, D as wsAcceptorCarrier, E as httpAcceptorCarrier, F as envVarViews, G as removeInstanceRecord, H as savedFilterId, I as overrideFingerprint, K as writeInstanceRecord, L as hashCanonical, M as createMemoryStorageAdapter_json, N as validateCommanderConfig, O as serveChannel, P as effectiveEnv, R as loadCommanderConfigFile, S as ensureStateDir, T as createRealmServerEngine, U as readInstanceRecord, V as withDependencies, W as recordDaemonAlive, a as parseLogsClientMessage, b as commanderPackageVersion, c as countOverrides, d as commanderControlDomain, g as COMMANDER_TICKET_PROTOCOL_PREFIX, i as runTaskPool, j as RuntimeCoordinate, k as createDefaultServeLogger, l as readEnvOverrides, n as readSavedFilters, o as createPortInspector, r as writeSavedFilters, s as applyEnvMutation, t as mutateSavedFilters, u as commanderChannel, v as commanderStatusRealm, w as createRealmAcceptor, x as commanderStatePaths, y as commanderRuntimeError, z as orderByDependency } from "./cli.mjs";
|
|
2
2
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
3
3
|
import { extname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { createNiceProcess, openProcessLedger, readProcessStartStamp, signalProcessGroup, taskkillTree } from "@nice-code/process";
|
|
@@ -364,9 +364,140 @@ function watchCommanderConfig(options) {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
//#endregion
|
|
367
|
+
//#region src/daemon/suiteRuns.ts
|
|
368
|
+
/** Tasks a tag-group run starts at once — a suite declares its own. */
|
|
369
|
+
const TAG_GROUP_PARALLEL = 4;
|
|
370
|
+
function createSuiteRunner(options) {
|
|
371
|
+
const { supervisor, publish, log } = options;
|
|
372
|
+
const runs = /* @__PURE__ */ new Map();
|
|
373
|
+
const live = /* @__PURE__ */ new Map();
|
|
374
|
+
const verdictOf = (report, id) => {
|
|
375
|
+
const outcome = report.results.find((result) => result.id === id)?.outcome;
|
|
376
|
+
if (outcome === "blocked") return "blocked";
|
|
377
|
+
return outcome === "failed" || outcome == null ? "fail" : "pass";
|
|
378
|
+
};
|
|
379
|
+
const evictTagGroupRuns = () => {
|
|
380
|
+
const ended = [...runs.entries()].filter(([, run]) => run.suite == null && run.endedAt != null).sort(([, a], [, b]) => (b.endedAt ?? 0) - (a.endedAt ?? 0));
|
|
381
|
+
for (const [key] of ended.slice(8)) {
|
|
382
|
+
runs.delete(key);
|
|
383
|
+
publish(key, null);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
return {
|
|
387
|
+
idle: async () => {
|
|
388
|
+
await Promise.all(live.values());
|
|
389
|
+
},
|
|
390
|
+
run: (input) => {
|
|
391
|
+
const config = supervisor.config;
|
|
392
|
+
const suite = input.suite == null ? void 0 : config.suites[input.suite];
|
|
393
|
+
if (input.suite != null && suite == null) return {
|
|
394
|
+
accepted: false,
|
|
395
|
+
reason: `unknown suite "${input.suite}"`
|
|
396
|
+
};
|
|
397
|
+
const known = new Set(config.processes.map((proc) => proc.id));
|
|
398
|
+
const direct = (suite?.ids ?? input.ids ?? []).filter((id) => known.has(id));
|
|
399
|
+
if (direct.length === 0) return {
|
|
400
|
+
accepted: false,
|
|
401
|
+
reason: "nothing to run"
|
|
402
|
+
};
|
|
403
|
+
const filterId = input.filter == null ? void 0 : savedFilterId(input.filter);
|
|
404
|
+
const runKey = suite?.name ?? `tg-${hashCanonical(filterId ?? [...direct].sort(), 12)}`;
|
|
405
|
+
if (live.has(runKey)) return {
|
|
406
|
+
accepted: false,
|
|
407
|
+
runKey,
|
|
408
|
+
reason: "already running"
|
|
409
|
+
};
|
|
410
|
+
const ordered = orderByDependency(config.processes, withDependencies(config.processes, direct));
|
|
411
|
+
const byId = new Map(config.processes.map((proc) => [proc.id, proc]));
|
|
412
|
+
const definitions = ordered.flatMap((id) => byId.get(id) ?? []);
|
|
413
|
+
const services = definitions.filter((proc) => proc.kind === "service");
|
|
414
|
+
const tasks = definitions.filter((proc) => proc.kind === "task");
|
|
415
|
+
const previous = runs.get(runKey);
|
|
416
|
+
const run = {
|
|
417
|
+
...suite != null ? { suite: suite.name } : {},
|
|
418
|
+
...filterId != null ? { filterId } : {},
|
|
419
|
+
startedAt: Date.now(),
|
|
420
|
+
...previous?.endedAt != null ? { previousDurationMs: previous.endedAt - previous.startedAt } : {},
|
|
421
|
+
members: Object.fromEntries(ordered.map((id) => [id, "pending"]))
|
|
422
|
+
};
|
|
423
|
+
const announce = () => publish(runKey, {
|
|
424
|
+
...run,
|
|
425
|
+
members: { ...run.members }
|
|
426
|
+
});
|
|
427
|
+
const mark = (id, verdict) => {
|
|
428
|
+
run.members[id] = verdict;
|
|
429
|
+
announce();
|
|
430
|
+
};
|
|
431
|
+
runs.set(runKey, run);
|
|
432
|
+
announce();
|
|
433
|
+
const execute = async () => {
|
|
434
|
+
const satisfied = /* @__PURE__ */ new Set();
|
|
435
|
+
if (services.length > 0) {
|
|
436
|
+
for (const proc of services) mark(proc.id, "running");
|
|
437
|
+
const report = await supervisor.start(services.map((proc) => proc.id), {
|
|
438
|
+
wait: true,
|
|
439
|
+
staggerMs: suite?.staggerMs ?? 0
|
|
440
|
+
});
|
|
441
|
+
for (const proc of services) mark(proc.id, verdictOf(report, proc.id));
|
|
442
|
+
for (const result of report.results) {
|
|
443
|
+
if (byId.get(result.id)?.kind !== "task") continue;
|
|
444
|
+
mark(result.id, result.outcome === "succeeded" ? "pass" : "fail");
|
|
445
|
+
if (result.outcome === "succeeded") satisfied.add(result.id);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const pool = await runTaskPool({
|
|
449
|
+
tasks: tasks.filter((task) => run.members[task.id] === "pending"),
|
|
450
|
+
parallel: input.parallel ?? suite?.parallel ?? TAG_GROUP_PARALLEL,
|
|
451
|
+
failFast: input.failFast ?? suite?.failFast ?? false,
|
|
452
|
+
run: async (task) => {
|
|
453
|
+
mark(task.id, "running");
|
|
454
|
+
const verdict = verdictOf(await supervisor.start([task.id], {
|
|
455
|
+
wait: true,
|
|
456
|
+
satisfied
|
|
457
|
+
}), task.id);
|
|
458
|
+
if (verdict === "pass") satisfied.add(task.id);
|
|
459
|
+
mark(task.id, verdict);
|
|
460
|
+
return verdict === "pass";
|
|
461
|
+
},
|
|
462
|
+
onBlocked: (task) => mark(task.id, "blocked"),
|
|
463
|
+
onFailFast: () => {
|
|
464
|
+
const running = tasks.filter((task) => run.members[task.id] === "running").map((task) => task.id);
|
|
465
|
+
if (running.length > 0) supervisor.stop(running);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
for (const task of pool.leftover) mark(task.id, "skipped");
|
|
469
|
+
run.endedAt = Date.now();
|
|
470
|
+
run.outcome = Object.values(run.members).every((verdict) => verdict === "pass") ? "passed" : "failed";
|
|
471
|
+
announce();
|
|
472
|
+
log(`run ${runKey}: ${run.outcome} in ${run.endedAt - run.startedAt} ms`);
|
|
473
|
+
evictTagGroupRuns();
|
|
474
|
+
};
|
|
475
|
+
const settled = execute().catch((error) => {
|
|
476
|
+
run.endedAt = Date.now();
|
|
477
|
+
run.outcome = "failed";
|
|
478
|
+
announce();
|
|
479
|
+
log(`run ${runKey}: aborted — ${error.message}`);
|
|
480
|
+
}).finally(() => live.delete(runKey));
|
|
481
|
+
live.set(runKey, settled);
|
|
482
|
+
return {
|
|
483
|
+
accepted: true,
|
|
484
|
+
runKey
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
367
490
|
//#region src/daemon/controlPlane.ts
|
|
368
491
|
const DAEMON_COORD = RuntimeCoordinate.env("commander_daemon");
|
|
369
492
|
const SLOW_CONSUMER_DROP_BYTES = 256 * 1024;
|
|
493
|
+
const LIVE_STATES = new Set([
|
|
494
|
+
"starting",
|
|
495
|
+
"running",
|
|
496
|
+
"ready",
|
|
497
|
+
"unready",
|
|
498
|
+
"backoff",
|
|
499
|
+
"stopping"
|
|
500
|
+
]);
|
|
370
501
|
function projectExit(exit) {
|
|
371
502
|
return {
|
|
372
503
|
...exit.code != null ? { code: exit.code } : {},
|
|
@@ -407,6 +538,7 @@ function projectProcess(status) {
|
|
|
407
538
|
notes: status.capability.notes
|
|
408
539
|
} } : {},
|
|
409
540
|
tags: status.tags,
|
|
541
|
+
optIn: status.optIn,
|
|
410
542
|
detail: {
|
|
411
543
|
command: status.detail.command,
|
|
412
544
|
cwd: status.detail.cwd,
|
|
@@ -437,8 +569,13 @@ function projectProcess(status) {
|
|
|
437
569
|
* Members are projected in DAG order (the same `orderByDependency` `up` spawns with), so the
|
|
438
570
|
* UI's "members in dependency order" and the CLI's execution order are one rule, not two.
|
|
439
571
|
*/
|
|
440
|
-
function
|
|
441
|
-
return Object.fromEntries(Object.
|
|
572
|
+
function projectSuites(config) {
|
|
573
|
+
return Object.fromEntries(Object.values(config.suites).map((suite) => [suite.name, {
|
|
574
|
+
...suite.description != null ? { description: suite.description } : {},
|
|
575
|
+
members: orderByDependency(config.processes, new Set(suite.ids)),
|
|
576
|
+
parallel: suite.parallel,
|
|
577
|
+
failFast: suite.failFast
|
|
578
|
+
}]));
|
|
442
579
|
}
|
|
443
580
|
function createControlPlane(options) {
|
|
444
581
|
const { supervisor, log } = options;
|
|
@@ -460,7 +597,9 @@ function createControlPlane(options) {
|
|
|
460
597
|
configRevisionHash: supervisor.config.configRevisionHash,
|
|
461
598
|
configError: [],
|
|
462
599
|
processes: Object.fromEntries(supervisor.status().map((status) => [status.id, projectProcess(status)])),
|
|
463
|
-
|
|
600
|
+
suites: projectSuites(supervisor.config),
|
|
601
|
+
runs: {},
|
|
602
|
+
savedFilters: [...options.savedFilters]
|
|
464
603
|
});
|
|
465
604
|
const engine = createRealmServerEngine(commanderStatusRealm, { initialState: initialState() });
|
|
466
605
|
supervisor.subscribe((id) => {
|
|
@@ -470,6 +609,22 @@ function createControlPlane(options) {
|
|
|
470
609
|
draft.processes[id] = projectProcess(status);
|
|
471
610
|
});
|
|
472
611
|
});
|
|
612
|
+
const suiteRunner = createSuiteRunner({
|
|
613
|
+
supervisor,
|
|
614
|
+
log,
|
|
615
|
+
publish: (runKey, run) => {
|
|
616
|
+
engine.update((draft) => {
|
|
617
|
+
if (run == null) delete draft.runs[runKey];
|
|
618
|
+
else draft.runs[runKey] = run;
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
const changeSavedFilters = async (change) => {
|
|
623
|
+
const next = await options.changeSavedFilters(change);
|
|
624
|
+
engine.update((draft) => {
|
|
625
|
+
draft.savedFilters = next;
|
|
626
|
+
});
|
|
627
|
+
};
|
|
473
628
|
const liveSockets = /* @__PURE__ */ new Set();
|
|
474
629
|
const acceptorAccess = {};
|
|
475
630
|
const server = serveChannel(runtime, commanderChannel, {
|
|
@@ -494,15 +649,49 @@ function createControlPlane(options) {
|
|
|
494
649
|
staggerMs: staggerMs ?? 0
|
|
495
650
|
});
|
|
496
651
|
},
|
|
497
|
-
stop: async ({ ids }) =>
|
|
652
|
+
stop: async ({ ids, withDependencies: alsoDependencies }) => {
|
|
653
|
+
if (alsoDependencies !== true) return supervisor.stop(ids);
|
|
654
|
+
const live = new Set(supervisor.status().filter((status) => LIVE_STATES.has(status.state)).map((status) => status.id));
|
|
655
|
+
const { stop, kept } = stopSetWithDependencies(supervisor.config.processes, ids, (id) => live.has(id));
|
|
656
|
+
const report = await supervisor.stop(stop);
|
|
657
|
+
return kept.length === 0 ? report : {
|
|
658
|
+
...report,
|
|
659
|
+
warnings: [...report.warnings, `left running — still needed by other live processes: ${kept.join(", ")}`]
|
|
660
|
+
};
|
|
661
|
+
},
|
|
498
662
|
restart: async ({ ids, wait, staggerMs }) => {
|
|
499
663
|
const config = supervisor.config;
|
|
500
664
|
const ordered = orderByDependency(config.processes, withDependencies(config.processes, ids));
|
|
501
665
|
return supervisor.restart(ordered, {
|
|
502
666
|
wait: wait ?? true,
|
|
503
|
-
staggerMs: staggerMs ?? 0
|
|
667
|
+
staggerMs: staggerMs ?? 0,
|
|
668
|
+
stopIds: ids
|
|
504
669
|
});
|
|
505
670
|
},
|
|
671
|
+
runSuite: async (input) => {
|
|
672
|
+
const report = suiteRunner.run(input);
|
|
673
|
+
if (report.accepted && input.filter != null) await changeSavedFilters({
|
|
674
|
+
kind: "ran",
|
|
675
|
+
query: input.filter,
|
|
676
|
+
at: Date.now()
|
|
677
|
+
});
|
|
678
|
+
return report;
|
|
679
|
+
},
|
|
680
|
+
saveFilter: async ({ filter, name }) => {
|
|
681
|
+
await changeSavedFilters({
|
|
682
|
+
kind: "pin",
|
|
683
|
+
query: filter,
|
|
684
|
+
name
|
|
685
|
+
});
|
|
686
|
+
return { ok: true };
|
|
687
|
+
},
|
|
688
|
+
removeFilter: async ({ id }) => {
|
|
689
|
+
await changeSavedFilters({
|
|
690
|
+
kind: "remove",
|
|
691
|
+
id
|
|
692
|
+
});
|
|
693
|
+
return { ok: true };
|
|
694
|
+
},
|
|
506
695
|
setEnv: async (input) => ({
|
|
507
696
|
ok: true,
|
|
508
697
|
warnings: await options.setEnvOverrides(input)
|
|
@@ -562,7 +751,7 @@ function createControlPlane(options) {
|
|
|
562
751
|
draft.configName = next.name;
|
|
563
752
|
draft.configRevisionHash = next.configRevisionHash;
|
|
564
753
|
draft.configError = [];
|
|
565
|
-
draft.
|
|
754
|
+
draft.suites = projectSuites(next);
|
|
566
755
|
for (const status of supervisor.status()) draft.processes[status.id] = projectProcess(status);
|
|
567
756
|
});
|
|
568
757
|
},
|
|
@@ -1363,6 +1552,7 @@ var CommanderSupervisor = class {
|
|
|
1363
1552
|
break;
|
|
1364
1553
|
}
|
|
1365
1554
|
if (dep.definition.kind === "task") {
|
|
1555
|
+
if (options.satisfied?.has(depId) === true) continue;
|
|
1366
1556
|
const taskResult = await (taskRuns.get(depId) ?? this._runTaskOnce(dep, taskRuns));
|
|
1367
1557
|
if (!orderedIds.includes(depId)) results.push({
|
|
1368
1558
|
...taskResult,
|
|
@@ -1647,8 +1837,13 @@ var CommanderSupervisor = class {
|
|
|
1647
1837
|
warnings
|
|
1648
1838
|
};
|
|
1649
1839
|
}
|
|
1840
|
+
/**
|
|
1841
|
+
* ⚠ Stops only `stopIds` — the ids the caller NAMED — then starts the whole ordered closure.
|
|
1842
|
+
* Stopping the closure bounced every shared dependency under its other live dependents: a
|
|
1843
|
+
* restart of three frontends took the backend down with it.
|
|
1844
|
+
*/
|
|
1650
1845
|
async restart(orderedIds, options = {}) {
|
|
1651
|
-
const stopped = await this.stop(orderedIds);
|
|
1846
|
+
const stopped = await this.stop(options.stopIds ?? orderedIds);
|
|
1652
1847
|
const started = await this.start(orderedIds, options);
|
|
1653
1848
|
return {
|
|
1654
1849
|
results: started.results.map((result) => {
|
|
@@ -1734,6 +1929,7 @@ var CommanderSupervisor = class {
|
|
|
1734
1929
|
unreadyReason: proc?.unreadyReason ?? null,
|
|
1735
1930
|
capability: proc?.capability ?? null,
|
|
1736
1931
|
tags: holder.definition.tags,
|
|
1932
|
+
optIn: holder.definition.optIn,
|
|
1737
1933
|
detail: describe(holder.definition, envVars)
|
|
1738
1934
|
};
|
|
1739
1935
|
});
|
|
@@ -1913,11 +2109,24 @@ async function startCommanderDaemon(argv) {
|
|
|
1913
2109
|
envWrites = run.catch(() => {});
|
|
1914
2110
|
return run;
|
|
1915
2111
|
};
|
|
2112
|
+
let savedFilters = await readSavedFilters(paths.savedFiltersPath);
|
|
2113
|
+
let filterWrites = Promise.resolve();
|
|
2114
|
+
const changeSavedFilters = (change) => {
|
|
2115
|
+
const run = filterWrites.then(async () => {
|
|
2116
|
+
savedFilters = mutateSavedFilters(savedFilters, change);
|
|
2117
|
+
await writeSavedFilters(paths.savedFiltersPath, savedFilters);
|
|
2118
|
+
return savedFilters;
|
|
2119
|
+
});
|
|
2120
|
+
filterWrites = run.catch(() => {});
|
|
2121
|
+
return run;
|
|
2122
|
+
};
|
|
1916
2123
|
const plane = createControlPlane({
|
|
1917
2124
|
supervisor,
|
|
1918
2125
|
generation,
|
|
1919
2126
|
reloadConfig: () => watcher?.reloadNow() ?? Promise.resolve(),
|
|
1920
2127
|
setEnvOverrides,
|
|
2128
|
+
savedFilters,
|
|
2129
|
+
changeSavedFilters,
|
|
1921
2130
|
requestShutdown: () => void shutdown(),
|
|
1922
2131
|
log
|
|
1923
2132
|
});
|
|
@@ -2068,7 +2277,7 @@ async function startCommanderDaemon(argv) {
|
|
|
2068
2277
|
configKey: resolved.configKey,
|
|
2069
2278
|
configRevisionHash: resolved.configRevisionHash,
|
|
2070
2279
|
configPath: resolved.configPath,
|
|
2071
|
-
protocolVersion:
|
|
2280
|
+
protocolVersion: 6,
|
|
2072
2281
|
packageVersion: await commanderPackageVersion(),
|
|
2073
2282
|
realmSchemaHash: commanderStatusRealm.schemaHash
|
|
2074
2283
|
});
|
|
@@ -2153,4 +2362,4 @@ async function runCommanderDaemon(argv) {
|
|
|
2153
2362
|
//#endregion
|
|
2154
2363
|
export { runCommanderDaemon };
|
|
2155
2364
|
|
|
2156
|
-
//# sourceMappingURL=main-
|
|
2365
|
+
//# sourceMappingURL=main-BBH2T2OI.mjs.map
|