@hydranium/cli 1.0.0-next.28 → 1.0.0-next.280
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 +75 -204
- package/bin/hydranium-cli.js +13 -0
- package/heap-analysis/heap/core/load.mjs +2 -2
- package/lib/cli-version.js.map +1 -1
- package/lib/cli.js +7 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands/analyze-heap-args.js.map +1 -1
- package/lib/commands/analyze-heap.d.ts +3 -0
- package/lib/commands/analyze-heap.d.ts.map +1 -1
- package/lib/commands/analyze-heap.js +2 -1
- package/lib/commands/analyze-heap.js.map +1 -1
- 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 +11 -9
- package/lib/commands/ast-ground-truth-args.js.map +1 -1
- package/lib/commands/ast-ground-truth-driver.js +2 -1
- package/lib/commands/ast-ground-truth-driver.js.map +1 -1
- package/lib/commands/ast-ground-truth.js +1 -1
- package/lib/commands/ast-ground-truth.js.map +1 -1
- package/lib/commands/client-session.d.ts +17 -0
- package/lib/commands/client-session.d.ts.map +1 -0
- package/lib/commands/client-session.js +27 -0
- package/lib/commands/client-session.js.map +1 -0
- package/lib/commands/create-args.d.ts +17 -0
- package/lib/commands/create-args.d.ts.map +1 -0
- package/lib/commands/create-args.js +53 -0
- package/lib/commands/create-args.js.map +1 -0
- package/lib/commands/create.d.ts +38 -0
- package/lib/commands/create.d.ts.map +1 -0
- package/lib/commands/create.js +47 -0
- package/lib/commands/create.js.map +1 -0
- package/lib/commands/delete-args.d.ts +17 -0
- package/lib/commands/delete-args.d.ts.map +1 -0
- package/lib/commands/delete-args.js +49 -0
- package/lib/commands/delete-args.js.map +1 -0
- package/lib/commands/delete.d.ts +30 -0
- package/lib/commands/delete.d.ts.map +1 -0
- package/lib/commands/delete.js +32 -0
- package/lib/commands/delete.js.map +1 -0
- package/lib/commands/generate-ast-builder.d.ts +49 -0
- package/lib/commands/generate-ast-builder.d.ts.map +1 -0
- package/lib/commands/generate-ast-builder.js +200 -0
- package/lib/commands/generate-ast-builder.js.map +1 -0
- package/lib/commands/generate-transfer-model-args.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-args.js +11 -1
- package/lib/commands/generate-transfer-model-args.js.map +1 -1
- package/lib/commands/generate-transfer-model-config.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-config.js +6 -3
- package/lib/commands/generate-transfer-model-config.js.map +1 -1
- package/lib/commands/generate-transfer-model.d.ts +9 -0
- package/lib/commands/generate-transfer-model.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model.js +18 -4
- package/lib/commands/generate-transfer-model.js.map +1 -1
- package/lib/commands/harness-args.d.ts +44 -42
- package/lib/commands/harness-args.d.ts.map +1 -1
- package/lib/commands/harness-args.js +109 -27
- package/lib/commands/harness-args.js.map +1 -1
- package/lib/commands/headless-harness.d.ts +37 -20
- package/lib/commands/headless-harness.d.ts.map +1 -1
- package/lib/commands/headless-harness.js +68 -17
- package/lib/commands/headless-harness.js.map +1 -1
- package/lib/commands/init-args.js +6 -6
- package/lib/commands/init-args.js.map +1 -1
- package/lib/commands/init-prompt.d.ts.map +1 -1
- package/lib/commands/init-templates.d.ts +8 -10
- package/lib/commands/init-templates.d.ts.map +1 -1
- package/lib/commands/init-templates.js +261 -167
- package/lib/commands/init-templates.js.map +1 -1
- package/lib/commands/init-wizard.js +4 -4
- package/lib/commands/init-wizard.js.map +1 -1
- package/lib/commands/init-workspace.d.ts +13 -3
- package/lib/commands/init-workspace.d.ts.map +1 -1
- package/lib/commands/init-workspace.js +21 -6
- package/lib/commands/init-workspace.js.map +1 -1
- package/lib/commands/init.d.ts +16 -10
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +17 -15
- 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 +13 -10
- package/lib/commands/lint-grammar-args.js.map +1 -1
- package/lib/commands/lint-grammar-driver.js +2 -1
- package/lib/commands/lint-grammar-driver.js.map +1 -1
- package/lib/commands/lint-grammar-report.js.map +1 -1
- package/lib/commands/lint-grammar.js +1 -1
- package/lib/commands/lint-grammar.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 +22 -11
- package/lib/commands/measure-memory-args.js.map +1 -1
- package/lib/commands/measure-memory-driver.js +5 -3
- package/lib/commands/measure-memory-driver.js.map +1 -1
- package/lib/commands/measure-memory.js +1 -1
- package/lib/commands/measure-memory.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 +12 -10
- package/lib/commands/model-docs-args.js.map +1 -1
- package/lib/commands/model-docs-driver.js +2 -1
- package/lib/commands/model-docs-driver.js.map +1 -1
- package/lib/commands/model-docs.js +1 -1
- package/lib/commands/model-docs.js.map +1 -1
- package/lib/commands/projects-args.d.ts.map +1 -1
- package/lib/commands/projects-args.js +5 -5
- package/lib/commands/projects-args.js.map +1 -1
- package/lib/commands/projects.d.ts +3 -4
- package/lib/commands/projects.d.ts.map +1 -1
- package/lib/commands/projects.js +2 -2
- package/lib/commands/projects.js.map +1 -1
- package/lib/commands/query-args.d.ts.map +1 -1
- package/lib/commands/query-args.js +5 -5
- package/lib/commands/query-args.js.map +1 -1
- package/lib/commands/query.d.ts +3 -4
- package/lib/commands/query.d.ts.map +1 -1
- package/lib/commands/query.js +2 -2
- package/lib/commands/query.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 +13 -10
- package/lib/commands/reflect-args.js.map +1 -1
- package/lib/commands/reflect-driver.js +2 -1
- package/lib/commands/reflect-driver.js.map +1 -1
- package/lib/commands/reflect-report.js.map +1 -1
- package/lib/commands/reflect.js +1 -1
- package/lib/commands/reflect.js.map +1 -1
- package/lib/commands/save-args.d.ts.map +1 -1
- package/lib/commands/save-args.js +7 -4
- package/lib/commands/save-args.js.map +1 -1
- package/lib/commands/save.d.ts +8 -4
- package/lib/commands/save.d.ts.map +1 -1
- package/lib/commands/save.js +12 -23
- package/lib/commands/save.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 +13 -10
- package/lib/commands/validate-args.js.map +1 -1
- package/lib/commands/validate-driver.js +2 -1
- package/lib/commands/validate-driver.js.map +1 -1
- package/lib/commands/validate-report.js.map +1 -1
- package/lib/commands/validate.js +1 -1
- package/lib/commands/validate.js.map +1 -1
- package/lib/commands/watch-args.d.ts.map +1 -1
- package/lib/commands/watch-args.js +6 -4
- package/lib/commands/watch-args.js.map +1 -1
- package/lib/commands/watch.d.ts +3 -4
- package/lib/commands/watch.d.ts.map +1 -1
- package/lib/commands/watch.js +20 -2
- package/lib/commands/watch.js.map +1 -1
- package/lib/driver-heap.d.ts +52 -0
- package/lib/driver-heap.d.ts.map +1 -0
- package/lib/driver-heap.js +51 -0
- package/lib/driver-heap.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/log-level.d.ts +21 -11
- package/lib/log-level.d.ts.map +1 -1
- package/lib/log-level.js +25 -14
- package/lib/log-level.js.map +1 -1
- package/lib/spawn-data-server.d.ts +9 -4
- package/lib/spawn-data-server.d.ts.map +1 -1
- package/lib/spawn-data-server.js +5 -4
- package/lib/spawn-data-server.js.map +1 -1
- package/lib/stderr-connection-logger.d.ts +12 -0
- package/lib/stderr-connection-logger.d.ts.map +1 -0
- package/lib/stderr-connection-logger.js +16 -0
- package/lib/stderr-connection-logger.js.map +1 -0
- package/lib/testing/echo-server.js +9 -1
- package/lib/testing/echo-server.js.map +1 -1
- package/package.json +50 -39
- package/src/cli.ts +7 -2
- package/src/commands/analyze-heap.ts +4 -1
- package/src/commands/ast-ground-truth-args.ts +15 -12
- package/src/commands/ast-ground-truth-driver.ts +2 -1
- package/src/commands/ast-ground-truth.ts +1 -1
- package/src/commands/client-session.ts +33 -0
- package/src/commands/create-args.ts +68 -0
- package/src/commands/create.ts +86 -0
- package/src/commands/delete-args.ts +64 -0
- package/src/commands/delete.ts +61 -0
- package/src/commands/generate-ast-builder.ts +246 -0
- package/src/commands/generate-transfer-model-args.ts +11 -1
- package/src/commands/generate-transfer-model-config.ts +6 -3
- package/src/commands/generate-transfer-model.ts +27 -4
- package/src/commands/harness-args.ts +95 -31
- package/src/commands/headless-harness.ts +86 -26
- package/src/commands/init-args.ts +6 -6
- package/src/commands/init-templates.ts +272 -169
- package/src/commands/init-wizard.ts +4 -4
- package/src/commands/init-workspace.ts +31 -7
- package/src/commands/init.ts +36 -26
- package/src/commands/lint-grammar-args.ts +17 -13
- package/src/commands/lint-grammar-driver.ts +2 -1
- package/src/commands/lint-grammar.ts +1 -1
- package/src/commands/measure-memory-args.ts +27 -14
- package/src/commands/measure-memory-driver.ts +5 -3
- package/src/commands/measure-memory.ts +1 -1
- package/src/commands/model-docs-args.ts +16 -13
- package/src/commands/model-docs-driver.ts +2 -1
- package/src/commands/model-docs.ts +1 -1
- package/src/commands/projects-args.ts +5 -4
- package/src/commands/projects.ts +4 -6
- package/src/commands/query-args.ts +5 -4
- package/src/commands/query.ts +4 -6
- package/src/commands/reflect-args.ts +17 -13
- package/src/commands/reflect-driver.ts +2 -1
- package/src/commands/reflect.ts +1 -1
- package/src/commands/save-args.ts +7 -3
- package/src/commands/save.ts +24 -27
- package/src/commands/validate-args.ts +17 -13
- package/src/commands/validate-driver.ts +2 -1
- package/src/commands/validate.ts +1 -1
- package/src/commands/watch-args.ts +6 -3
- package/src/commands/watch.ts +28 -7
- package/src/driver-heap.ts +65 -0
- package/src/index.ts +3 -0
- package/src/log-level.ts +42 -14
- package/src/spawn-data-server.ts +17 -5
- package/src/stderr-connection-logger.ts +18 -0
- package/src/testing/echo-server.ts +11 -2
package/src/commands/projects.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { Project, TransferElement } from '@hydranium/protocol';
|
|
11
11
|
import type { DataServerProtocol } from '@hydranium/protocol/data';
|
|
12
|
-
import {
|
|
12
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
13
13
|
import { withDataServer } from '../spawn-data-server.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -17,7 +17,7 @@ import { withDataServer } from '../spawn-data-server.js';
|
|
|
17
17
|
* `serverArgs` mirror what an adopter would pass to spawn the data-server
|
|
18
18
|
* subprocess.
|
|
19
19
|
*/
|
|
20
|
-
export interface ProjectsCommandOptions {
|
|
20
|
+
export interface ProjectsCommandOptions extends LogOptions {
|
|
21
21
|
/**
|
|
22
22
|
* Command-line tokens used to spawn the data-server child. Mirrors
|
|
23
23
|
* the `--server "<cmd> [args...]"` shape on the CLI surface — split
|
|
@@ -26,8 +26,6 @@ export interface ProjectsCommandOptions {
|
|
|
26
26
|
readonly serverCommand: string;
|
|
27
27
|
readonly serverArgs?: readonly string[];
|
|
28
28
|
readonly cwd?: string;
|
|
29
|
-
/** Log threshold for the spawned server, set on its `HYDRANIUM_LOG_LEVEL` env. */
|
|
30
|
-
readonly logLevel?: LogThreshold;
|
|
31
29
|
/**
|
|
32
30
|
* Output sink. Default: `process.stdout.write`. Tests inject a
|
|
33
31
|
* capturing stub.
|
|
@@ -60,7 +58,7 @@ export async function runProjects(options: ProjectsCommandOptions): Promise<void
|
|
|
60
58
|
command: options.serverCommand,
|
|
61
59
|
args: options.serverArgs,
|
|
62
60
|
cwd: options.cwd,
|
|
63
|
-
env:
|
|
61
|
+
env: logEnv(options)
|
|
64
62
|
},
|
|
65
63
|
async server => {
|
|
66
64
|
const projects = await server.getProjects();
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
assertRequired,
|
|
12
12
|
exitWithUsage,
|
|
13
13
|
helpRequested,
|
|
14
|
+
logHelpLines,
|
|
14
15
|
parseFlagOptions,
|
|
15
16
|
parseServerSpawnOptions,
|
|
16
17
|
printHelp,
|
|
@@ -35,7 +36,7 @@ export const QUERY_VALUE_FLAGS: readonly string[] = QUERY_FLAGS;
|
|
|
35
36
|
|
|
36
37
|
/** The `--help` text, as data, held to {@link QUERY_FLAGS} by a test. */
|
|
37
38
|
export const QUERY_HELP: readonly string[] = [
|
|
38
|
-
'Usage: hydranium-cli query --server "<cmd> [args...]" --uri <uri> [--cwd <dir>] [--log-level <level>]',
|
|
39
|
+
'Usage: hydranium-cli query --server "<cmd> [args...]" --uri <uri> [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
39
40
|
'',
|
|
40
41
|
'Print the data-server document envelope for `<uri>` as a single JSON line.',
|
|
41
42
|
'',
|
|
@@ -43,13 +44,13 @@ export const QUERY_HELP: readonly string[] = [
|
|
|
43
44
|
' --server "<cmd>" Command-line for the data-server subprocess (required).',
|
|
44
45
|
' --uri <uri> Document URI (required).',
|
|
45
46
|
' --cwd <dir> Working directory for the spawned child. Default: cwd.',
|
|
46
|
-
'
|
|
47
|
+
...logHelpLines(19, 'the spawned server')
|
|
47
48
|
];
|
|
48
49
|
|
|
49
50
|
export function parseQueryArgs(args: string[], onError: UsageError = exitWithUsage): QueryCommandOptions {
|
|
50
|
-
const { serverCommand, serverArgs, cwd, logLevel, extra } = parseServerSpawnOptions(args, 'query', onError);
|
|
51
|
+
const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'query', onError);
|
|
51
52
|
const { uri } = parseFlagOptions(extra, 'query', OWN_FLAGS, onError);
|
|
52
|
-
return { serverCommand, serverArgs, cwd, logLevel, uri: assertRequired(uri, '--uri', 'query', onError) };
|
|
53
|
+
return { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, uri: assertRequired(uri, '--uri', 'query', onError) };
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export function runQueryCommand(args: string[]): Promise<void> {
|
package/src/commands/query.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { TransferElement } from '@hydranium/protocol';
|
|
11
11
|
import type { DataServerProtocol } from '@hydranium/protocol/data';
|
|
12
|
-
import {
|
|
12
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
13
13
|
import { withDataServer } from '../spawn-data-server.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -22,12 +22,10 @@ import { withDataServer } from '../spawn-data-server.js';
|
|
|
22
22
|
* Test-only `__proxyForTest` bypasses the spawn for unit tests; the
|
|
23
23
|
* production CLI never passes it.
|
|
24
24
|
*/
|
|
25
|
-
export interface QueryCommandOptions {
|
|
25
|
+
export interface QueryCommandOptions extends LogOptions {
|
|
26
26
|
readonly serverCommand: string;
|
|
27
27
|
readonly serverArgs?: readonly string[];
|
|
28
28
|
readonly cwd?: string;
|
|
29
|
-
/** Log threshold for the spawned server, set on its `HYDRANIUM_LOG_LEVEL` env. */
|
|
30
|
-
readonly logLevel?: LogThreshold;
|
|
31
29
|
readonly uri: string;
|
|
32
30
|
readonly write?: (line: string) => void;
|
|
33
31
|
readonly __proxyForTest?: DataServerProtocol<TransferElement>;
|
|
@@ -48,7 +46,7 @@ export async function runQuery(options: QueryCommandOptions): Promise<void> {
|
|
|
48
46
|
command: options.serverCommand,
|
|
49
47
|
args: options.serverArgs,
|
|
50
48
|
cwd: options.cwd,
|
|
51
|
-
env:
|
|
49
|
+
env: logEnv(options)
|
|
52
50
|
},
|
|
53
51
|
async server => {
|
|
54
52
|
const doc = await server.getModelDocument({ uri: options.uri, includeDiagnostics: true });
|
|
@@ -9,34 +9,36 @@
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
exitWithUsage,
|
|
12
|
+
HARNESS_VALUE_FLAGS,
|
|
12
13
|
helpRequested,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
importHelpLines,
|
|
15
|
+
LOG_VALUE_FLAGS,
|
|
16
|
+
logHelpLines,
|
|
17
|
+
logOptions,
|
|
16
18
|
parseHarnessArgs,
|
|
17
19
|
printHelp,
|
|
18
|
-
SERVICES_FLAG,
|
|
19
20
|
type UsageError
|
|
20
21
|
} from './harness-args.js';
|
|
21
22
|
import { OUT_FILE_FLAG } from './headless-harness.js';
|
|
22
23
|
import { runReflect, type ReflectCommandOptions } from './reflect.js';
|
|
23
24
|
|
|
24
|
-
const VALUE_FLAGS = [OUT_FILE_FLAG,
|
|
25
|
+
const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS] as const;
|
|
25
26
|
const BOOL_FLAGS = ['--json'] as const;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Every flag `reflect` accepts, derived from the sets the parser is handed so
|
|
29
|
-
* the list cannot claim a flag the parser would reject.
|
|
30
|
-
* by the shared harness parser itself,
|
|
30
|
+
* the list cannot claim a flag the parser would reject.
|
|
31
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
32
|
+
* so they are in neither set.
|
|
31
33
|
*/
|
|
32
|
-
export const REFLECT_FLAGS: readonly string[] = [
|
|
34
|
+
export const REFLECT_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
|
|
33
35
|
|
|
34
36
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
35
|
-
export const REFLECT_VALUE_FLAGS: readonly string[] = [
|
|
37
|
+
export const REFLECT_VALUE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
36
38
|
|
|
37
39
|
/** The `--help` text, as data, held to {@link REFLECT_FLAGS} by a test. */
|
|
38
40
|
export const REFLECT_HELP: readonly string[] = [
|
|
39
|
-
'Usage: hydranium-cli reflect --services <module> [--json] [--out-file <file>] [--log-level <lvl>]',
|
|
41
|
+
'Usage: hydranium-cli reflect --services <module> [--import <specifier>]... [--json] [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
40
42
|
'',
|
|
41
43
|
"Dump a head's grammar/AST reflection — the type hierarchy, each language's",
|
|
42
44
|
'terminals and entry rule, and every cross-reference target. Read-only: no',
|
|
@@ -46,23 +48,25 @@ export const REFLECT_HELP: readonly string[] = [
|
|
|
46
48
|
'',
|
|
47
49
|
'Options:',
|
|
48
50
|
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
51
|
+
...importHelpLines(22),
|
|
49
52
|
' --json Emit the raw JSON reflection instead of the Markdown report.',
|
|
50
53
|
' --out-file <file> Write the report to this file instead of stdout. Written',
|
|
51
54
|
' only once the report exists, unlike a shell redirection,',
|
|
52
55
|
' which truncates the file before the head is even booted.',
|
|
53
|
-
|
|
56
|
+
...logHelpLines(22)
|
|
54
57
|
];
|
|
55
58
|
|
|
56
59
|
export function parseReflectArgs(args: string[], onError: UsageError = exitWithUsage): ReflectCommandOptions {
|
|
57
|
-
const { servicesModule, options } = parseHarnessArgs(args, 'reflect', VALUE_FLAGS, BOOL_FLAGS, {
|
|
60
|
+
const { servicesModule, imports, options } = parseHarnessArgs(args, 'reflect', VALUE_FLAGS, BOOL_FLAGS, {
|
|
58
61
|
requireWorkspace: false,
|
|
59
62
|
onError
|
|
60
63
|
});
|
|
61
64
|
return {
|
|
62
65
|
servicesModule,
|
|
66
|
+
imports,
|
|
63
67
|
json: options['--json'] === 'true',
|
|
64
68
|
outFile: options[OUT_FILE_FLAG],
|
|
65
|
-
|
|
69
|
+
...logOptions(options)
|
|
66
70
|
};
|
|
67
71
|
}
|
|
68
72
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* imported — only spawned.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { describeError } from '@hydranium/protocol';
|
|
19
20
|
import { emitReport, loadHeadlessContext, OUT_FILE_FLAG } from './headless-harness.js';
|
|
20
21
|
import { formatReflectionReport } from './reflect-report.js';
|
|
21
22
|
|
|
@@ -71,6 +72,6 @@ async function main(argv: string[]): Promise<number> {
|
|
|
71
72
|
main(process.argv.slice(2))
|
|
72
73
|
.then(code => process.exit(code))
|
|
73
74
|
.catch((error: unknown) => {
|
|
74
|
-
console.error(
|
|
75
|
+
console.error(describeError(error));
|
|
75
76
|
process.exit(1);
|
|
76
77
|
});
|
package/src/commands/reflect.ts
CHANGED
|
@@ -47,5 +47,5 @@ export function buildReflectDriverArgs(options: ReflectCommandOptions): string[]
|
|
|
47
47
|
* the binary language-agnostic.
|
|
48
48
|
*/
|
|
49
49
|
export function runReflect(options: ReflectCommandOptions): Promise<void> {
|
|
50
|
-
return runDriverChild([
|
|
50
|
+
return runDriverChild([DRIVER, ...buildReflectDriverArgs(options)], options);
|
|
51
51
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
assertRequired,
|
|
12
12
|
exitWithUsage,
|
|
13
13
|
helpRequested,
|
|
14
|
+
logHelpLines,
|
|
14
15
|
parseFlagOptions,
|
|
15
16
|
parseServerSpawnOptions,
|
|
16
17
|
printHelp,
|
|
@@ -36,9 +37,10 @@ export const SAVE_VALUE_FLAGS: readonly string[] = SAVE_FLAGS;
|
|
|
36
37
|
|
|
37
38
|
/** The `--help` text, as data, held to {@link SAVE_FLAGS} by a test. */
|
|
38
39
|
export const SAVE_HELP: readonly string[] = [
|
|
39
|
-
'Usage: hydranium-cli save --server "<cmd>..." --uri <uri> --content <text|@file> [--client-id <id>] [--cwd <dir>] [--log-level <level>]',
|
|
40
|
+
'Usage: hydranium-cli save --server "<cmd>..." --uri <uri> --content <text|@file> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
40
41
|
'',
|
|
41
42
|
'Update the document at `<uri>` with `<content>` and persist via saveModelDocument.',
|
|
43
|
+
'Fails when the file does not exist; `create` writes a new one.',
|
|
42
44
|
'Output is the post-save envelope as a single JSON line.',
|
|
43
45
|
'',
|
|
44
46
|
'Options:',
|
|
@@ -48,17 +50,19 @@ export const SAVE_HELP: readonly string[] = [
|
|
|
48
50
|
' (escape with `\\@` for literal `@`-leading content).',
|
|
49
51
|
' --client-id <id> clientId for authorship attribution. Default: hydranium-cli.',
|
|
50
52
|
' --cwd <dir> Working directory for the spawned child. Default: cwd.',
|
|
51
|
-
'
|
|
53
|
+
...logHelpLines(22, 'the spawned server')
|
|
52
54
|
];
|
|
53
55
|
|
|
54
56
|
export function parseSaveArgs(args: string[], onError: UsageError = exitWithUsage): SaveCommandOptions {
|
|
55
|
-
const { serverCommand, serverArgs, cwd, logLevel, extra } = parseServerSpawnOptions(args, 'save', onError);
|
|
57
|
+
const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'save', onError);
|
|
56
58
|
const { uri, content, clientId } = parseFlagOptions(extra, 'save', OWN_FLAGS, onError);
|
|
57
59
|
return {
|
|
58
60
|
serverCommand,
|
|
59
61
|
serverArgs,
|
|
60
62
|
cwd,
|
|
61
63
|
logLevel,
|
|
64
|
+
logFile,
|
|
65
|
+
logFileLevel,
|
|
62
66
|
uri: assertRequired(uri, '--uri', 'save', onError),
|
|
63
67
|
content: assertRequired(content, '--content', 'save', onError),
|
|
64
68
|
clientId
|
package/src/commands/save.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { TransferElement } from '@hydranium/protocol';
|
|
11
11
|
import type { DataServerProtocol } from '@hydranium/protocol/data';
|
|
12
|
-
import
|
|
13
|
-
import { logLevelEnv } from '../log-level.js';
|
|
12
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
14
13
|
import { withDataServer } from '../spawn-data-server.js';
|
|
14
|
+
import { withClientSession } from './client-session.js';
|
|
15
|
+
import { resolveContent } from './harness-args.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Options for the {@link runSave} subcommand. Updates the document at
|
|
@@ -23,13 +24,16 @@ import { withDataServer } from '../spawn-data-server.js';
|
|
|
23
24
|
*
|
|
24
25
|
* `clientId` defaults to `'hydranium-cli'` — adopters wanting a richer
|
|
25
26
|
* identity (per-user, per-script) override.
|
|
27
|
+
*
|
|
28
|
+
* The command saves as a client session under `clientId`: it registers the
|
|
29
|
+
* session, opens the document, saves, and ends the session, which leaves
|
|
30
|
+
* nothing open behind it. A missing file fails the open; `runCreate` writes a
|
|
31
|
+
* new one.
|
|
26
32
|
*/
|
|
27
|
-
export interface SaveCommandOptions {
|
|
33
|
+
export interface SaveCommandOptions extends LogOptions {
|
|
28
34
|
readonly serverCommand: string;
|
|
29
35
|
readonly serverArgs?: readonly string[];
|
|
30
36
|
readonly cwd?: string;
|
|
31
|
-
/** Log threshold for the spawned server, set on its `HYDRANIUM_LOG_LEVEL` env. */
|
|
32
|
-
readonly logLevel?: LogThreshold;
|
|
33
37
|
readonly uri: string;
|
|
34
38
|
/** Literal content text, or `@<path>` to read from a file. */
|
|
35
39
|
readonly content: string;
|
|
@@ -46,8 +50,7 @@ export async function runSave(options: SaveCommandOptions): Promise<void> {
|
|
|
46
50
|
const model = await resolveContent(options.content, options.__readFileForTest);
|
|
47
51
|
|
|
48
52
|
if (options.__proxyForTest) {
|
|
49
|
-
|
|
50
|
-
write(`${JSON.stringify(doc)}\n`);
|
|
53
|
+
write(`${JSON.stringify(await saveOpened(options.__proxyForTest, options.uri, clientId, model))}\n`);
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -56,29 +59,23 @@ export async function runSave(options: SaveCommandOptions): Promise<void> {
|
|
|
56
59
|
command: options.serverCommand,
|
|
57
60
|
args: options.serverArgs,
|
|
58
61
|
cwd: options.cwd,
|
|
59
|
-
env:
|
|
62
|
+
env: logEnv(options)
|
|
60
63
|
},
|
|
61
64
|
async server => {
|
|
62
|
-
|
|
63
|
-
write(`${JSON.stringify(doc)}\n`);
|
|
65
|
+
write(`${JSON.stringify(await saveOpened(server, options.uri, clientId, model))}\n`);
|
|
64
66
|
}
|
|
65
67
|
);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
if (content.startsWith('\\@')) {
|
|
81
|
-
return content.slice(1);
|
|
82
|
-
}
|
|
83
|
-
return content;
|
|
70
|
+
/** Open `uri` as the session `clientId` and save `model` to it, then end the session. */
|
|
71
|
+
function saveOpened(
|
|
72
|
+
server: Pick<DataServerProtocol<TransferElement>, 'createSession' | 'openModelDocument' | 'saveModelDocument' | 'closeSession'>,
|
|
73
|
+
uri: string,
|
|
74
|
+
clientId: string,
|
|
75
|
+
model: string
|
|
76
|
+
): Promise<unknown> {
|
|
77
|
+
return withClientSession(server, clientId, async () => {
|
|
78
|
+
await server.openModelDocument({ uri, clientId });
|
|
79
|
+
return server.saveModelDocument({ uri, clientId, model, baseVersion: 'any' });
|
|
80
|
+
});
|
|
84
81
|
}
|
|
@@ -9,34 +9,36 @@
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
exitWithUsage,
|
|
12
|
+
HARNESS_VALUE_FLAGS,
|
|
12
13
|
helpRequested,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
importHelpLines,
|
|
15
|
+
LOG_VALUE_FLAGS,
|
|
16
|
+
logHelpLines,
|
|
17
|
+
logOptions,
|
|
16
18
|
parseHarnessArgs,
|
|
17
19
|
printHelp,
|
|
18
|
-
SERVICES_FLAG,
|
|
19
20
|
type UsageError
|
|
20
21
|
} from './harness-args.js';
|
|
21
22
|
import { OUT_FILE_FLAG } from './headless-harness.js';
|
|
22
23
|
import { runValidate, type ValidateCommandOptions } from './validate.js';
|
|
23
24
|
|
|
24
|
-
const VALUE_FLAGS = [OUT_FILE_FLAG,
|
|
25
|
+
const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS] as const;
|
|
25
26
|
const BOOL_FLAGS = ['--strict', '--json'] as const;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Every flag `validate` accepts, derived from the sets the parser is handed so
|
|
29
|
-
* the list cannot claim a flag the parser would reject.
|
|
30
|
-
* by the shared harness parser itself,
|
|
30
|
+
* the list cannot claim a flag the parser would reject.
|
|
31
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
32
|
+
* so they are in neither set.
|
|
31
33
|
*/
|
|
32
|
-
export const VALIDATE_FLAGS: readonly string[] = [
|
|
34
|
+
export const VALIDATE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS, ...BOOL_FLAGS];
|
|
33
35
|
|
|
34
36
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
35
|
-
export const VALIDATE_VALUE_FLAGS: readonly string[] = [
|
|
37
|
+
export const VALIDATE_VALUE_FLAGS: readonly string[] = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
36
38
|
|
|
37
39
|
/** The `--help` text, as data, held to {@link VALIDATE_FLAGS} by a test. */
|
|
38
40
|
export const VALIDATE_HELP: readonly string[] = [
|
|
39
|
-
'Usage: hydranium-cli validate --services <module> <workspace> [--strict] [--json] [--out-file <file>] [--log-level <lvl>]',
|
|
41
|
+
'Usage: hydranium-cli validate --services <module> [--import <specifier>]... <workspace> [--strict] [--json] [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
40
42
|
'',
|
|
41
43
|
'Build a workspace headlessly and report its validation diagnostics — a CI gate:',
|
|
42
44
|
'the process exits non-zero when any error is found. `<module>` is an ESM module',
|
|
@@ -45,6 +47,7 @@ export const VALIDATE_HELP: readonly string[] = [
|
|
|
45
47
|
'',
|
|
46
48
|
'Options:',
|
|
47
49
|
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
50
|
+
...importHelpLines(22),
|
|
48
51
|
' <workspace> Workspace root (path or file URI) to validate (required).',
|
|
49
52
|
' --strict Also fail (non-zero exit) on warnings, not only errors.',
|
|
50
53
|
' --json Emit the raw JSON result instead of the human report.',
|
|
@@ -52,18 +55,19 @@ export const VALIDATE_HELP: readonly string[] = [
|
|
|
52
55
|
' still decides the exit code, and the file is written only',
|
|
53
56
|
' once the report exists, unlike a shell redirection, which',
|
|
54
57
|
' truncates the file before the workspace is even built.',
|
|
55
|
-
|
|
58
|
+
...logHelpLines(22)
|
|
56
59
|
];
|
|
57
60
|
|
|
58
61
|
export function parseValidateArgs(args: string[], onError: UsageError = exitWithUsage): ValidateCommandOptions {
|
|
59
|
-
const { servicesModule, workspace, options } = parseHarnessArgs(args, 'validate', VALUE_FLAGS, BOOL_FLAGS, { onError });
|
|
62
|
+
const { servicesModule, imports, workspace, options } = parseHarnessArgs(args, 'validate', VALUE_FLAGS, BOOL_FLAGS, { onError });
|
|
60
63
|
return {
|
|
61
64
|
servicesModule,
|
|
65
|
+
imports,
|
|
62
66
|
workspace,
|
|
63
67
|
strict: options['--strict'] === 'true',
|
|
64
68
|
json: options['--json'] === 'true',
|
|
65
69
|
outFile: options[OUT_FILE_FLAG],
|
|
66
|
-
|
|
70
|
+
...logOptions(options)
|
|
67
71
|
};
|
|
68
72
|
}
|
|
69
73
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* `--strict` also fails on warnings). Never imported — only spawned.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { describeError } from '@hydranium/protocol';
|
|
19
20
|
import { emitReport, loadHeadlessContext, OUT_FILE_FLAG } from './headless-harness.js';
|
|
20
21
|
import { formatValidationReport, validationExitCode } from './validate-report.js';
|
|
21
22
|
|
|
@@ -79,6 +80,6 @@ async function main(argv: string[]): Promise<number> {
|
|
|
79
80
|
main(process.argv.slice(2))
|
|
80
81
|
.then(code => process.exit(code))
|
|
81
82
|
.catch((error: unknown) => {
|
|
82
|
-
console.error(
|
|
83
|
+
console.error(describeError(error));
|
|
83
84
|
process.exit(1);
|
|
84
85
|
});
|
package/src/commands/validate.ts
CHANGED
|
@@ -54,5 +54,5 @@ export function buildValidateDriverArgs(options: ValidateCommandOptions): string
|
|
|
54
54
|
* The child's exit code propagates to this process so shells and CI see the gate.
|
|
55
55
|
*/
|
|
56
56
|
export function runValidate(options: ValidateCommandOptions): Promise<void> {
|
|
57
|
-
return runDriverChild([
|
|
57
|
+
return runDriverChild([DRIVER, ...buildValidateDriverArgs(options)], options);
|
|
58
58
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
assertRequired,
|
|
12
12
|
exitWithUsage,
|
|
13
13
|
helpRequested,
|
|
14
|
+
logHelpLines,
|
|
14
15
|
parseFlagOptions,
|
|
15
16
|
parseServerSpawnOptions,
|
|
16
17
|
printHelp,
|
|
@@ -35,7 +36,7 @@ export const WATCH_VALUE_FLAGS: readonly string[] = WATCH_FLAGS;
|
|
|
35
36
|
|
|
36
37
|
/** The `--help` text, as data, held to {@link WATCH_FLAGS} by a test. */
|
|
37
38
|
export const WATCH_HELP: readonly string[] = [
|
|
38
|
-
'Usage: hydranium-cli watch --server "<cmd>..." --uri <uri> [--client-id <id>] [--cwd <dir>] [--log-level <level>]',
|
|
39
|
+
'Usage: hydranium-cli watch --server "<cmd>..." --uri <uri> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
39
40
|
'',
|
|
40
41
|
'Subscribe to document updates at `<uri>` and print events as newline-delimited',
|
|
41
42
|
'JSON. Long-running — exits cleanly on SIGINT (Ctrl-C).',
|
|
@@ -45,18 +46,20 @@ export const WATCH_HELP: readonly string[] = [
|
|
|
45
46
|
' --uri <uri> Document URI (required).',
|
|
46
47
|
' --client-id <id> Subscriber identity. Default: hydranium-cli.',
|
|
47
48
|
' --cwd <dir> Working directory for the spawned child. Default: cwd.',
|
|
48
|
-
'
|
|
49
|
+
...logHelpLines(22, 'the spawned server')
|
|
49
50
|
];
|
|
50
51
|
|
|
51
52
|
/** Parse the argv; the abort signal is the entry point's to supply, not the command line's. */
|
|
52
53
|
export function parseWatchArgs(args: string[], onError: UsageError = exitWithUsage): WatchCommandOptions {
|
|
53
|
-
const { serverCommand, serverArgs, cwd, logLevel, extra } = parseServerSpawnOptions(args, 'watch', onError);
|
|
54
|
+
const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'watch', onError);
|
|
54
55
|
const { uri, clientId } = parseFlagOptions(extra, 'watch', OWN_FLAGS, onError);
|
|
55
56
|
return {
|
|
56
57
|
serverCommand,
|
|
57
58
|
serverArgs,
|
|
58
59
|
cwd,
|
|
59
60
|
logLevel,
|
|
61
|
+
logFile,
|
|
62
|
+
logFileLevel,
|
|
60
63
|
uri: assertRequired(uri, '--uri', 'watch', onError),
|
|
61
64
|
clientId
|
|
62
65
|
};
|
package/src/commands/watch.ts
CHANGED
|
@@ -7,9 +7,14 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
|
|
10
|
+
import type { TransferElement } from '@hydranium/protocol';
|
|
11
|
+
import type {
|
|
12
|
+
DataClientProtocol,
|
|
13
|
+
DataServerProtocol,
|
|
14
|
+
TransferDocumentDeletedEvent,
|
|
15
|
+
TransferDocumentUpdatedEvent
|
|
16
|
+
} from '@hydranium/protocol/data';
|
|
17
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
13
18
|
import { spawnDataServer } from '../spawn-data-server.js';
|
|
14
19
|
|
|
15
20
|
/**
|
|
@@ -22,12 +27,10 @@ import { spawnDataServer } from '../spawn-data-server.js';
|
|
|
22
27
|
* — production CLI wires SIGINT directly. `__handleForTest` bypasses
|
|
23
28
|
* the spawn step for unit tests.
|
|
24
29
|
*/
|
|
25
|
-
export interface WatchCommandOptions {
|
|
30
|
+
export interface WatchCommandOptions extends LogOptions {
|
|
26
31
|
readonly serverCommand: string;
|
|
27
32
|
readonly serverArgs?: readonly string[];
|
|
28
33
|
readonly cwd?: string;
|
|
29
|
-
/** Log threshold for the spawned server, set on its `HYDRANIUM_LOG_LEVEL` env. */
|
|
30
|
-
readonly logLevel?: LogThreshold;
|
|
31
34
|
readonly uri: string;
|
|
32
35
|
readonly clientId?: string;
|
|
33
36
|
readonly write?: (line: string) => void;
|
|
@@ -132,6 +135,24 @@ export async function runWatch(options: WatchCommandOptions): Promise<void> {
|
|
|
132
135
|
onDocumentSaved(): void {
|
|
133
136
|
// Persistence is out of band for the per-URI update view.
|
|
134
137
|
},
|
|
138
|
+
onDocumentDirtyChanged(): void {
|
|
139
|
+
// Out of band for the per-URI update view, as persistence is.
|
|
140
|
+
},
|
|
141
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void {
|
|
142
|
+
// In band, unlike the two neighbours: this is the end of the stream
|
|
143
|
+
// the view exists to show, and a consumer that never hears it waits
|
|
144
|
+
// forever for an update that cannot come. The line carries no
|
|
145
|
+
// `document`, so a reader must switch on shape rather than assume one.
|
|
146
|
+
if (event.uri !== options.uri) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
write(`${JSON.stringify(event)}\n`);
|
|
150
|
+
},
|
|
151
|
+
onDocumentsBuilt(): void {
|
|
152
|
+
// Out of band for a per-URI view by construction: this notification
|
|
153
|
+
// carries only documents nobody watches, and this command watches the
|
|
154
|
+
// one URI it was given.
|
|
155
|
+
},
|
|
135
156
|
onProjectsChanged(): void {
|
|
136
157
|
// Project lifecycle is out of band for the per-URI update view.
|
|
137
158
|
}
|
|
@@ -146,7 +167,7 @@ export async function runWatch(options: WatchCommandOptions): Promise<void> {
|
|
|
146
167
|
command: options.serverCommand,
|
|
147
168
|
args: options.serverArgs,
|
|
148
169
|
cwd: options.cwd,
|
|
149
|
-
env:
|
|
170
|
+
env: logEnv(options)
|
|
150
171
|
},
|
|
151
172
|
localClient
|
|
152
173
|
);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
|
|
10
|
+
import { heapCeilingArgs } from '@hydranium/core/node';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Heap ceiling in MiB for a driver child on a machine with no cgroup limit.
|
|
14
|
+
*
|
|
15
|
+
* The subcommands that spawn one build a whole workspace in that child —
|
|
16
|
+
* `measure-memory` deliberately so, `analyze-heap` loads an entire heap
|
|
17
|
+
* snapshot — so the default Node would pick from physical RAM is too low for
|
|
18
|
+
* the workspaces these are pointed at.
|
|
19
|
+
*/
|
|
20
|
+
export const DRIVER_HEAP_MB = 8192;
|
|
21
|
+
|
|
22
|
+
/** Environment variable an operator raises or lowers {@link driverHeapArgs} with. */
|
|
23
|
+
export const DRIVER_HEAP_ENV = 'HYDRANIUM_CLI_MAX_OLD_SPACE_MB';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Smallest ceiling {@link DRIVER_HEAP_ENV} may state. A driver child builds a
|
|
27
|
+
* whole workspace, so a value this far below the default is a unit mistake
|
|
28
|
+
* rather than a deliberate squeeze.
|
|
29
|
+
*/
|
|
30
|
+
export const MIN_DRIVER_HEAP_MB = 256;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A cgroup reading, so a caller — in practice a test — can decide the ceiling
|
|
34
|
+
* instead of inheriting the machine's. Omitted fields fall back to this
|
|
35
|
+
* process's own reading.
|
|
36
|
+
*/
|
|
37
|
+
export interface HeapReading {
|
|
38
|
+
readonly constrained?: number;
|
|
39
|
+
readonly total?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The `execArgv` prefix every driver child is spawned under.
|
|
44
|
+
*
|
|
45
|
+
* Inside a container this is EMPTY on purpose. {@link DRIVER_HEAP_MB} is sized
|
|
46
|
+
* for a workstation, and handing it to a process under a smaller cgroup limit
|
|
47
|
+
* is worse than handing it nothing: V8 has no reason to collect hard below a
|
|
48
|
+
* ceiling it will never reach, so the kernel OOM-kills the container first and
|
|
49
|
+
* the failure arrives as a signal against the whole cgroup rather than as a
|
|
50
|
+
* heap error the parent can attribute. Left to itself, Node sizes the heap from
|
|
51
|
+
* the limit instead.
|
|
52
|
+
*
|
|
53
|
+
* That trades away the ability to use a LARGE container's memory, since Node's
|
|
54
|
+
* derived default is a fraction of the limit — which is what {@link DRIVER_HEAP_ENV}
|
|
55
|
+
* is for. An operator who states a number has decided, so it wins in a
|
|
56
|
+
* container too.
|
|
57
|
+
*/
|
|
58
|
+
export function driverHeapArgs(reading: HeapReading = {}): string[] {
|
|
59
|
+
return heapCeilingArgs({
|
|
60
|
+
desktopDefaultMb: DRIVER_HEAP_MB,
|
|
61
|
+
envValue: process.env[DRIVER_HEAP_ENV],
|
|
62
|
+
minMb: MIN_DRIVER_HEAP_MB,
|
|
63
|
+
...reading
|
|
64
|
+
});
|
|
65
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
+
export * from './commands/create.js';
|
|
11
|
+
export * from './commands/delete.js';
|
|
12
|
+
export * from './commands/generate-ast-builder.js';
|
|
10
13
|
export * from './commands/generate-transfer-model.js';
|
|
11
14
|
export * from './commands/projects.js';
|
|
12
15
|
export * from './commands/query.js';
|