@hydranium/cli 1.0.0-next.210 → 1.0.0-next.213
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/init-templates.d.ts.map +1 -1
- package/lib/commands/init-templates.js +42 -2
- package/lib/commands/init-templates.js.map +1 -1
- package/lib/commands/init-workspace.d.ts +6 -0
- package/lib/commands/init-workspace.d.ts.map +1 -1
- package/lib/commands/init-workspace.js +11 -1
- package/lib/commands/init-workspace.js.map +1 -1
- package/lib/commands/init.d.ts +6 -0
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +4 -2
- package/lib/commands/init.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 +14 -14
- 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/init-templates.ts +44 -2
- package/src/commands/init-workspace.ts +15 -1
- package/src/commands/init.ts +10 -2
- 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;AA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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,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AED,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,UAA0B,GAAG,MAAM,GAAG,SAAS,CAS9H;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC7B,KAAK,EAAE,MAAM,EAAE,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,GAAE,UAA0B,GACnC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAgBpC;AAMD,mEAAmE;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,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAmB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAQvE;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC1C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"harness-args.js","sourceRoot":"","sources":["../../src/commands/harness-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AA2BlF,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAmB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAQvE;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC1C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CA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AAO,CAAC,oDAAoD,WAAW,UAAU,CAAC,CAAC;IACtF,CAAC;IACD,sEAAsE;IACtE,iEAAiE;IACjE,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,CAAC,aAAa,EAAE,GAAG,UAAU,CAAC,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,O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ACnF,QAAQ,CAAC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,WAAW,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAOnG"}
|
|
@@ -13,7 +13,7 @@ import * as path from 'node:path';
|
|
|
13
13
|
import { pathToFileURL } from 'node:url';
|
|
14
14
|
import { driverHeapArgs } 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,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAoB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAmB,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
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,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAoB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAmB,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE/D,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAoB1C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,c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H,SAAS,eAAe,CAAC,SAAiB;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-templates.d.ts","sourceRoot":"","sources":["../../src/commands/init-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAoElF,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAA8B,MAAM,WAAW,CAAC;AAGvF,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;
|
|
1
|
+
{"version":3,"file":"init-templates.d.ts","sourceRoot":"","sources":["../../src/commands/init-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAoElF,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAA8B,MAAM,WAAW,CAAC;AAGvF,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAg9DD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,eAAe,GAAG,QAAQ,EAAE,CAqD3E"}
|
|
@@ -195,7 +195,12 @@ const HEAD_FRAMEWORK_DEPENDENCIES = {
|
|
|
195
195
|
const HEAD_THIRD_PARTY_DEPENDENCIES = {
|
|
196
196
|
lsp: {
|
|
197
197
|
langium: '4.3.1',
|
|
198
|
-
|
|
198
|
+
// Exact, as are the protocol and transport it pins, so Langium and the
|
|
199
|
+
// framework share their copies; across copies, an error a handler throws
|
|
200
|
+
// or returns loses its code, and a later patch can pin another protocol.
|
|
201
|
+
'vscode-languageserver': '10.0.1',
|
|
202
|
+
'vscode-jsonrpc': '9.0.0',
|
|
203
|
+
'vscode-languageserver-protocol': '3.18.1'
|
|
199
204
|
},
|
|
200
205
|
data: {},
|
|
201
206
|
glsp: {
|
|
@@ -207,6 +212,22 @@ const HEAD_THIRD_PARTY_DEPENDENCIES = {
|
|
|
207
212
|
'reflect-metadata': '~0.2.2'
|
|
208
213
|
}
|
|
209
214
|
};
|
|
215
|
+
/** Whether an npm version is 11.6.0 or later, the first that installs `vitest` 4.1's peer set; `11.6.0-rc.1` is earlier. */
|
|
216
|
+
function installsVitest41(npmVersion) {
|
|
217
|
+
const [release, prerelease] = (npmVersion ?? '0.0.0').split('-', 2);
|
|
218
|
+
const [major, minor, patch] = release.split('.').map(Number);
|
|
219
|
+
return major > 11 || (major === 11 && (minor > 6 || (minor === 6 && (patch > 0 || prerelease === undefined))));
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Whether the scaffold holds `vitest` below 4.1, whose peer set crashes npm
|
|
223
|
+
* before 11.6 (every npm a Node 22 release bundles) on the first install. Only a
|
|
224
|
+
* workspace root declaring a newer npm lifts it, and only when `init` runs under
|
|
225
|
+
* an npm known to be newer: npm does not enforce `packageManager`.
|
|
226
|
+
*/
|
|
227
|
+
function pinsVitest(composition) {
|
|
228
|
+
const workspace = composition.packaging.workspace;
|
|
229
|
+
return !(installsVitest41(workspace?.packageManagerNpm) && installsVitest41(workspace?.npmVersion));
|
|
230
|
+
}
|
|
210
231
|
/** The dependency block for a head set, merged and sorted as npm writes it. */
|
|
211
232
|
function dependencyBlock(composition, indent) {
|
|
212
233
|
const merged = {};
|
|
@@ -290,7 +311,7 @@ __DEPENDENCIES__
|
|
|
290
311
|
"langium-cli": "4.3.0",
|
|
291
312
|
"rimraf": "^5.0.0",
|
|
292
313
|
"typescript": "^7.0.2",
|
|
293
|
-
"vitest": "
|
|
314
|
+
"vitest": "__VITEST__"
|
|
294
315
|
},
|
|
295
316
|
"engines": {
|
|
296
317
|
"node": ">=22.13"
|
|
@@ -354,6 +375,7 @@ function packageJson(composition) {
|
|
|
354
375
|
.replace('__KEYWORDS__', keywords)
|
|
355
376
|
.replace('__BIN__', binBlock(composition))
|
|
356
377
|
.replace('__LINT__', lint)
|
|
378
|
+
.replace('__VITEST__', pinsVitest(composition) ? '~4.0.18' : '^4.0.0')
|
|
357
379
|
.replace('__PRIVATE__', composition.packaging.private ? ' "private": true,\n' : '')
|
|
358
380
|
.replace('__NPM_RUN__', npmRun(composition))
|
|
359
381
|
.replace('__FRAMEWORK_PIN__', frameworkPin(composition))
|
|
@@ -1458,6 +1480,24 @@ function readme(composition) {
|
|
|
1458
1480
|
'atomic set and depends on a single physical copy, so a floating range can',
|
|
1459
1481
|
'silently resolve a second one.',
|
|
1460
1482
|
'',
|
|
1483
|
+
'`vscode-languageserver` is pinned to `10.0.1`, and',
|
|
1484
|
+
'`vscode-languageserver-protocol` and `vscode-jsonrpc` to the `3.18.1` and',
|
|
1485
|
+
'`9.0.0` it pins, so Langium, the LSP connection and the framework share one',
|
|
1486
|
+
'copy of each. With two, an error a Langium handler returns, such as a request',
|
|
1487
|
+
'for a document the server does not have, reaches the client as a result, and a',
|
|
1488
|
+
'framework error your own LSP handler throws loses its code. The Langium 4.4',
|
|
1489
|
+
'upgrade',
|
|
1490
|
+
'([eclipse-emfcloud/hydranium#142](https://github.com/eclipse-emfcloud/hydranium/issues/142))',
|
|
1491
|
+
'replaces these pins.',
|
|
1492
|
+
'',
|
|
1493
|
+
...(pinsVitest(composition)
|
|
1494
|
+
? [
|
|
1495
|
+
'`vitest` is held below 4.1, whose peer set crashes the npm every Node 22',
|
|
1496
|
+
'release bundles. Raise it once every npm that installs this project is',
|
|
1497
|
+
'11.6 or later.',
|
|
1498
|
+
''
|
|
1499
|
+
]
|
|
1500
|
+
: []),
|
|
1461
1501
|
'## If your repo gates license headers',
|
|
1462
1502
|
'',
|
|
1463
1503
|
'The emitted `.ts` files carry no copyright header — the scaffold cannot know',
|