@hydranium/cli 1.0.0-next.212 → 1.0.0-next.214
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/lib/commands/ast-ground-truth-args.d.ts +3 -2
- package/lib/commands/ast-ground-truth-args.d.ts.map +1 -1
- package/lib/commands/ast-ground-truth-args.js +9 -7
- package/lib/commands/ast-ground-truth-args.js.map +1 -1
- package/lib/commands/harness-args.d.ts +18 -7
- package/lib/commands/harness-args.d.ts.map +1 -1
- package/lib/commands/harness-args.js +31 -13
- package/lib/commands/harness-args.js.map +1 -1
- package/lib/commands/headless-harness.d.ts +5 -2
- package/lib/commands/headless-harness.d.ts.map +1 -1
- package/lib/commands/headless-harness.js +50 -7
- package/lib/commands/headless-harness.js.map +1 -1
- package/lib/commands/lint-grammar-args.d.ts +3 -2
- package/lib/commands/lint-grammar-args.d.ts.map +1 -1
- package/lib/commands/lint-grammar-args.js +10 -7
- package/lib/commands/lint-grammar-args.js.map +1 -1
- package/lib/commands/measure-memory-args.d.ts +3 -2
- package/lib/commands/measure-memory-args.d.ts.map +1 -1
- package/lib/commands/measure-memory-args.js +10 -7
- package/lib/commands/measure-memory-args.js.map +1 -1
- package/lib/commands/model-docs-args.d.ts +4 -3
- package/lib/commands/model-docs-args.d.ts.map +1 -1
- package/lib/commands/model-docs-args.js +10 -8
- package/lib/commands/model-docs-args.js.map +1 -1
- package/lib/commands/reflect-args.d.ts +3 -2
- package/lib/commands/reflect-args.d.ts.map +1 -1
- package/lib/commands/reflect-args.js +10 -7
- package/lib/commands/reflect-args.js.map +1 -1
- package/lib/commands/validate-args.d.ts +3 -2
- package/lib/commands/validate-args.d.ts.map +1 -1
- package/lib/commands/validate-args.js +10 -7
- package/lib/commands/validate-args.js.map +1 -1
- package/package.json +9 -9
- package/src/commands/ast-ground-truth-args.ts +10 -7
- package/src/commands/harness-args.ts +36 -14
- package/src/commands/headless-harness.ts +54 -7
- package/src/commands/lint-grammar-args.ts +11 -7
- package/src/commands/measure-memory-args.ts +11 -7
- package/src/commands/model-docs-args.ts +11 -8
- package/src/commands/reflect-args.ts +11 -7
- package/src/commands/validate-args.ts +11 -7
package/README.md
CHANGED
|
@@ -61,6 +61,14 @@ Most subcommands take `--services <module>`: an ESM module exporting a zero-arg
|
|
|
61
61
|
`createServices(): { shared }` thunk — normally your build's `./lib/services.js`. The head wires its
|
|
62
62
|
own filesystem inside, so the CLI boots it with no arguments.
|
|
63
63
|
|
|
64
|
+
To run the head from its TypeScript source instead, register a loader with `--import <specifier>`
|
|
65
|
+
(repeatable), which the CLI passes as Node's own `--import` to the process that imports the head:
|
|
66
|
+
`npx hydranium-cli reflect --import tsx --services ./src/services.ts`. A package name resolves from
|
|
67
|
+
the directory the command runs in, as Node's flag does; a path, absolute or relative, is resolved
|
|
68
|
+
against that directory and passed on as a file URL, so Windows paths work too. Node's built-in type
|
|
69
|
+
stripping is not enough on its own: it neither maps a head's `./x.js` imports to their `.ts` sources
|
|
70
|
+
nor accepts the namespaces Langium generates.
|
|
71
|
+
|
|
64
72
|
**Scaffolding**
|
|
65
73
|
|
|
66
74
|
- `init <target-dir>` — scaffold a new language project. See the section below.
|
|
@@ -10,8 +10,9 @@ import { type AstGroundTruthCommandOptions } from './ast-ground-truth.js';
|
|
|
10
10
|
import { type UsageError } from './harness-args.js';
|
|
11
11
|
/**
|
|
12
12
|
* Every flag `ast-ground-truth` accepts, derived from the sets the parser is
|
|
13
|
-
* handed so the list cannot claim a flag the parser would reject.
|
|
14
|
-
*
|
|
13
|
+
* handed so the list cannot claim a flag the parser would reject.
|
|
14
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
15
|
+
* so they are in neither set.
|
|
15
16
|
*/
|
|
16
17
|
export declare const AST_GROUND_TRUTH_FLAGS: readonly string[];
|
|
17
18
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-ground-truth-args.d.ts","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAqB,KAAK,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,
|
|
1
|
+
{"version":3,"file":"ast-ground-truth-args.d.ts","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAqB,KAAK,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAUJ,KAAK,UAAU,EACjB,MAAM,mBAAmB,CAAC;AAK3B;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAA6C,CAAC;AAElG,oFAAoF;AACpF,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAA2B,CAAC;AAEtF,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAclD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAA0B,GAAG,4BAA4B,CAGzH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAMtE"}
|
|
@@ -7,20 +7,21 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { runAstGroundTruth } from './ast-ground-truth.js';
|
|
10
|
-
import { exitWithUsage, helpRequested, LOG_VALUE_FLAGS, logHelpLines, logOptions, parseHarnessArgs, printHelp
|
|
10
|
+
import { exitWithUsage, HARNESS_VALUE_FLAGS, helpRequested, importHelpLines, LOG_VALUE_FLAGS, logHelpLines, logOptions, parseHarnessArgs, printHelp } from './harness-args.js';
|
|
11
11
|
import { OUT_FILE_FLAG } from './headless-harness.js';
|
|
12
12
|
const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS];
|
|
13
13
|
/**
|
|
14
14
|
* Every flag `ast-ground-truth` accepts, derived from the sets the parser is
|
|
15
|
-
* handed so the list cannot claim a flag the parser would reject.
|
|
16
|
-
*
|
|
15
|
+
* handed so the list cannot claim a flag the parser would reject.
|
|
16
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
17
|
+
* so they are in neither set.
|
|
17
18
|
*/
|
|
18
|
-
export const AST_GROUND_TRUTH_FLAGS = [
|
|
19
|
+
export const AST_GROUND_TRUTH_FLAGS = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
19
20
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
20
21
|
export const AST_GROUND_TRUTH_VALUE_FLAGS = AST_GROUND_TRUTH_FLAGS;
|
|
21
22
|
/** The `--help` text, as data, held to {@link AST_GROUND_TRUTH_FLAGS} by a test. */
|
|
22
23
|
export const AST_GROUND_TRUTH_HELP = [
|
|
23
|
-
'Usage: hydranium-cli ast-ground-truth --services <module> <workspace> [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
24
|
+
'Usage: hydranium-cli ast-ground-truth --services <module> [--import <specifier>]... <workspace> [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
24
25
|
'',
|
|
25
26
|
"Tally a workspace's live-model AST nodes by `$type` — the ground truth that",
|
|
26
27
|
'`analyze-heap --validate <gt.json>` checks a heap snapshot against. `<module>`',
|
|
@@ -29,13 +30,14 @@ export const AST_GROUND_TRUTH_HELP = [
|
|
|
29
30
|
'',
|
|
30
31
|
'Options:',
|
|
31
32
|
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
33
|
+
...importHelpLines(22),
|
|
32
34
|
' <workspace> Workspace root (path or file URI) to build (required).',
|
|
33
35
|
' --out-file <file> Write the JSON to this file instead of stdout.',
|
|
34
36
|
...logHelpLines(22)
|
|
35
37
|
];
|
|
36
38
|
export function parseAstGroundTruthArgs(args, onError = exitWithUsage) {
|
|
37
|
-
const { servicesModule, workspace, options } = parseHarnessArgs(args, 'ast-ground-truth', VALUE_FLAGS, [], { onError });
|
|
38
|
-
return { servicesModule, workspace, outFile: options[OUT_FILE_FLAG], ...logOptions(options) };
|
|
39
|
+
const { servicesModule, imports, workspace, options } = parseHarnessArgs(args, 'ast-ground-truth', VALUE_FLAGS, [], { onError });
|
|
40
|
+
return { servicesModule, imports, workspace, outFile: options[OUT_FILE_FLAG], ...logOptions(options) };
|
|
39
41
|
}
|
|
40
42
|
export function runAstGroundTruthCommand(args) {
|
|
41
43
|
if (helpRequested(args, AST_GROUND_TRUTH_VALUE_FLAGS)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-ground-truth-args.js","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,iBAAiB,EAAqC,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EACJ,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,SAAS,
|
|
1
|
+
{"version":3,"file":"ast-ground-truth-args.js","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,iBAAiB,EAAqC,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EACJ,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,SAAS,EAEX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,WAAW,GAAG,CAAC,aAAa,EAAE,GAAG,eAAe,CAAU,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB,CAAC,GAAG,mBAAmB,EAAE,GAAG,WAAW,CAAC,CAAC;AAElG,oFAAoF;AACpF,MAAM,CAAC,MAAM,4BAA4B,GAAsB,sBAAsB,CAAC;AAEtF,oFAAoF;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACrD,sLAAsL;IACtL,EAAE;IACF,6EAA6E;IAC7E,gFAAgF;IAChF,oEAAoE;IACpE,0EAA0E;IAC1E,EAAE;IACF,UAAU;IACV,yFAAyF;IACzF,GAAG,eAAe,CAAC,EAAE,CAAC;IACtB,gFAAgF;IAChF,wEAAwE;IACxE,GAAG,YAAY,CAAC,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,UAAU,uBAAuB,CAAC,IAAc,EAAE,OAAO,GAAe,aAAa;IACxF,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACjI,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;AAC1G,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAc;IACpD,IAAI,aAAa,CAAC,IAAI,EAAE,4BAA4B,CAAC,EAAE,CAAC;QACrD,SAAS,CAAC,qBAAqB,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,iBAAiB,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -21,8 +21,15 @@ export type UsageError = (message: string) => never;
|
|
|
21
21
|
* bundled heap analyzer exits with for a usage error.
|
|
22
22
|
*/
|
|
23
23
|
export declare function exitWithUsage(message: string): never;
|
|
24
|
-
/**
|
|
24
|
+
/** Names the head's services module; every harness subcommand requires it. */
|
|
25
25
|
export declare const SERVICES_FLAG = "--services";
|
|
26
|
+
/**
|
|
27
|
+
* Registers a loader in the driver child that imports the head. The child is a
|
|
28
|
+
* fresh `node`, so a loader registered on the CLI's own process never reaches it.
|
|
29
|
+
*/
|
|
30
|
+
export declare const IMPORT_FLAG = "--import";
|
|
31
|
+
/** The value flags {@link parseHarnessArgs} consumes itself, before any the subcommand declares. */
|
|
32
|
+
export declare const HARNESS_VALUE_FLAGS: readonly ["--services", "--import"];
|
|
26
33
|
/**
|
|
27
34
|
* The one spelling of the log threshold, shared by both subcommand families.
|
|
28
35
|
*
|
|
@@ -49,6 +56,8 @@ export declare const SERVER_SPAWN_VALUE_FLAGS: readonly string[];
|
|
|
49
56
|
* next line, at the column.
|
|
50
57
|
*/
|
|
51
58
|
export declare function logHelpLines(padTo: number, head?: string): string[];
|
|
59
|
+
/** The `--help` lines every `--services` subcommand describes {@link IMPORT_FLAG} with, aligned as {@link logHelpLines}. */
|
|
60
|
+
export declare function importHelpLines(padTo: number): string[];
|
|
52
61
|
/**
|
|
53
62
|
* Narrow the raw {@link LOG_VALUE_FLAGS} values a parser collected, leaving
|
|
54
63
|
* absent flags absent.
|
|
@@ -80,6 +89,8 @@ export declare function printHelp(lines: readonly string[]): void;
|
|
|
80
89
|
/** What {@link parseHarnessArgs} recovered from an argv. */
|
|
81
90
|
export interface ParsedHarnessArgs {
|
|
82
91
|
servicesModule: string;
|
|
92
|
+
/** The {@link IMPORT_FLAG} values in the order given, absent when there were none. */
|
|
93
|
+
imports?: string[];
|
|
83
94
|
/**
|
|
84
95
|
* An absolute directory path, resolved by {@link resolveWorkspaceArgument} and
|
|
85
96
|
* checked to exist. `''` when the subcommand declared `requireWorkspace: false`.
|
|
@@ -107,12 +118,12 @@ export interface HarnessArgsConfig {
|
|
|
107
118
|
}
|
|
108
119
|
/**
|
|
109
120
|
* Shared parser for the headless-harness subcommands. Consumes the required
|
|
110
|
-
* `--services <module>` value flag
|
|
111
|
-
* the `valueFlags` (each takes a value)
|
|
112
|
-
* as `'true'`) the subcommand
|
|
113
|
-
* `--services`/`<workspace>` are usage
|
|
114
|
-
*
|
|
115
|
-
* be left to the run.
|
|
121
|
+
* `--services <module>` value flag, the repeatable `--import <specifier>` and a
|
|
122
|
+
* single positional `<workspace>`, plus the `valueFlags` (each takes a value)
|
|
123
|
+
* and `boolFlags` (presence-only, recorded as `'true'`) the subcommand
|
|
124
|
+
* recognises. Unknown flags or a missing `--services`/`<workspace>` are usage
|
|
125
|
+
* errors, and so is a `<workspace>` that reaches no directory — see
|
|
126
|
+
* {@link resolveWorkspaceArgument} for why that cannot be left to the run.
|
|
116
127
|
*/
|
|
117
128
|
export declare function parseHarnessArgs(args: string[], commandName: string, valueFlags: readonly string[], boolFlags: readonly string[], config?: HarnessArgsConfig): ParsedHarnessArgs;
|
|
118
129
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness-args.d.ts","sourceRoot":"","sources":["../../src/commands/harness-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AA8BlF,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,iBAAiB,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;AAEpD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAGpD;AAED,
|
|
1
|
+
{"version":3,"file":"harness-args.d.ts","sourceRoot":"","sources":["../../src/commands/harness-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AA8BlF,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,iBAAiB,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;AAEpD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,KA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EAAmE;AACnE,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,KAAK,EAAE,MAAM,EAAE,CAAC;CAClB;AAkBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,UAA0B,GAAG,YAAY,CA8C9H"}
|
|
@@ -22,8 +22,15 @@ export function exitWithUsage(message) {
|
|
|
22
22
|
console.error(message);
|
|
23
23
|
process.exit(2);
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/** Names the head's services module; every harness subcommand requires it. */
|
|
26
26
|
export const SERVICES_FLAG = '--services';
|
|
27
|
+
/**
|
|
28
|
+
* Registers a loader in the driver child that imports the head. The child is a
|
|
29
|
+
* fresh `node`, so a loader registered on the CLI's own process never reaches it.
|
|
30
|
+
*/
|
|
31
|
+
export const IMPORT_FLAG = '--import';
|
|
32
|
+
/** The value flags {@link parseHarnessArgs} consumes itself, before any the subcommand declares. */
|
|
33
|
+
export const HARNESS_VALUE_FLAGS = [SERVICES_FLAG, IMPORT_FLAG];
|
|
27
34
|
/**
|
|
28
35
|
* The one spelling of the log threshold, shared by both subcommand families.
|
|
29
36
|
*
|
|
@@ -50,13 +57,19 @@ export const SERVER_SPAWN_VALUE_FLAGS = ['--server', '--cwd', ...LOG_VALUE_FLAGS
|
|
|
50
57
|
* next line, at the column.
|
|
51
58
|
*/
|
|
52
59
|
export function logHelpLines(padTo, head = 'the head this boots') {
|
|
53
|
-
const line = (flag, text) => flag.length < padTo - 1 ? [` ${flag.padEnd(padTo)}${text}`] : [` ${flag}`, `${' '.repeat(padTo + 2)}${text}`];
|
|
54
60
|
return [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
helpLine(`${LOG_LEVEL_FLAG} <lvl>`, `Log threshold for ${head} (off|error|warn|info|debug|trace).`, padTo),
|
|
62
|
+
helpLine(`${LOG_FILE_FLAG} <file>`, `Also write ${head}'s log to <file>; {workspace} expands to the workspace.`, padTo),
|
|
63
|
+
helpLine(`${LOG_FILE_LEVEL_FLAG} <lvl>`, `Threshold for that file, which the log-level setting does not change.`, padTo)
|
|
58
64
|
].flat();
|
|
59
65
|
}
|
|
66
|
+
/** The `--help` lines every `--services` subcommand describes {@link IMPORT_FLAG} with, aligned as {@link logHelpLines}. */
|
|
67
|
+
export function importHelpLines(padTo) {
|
|
68
|
+
return helpLine(`${IMPORT_FLAG} <specifier>`, 'Loader to register before importing <module>, e.g. tsx (repeatable).', padTo);
|
|
69
|
+
}
|
|
70
|
+
function helpLine(flag, text, padTo) {
|
|
71
|
+
return flag.length < padTo - 1 ? [` ${flag.padEnd(padTo)}${text}`] : [` ${flag}`, `${' '.repeat(padTo + 2)}${text}`];
|
|
72
|
+
}
|
|
60
73
|
/**
|
|
61
74
|
* Narrow the raw {@link LOG_VALUE_FLAGS} values a parser collected, leaving
|
|
62
75
|
* absent flags absent.
|
|
@@ -114,12 +127,12 @@ export function printHelp(lines) {
|
|
|
114
127
|
}
|
|
115
128
|
/**
|
|
116
129
|
* Shared parser for the headless-harness subcommands. Consumes the required
|
|
117
|
-
* `--services <module>` value flag
|
|
118
|
-
* the `valueFlags` (each takes a value)
|
|
119
|
-
* as `'true'`) the subcommand
|
|
120
|
-
* `--services`/`<workspace>` are usage
|
|
121
|
-
*
|
|
122
|
-
* be left to the run.
|
|
130
|
+
* `--services <module>` value flag, the repeatable `--import <specifier>` and a
|
|
131
|
+
* single positional `<workspace>`, plus the `valueFlags` (each takes a value)
|
|
132
|
+
* and `boolFlags` (presence-only, recorded as `'true'`) the subcommand
|
|
133
|
+
* recognises. Unknown flags or a missing `--services`/`<workspace>` are usage
|
|
134
|
+
* errors, and so is a `<workspace>` that reaches no directory — see
|
|
135
|
+
* {@link resolveWorkspaceArgument} for why that cannot be left to the run.
|
|
123
136
|
*/
|
|
124
137
|
export function parseHarnessArgs(args, commandName, valueFlags, boolFlags, config = {}) {
|
|
125
138
|
const requireWorkspace = config.requireWorkspace ?? true;
|
|
@@ -130,6 +143,7 @@ export function parseHarnessArgs(args, commandName, valueFlags, boolFlags, confi
|
|
|
130
143
|
const options = {};
|
|
131
144
|
const values = {};
|
|
132
145
|
let servicesModule;
|
|
146
|
+
let imports;
|
|
133
147
|
let workspace;
|
|
134
148
|
for (let index = 0; index < args.length; index += 1) {
|
|
135
149
|
const flag = args[index];
|
|
@@ -141,9 +155,12 @@ export function parseHarnessArgs(args, commandName, valueFlags, boolFlags, confi
|
|
|
141
155
|
index += 1;
|
|
142
156
|
return value;
|
|
143
157
|
};
|
|
144
|
-
if (flag ===
|
|
158
|
+
if (flag === SERVICES_FLAG) {
|
|
145
159
|
servicesModule = next();
|
|
146
160
|
}
|
|
161
|
+
else if (flag === IMPORT_FLAG) {
|
|
162
|
+
(imports ??= []).push(next());
|
|
163
|
+
}
|
|
147
164
|
else if (boolSet.has(flag)) {
|
|
148
165
|
options[flag] = 'true';
|
|
149
166
|
}
|
|
@@ -164,7 +181,8 @@ export function parseHarnessArgs(args, commandName, valueFlags, boolFlags, confi
|
|
|
164
181
|
}
|
|
165
182
|
}
|
|
166
183
|
return {
|
|
167
|
-
servicesModule: assertRequired(servicesModule,
|
|
184
|
+
servicesModule: assertRequired(servicesModule, SERVICES_FLAG, commandName, onError),
|
|
185
|
+
imports,
|
|
168
186
|
workspace: requireWorkspace
|
|
169
187
|
? resolveWorkspaceArgument(assertRequired(workspace, '<workspace>', commandName, onError), commandName, onError)
|
|
170
188
|
: (workspace ?? ''),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness-args.js","sourceRoot":"","sources":["../../src/commands/harness-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AA2BlF,OAAO,EAAE,QAAQ,EAA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AAC,GAAG,MAAM,CAAC;IAC9C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9F,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,CACJ,2DAA2D,QAAQ,kCAAkC;gBAClG,YAAY,GAAG,wFAAwF;gBACvG,sEAAsE,WAAW,UAAU,CAChG,CAAC;QACL,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;AAC7E,CAAC"}
|
|
@@ -31,8 +31,9 @@ export interface HeadlessContext {
|
|
|
31
31
|
* its `createServices` thunk AND the `@hydranium/core/node` harness, both
|
|
32
32
|
* resolved from the HEAD's location rather than the CLI's.
|
|
33
33
|
*
|
|
34
|
-
* The module is an ESM file
|
|
35
|
-
*
|
|
34
|
+
* The module is an ESM file exporting a ZERO-ARG `createServices(): { shared }`:
|
|
35
|
+
* a compiled `lib/*.js`, or the TypeScript source when the child was started
|
|
36
|
+
* with a loader through {@link IMPORT_FLAG}. `hydranium-cli` is language-agnostic
|
|
36
37
|
* and cannot statically import a head's `create<Lang>Services`, so the dynamic
|
|
37
38
|
* import is the seam that keeps the binary head-neutral. Resolving the harness
|
|
38
39
|
* from the head's graph (via `createRequire` rooted at the head module) rather
|
|
@@ -75,6 +76,8 @@ export type SpawnDriverChild = (execArgs: string[], env?: Record<string, string>
|
|
|
75
76
|
* variable still wins where a caller set one.
|
|
76
77
|
*/
|
|
77
78
|
export interface DriverSpawnOptions extends LogOptions {
|
|
79
|
+
/** Specifiers the driver child registers with Node's `--import`, in order, before it imports the head. */
|
|
80
|
+
readonly imports?: readonly string[];
|
|
78
81
|
/** Test-only: capture the node argv and env instead of spawning the real child. */
|
|
79
82
|
readonly __spawnForTest?: SpawnDriverChild;
|
|
80
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless-harness.d.ts","sourceRoot":"","sources":["../../src/commands/headless-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG1D,kFAAkF;AAClF,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,6EAA6E;AAC7E,KAAK,cAAc,GAAG,OAAO,iBAAiB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;AAE5F,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC7B,gEAAgE;IAChE,cAAc,EAAE,eAAe,CAAC;IAChC,yEAAyE;IACzE,QAAQ,EAAE,cAAc,CAAC;CAC3B;AAED
|
|
1
|
+
{"version":3,"file":"headless-harness.d.ts","sourceRoot":"","sources":["../../src/commands/headless-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG1D,kFAAkF;AAClF,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,6EAA6E;AAC7E,KAAK,cAAc,GAAG,OAAO,iBAAiB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;AAE5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gs } from '../driver-heap.js';
|
|
15
15
|
import { logEnv } from '../log-level.js';
|
|
16
|
-
import { SERVICES_FLAG } from './harness-args.js';
|
|
16
|
+
import { IMPORT_FLAG, SERVICES_FLAG } from './harness-args.js';
|
|
17
17
|
/** The flag every report-producing subcommand names its destination file with. */
|
|
18
18
|
export const OUT_FILE_FLAG = '--out-file';
|
|
19
19
|
/**
|
|
@@ -21,8 +21,9 @@ export const OUT_FILE_FLAG = '--out-file';
|
|
|
21
21
|
* its `createServices` thunk AND the `@hydranium/core/node` harness, both
|
|
22
22
|
* resolved from the HEAD's location rather than the CLI's.
|
|
23
23
|
*
|
|
24
|
-
* The module is an ESM file
|
|
25
|
-
*
|
|
24
|
+
* The module is an ESM file exporting a ZERO-ARG `createServices(): { shared }`:
|
|
25
|
+
* a compiled `lib/*.js`, or the TypeScript source when the child was started
|
|
26
|
+
* with a loader through {@link IMPORT_FLAG}. `hydranium-cli` is language-agnostic
|
|
26
27
|
* and cannot statically import a head's `create<Lang>Services`, so the dynamic
|
|
27
28
|
* import is the seam that keeps the binary head-neutral. Resolving the harness
|
|
28
29
|
* from the head's graph (via `createRequire` rooted at the head module) rather
|
|
@@ -42,11 +43,17 @@ export async function loadHeadlessContext(servicesModule) {
|
|
|
42
43
|
const stats = statSync(modulePath, { throwIfNoEntry: false });
|
|
43
44
|
if (stats === undefined || !stats.isFile()) {
|
|
44
45
|
throw new Error(`${SERVICES_FLAG} must name an existing ESM file; '${servicesModule}' resolved to ${modulePath}, ` +
|
|
45
|
-
`which is not one. Pass the head's
|
|
46
|
-
'not
|
|
46
|
+
`which is not one. Pass the path of the head's entry, e.g. \`${SERVICES_FLAG} ./lib/services.js\` — ` +
|
|
47
|
+
'not a package name.');
|
|
47
48
|
}
|
|
48
49
|
const moduleUrl = pathToFileURL(modulePath).href;
|
|
49
|
-
|
|
50
|
+
let imported;
|
|
51
|
+
try {
|
|
52
|
+
imported = (await import(moduleUrl));
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
throw withLoaderHint(err, modulePath);
|
|
56
|
+
}
|
|
50
57
|
const createServices = imported.createServices;
|
|
51
58
|
if (typeof createServices !== 'function') {
|
|
52
59
|
throw new Error(`Services module '${servicesModule}' must export a zero-arg 'createServices(): { shared }' ` +
|
|
@@ -58,6 +65,30 @@ export async function loadHeadlessContext(servicesModule) {
|
|
|
58
65
|
const coreNode = (await import(pathToFileURL(coreNodePath).href));
|
|
59
66
|
return { createServices: createServices, coreNode };
|
|
60
67
|
}
|
|
68
|
+
/** The codes Node fails a TypeScript entry with when no loader handled it, depending on its version. */
|
|
69
|
+
const UNLOADED_TYPESCRIPT_CODES = new Set([
|
|
70
|
+
'ERR_UNKNOWN_FILE_EXTENSION',
|
|
71
|
+
'ERR_MODULE_NOT_FOUND',
|
|
72
|
+
'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX'
|
|
73
|
+
]);
|
|
74
|
+
/**
|
|
75
|
+
* Append a loader hint to a TypeScript entry's import failure, unless the child
|
|
76
|
+
* was started with {@link IMPORT_FLAG}, where the hint would only repeat the
|
|
77
|
+
* caller's own command. Appended rather than substituted: a loader set through
|
|
78
|
+
* `NODE_OPTIONS` does not show in `execArgv`, and under it the failure can be a
|
|
79
|
+
* missing module that only Node's own message names.
|
|
80
|
+
*/
|
|
81
|
+
function withLoaderHint(err, modulePath) {
|
|
82
|
+
if (!(err instanceof Error) || !/\.[cm]?ts$/.test(modulePath) || !('code' in err) || typeof err.code !== 'string') {
|
|
83
|
+
return err;
|
|
84
|
+
}
|
|
85
|
+
if (!UNLOADED_TYPESCRIPT_CODES.has(err.code) || process.execArgv.some(arg => arg.startsWith(IMPORT_FLAG))) {
|
|
86
|
+
return err;
|
|
87
|
+
}
|
|
88
|
+
return new Error(`${err.message}\nA TypeScript head needs a loader registered with \`${IMPORT_FLAG}\`, e.g. \`${IMPORT_FLAG} tsx\`.`, {
|
|
89
|
+
cause: err
|
|
90
|
+
});
|
|
91
|
+
}
|
|
61
92
|
/**
|
|
62
93
|
* Child-side: deliver a finished report — to `outFile` when one was named, else
|
|
63
94
|
* to stdout.
|
|
@@ -121,9 +152,21 @@ export function spawnNodeChild(execArgs, env) {
|
|
|
121
152
|
*/
|
|
122
153
|
export async function runDriverChild(execArgs, options) {
|
|
123
154
|
const spawnChild = options.__spawnForTest ?? spawnNodeChild;
|
|
124
|
-
const
|
|
155
|
+
const importArgs = (options.imports ?? []).map(specifier => `${IMPORT_FLAG}=${loaderSpecifier(specifier)}`);
|
|
156
|
+
const code = await spawnChild([...driverHeapArgs(options.__heapReadingForTest), ...importArgs, ...execArgs], logEnv(options));
|
|
125
157
|
if (code) {
|
|
126
158
|
process.exitCode = code;
|
|
127
159
|
}
|
|
128
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* A path, absolute or `./`/`../` relative with either separator, becomes a file
|
|
163
|
+
* URL resolved against the caller's directory. Node reads `--import` as a URL or
|
|
164
|
+
* package specifier, so it would take a Windows `C:\…` for the URL scheme `c:`
|
|
165
|
+
* and a `.\…` for a package name. Any other specifier passes through as Node
|
|
166
|
+
* reads it.
|
|
167
|
+
*/
|
|
168
|
+
function loaderSpecifier(specifier) {
|
|
169
|
+
const isPath = path.isAbsolute(specifier) || /^\.\.?[\\/]/.test(specifier);
|
|
170
|
+
return isPath ? pathToFileURL(path.resolve(specifier)).href : specifier;
|
|
171
|
+
}
|
|
129
172
|
//# sourceMappingURL=headless-harness.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless-harness.js","sourceRoot":"","sources":["../../src/commands/headless-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAA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.js';
|
|
11
11
|
/**
|
|
12
12
|
* Every flag `lint-grammar` accepts, derived from the sets the parser is handed
|
|
13
|
-
* so the list cannot claim a flag the parser would reject.
|
|
14
|
-
* consumed by the shared harness parser itself,
|
|
13
|
+
* so the list cannot claim a flag the parser would reject.
|
|
14
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
15
|
+
* so they are in neither set.
|
|
15
16
|
*/
|
|
16
17
|
export declare const LINT_GRAMMAR_FLAGS: readonly string[];
|
|
17
18
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint-grammar-args.d.ts","sourceRoot":"","sources":["../../src/commands/lint-grammar-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"lint-grammar-args.d.ts","sourceRoot":"","sources":["../../src/commands/lint-grammar-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAUJ,KAAK,UAAU,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAkB,KAAK,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAMnF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAuF,CAAC;AAExI,oFAAoF;AACpF,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAAwE,CAAC;AAE/H,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAmB9C,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAA0B,GAAG,yBAAyB,CAcnH;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAMnE"}
|
|
@@ -6,22 +6,23 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { exitWithUsage, helpRequested, LOG_VALUE_FLAGS, logHelpLines, logOptions, parseHarnessArgs, printHelp
|
|
9
|
+
import { exitWithUsage, HARNESS_VALUE_FLAGS, helpRequested, importHelpLines, LOG_VALUE_FLAGS, logHelpLines, logOptions, parseHarnessArgs, printHelp } from './harness-args.js';
|
|
10
10
|
import { runLintGrammar } from './lint-grammar.js';
|
|
11
11
|
const VALUE_FLAGS = [...LOG_VALUE_FLAGS];
|
|
12
12
|
const BOOL_FLAGS = ['--strict', '--json'];
|
|
13
13
|
const REPEATABLE_VALUE_FLAGS = ['--name-property'];
|
|
14
14
|
/**
|
|
15
15
|
* Every flag `lint-grammar` accepts, derived from the sets the parser is handed
|
|
16
|
-
* so the list cannot claim a flag the parser would reject.
|
|
17
|
-
* consumed by the shared harness parser itself,
|
|
16
|
+
* so the list cannot claim a flag the parser would reject.
|
|
17
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
18
|
+
* so they are in neither set.
|
|
18
19
|
*/
|
|
19
|
-
export const LINT_GRAMMAR_FLAGS = [
|
|
20
|
+
export const LINT_GRAMMAR_FLAGS = [...HARNESS_VALUE_FLAGS, ...REPEATABLE_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
|
|
20
21
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
21
|
-
export const LINT_GRAMMAR_VALUE_FLAGS = [
|
|
22
|
+
export const LINT_GRAMMAR_VALUE_FLAGS = [...HARNESS_VALUE_FLAGS, ...REPEATABLE_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
22
23
|
/** The `--help` text, as data, held to {@link LINT_GRAMMAR_FLAGS} by a test. */
|
|
23
24
|
export const LINT_GRAMMAR_HELP = [
|
|
24
|
-
'Usage: hydranium-cli lint-grammar --services <module> [--name-property <p>]... [--strict] [--json] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
25
|
+
'Usage: hydranium-cli lint-grammar --services <module> [--import <specifier>]... [--name-property <p>]... [--strict] [--json] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
25
26
|
'',
|
|
26
27
|
"Check a head's grammar against the framework's conventions — a CI gate: the",
|
|
27
28
|
'process exits non-zero when a violation is found. Read-only: no workspace is',
|
|
@@ -33,6 +34,7 @@ export const LINT_GRAMMAR_HELP = [
|
|
|
33
34
|
'',
|
|
34
35
|
'Options:',
|
|
35
36
|
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
37
|
+
...importHelpLines(23),
|
|
36
38
|
' --name-property <p> Property that satisfies the nameability convention',
|
|
37
39
|
' (repeatable). Default: name.',
|
|
38
40
|
' --strict Also fail (non-zero exit) on warnings, not only errors.',
|
|
@@ -40,13 +42,14 @@ export const LINT_GRAMMAR_HELP = [
|
|
|
40
42
|
...logHelpLines(23)
|
|
41
43
|
];
|
|
42
44
|
export function parseLintGrammarArgs(args, onError = exitWithUsage) {
|
|
43
|
-
const { servicesModule, options, values } = parseHarnessArgs(args, 'lint-grammar', VALUE_FLAGS, BOOL_FLAGS, {
|
|
45
|
+
const { servicesModule, imports, options, values } = parseHarnessArgs(args, 'lint-grammar', VALUE_FLAGS, BOOL_FLAGS, {
|
|
44
46
|
requireWorkspace: false,
|
|
45
47
|
repeatableValueFlags: REPEATABLE_VALUE_FLAGS,
|
|
46
48
|
onError
|
|
47
49
|
});
|
|
48
50
|
return {
|
|
49
51
|
servicesModule,
|
|
52
|
+
imports,
|
|
50
53
|
nameProperties: values['--name-property'],
|
|
51
54
|
strict: options['--strict'] === 'true',
|
|
52
55
|
json: options['--json'] === 'true',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint-grammar-args.js","sourceRoot":"","sources":["../../src/commands/lint-grammar-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,UAAU,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EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE;QAClH,gBAAgB,EAAE,KAAK;QACvB,oBAAoB,EAAE,sBAAsB;QAC5C,OAAO;KACT,CAAC,CAAC;IACH,OAAO;QACJ,cAAc;QACd,OAAO;QACP,cAAc,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,MAAM;QACtC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,MAAM;QAClC,GAAG,UAAU,CAAC,OAAO,CAAC;KACxB,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAc;IACjD,IAAI,aAAa,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAE,CAAC;QACjD,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,cAAc,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -10,8 +10,9 @@ import { type UsageError } from './harness-args.js';
|
|
|
10
10
|
import { type MeasureMemoryCommandOptions } from './measure-memory.js';
|
|
11
11
|
/**
|
|
12
12
|
* Every flag `measure-memory` accepts, derived from the sets the parser is
|
|
13
|
-
* handed so the list cannot claim a flag the parser would reject.
|
|
14
|
-
*
|
|
13
|
+
* handed so the list cannot claim a flag the parser would reject.
|
|
14
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
15
|
+
* so they are in neither set.
|
|
15
16
|
*/
|
|
16
17
|
export declare const MEASURE_MEMORY_FLAGS: readonly string[];
|
|
17
18
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure-memory-args.d.ts","sourceRoot":"","sources":["../../src/commands/measure-memory-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"measure-memory-args.d.ts","sourceRoot":"","sources":["../../src/commands/measure-memory-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAYJ,KAAK,UAAU,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA4C,KAAK,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAcjH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAA4D,CAAC;AAE/G,oFAAoF;AACpF,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAA6C,CAAC;AAEtG,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA+BhD,CAAC;AAwBF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAA0B,GAAG,2BAA2B,CAsBvH;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrE"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { exitWithUsage, helpRequested, LOG_FILE_FLAG, LOG_VALUE_FLAGS, logHelpLines, logOptions, numericOption, parseHarnessArgs, printHelp
|
|
9
|
+
import { exitWithUsage, HARNESS_VALUE_FLAGS, helpRequested, importHelpLines, LOG_FILE_FLAG, LOG_VALUE_FLAGS, logHelpLines, logOptions, numericOption, parseHarnessArgs, printHelp } from './harness-args.js';
|
|
10
10
|
import { parseProfileDimensions, runMeasureMemory } from './measure-memory.js';
|
|
11
11
|
const VALUE_FLAGS = [
|
|
12
12
|
'--edits',
|
|
@@ -21,15 +21,16 @@ const VALUE_FLAGS = [
|
|
|
21
21
|
const BOOL_FLAGS = ['--snapshot', '--json'];
|
|
22
22
|
/**
|
|
23
23
|
* Every flag `measure-memory` accepts, derived from the sets the parser is
|
|
24
|
-
* handed so the list cannot claim a flag the parser would reject.
|
|
25
|
-
*
|
|
24
|
+
* handed so the list cannot claim a flag the parser would reject.
|
|
25
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
26
|
+
* so they are in neither set.
|
|
26
27
|
*/
|
|
27
|
-
export const MEASURE_MEMORY_FLAGS = [
|
|
28
|
+
export const MEASURE_MEMORY_FLAGS = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
|
|
28
29
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
29
|
-
export const MEASURE_MEMORY_VALUE_FLAGS = [
|
|
30
|
+
export const MEASURE_MEMORY_VALUE_FLAGS = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
30
31
|
/** The `--help` text, as data, held to {@link MEASURE_MEMORY_FLAGS} by a test. */
|
|
31
32
|
export const MEASURE_MEMORY_HELP = [
|
|
32
|
-
'Usage: hydranium-cli measure-memory --services <module> <workspace> [options]',
|
|
33
|
+
'Usage: hydranium-cli measure-memory --services <module> [--import <specifier>]... <workspace> [options]',
|
|
33
34
|
'',
|
|
34
35
|
'Measure model-store memory for a workspace. `<module>` is an ESM module that',
|
|
35
36
|
'exports a zero-arg `createServices(): { shared }` thunk (the head wires its own',
|
|
@@ -38,6 +39,7 @@ export const MEASURE_MEMORY_HELP = [
|
|
|
38
39
|
'',
|
|
39
40
|
'Options:',
|
|
40
41
|
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
42
|
+
...importHelpLines(22),
|
|
41
43
|
' <workspace> Workspace root (path or file URI) to build (required).',
|
|
42
44
|
' --edits <N> Rebuild-churn cycles to probe for retention. Default: 0 (skip).',
|
|
43
45
|
' --edit-docs <N> Documents to churn per cycle. Default: 25.',
|
|
@@ -82,7 +84,7 @@ function validatedProfile(csv, onError) {
|
|
|
82
84
|
return csv;
|
|
83
85
|
}
|
|
84
86
|
export function parseMeasureMemoryArgs(args, onError = exitWithUsage) {
|
|
85
|
-
const { servicesModule, workspace, options } = parseHarnessArgs(args, 'measure-memory', VALUE_FLAGS, BOOL_FLAGS, { onError });
|
|
87
|
+
const { servicesModule, imports, workspace, options } = parseHarnessArgs(args, 'measure-memory', VALUE_FLAGS, BOOL_FLAGS, { onError });
|
|
86
88
|
// The profiling session points the log at its own `server.log`, which would
|
|
87
89
|
// replace the requested file without a word.
|
|
88
90
|
if (options['--profile'] !== undefined && options[LOG_FILE_FLAG] !== undefined) {
|
|
@@ -90,6 +92,7 @@ export function parseMeasureMemoryArgs(args, onError = exitWithUsage) {
|
|
|
90
92
|
}
|
|
91
93
|
return {
|
|
92
94
|
servicesModule,
|
|
95
|
+
imports,
|
|
93
96
|
workspace,
|
|
94
97
|
editCycles: numericOption(options['--edits'], '--edits', onError),
|
|
95
98
|
editDocs: numericOption(options['--edit-docs'], '--edit-docs', onError),
|