@hydranium/cli 1.0.0-next.272 → 1.0.0-next.273
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 -6
- package/lib/cli.js +2 -0
- package/lib/cli.js.map +1 -1
- 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 +41 -0
- package/lib/commands/delete.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +10 -10
- package/src/cli.ts +2 -0
- package/src/commands/delete-args.ts +64 -0
- package/src/commands/delete.ts +69 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ and the other commands drive your built head from a shell or a CI step.
|
|
|
15
15
|
own docs.
|
|
16
16
|
- Generate the serializable transfer model from Langium's generated AST.
|
|
17
17
|
- Measure model-store memory and analyze a V8 heap snapshot.
|
|
18
|
-
- List, read, save and watch documents through a spawned data server,
|
|
19
|
-
JSON a script can pipe.
|
|
18
|
+
- List, read, save and watch documents through a spawned data server,
|
|
19
|
+
printing JSON a script can pipe, and delete them.
|
|
20
20
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
@@ -60,8 +60,8 @@ lists each command's flags.
|
|
|
60
60
|
once or on watch.
|
|
61
61
|
- **Memory.** Measure a workspace's model-store memory, and analyze a heap
|
|
62
62
|
snapshot.
|
|
63
|
-
- **Data server.** Spawn your data head and list projects, or query, save
|
|
64
|
-
watch a document.
|
|
63
|
+
- **Data server.** Spawn your data head and list projects, or query, save,
|
|
64
|
+
delete or watch a document.
|
|
65
65
|
|
|
66
66
|
The commands that boot your head take `--services <module>`. That is an ESM
|
|
67
67
|
module exporting a zero-arg `createServices()` that returns `{ shared }`,
|
|
@@ -78,8 +78,10 @@ as the entry's argument rather than through `--cwd`:
|
|
|
78
78
|
hydranium-cli projects --server "node ./lib/data-server-main.js ./models"
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
`save`
|
|
82
|
-
|
|
81
|
+
`save` and `delete` spawn a data server of their own, and a workspace has one
|
|
82
|
+
writer. Saving or deleting in a workspace an editor has open makes two
|
|
83
|
+
writers, and one write is lost: an editor that holds a deleted file can save it
|
|
84
|
+
back.
|
|
83
85
|
|
|
84
86
|
Commands that spawn a child give it a heap ceiling; set
|
|
85
87
|
`HYDRANIUM_CLI_MAX_OLD_SPACE_MB` to state your own in MiB.
|
package/lib/cli.js
CHANGED
|
@@ -12,6 +12,7 @@ import { describeError } from '@hydranium/protocol';
|
|
|
12
12
|
import { readCliVersion } from './cli-version.js';
|
|
13
13
|
import { runAnalyzeHeapCommand } from './commands/analyze-heap-args.js';
|
|
14
14
|
import { runAstGroundTruthCommand } from './commands/ast-ground-truth-args.js';
|
|
15
|
+
import { runDeleteCommand } from './commands/delete-args.js';
|
|
15
16
|
import { runGenerateTransferModelCommand } from './commands/generate-transfer-model-args.js';
|
|
16
17
|
import { runInitCommand } from './commands/init-args.js';
|
|
17
18
|
import { InitWizardCancelled } from './commands/init-prompt.js';
|
|
@@ -43,6 +44,7 @@ const COMMANDS = {
|
|
|
43
44
|
summary: "Tally a workspace's live-model $types (analyze-heap --validate input).",
|
|
44
45
|
run: runAstGroundTruthCommand
|
|
45
46
|
},
|
|
47
|
+
delete: { summary: 'Delete a document, its file included, via a data-server subprocess.', run: runDeleteCommand },
|
|
46
48
|
'generate-transfer-model': {
|
|
47
49
|
summary: 'Generate a transfer-model TypeScript file from a Langium AST.',
|
|
48
50
|
run: runGenerateTransferModelCommand
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";A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,CAAC,GAAG,CAAC,EAAE;IACrC,yEAAyE;IACzE,4EAA4E;IAC5E,gDAAgD;IAChD,IAAI,GAAG,YAAY,mBAAmB,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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
|
+
import { type UsageError } from './harness-args.js';
|
|
10
|
+
import { type DeleteCommandOptions } from './delete.js';
|
|
11
|
+
/** Every flag `delete` accepts, each of which takes a value. */
|
|
12
|
+
export declare const DELETE_FLAGS: readonly string[];
|
|
13
|
+
/** The `--help` text, as data, held to {@link DELETE_FLAGS} by a test. */
|
|
14
|
+
export declare const DELETE_HELP: readonly string[];
|
|
15
|
+
export declare function parseDeleteArgs(args: string[], onError?: UsageError): DeleteCommandOptions;
|
|
16
|
+
export declare function runDeleteCommand(args: string[]): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=delete-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-args.d.ts","sourceRoot":"","sources":["../../src/commands/delete-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EASJ,KAAK,UAAU,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,oBAAoB,EAAa,MAAM,aAAa,CAAC;AAInE,gEAAgE;AAChE,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAgD,CAAC;AAE3F,0EAA0E;AAC1E,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAYxC,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAA0B,GAAG,oBAAoB,CAazG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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
|
+
import { assertRequired, exitWithUsage, helpRequested, logHelpLines, parseFlagOptions, parseServerSpawnOptions, printHelp, SERVER_SPAWN_VALUE_FLAGS } from './harness-args.js';
|
|
10
|
+
import { runDelete } from './delete.js';
|
|
11
|
+
const OWN_FLAGS = ['--uri', '--client-id'];
|
|
12
|
+
/** Every flag `delete` accepts, each of which takes a value. */
|
|
13
|
+
export const DELETE_FLAGS = [...SERVER_SPAWN_VALUE_FLAGS, ...OWN_FLAGS];
|
|
14
|
+
/** The `--help` text, as data, held to {@link DELETE_FLAGS} by a test. */
|
|
15
|
+
export const DELETE_HELP = [
|
|
16
|
+
'Usage: hydranium-cli delete --server "<cmd>..." --uri <uri> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
17
|
+
'',
|
|
18
|
+
'Delete the document at `<uri>`, its file and then the document, via deleteModelDocument,',
|
|
19
|
+
'whatever text it holds. Prints nothing.',
|
|
20
|
+
'',
|
|
21
|
+
'Options:',
|
|
22
|
+
' --server "<cmd>" Command-line for the data-server subprocess (required).',
|
|
23
|
+
' --uri <uri> Document URI (required).',
|
|
24
|
+
' --client-id <id> clientId the deletion is attributed to. Default: hydranium-cli.',
|
|
25
|
+
' --cwd <dir> Working directory for the spawned child. Default: cwd.',
|
|
26
|
+
...logHelpLines(22, 'the spawned server')
|
|
27
|
+
];
|
|
28
|
+
export function parseDeleteArgs(args, onError = exitWithUsage) {
|
|
29
|
+
const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'delete', onError);
|
|
30
|
+
const { uri, clientId } = parseFlagOptions(extra, 'delete', OWN_FLAGS, onError);
|
|
31
|
+
return {
|
|
32
|
+
serverCommand,
|
|
33
|
+
serverArgs,
|
|
34
|
+
cwd,
|
|
35
|
+
logLevel,
|
|
36
|
+
logFile,
|
|
37
|
+
logFileLevel,
|
|
38
|
+
uri: assertRequired(uri, '--uri', 'delete', onError),
|
|
39
|
+
clientId
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function runDeleteCommand(args) {
|
|
43
|
+
if (helpRequested(args, DELETE_FLAGS)) {
|
|
44
|
+
printHelp(DELETE_HELP);
|
|
45
|
+
return Promise.resolve();
|
|
46
|
+
}
|
|
47
|
+
return runDelete(parseDeleteArgs(args));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=delete-args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-args.js","sourceRoot":"","sources":["../../src/commands/delete-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,wBAAwB,EAE1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA6B,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,aAAa,CAAU,CAAC;AAEpD,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAsB,CAAC,GAAG,wBAAwB,EAAE,GAAG,SAAS,CAAC,CAAC;AAE3F,0EAA0E;AAC1E,MAAM,CAAC,MAAM,WAAW,GAAsB;IAC3C,+JAA+J;IAC/J,EAAE;IACF,0FAA0F;IAC1F,yCAAyC;IACzC,EAAE;IACF,UAAU;IACV,iFAAiF;IACjF,kDAAkD;IAClD,yFAAyF;IACzF,gFAAgF;IAChF,GAAG,YAAY,CAAC,EAAE,EAAE,oBAAoB,CAAC;CAC3C,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,IAAc,EAAE,OAAO,GAAe,aAAa;IAChF,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,uBAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpI,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAChF,OAAO;QACJ,aAAa;QACb,UAAU;QACV,GAAG;QACH,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;QACpD,QAAQ;KACV,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC5C,IAAI,aAAa,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC;QACrC,SAAS,CAAC,WAAW,CAAC,CAAC;QACvB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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
|
+
import type { TransferElement } from '@hydranium/protocol';
|
|
10
|
+
import type { DataServerProtocol } from '@hydranium/protocol/data';
|
|
11
|
+
import { type LogOptions } from '../log-level.js';
|
|
12
|
+
/**
|
|
13
|
+
* Options for the {@link runDelete} subcommand. Deletes the document at `uri`,
|
|
14
|
+
* its file and then the document, via the data-server's `deleteModelDocument`
|
|
15
|
+
* RPC, whatever text it holds. Prints nothing; a failed delete rejects.
|
|
16
|
+
*
|
|
17
|
+
* `clientId` defaults to `'hydranium-cli'`. The command deletes as a client
|
|
18
|
+
* session under it: it registers the session, opens the document, deletes it,
|
|
19
|
+
* and ends the session.
|
|
20
|
+
*/
|
|
21
|
+
export interface DeleteCommandOptions extends LogOptions {
|
|
22
|
+
readonly serverCommand: string;
|
|
23
|
+
readonly serverArgs?: readonly string[];
|
|
24
|
+
readonly cwd?: string;
|
|
25
|
+
readonly uri: string;
|
|
26
|
+
readonly clientId?: string;
|
|
27
|
+
readonly __proxyForTest?: DataServerProtocol<TransferElement>;
|
|
28
|
+
}
|
|
29
|
+
export declare function runDelete(options: DeleteCommandOptions): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG1D;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACrD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;CAChE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAe5E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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
|
+
import { logEnv } from '../log-level.js';
|
|
10
|
+
import { withDataServer } from '../spawn-data-server.js';
|
|
11
|
+
export async function runDelete(options) {
|
|
12
|
+
const clientId = options.clientId ?? 'hydranium-cli';
|
|
13
|
+
if (options.__proxyForTest) {
|
|
14
|
+
await deleteOpened(options.__proxyForTest, options.uri, clientId);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
await withDataServer({
|
|
18
|
+
command: options.serverCommand,
|
|
19
|
+
args: options.serverArgs,
|
|
20
|
+
cwd: options.cwd,
|
|
21
|
+
env: logEnv(options)
|
|
22
|
+
}, server => deleteOpened(server, options.uri, clientId));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Delete `uri` as the session `clientId`, and end the session whether the
|
|
26
|
+
* delete succeeded or not. An end that fails after a failed delete is
|
|
27
|
+
* swallowed: the delete's error is the one the user needs.
|
|
28
|
+
*/
|
|
29
|
+
async function deleteOpened(server, uri, clientId) {
|
|
30
|
+
await server.createSession({ clientId, label: 'hydranium-cli' });
|
|
31
|
+
try {
|
|
32
|
+
await server.openModelDocument({ uri, clientId });
|
|
33
|
+
await server.deleteModelDocument({ uri, clientId, baseVersion: 'any' });
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
await server.closeSession({ clientId }).catch(() => undefined);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
await server.closeSession({ clientId });
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF,OAAO,EAAE,MAAM,EAAmB,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAoBzD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA6B;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC;IACrD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC1B,MAAM,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAClE,OAAO;IACV,CAAC;IACD,MAAM,cAAc,CACjB;QACG,OAAO,EAAE,OAAO,CAAC,aAAa;QAC9B,IAAI,EAAE,OAAO,CAAC,UAAU;QACxB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC;KACtB,EACD,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CACvD,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,YAAY,CACxB,MAAiI,EACjI,GAAW,EACX,QAAgB;IAEhB,MAAM,MAAM,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC;QACF,MAAM,MAAM,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QAClD,MAAM,MAAM,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACvB,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/D,MAAM,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
+
export * from './commands/delete.js';
|
|
9
10
|
export * from './commands/generate-ast-builder.js';
|
|
10
11
|
export * from './commands/generate-transfer-model.js';
|
|
11
12
|
export * from './commands/projects.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
+
export * from './commands/delete.js';
|
|
9
10
|
export * from './commands/generate-ast-builder.js';
|
|
10
11
|
export * from './commands/generate-transfer-model.js';
|
|
11
12
|
export * from './commands/projects.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydranium/cli",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.273",
|
|
4
4
|
"description": "Build-time codegen tools + data-server subcommands for the hydranium framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@eclipse-glsp/graph": "2.7.0",
|
|
73
73
|
"@eclipse-glsp/server": "2.7.0",
|
|
74
|
-
"@hydranium/core": "1.0.0-next.
|
|
75
|
-
"@hydranium/data-server": "1.0.0-next.
|
|
76
|
-
"@hydranium/glsp-server": "1.0.0-next.
|
|
77
|
-
"@hydranium/langium": "1.0.0-next.
|
|
78
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
74
|
+
"@hydranium/core": "1.0.0-next.273",
|
|
75
|
+
"@hydranium/data-server": "1.0.0-next.273",
|
|
76
|
+
"@hydranium/glsp-server": "1.0.0-next.273",
|
|
77
|
+
"@hydranium/langium": "1.0.0-next.273",
|
|
78
|
+
"@hydranium/protocol": "1.0.0-next.273",
|
|
79
79
|
"@types/node": "^22.0.0",
|
|
80
80
|
"inversify": "6.2.2",
|
|
81
81
|
"langium": "4.3.1",
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"vscode-languageserver-protocol": "3.18.1"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
|
-
"@hydranium/core": "1.0.0-next.
|
|
93
|
-
"@hydranium/data-server": "1.0.0-next.
|
|
94
|
-
"@hydranium/langium": "1.0.0-next.
|
|
95
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
92
|
+
"@hydranium/core": "1.0.0-next.273",
|
|
93
|
+
"@hydranium/data-server": "1.0.0-next.273",
|
|
94
|
+
"@hydranium/langium": "1.0.0-next.273",
|
|
95
|
+
"@hydranium/protocol": "1.0.0-next.273",
|
|
96
96
|
"@memlab/core": "^2.0.3",
|
|
97
97
|
"@memlab/heap-analysis": "^2.0.3",
|
|
98
98
|
"vscode-jsonrpc": "^9.0.0"
|
package/src/cli.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { describeError } from '@hydranium/protocol';
|
|
|
13
13
|
import { readCliVersion } from './cli-version.js';
|
|
14
14
|
import { runAnalyzeHeapCommand } from './commands/analyze-heap-args.js';
|
|
15
15
|
import { runAstGroundTruthCommand } from './commands/ast-ground-truth-args.js';
|
|
16
|
+
import { runDeleteCommand } from './commands/delete-args.js';
|
|
16
17
|
import { runGenerateTransferModelCommand } from './commands/generate-transfer-model-args.js';
|
|
17
18
|
import { runInitCommand } from './commands/init-args.js';
|
|
18
19
|
import { InitWizardCancelled } from './commands/init-prompt.js';
|
|
@@ -45,6 +46,7 @@ const COMMANDS: Record<string, { readonly summary: string; readonly run: (args:
|
|
|
45
46
|
summary: "Tally a workspace's live-model $types (analyze-heap --validate input).",
|
|
46
47
|
run: runAstGroundTruthCommand
|
|
47
48
|
},
|
|
49
|
+
delete: { summary: 'Delete a document, its file included, via a data-server subprocess.', run: runDeleteCommand },
|
|
48
50
|
'generate-transfer-model': {
|
|
49
51
|
summary: 'Generate a transfer-model TypeScript file from a Langium AST.',
|
|
50
52
|
run: runGenerateTransferModelCommand
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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 {
|
|
11
|
+
assertRequired,
|
|
12
|
+
exitWithUsage,
|
|
13
|
+
helpRequested,
|
|
14
|
+
logHelpLines,
|
|
15
|
+
parseFlagOptions,
|
|
16
|
+
parseServerSpawnOptions,
|
|
17
|
+
printHelp,
|
|
18
|
+
SERVER_SPAWN_VALUE_FLAGS,
|
|
19
|
+
type UsageError
|
|
20
|
+
} from './harness-args.js';
|
|
21
|
+
import { type DeleteCommandOptions, runDelete } from './delete.js';
|
|
22
|
+
|
|
23
|
+
const OWN_FLAGS = ['--uri', '--client-id'] as const;
|
|
24
|
+
|
|
25
|
+
/** Every flag `delete` accepts, each of which takes a value. */
|
|
26
|
+
export const DELETE_FLAGS: readonly string[] = [...SERVER_SPAWN_VALUE_FLAGS, ...OWN_FLAGS];
|
|
27
|
+
|
|
28
|
+
/** The `--help` text, as data, held to {@link DELETE_FLAGS} by a test. */
|
|
29
|
+
export const DELETE_HELP: readonly string[] = [
|
|
30
|
+
'Usage: hydranium-cli delete --server "<cmd>..." --uri <uri> [--client-id <id>] [--cwd <dir>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
31
|
+
'',
|
|
32
|
+
'Delete the document at `<uri>`, its file and then the document, via deleteModelDocument,',
|
|
33
|
+
'whatever text it holds. Prints nothing.',
|
|
34
|
+
'',
|
|
35
|
+
'Options:',
|
|
36
|
+
' --server "<cmd>" Command-line for the data-server subprocess (required).',
|
|
37
|
+
' --uri <uri> Document URI (required).',
|
|
38
|
+
' --client-id <id> clientId the deletion is attributed to. Default: hydranium-cli.',
|
|
39
|
+
' --cwd <dir> Working directory for the spawned child. Default: cwd.',
|
|
40
|
+
...logHelpLines(22, 'the spawned server')
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export function parseDeleteArgs(args: string[], onError: UsageError = exitWithUsage): DeleteCommandOptions {
|
|
44
|
+
const { serverCommand, serverArgs, cwd, logLevel, logFile, logFileLevel, extra } = parseServerSpawnOptions(args, 'delete', onError);
|
|
45
|
+
const { uri, clientId } = parseFlagOptions(extra, 'delete', OWN_FLAGS, onError);
|
|
46
|
+
return {
|
|
47
|
+
serverCommand,
|
|
48
|
+
serverArgs,
|
|
49
|
+
cwd,
|
|
50
|
+
logLevel,
|
|
51
|
+
logFile,
|
|
52
|
+
logFileLevel,
|
|
53
|
+
uri: assertRequired(uri, '--uri', 'delete', onError),
|
|
54
|
+
clientId
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function runDeleteCommand(args: string[]): Promise<void> {
|
|
59
|
+
if (helpRequested(args, DELETE_FLAGS)) {
|
|
60
|
+
printHelp(DELETE_HELP);
|
|
61
|
+
return Promise.resolve();
|
|
62
|
+
}
|
|
63
|
+
return runDelete(parseDeleteArgs(args));
|
|
64
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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 type { TransferElement } from '@hydranium/protocol';
|
|
11
|
+
import type { DataServerProtocol } from '@hydranium/protocol/data';
|
|
12
|
+
import { logEnv, type LogOptions } from '../log-level.js';
|
|
13
|
+
import { withDataServer } from '../spawn-data-server.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Options for the {@link runDelete} subcommand. Deletes the document at `uri`,
|
|
17
|
+
* its file and then the document, via the data-server's `deleteModelDocument`
|
|
18
|
+
* RPC, whatever text it holds. Prints nothing; a failed delete rejects.
|
|
19
|
+
*
|
|
20
|
+
* `clientId` defaults to `'hydranium-cli'`. The command deletes as a client
|
|
21
|
+
* session under it: it registers the session, opens the document, deletes it,
|
|
22
|
+
* and ends the session.
|
|
23
|
+
*/
|
|
24
|
+
export interface DeleteCommandOptions extends LogOptions {
|
|
25
|
+
readonly serverCommand: string;
|
|
26
|
+
readonly serverArgs?: readonly string[];
|
|
27
|
+
readonly cwd?: string;
|
|
28
|
+
readonly uri: string;
|
|
29
|
+
readonly clientId?: string;
|
|
30
|
+
readonly __proxyForTest?: DataServerProtocol<TransferElement>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function runDelete(options: DeleteCommandOptions): Promise<void> {
|
|
34
|
+
const clientId = options.clientId ?? 'hydranium-cli';
|
|
35
|
+
if (options.__proxyForTest) {
|
|
36
|
+
await deleteOpened(options.__proxyForTest, options.uri, clientId);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
await withDataServer(
|
|
40
|
+
{
|
|
41
|
+
command: options.serverCommand,
|
|
42
|
+
args: options.serverArgs,
|
|
43
|
+
cwd: options.cwd,
|
|
44
|
+
env: logEnv(options)
|
|
45
|
+
},
|
|
46
|
+
server => deleteOpened(server, options.uri, clientId)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Delete `uri` as the session `clientId`, and end the session whether the
|
|
52
|
+
* delete succeeded or not. An end that fails after a failed delete is
|
|
53
|
+
* swallowed: the delete's error is the one the user needs.
|
|
54
|
+
*/
|
|
55
|
+
async function deleteOpened(
|
|
56
|
+
server: Pick<DataServerProtocol<TransferElement>, 'createSession' | 'openModelDocument' | 'deleteModelDocument' | 'closeSession'>,
|
|
57
|
+
uri: string,
|
|
58
|
+
clientId: string
|
|
59
|
+
): Promise<void> {
|
|
60
|
+
await server.createSession({ clientId, label: 'hydranium-cli' });
|
|
61
|
+
try {
|
|
62
|
+
await server.openModelDocument({ uri, clientId });
|
|
63
|
+
await server.deleteModelDocument({ uri, clientId, baseVersion: 'any' });
|
|
64
|
+
} catch (error: unknown) {
|
|
65
|
+
await server.closeSession({ clientId }).catch(() => undefined);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
await server.closeSession({ clientId });
|
|
69
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
+
export * from './commands/delete.js';
|
|
10
11
|
export * from './commands/generate-ast-builder.js';
|
|
11
12
|
export * from './commands/generate-transfer-model.js';
|
|
12
13
|
export * from './commands/projects.js';
|