@nice-code/commander 0.107.0 → 0.109.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/build/cli.cjs +6 -2
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +6 -2
- package/build/cli.mjs.map +1 -1
- package/build/client/assets/index-DmSR4VsH.js +23 -0
- package/build/client/assets/{index-RGFhhnpd.js.map → index-DmSR4VsH.js.map} +1 -1
- package/build/client/index.html +1 -1
- package/build/config.cjs +10 -1
- package/build/config.cjs.map +1 -1
- package/build/config.d.cts +42 -19
- package/build/config.d.mts +42 -19
- package/build/config.mjs +10 -1
- package/build/config.mjs.map +1 -1
- package/build/{main-BHPsC_5Q.cjs → main-CVu9gjbx.cjs} +67 -4
- package/build/main-CVu9gjbx.cjs.map +1 -0
- package/build/{main-1B7viLr8.mjs → main-CWWlV2U5.mjs} +69 -6
- package/build/main-CWWlV2U5.mjs.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-RGFhhnpd.js +0 -23
- package/build/main-1B7viLr8.mjs.map +0 -1
- package/build/main-BHPsC_5Q.cjs.map +0 -1
package/build/client/index.html
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
* { box-sizing: border-box; }
|
|
26
26
|
</style>
|
|
27
|
-
<script type="module" crossorigin src="/assets/index-
|
|
27
|
+
<script type="module" crossorigin src="/assets/index-DmSR4VsH.js"></script>
|
|
28
28
|
<link rel="stylesheet" crossorigin href="/assets/index-DLZZdohI.css">
|
|
29
29
|
</head>
|
|
30
30
|
<body>
|
package/build/config.cjs
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_types = require("./types-CIdWQGjF.cjs");
|
|
3
3
|
//#region src/config.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Identity helper so `commander.config.ts` files are typed end to end: an unknown or removed key is
|
|
6
|
+
* a type error, and so is a `dependsOn`, suite `include`/`exclude`, `defaultSelection` or endpoint
|
|
7
|
+
* `ready` that names something the config never declares.
|
|
8
|
+
*
|
|
9
|
+
* ⚠ The reference checks need literal ids. Processes built from a list typed `{ id: string }[]`
|
|
10
|
+
* widen every id to `string` and switch those checks off — declare the list `as const` instead.
|
|
11
|
+
* A `.map()` callback is not contextually typed, so write `dependsOn: [...] as const` there, as
|
|
12
|
+
* with `kind`.
|
|
13
|
+
*/
|
|
5
14
|
function defineCommanderConfig(config) {
|
|
6
15
|
return config;
|
|
7
16
|
}
|
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 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
|
|
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 type TCommanderTagTerm,\n} from \"./config/types\";\n\n/**\n * Identity helper so `commander.config.ts` files are typed end to end: an unknown or removed key is\n * a type error, and so is a `dependsOn`, suite `include`/`exclude`, `defaultSelection` or endpoint\n * `ready` that names something the config never declares.\n *\n * ⚠ The reference checks need literal ids. Processes built from a list typed `{ id: string }[]`\n * widen every id to `string` and switch those checks off — declare the list `as const` instead.\n * A `.map()` callback is not contextually typed, so write `dependsOn: [...] as const` there, as\n * with `kind`.\n */\nexport function defineCommanderConfig<\n TProcessId extends string,\n TSuiteName extends string = never,\n TEndpointName extends string = never,\n>(\n config: ICommanderConfig<TProcessId, TSuiteName, TEndpointName>,\n): ICommanderConfig<TProcessId, TSuiteName, TEndpointName> {\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAAgB,sBAKd,QACyD;CACzD,OAAO;AACT"}
|
package/build/config.d.cts
CHANGED
|
@@ -3,6 +3,10 @@ import { INiceProcessRestartOptions, INiceProcessStopOptions, TNiceProcessKind,
|
|
|
3
3
|
//#region src/config/types.d.ts
|
|
4
4
|
/** Ids appear in CLI selectors, URLs and ledger filenames — never option-shaped (edge 31). */
|
|
5
5
|
declare const COMMANDER_ID_PATTERN: RegExp;
|
|
6
|
+
/** The built-in selection word a config may never redefine. */
|
|
7
|
+
declare const RESERVED_SELECTOR_NAME = "all";
|
|
8
|
+
/** The literal ids a config declared, or `never` once they widened to `string` (built at runtime). */
|
|
9
|
+
type TKnownIds<TId extends string> = string extends TId ? never : TId;
|
|
6
10
|
type TCommanderEndpointProtocol = "tcp" | "http";
|
|
7
11
|
type TCommanderEndpointOwnership = "exclusive" | "shared" | "observed";
|
|
8
12
|
interface ICommanderEndpointHealth {
|
|
@@ -11,9 +15,9 @@ interface ICommanderEndpointHealth {
|
|
|
11
15
|
/** Bounded body read must contain this marker. */
|
|
12
16
|
match?: string;
|
|
13
17
|
}
|
|
14
|
-
interface ICommanderEndpoint {
|
|
18
|
+
interface ICommanderEndpoint<TEndpointName extends string = string> {
|
|
15
19
|
/** Unique per process; referenced by `ready: { kind: "endpoint" }` and UI badges. */
|
|
16
|
-
name:
|
|
20
|
+
name: TEndpointName;
|
|
17
21
|
protocol: TCommanderEndpointProtocol;
|
|
18
22
|
host?: string;
|
|
19
23
|
port: number;
|
|
@@ -29,9 +33,9 @@ interface ICommanderEndpoint {
|
|
|
29
33
|
* Readiness sugar: `ready: { kind: "endpoint", endpoint: "web" }` expands against the named
|
|
30
34
|
* endpoint — tcp → `port` readiness, http → `httpOk` against `health.path` (+ `health.match`).
|
|
31
35
|
*/
|
|
32
|
-
type TCommanderReady = TNiceProcessReady | {
|
|
36
|
+
type TCommanderReady<TEndpointName extends string = string> = TNiceProcessReady | {
|
|
33
37
|
kind: "endpoint";
|
|
34
|
-
endpoint:
|
|
38
|
+
endpoint: TEndpointName;
|
|
35
39
|
timeoutMs?: number;
|
|
36
40
|
healthProbeMs?: number;
|
|
37
41
|
};
|
|
@@ -58,8 +62,12 @@ interface ICommanderEnvVar {
|
|
|
58
62
|
/** A start refuses unless a value is in hand (default, override, or inherited). */
|
|
59
63
|
required?: boolean;
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The type parameters are what `defineCommanderConfig` infers from the whole config: every
|
|
67
|
+
* declared process id and endpoint name, so a reference to one that does not exist is a type error.
|
|
68
|
+
*/
|
|
69
|
+
interface ICommanderProcessDefinition<TProcessId extends string = string, TEndpointName extends string = string> {
|
|
70
|
+
id: TProcessId;
|
|
63
71
|
/** Default from `defaults.kind`, else "service". */
|
|
64
72
|
kind?: TNiceProcessKind;
|
|
65
73
|
/** Relative cwd resolves against the config file's realpath directory, never the shell's. */
|
|
@@ -89,8 +97,8 @@ interface ICommanderProcessDefinition {
|
|
|
89
97
|
* Transitive: starting this starts each dependency first and waits for it — service
|
|
90
98
|
* dependencies until ready, task dependencies until succeeded. Acyclic, validated at load.
|
|
91
99
|
*/
|
|
92
|
-
dependsOn?:
|
|
93
|
-
endpoints?: ICommanderEndpoint[];
|
|
100
|
+
dependsOn?: readonly NoInfer<TProcessId>[];
|
|
101
|
+
endpoints?: ICommanderEndpoint<TEndpointName>[];
|
|
94
102
|
/**
|
|
95
103
|
* A start that finds an `exclusive` endpoint held by a STRAY — this same command (argv + cwd)
|
|
96
104
|
* running outside the daemon, typically started by hand in a terminal that has since gone —
|
|
@@ -100,7 +108,8 @@ interface ICommanderProcessDefinition {
|
|
|
100
108
|
replaceSame?: boolean;
|
|
101
109
|
/** Primary "open" link when no endpoint owns it. */
|
|
102
110
|
url?: string;
|
|
103
|
-
|
|
111
|
+
/** An `endpoint` readiness names an endpoint of this same process (checked at load). */
|
|
112
|
+
ready?: TCommanderReady<NoInfer<TEndpointName>>;
|
|
104
113
|
stop?: INiceProcessStopOptions;
|
|
105
114
|
/** Automatic restart is service-only in v1; a task is explicitly rerun. */
|
|
106
115
|
restart?: INiceProcessRestartOptions;
|
|
@@ -120,15 +129,15 @@ type TCommanderTagQueryOr = TCommanderTagQuery | readonly TCommanderTagQuery[];
|
|
|
120
129
|
* A named run-unit: several processes you mean to run as ONE thing (`verify`, `dev`). A label is
|
|
121
130
|
* a tag — a suite must resolve to at least two members.
|
|
122
131
|
*/
|
|
123
|
-
interface ICommanderSuiteDefinition {
|
|
132
|
+
interface ICommanderSuiteDefinition<TProcessId extends string = string, TSuiteName extends string = string> {
|
|
124
133
|
/** One line — shown on the suite's card and in `list`. */
|
|
125
134
|
description?: string;
|
|
126
135
|
/** Tag-equality selection: OR of AND-maps. Skips `optIn` processes. */
|
|
127
136
|
where?: TCommanderTagQueryOr;
|
|
128
137
|
/** Process ids and/or other suite names. Suite references must be acyclic. */
|
|
129
|
-
include?: readonly
|
|
138
|
+
include?: readonly NoInfer<TProcessId | TSuiteName>[];
|
|
130
139
|
/** Excluded ids and/or tag queries, applied last. */
|
|
131
|
-
exclude?: readonly (
|
|
140
|
+
exclude?: readonly (NoInfer<TProcessId> | TCommanderTagQuery)[] | TCommanderTagQuery;
|
|
132
141
|
/** How many tasks run at once. Default 4. */
|
|
133
142
|
parallel?: number;
|
|
134
143
|
/** Stop scheduling tasks after the first failure. Default false. */
|
|
@@ -149,17 +158,22 @@ interface ICommanderDefaults {
|
|
|
149
158
|
};
|
|
150
159
|
tags?: Record<string, string | readonly string[]>;
|
|
151
160
|
}
|
|
152
|
-
|
|
161
|
+
/** One `key=value` selection term. */
|
|
162
|
+
type TCommanderTagTerm = `${string}=${string}`;
|
|
163
|
+
interface ICommanderConfig<TProcessId extends string = string, TSuiteName extends string = string, TEndpointName extends string = string> {
|
|
153
164
|
/** Config name — also the data-dir slug seed (D6). Same charset as ids. */
|
|
154
165
|
name: string;
|
|
155
166
|
defaults?: ICommanderDefaults;
|
|
156
|
-
processes: ICommanderProcessDefinition[];
|
|
157
|
-
|
|
167
|
+
processes: ICommanderProcessDefinition<TProcessId, TEndpointName>[];
|
|
168
|
+
/** Keyed by suite name — never `all` (the built-in selector) and never a process id. */
|
|
169
|
+
suites?: { [TName in TSuiteName]: TName extends typeof RESERVED_SELECTOR_NAME ? `'${TName}' is the built-in selector: pick another suite name` : TName extends TKnownIds<TProcessId> ? `'${TName}' is already a process id: pick another suite name` : ICommanderSuiteDefinition<TProcessId, TSuiteName> };
|
|
158
170
|
/**
|
|
159
171
|
* Selection used by a bare `up` — a suite name, a process id, or one `tag=value` term. Without
|
|
160
172
|
* it, bare `up` prints the available suites and exits without mutating anything.
|
|
161
173
|
*/
|
|
162
|
-
defaultSelection?:
|
|
174
|
+
defaultSelection?: NoInfer<TProcessId | TSuiteName> | TCommanderTagTerm;
|
|
175
|
+
/** @deprecated Removed: organise processes with `tags`, and declare a run-unit under `suites`. */
|
|
176
|
+
groups?: "`groups` was removed: organise processes with `tags`, and declare run-units under `suites`";
|
|
163
177
|
/** Local config helpers the D2 loader cannot discover automatically (repo-relative). */
|
|
164
178
|
watchFiles?: readonly string[];
|
|
165
179
|
daemon?: {
|
|
@@ -168,8 +182,17 @@ interface ICommanderConfig {
|
|
|
168
182
|
}
|
|
169
183
|
//#endregion
|
|
170
184
|
//#region src/config.d.ts
|
|
171
|
-
/**
|
|
172
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Identity helper so `commander.config.ts` files are typed end to end: an unknown or removed key is
|
|
187
|
+
* a type error, and so is a `dependsOn`, suite `include`/`exclude`, `defaultSelection` or endpoint
|
|
188
|
+
* `ready` that names something the config never declares.
|
|
189
|
+
*
|
|
190
|
+
* ⚠ The reference checks need literal ids. Processes built from a list typed `{ id: string }[]`
|
|
191
|
+
* widen every id to `string` and switch those checks off — declare the list `as const` instead.
|
|
192
|
+
* A `.map()` callback is not contextually typed, so write `dependsOn: [...] as const` there, as
|
|
193
|
+
* with `kind`.
|
|
194
|
+
*/
|
|
195
|
+
declare function defineCommanderConfig<TProcessId extends string, TSuiteName extends string = never, TEndpointName extends string = never>(config: ICommanderConfig<TProcessId, TSuiteName, TEndpointName>): ICommanderConfig<TProcessId, TSuiteName, TEndpointName>;
|
|
173
196
|
//#endregion
|
|
174
|
-
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 };
|
|
197
|
+
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, type TCommanderTagTerm, defineCommanderConfig };
|
|
175
198
|
//# sourceMappingURL=config.d.cts.map
|
package/build/config.d.mts
CHANGED
|
@@ -3,6 +3,10 @@ import { INiceProcessRestartOptions, INiceProcessStopOptions, TNiceProcessKind,
|
|
|
3
3
|
//#region src/config/types.d.ts
|
|
4
4
|
/** Ids appear in CLI selectors, URLs and ledger filenames — never option-shaped (edge 31). */
|
|
5
5
|
declare const COMMANDER_ID_PATTERN: RegExp;
|
|
6
|
+
/** The built-in selection word a config may never redefine. */
|
|
7
|
+
declare const RESERVED_SELECTOR_NAME = "all";
|
|
8
|
+
/** The literal ids a config declared, or `never` once they widened to `string` (built at runtime). */
|
|
9
|
+
type TKnownIds<TId extends string> = string extends TId ? never : TId;
|
|
6
10
|
type TCommanderEndpointProtocol = "tcp" | "http";
|
|
7
11
|
type TCommanderEndpointOwnership = "exclusive" | "shared" | "observed";
|
|
8
12
|
interface ICommanderEndpointHealth {
|
|
@@ -11,9 +15,9 @@ interface ICommanderEndpointHealth {
|
|
|
11
15
|
/** Bounded body read must contain this marker. */
|
|
12
16
|
match?: string;
|
|
13
17
|
}
|
|
14
|
-
interface ICommanderEndpoint {
|
|
18
|
+
interface ICommanderEndpoint<TEndpointName extends string = string> {
|
|
15
19
|
/** Unique per process; referenced by `ready: { kind: "endpoint" }` and UI badges. */
|
|
16
|
-
name:
|
|
20
|
+
name: TEndpointName;
|
|
17
21
|
protocol: TCommanderEndpointProtocol;
|
|
18
22
|
host?: string;
|
|
19
23
|
port: number;
|
|
@@ -29,9 +33,9 @@ interface ICommanderEndpoint {
|
|
|
29
33
|
* Readiness sugar: `ready: { kind: "endpoint", endpoint: "web" }` expands against the named
|
|
30
34
|
* endpoint — tcp → `port` readiness, http → `httpOk` against `health.path` (+ `health.match`).
|
|
31
35
|
*/
|
|
32
|
-
type TCommanderReady = TNiceProcessReady | {
|
|
36
|
+
type TCommanderReady<TEndpointName extends string = string> = TNiceProcessReady | {
|
|
33
37
|
kind: "endpoint";
|
|
34
|
-
endpoint:
|
|
38
|
+
endpoint: TEndpointName;
|
|
35
39
|
timeoutMs?: number;
|
|
36
40
|
healthProbeMs?: number;
|
|
37
41
|
};
|
|
@@ -58,8 +62,12 @@ interface ICommanderEnvVar {
|
|
|
58
62
|
/** A start refuses unless a value is in hand (default, override, or inherited). */
|
|
59
63
|
required?: boolean;
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The type parameters are what `defineCommanderConfig` infers from the whole config: every
|
|
67
|
+
* declared process id and endpoint name, so a reference to one that does not exist is a type error.
|
|
68
|
+
*/
|
|
69
|
+
interface ICommanderProcessDefinition<TProcessId extends string = string, TEndpointName extends string = string> {
|
|
70
|
+
id: TProcessId;
|
|
63
71
|
/** Default from `defaults.kind`, else "service". */
|
|
64
72
|
kind?: TNiceProcessKind;
|
|
65
73
|
/** Relative cwd resolves against the config file's realpath directory, never the shell's. */
|
|
@@ -89,8 +97,8 @@ interface ICommanderProcessDefinition {
|
|
|
89
97
|
* Transitive: starting this starts each dependency first and waits for it — service
|
|
90
98
|
* dependencies until ready, task dependencies until succeeded. Acyclic, validated at load.
|
|
91
99
|
*/
|
|
92
|
-
dependsOn?:
|
|
93
|
-
endpoints?: ICommanderEndpoint[];
|
|
100
|
+
dependsOn?: readonly NoInfer<TProcessId>[];
|
|
101
|
+
endpoints?: ICommanderEndpoint<TEndpointName>[];
|
|
94
102
|
/**
|
|
95
103
|
* A start that finds an `exclusive` endpoint held by a STRAY — this same command (argv + cwd)
|
|
96
104
|
* running outside the daemon, typically started by hand in a terminal that has since gone —
|
|
@@ -100,7 +108,8 @@ interface ICommanderProcessDefinition {
|
|
|
100
108
|
replaceSame?: boolean;
|
|
101
109
|
/** Primary "open" link when no endpoint owns it. */
|
|
102
110
|
url?: string;
|
|
103
|
-
|
|
111
|
+
/** An `endpoint` readiness names an endpoint of this same process (checked at load). */
|
|
112
|
+
ready?: TCommanderReady<NoInfer<TEndpointName>>;
|
|
104
113
|
stop?: INiceProcessStopOptions;
|
|
105
114
|
/** Automatic restart is service-only in v1; a task is explicitly rerun. */
|
|
106
115
|
restart?: INiceProcessRestartOptions;
|
|
@@ -120,15 +129,15 @@ type TCommanderTagQueryOr = TCommanderTagQuery | readonly TCommanderTagQuery[];
|
|
|
120
129
|
* A named run-unit: several processes you mean to run as ONE thing (`verify`, `dev`). A label is
|
|
121
130
|
* a tag — a suite must resolve to at least two members.
|
|
122
131
|
*/
|
|
123
|
-
interface ICommanderSuiteDefinition {
|
|
132
|
+
interface ICommanderSuiteDefinition<TProcessId extends string = string, TSuiteName extends string = string> {
|
|
124
133
|
/** One line — shown on the suite's card and in `list`. */
|
|
125
134
|
description?: string;
|
|
126
135
|
/** Tag-equality selection: OR of AND-maps. Skips `optIn` processes. */
|
|
127
136
|
where?: TCommanderTagQueryOr;
|
|
128
137
|
/** Process ids and/or other suite names. Suite references must be acyclic. */
|
|
129
|
-
include?: readonly
|
|
138
|
+
include?: readonly NoInfer<TProcessId | TSuiteName>[];
|
|
130
139
|
/** Excluded ids and/or tag queries, applied last. */
|
|
131
|
-
exclude?: readonly (
|
|
140
|
+
exclude?: readonly (NoInfer<TProcessId> | TCommanderTagQuery)[] | TCommanderTagQuery;
|
|
132
141
|
/** How many tasks run at once. Default 4. */
|
|
133
142
|
parallel?: number;
|
|
134
143
|
/** Stop scheduling tasks after the first failure. Default false. */
|
|
@@ -149,17 +158,22 @@ interface ICommanderDefaults {
|
|
|
149
158
|
};
|
|
150
159
|
tags?: Record<string, string | readonly string[]>;
|
|
151
160
|
}
|
|
152
|
-
|
|
161
|
+
/** One `key=value` selection term. */
|
|
162
|
+
type TCommanderTagTerm = `${string}=${string}`;
|
|
163
|
+
interface ICommanderConfig<TProcessId extends string = string, TSuiteName extends string = string, TEndpointName extends string = string> {
|
|
153
164
|
/** Config name — also the data-dir slug seed (D6). Same charset as ids. */
|
|
154
165
|
name: string;
|
|
155
166
|
defaults?: ICommanderDefaults;
|
|
156
|
-
processes: ICommanderProcessDefinition[];
|
|
157
|
-
|
|
167
|
+
processes: ICommanderProcessDefinition<TProcessId, TEndpointName>[];
|
|
168
|
+
/** Keyed by suite name — never `all` (the built-in selector) and never a process id. */
|
|
169
|
+
suites?: { [TName in TSuiteName]: TName extends typeof RESERVED_SELECTOR_NAME ? `'${TName}' is the built-in selector: pick another suite name` : TName extends TKnownIds<TProcessId> ? `'${TName}' is already a process id: pick another suite name` : ICommanderSuiteDefinition<TProcessId, TSuiteName> };
|
|
158
170
|
/**
|
|
159
171
|
* Selection used by a bare `up` — a suite name, a process id, or one `tag=value` term. Without
|
|
160
172
|
* it, bare `up` prints the available suites and exits without mutating anything.
|
|
161
173
|
*/
|
|
162
|
-
defaultSelection?:
|
|
174
|
+
defaultSelection?: NoInfer<TProcessId | TSuiteName> | TCommanderTagTerm;
|
|
175
|
+
/** @deprecated Removed: organise processes with `tags`, and declare a run-unit under `suites`. */
|
|
176
|
+
groups?: "`groups` was removed: organise processes with `tags`, and declare run-units under `suites`";
|
|
163
177
|
/** Local config helpers the D2 loader cannot discover automatically (repo-relative). */
|
|
164
178
|
watchFiles?: readonly string[];
|
|
165
179
|
daemon?: {
|
|
@@ -168,8 +182,17 @@ interface ICommanderConfig {
|
|
|
168
182
|
}
|
|
169
183
|
//#endregion
|
|
170
184
|
//#region src/config.d.ts
|
|
171
|
-
/**
|
|
172
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Identity helper so `commander.config.ts` files are typed end to end: an unknown or removed key is
|
|
187
|
+
* a type error, and so is a `dependsOn`, suite `include`/`exclude`, `defaultSelection` or endpoint
|
|
188
|
+
* `ready` that names something the config never declares.
|
|
189
|
+
*
|
|
190
|
+
* ⚠ The reference checks need literal ids. Processes built from a list typed `{ id: string }[]`
|
|
191
|
+
* widen every id to `string` and switch those checks off — declare the list `as const` instead.
|
|
192
|
+
* A `.map()` callback is not contextually typed, so write `dependsOn: [...] as const` there, as
|
|
193
|
+
* with `kind`.
|
|
194
|
+
*/
|
|
195
|
+
declare function defineCommanderConfig<TProcessId extends string, TSuiteName extends string = never, TEndpointName extends string = never>(config: ICommanderConfig<TProcessId, TSuiteName, TEndpointName>): ICommanderConfig<TProcessId, TSuiteName, TEndpointName>;
|
|
173
196
|
//#endregion
|
|
174
|
-
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 };
|
|
197
|
+
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, type TCommanderTagTerm, defineCommanderConfig };
|
|
175
198
|
//# sourceMappingURL=config.d.mts.map
|
package/build/config.mjs
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { t as COMMANDER_ID_PATTERN } from "./types-B3WIUo4S.mjs";
|
|
2
2
|
//#region src/config.ts
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Identity helper so `commander.config.ts` files are typed end to end: an unknown or removed key is
|
|
5
|
+
* a type error, and so is a `dependsOn`, suite `include`/`exclude`, `defaultSelection` or endpoint
|
|
6
|
+
* `ready` that names something the config never declares.
|
|
7
|
+
*
|
|
8
|
+
* ⚠ The reference checks need literal ids. Processes built from a list typed `{ id: string }[]`
|
|
9
|
+
* widen every id to `string` and switch those checks off — declare the list `as const` instead.
|
|
10
|
+
* A `.map()` callback is not contextually typed, so write `dependsOn: [...] as const` there, as
|
|
11
|
+
* with `kind`.
|
|
12
|
+
*/
|
|
4
13
|
function defineCommanderConfig(config) {
|
|
5
14
|
return config;
|
|
6
15
|
}
|
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 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
|
|
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 type TCommanderTagTerm,\n} from \"./config/types\";\n\n/**\n * Identity helper so `commander.config.ts` files are typed end to end: an unknown or removed key is\n * a type error, and so is a `dependsOn`, suite `include`/`exclude`, `defaultSelection` or endpoint\n * `ready` that names something the config never declares.\n *\n * ⚠ The reference checks need literal ids. Processes built from a list typed `{ id: string }[]`\n * widen every id to `string` and switch those checks off — declare the list `as const` instead.\n * A `.map()` callback is not contextually typed, so write `dependsOn: [...] as const` there, as\n * with `kind`.\n */\nexport function defineCommanderConfig<\n TProcessId extends string,\n TSuiteName extends string = never,\n TEndpointName extends string = never,\n>(\n config: ICommanderConfig<TProcessId, TSuiteName, TEndpointName>,\n): ICommanderConfig<TProcessId, TSuiteName, TEndpointName> {\n return config;\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,sBAKd,QACyD;CACzD,OAAO;AACT"}
|
|
@@ -511,6 +511,7 @@ function projectProcess(status) {
|
|
|
511
511
|
state: status.state,
|
|
512
512
|
...status.pid != null ? { pid: status.pid } : {},
|
|
513
513
|
...status.startedAt != null ? { startedAt: status.startedAt } : {},
|
|
514
|
+
...status.lastStartedAt != null ? { lastStartedAt: status.lastStartedAt } : {},
|
|
514
515
|
...status.sawOutputAt != null ? { sawOutputAt: status.sawOutputAt } : {},
|
|
515
516
|
...status.lastTask != null ? { lastTask: {
|
|
516
517
|
outcome: status.lastTask.outcome,
|
|
@@ -765,6 +766,41 @@ function createControlPlane(options) {
|
|
|
765
766
|
};
|
|
766
767
|
}
|
|
767
768
|
//#endregion
|
|
769
|
+
//#region src/daemon/lastStarts.ts
|
|
770
|
+
const STORE_VERSION = 1;
|
|
771
|
+
/** Newest first, capped at `MAX_LAST_STARTS`. */
|
|
772
|
+
function bounded(entries) {
|
|
773
|
+
return Object.fromEntries([...entries].sort(([, a], [, b]) => b - a).slice(0, 256));
|
|
774
|
+
}
|
|
775
|
+
/** Missing, unreadable or corrupt all read as "nothing started yet" — never a reason to fail a boot. */
|
|
776
|
+
async function readLastStarts(path) {
|
|
777
|
+
try {
|
|
778
|
+
const parsed = JSON.parse(await (0, node_fs_promises.readFile)(path, "utf8"));
|
|
779
|
+
if (parsed == null || typeof parsed !== "object" || !("processes" in parsed)) return {};
|
|
780
|
+
const processes = parsed.processes;
|
|
781
|
+
if (processes == null || typeof processes !== "object" || Array.isArray(processes)) return {};
|
|
782
|
+
return bounded(Object.entries(processes).filter((entry) => typeof entry[1] === "number" && Number.isFinite(entry[1])));
|
|
783
|
+
} catch {
|
|
784
|
+
return {};
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
async function writeLastStarts(path, lastStarts) {
|
|
788
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), {
|
|
789
|
+
recursive: true,
|
|
790
|
+
mode: 448
|
|
791
|
+
});
|
|
792
|
+
const temp = `${path}.${process.pid}.tmp`;
|
|
793
|
+
const store = {
|
|
794
|
+
version: STORE_VERSION,
|
|
795
|
+
processes: bounded(Object.entries(lastStarts))
|
|
796
|
+
};
|
|
797
|
+
await (0, node_fs_promises.writeFile)(temp, `${JSON.stringify(store, null, 2)}\n`, {
|
|
798
|
+
encoding: "utf8",
|
|
799
|
+
mode: 384
|
|
800
|
+
});
|
|
801
|
+
await (0, node_fs_promises.rename)(temp, path);
|
|
802
|
+
}
|
|
803
|
+
//#endregion
|
|
768
804
|
//#region src/daemon/history.ts
|
|
769
805
|
/** Entries one read may return. A viewer renders a screenful; this is already generous. */
|
|
770
806
|
const MAX_HISTORY_ENTRIES = 2e3;
|
|
@@ -1327,6 +1363,8 @@ var CommanderSupervisor = class {
|
|
|
1327
1363
|
_lineListeners = /* @__PURE__ */ new Map();
|
|
1328
1364
|
_mergedListeners = /* @__PURE__ */ new Set();
|
|
1329
1365
|
_envOverrides;
|
|
1366
|
+
_lastStarts;
|
|
1367
|
+
_onStart;
|
|
1330
1368
|
_stopping = false;
|
|
1331
1369
|
/** The daemon and its ancestors — never a stray, never signalled. Read once. */
|
|
1332
1370
|
_protectedPids = null;
|
|
@@ -1337,6 +1375,8 @@ var CommanderSupervisor = class {
|
|
|
1337
1375
|
this._depWaitMs = options.depWaitMs ?? 6e4;
|
|
1338
1376
|
this._logsDir = options.logsDir;
|
|
1339
1377
|
this._envOverrides = options.envOverrides ?? {};
|
|
1378
|
+
this._lastStarts = options.lastStarts ?? {};
|
|
1379
|
+
this._onStart = options.onStart;
|
|
1340
1380
|
for (const definition of options.config.processes) this._holders.set(definition.id, this._newHolder(definition));
|
|
1341
1381
|
}
|
|
1342
1382
|
get config() {
|
|
@@ -1387,6 +1427,11 @@ var CommanderSupervisor = class {
|
|
|
1387
1427
|
});
|
|
1388
1428
|
if (holder.recentRuns.length > RECENT_RUNS_CAP) holder.recentRuns.shift();
|
|
1389
1429
|
}
|
|
1430
|
+
_markStarted(holder) {
|
|
1431
|
+
const at = Date.now();
|
|
1432
|
+
holder.startedAt = at;
|
|
1433
|
+
this._onStart?.(holder.definition.id, at);
|
|
1434
|
+
}
|
|
1390
1435
|
/** Close the live tail record — idempotent; the first close wins. */
|
|
1391
1436
|
_runEnded(holder, outcome) {
|
|
1392
1437
|
const tail = holder.recentRuns[holder.recentRuns.length - 1];
|
|
@@ -1702,7 +1747,7 @@ var CommanderSupervisor = class {
|
|
|
1702
1747
|
spawned += 1;
|
|
1703
1748
|
try {
|
|
1704
1749
|
await proc.start();
|
|
1705
|
-
|
|
1750
|
+
this._markStarted(holder);
|
|
1706
1751
|
holder.stale = false;
|
|
1707
1752
|
holder.startError = null;
|
|
1708
1753
|
this._recomputeDegraded();
|
|
@@ -1782,7 +1827,7 @@ var CommanderSupervisor = class {
|
|
|
1782
1827
|
}
|
|
1783
1828
|
try {
|
|
1784
1829
|
await proc.start();
|
|
1785
|
-
|
|
1830
|
+
this._markStarted(holder);
|
|
1786
1831
|
holder.stale = false;
|
|
1787
1832
|
holder.startError = null;
|
|
1788
1833
|
this._notify(id);
|
|
@@ -2018,6 +2063,7 @@ var CommanderSupervisor = class {
|
|
|
2018
2063
|
state,
|
|
2019
2064
|
pid: proc?.pid ?? null,
|
|
2020
2065
|
startedAt: holder.startedAt,
|
|
2066
|
+
lastStartedAt: holder.startedAt ?? this._lastStarts[holder.definition.id] ?? null,
|
|
2021
2067
|
sawOutputAt: holder.sawOutputAt,
|
|
2022
2068
|
lastTask: holder.lastTask,
|
|
2023
2069
|
recentRuns: holder.recentRuns.map((run) => ({ ...run })),
|
|
@@ -2196,12 +2242,29 @@ async function startCommanderDaemon(argv) {
|
|
|
2196
2242
|
});
|
|
2197
2243
|
const sink = new AggregateSink(paths.logsDir, paths.ingestSeqPath, generation);
|
|
2198
2244
|
const envOverrides = await require_cli.readEnvOverrides(paths.envOverridesPath);
|
|
2245
|
+
let lastStarts = await readLastStarts(paths.lastStartsPath);
|
|
2246
|
+
let lastStartsQueued = false;
|
|
2247
|
+
let lastStartsWrites = Promise.resolve();
|
|
2248
|
+
const recordStart = (id, at) => {
|
|
2249
|
+
lastStarts = {
|
|
2250
|
+
...lastStarts,
|
|
2251
|
+
[id]: at
|
|
2252
|
+
};
|
|
2253
|
+
if (lastStartsQueued) return;
|
|
2254
|
+
lastStartsQueued = true;
|
|
2255
|
+
lastStartsWrites = lastStartsWrites.then(async () => {
|
|
2256
|
+
lastStartsQueued = false;
|
|
2257
|
+
await writeLastStarts(paths.lastStartsPath, lastStarts).catch((error) => log(`last starts not saved: ${error.message}`));
|
|
2258
|
+
});
|
|
2259
|
+
};
|
|
2199
2260
|
const supervisor = new CommanderSupervisor({
|
|
2200
2261
|
config: resolved,
|
|
2201
2262
|
ledger,
|
|
2202
2263
|
sink,
|
|
2203
2264
|
logsDir: paths.logsDir,
|
|
2204
|
-
envOverrides
|
|
2265
|
+
envOverrides,
|
|
2266
|
+
lastStarts,
|
|
2267
|
+
onStart: recordStart
|
|
2205
2268
|
});
|
|
2206
2269
|
const token = (0, node_crypto.randomUUID)();
|
|
2207
2270
|
const auth = new CommanderAuth(token);
|
|
@@ -2486,4 +2549,4 @@ async function runCommanderDaemon(argv) {
|
|
|
2486
2549
|
//#endregion
|
|
2487
2550
|
exports.runCommanderDaemon = runCommanderDaemon;
|
|
2488
2551
|
|
|
2489
|
-
//# sourceMappingURL=main-
|
|
2552
|
+
//# sourceMappingURL=main-CVu9gjbx.cjs.map
|