@hydranium/cli 1.0.0-next.217 → 1.0.0-next.219
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/lib/spawn-data-server.d.ts +6 -1
- package/lib/spawn-data-server.d.ts.map +1 -1
- package/lib/spawn-data-server.js +2 -1
- 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 +8 -1
- package/lib/testing/echo-server.js.map +1 -1
- package/package.json +9 -9
- package/src/spawn-data-server.ts +14 -2
- package/src/stderr-connection-logger.ts +18 -0
- package/src/testing/echo-server.ts +10 -2
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { type TransferDiagnostic, type TransferElement } from '@hydranium/protocol';
|
|
10
10
|
import { type DataClientProtocol, type DataServerProtocol } from '@hydranium/protocol/data';
|
|
11
11
|
import { type ChildProcess } from 'node:child_process';
|
|
12
|
-
import { type MessageConnection } from 'vscode-jsonrpc/node';
|
|
12
|
+
import { type Logger as ConnectionLogger, type MessageConnection } from 'vscode-jsonrpc/node';
|
|
13
13
|
/**
|
|
14
14
|
* Options for {@link spawnDataServer}. `command` is the binary or script
|
|
15
15
|
* path; `args` are the command-line arguments passed to it. The adopter's
|
|
@@ -42,6 +42,11 @@ export interface SpawnDataServerOptions {
|
|
|
42
42
|
* scripted use; set to `'pipe'` to capture for assertion in tests.
|
|
43
43
|
*/
|
|
44
44
|
readonly stderr?: 'inherit' | 'ignore' | 'pipe';
|
|
45
|
+
/**
|
|
46
|
+
* Where the connection to the child logs its protocol faults, such as a
|
|
47
|
+
* response that matches no request. Default: this process's stderr.
|
|
48
|
+
*/
|
|
49
|
+
readonly logger?: ConnectionLogger;
|
|
45
50
|
}
|
|
46
51
|
/**
|
|
47
52
|
* Lifecycle handle for a spawned data-server. Owns the child process,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-data-server.d.ts","sourceRoot":"","sources":["../src/spawn-data-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAkB,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAGJ,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"spawn-data-server.d.ts","sourceRoot":"","sources":["../src/spawn-data-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAkB,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAGJ,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAIJ,KAAK,MAAM,IAAI,gBAAgB,EAC/B,KAAK,iBAAiB,EACxB,MAAM,qBAAqB,CAAC;AAG7B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,sBAAsB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC5D;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAChD;;;OAG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GED
|
@@ -10,6 +10,7 @@ import { createRpcProxy } from '@hydranium/protocol';
|
|
|
10
10
|
import { DATA_CLIENT_PROTOCOL_METHODS, DATA_SERVER_WIRE_PREFIX } from '@hydranium/protocol/data';
|
|
11
11
|
import { spawn } from 'node:child_process';
|
|
12
12
|
import { StreamMessageReader, StreamMessageWriter, createMessageConnection } from 'vscode-jsonrpc/node';
|
|
13
|
+
import { STDERR_CONNECTION_LOGGER } from './stderr-connection-logger.js';
|
|
13
14
|
/**
|
|
14
15
|
* Spawn a data-server subprocess and wire a typed proxy over its
|
|
15
16
|
* stdio JSON-RPC. The function returns once the connection is
|
|
@@ -61,7 +62,7 @@ export function spawnDataServer(options, localClient) {
|
|
|
61
62
|
});
|
|
62
63
|
const reader = new StreamMessageReader(child.stdout);
|
|
63
64
|
const writer = new StreamMessageWriter(child.stdin);
|
|
64
|
-
const connection = createMessageConnection(reader, writer);
|
|
65
|
+
const connection = createMessageConnection(reader, writer, options.logger ?? STDERR_CONNECTION_LOGGER);
|
|
65
66
|
// Consume transport error / close so a child that dies mid-stream (its stdout
|
|
66
67
|
// closing, a write landing on a torn-down stdin) is observed here rather than
|
|
67
68
|
// escaping as an unhandled error — the death is reported via `whenTerminated`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-data-server.js","sourceRoot":"","sources":["../src/spawn-data-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,cAAc,EAAiD,MAAM,qBAAqB,CAAC;AACpG,OAAO,EACJ,4BAA4B,EAC5B,uBAAuB,EAGzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"spawn-data-server.js","sourceRoot":"","sources":["../src/spawn-data-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,cAAc,EAAiD,MAAM,qBAAqB,CAAC;AAC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O;YACV,CAAC;YACD,MAAM,MAAM,GAAG,GAAS,EAAE;gBACvB,YAAY,CAAC,SAAS,CAAC,CAAC;gBACxB,QAAQ,EAAE,CAAC;YACd,CAAC,CAAC;YACF,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC3B,6DAA6D;YAC7D,sEAAsE;YACtE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACtB,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC/B,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC,EAAE,SAAS,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,eAAe,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACjC,OAA+B,EAC/B,GAAyH,EACzH,WAAwD;IAExD,MAAM,MAAM,GAAG,eAAe,CAAyB,OAAO,EAAE,WAAW,CAAC,CAAC;IAC7E,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,4EAA4E;IAC5E,iFAAiF;IACjF,wEAAwE;IACxE,KAAK,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACvC,IAAI,CAAC;QACF,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;IAClE,CAAC;YAAS,CAAC;QACR,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 { Logger as ConnectionLogger } from 'vscode-jsonrpc/node';
|
|
10
|
+
/** Every connection line goes to stderr: stdout carries the command's output or the protocol stream. */
|
|
11
|
+
export declare const STDERR_CONNECTION_LOGGER: ConnectionLogger;
|
|
12
|
+
//# sourceMappingURL=stderr-connection-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stderr-connection-logger.d.ts","sourceRoot":"","sources":["../src/stderr-connection-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEtE,wGAAwG;AACxG,eAAO,MAAM,wBAAwB,EAAE,gBAKtC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
/** Every connection line goes to stderr: stdout carries the command's output or the protocol stream. */
|
|
10
|
+
export const STDERR_CONNECTION_LOGGER = {
|
|
11
|
+
error: message => console.error(message),
|
|
12
|
+
warn: message => console.error(message),
|
|
13
|
+
info: message => console.error(message),
|
|
14
|
+
log: message => console.error(message)
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=stderr-connection-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stderr-connection-logger.js","sourceRoot":"","sources":["../src/stderr-connection-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF,wGAAwG;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAqB;IACvD,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IACxC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IACvC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IACvC,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;CACxC,CAAC"}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { DataServer } from '@hydranium/data-server';
|
|
20
20
|
import { makeTestServices } from '@hydranium/core/testing';
|
|
21
21
|
import { StreamMessageReader, StreamMessageWriter, createMessageConnection } from 'vscode-jsonrpc/node';
|
|
22
|
+
import { STDERR_CONNECTION_LOGGER } from '../stderr-connection-logger.js';
|
|
22
23
|
function parseFakeRoot(text) {
|
|
23
24
|
const match = /^name:(.+)$/.exec(text);
|
|
24
25
|
return { $type: 'FakeRoot', name: match ? match[1] : 'unknown' };
|
|
@@ -60,7 +61,13 @@ function main() {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
|
-
const
|
|
64
|
+
const writer = new StreamMessageWriter(process.stdout);
|
|
65
|
+
const connection = createMessageConnection(new StreamMessageReader(process.stdin), writer, STDERR_CONNECTION_LOGGER);
|
|
66
|
+
if (process.argv.includes('--send-response-without-id')) {
|
|
67
|
+
// A response the parent cannot match to a request, for its connection to log.
|
|
68
|
+
const response = { jsonrpc: '2.0', id: null, result: null };
|
|
69
|
+
writer.write(response).catch((error) => STDERR_CONNECTION_LOGGER.error(String(error)));
|
|
70
|
+
}
|
|
64
71
|
if (process.argv.includes('--exit-on-request')) {
|
|
65
72
|
// Fail-fast fixture mode: read a full request (the reader parses the whole
|
|
66
73
|
// message, so the parent's write completed — no partial-write race) then die
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echo-server.js","sourceRoot":"","sources":["../../src/testing/echo-server.ts"],"names":[],"mappings":";AACA;;;;;;;kFAOkF;AAElF;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"echo-server.js","sourceRoot":"","sources":["../../src/testing/echo-server.ts"],"names":[],"mappings":";AACA;;;;;;;kFAOkF;AAElF;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,uBAAuB,EAAwB,MAAM,qBAAqB,CAAC;AAC9H,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAO1E,SAAS,aAAa,CAAC,IAAY;IAChC,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAc,CAAC;AAChF,CAAC;AAED,SAAS,IAAI;IACV,MAAM,MAAM,GAAG,gBAAgB,CAA4B;QACxD,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE;QAC9C,aAAa,EAAE;YACZ;gBACG,GAAG,EAAE,wBAAwB;gBAC7B,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAc;aAC1D;YACD;gBACG,kEAAkE;gBAClE,iEAA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AAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,uBAAuB,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAErH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,CAAC;QACvD,8EAA8E;QAC9E,MAAM,QAAQ,GAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC7E,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnG,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC9C,2EAA2E;QAC3E,6EAA6E;QAC7E,8EAA8E;QAC9E,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,UAAU,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO;IACV,CAAC;IAED,IAAI,UAAU,CAAW,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtD,UAAU,CAAC,MAAM,EAAE,CAAC;IACpB,sEAAsE;IACtE,qEAAqE;IACrE,6CAA6C;AAChD,CAAC;AAED,IAAI,EAAE,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.219",
|
|
4
4
|
"description": "Build-time codegen tools + data-server subcommands for the hydranium framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -69,20 +69,20 @@
|
|
|
69
69
|
"ts-morph": "^25.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@hydranium/core": "1.0.0-next.
|
|
73
|
-
"@hydranium/data-server": "1.0.0-next.
|
|
74
|
-
"@hydranium/langium": "1.0.0-next.
|
|
75
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
72
|
+
"@hydranium/core": "1.0.0-next.219",
|
|
73
|
+
"@hydranium/data-server": "1.0.0-next.219",
|
|
74
|
+
"@hydranium/langium": "1.0.0-next.219",
|
|
75
|
+
"@hydranium/protocol": "1.0.0-next.219",
|
|
76
76
|
"rimraf": "^5.0.0",
|
|
77
77
|
"typescript": "^7.0.2",
|
|
78
78
|
"vscode-jsonrpc": "9.0.0",
|
|
79
79
|
"vscode-languageserver": "10.0.1"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@hydranium/core": "1.0.0-next.
|
|
83
|
-
"@hydranium/data-server": "1.0.0-next.
|
|
84
|
-
"@hydranium/langium": "1.0.0-next.
|
|
85
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
82
|
+
"@hydranium/core": "1.0.0-next.219",
|
|
83
|
+
"@hydranium/data-server": "1.0.0-next.219",
|
|
84
|
+
"@hydranium/langium": "1.0.0-next.219",
|
|
85
|
+
"@hydranium/protocol": "1.0.0-next.219",
|
|
86
86
|
"@memlab/core": "^2.0.3",
|
|
87
87
|
"@memlab/heap-analysis": "^2.0.3",
|
|
88
88
|
"vscode-jsonrpc": "^9.0.0"
|
package/src/spawn-data-server.ts
CHANGED
|
@@ -15,7 +15,14 @@ import {
|
|
|
15
15
|
type DataServerProtocol
|
|
16
16
|
} from '@hydranium/protocol/data';
|
|
17
17
|
import { type ChildProcess, spawn } from 'node:child_process';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
StreamMessageReader,
|
|
20
|
+
StreamMessageWriter,
|
|
21
|
+
createMessageConnection,
|
|
22
|
+
type Logger as ConnectionLogger,
|
|
23
|
+
type MessageConnection
|
|
24
|
+
} from 'vscode-jsonrpc/node';
|
|
25
|
+
import { STDERR_CONNECTION_LOGGER } from './stderr-connection-logger.js';
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
28
|
* Options for {@link spawnDataServer}. `command` is the binary or script
|
|
@@ -49,6 +56,11 @@ export interface SpawnDataServerOptions {
|
|
|
49
56
|
* scripted use; set to `'pipe'` to capture for assertion in tests.
|
|
50
57
|
*/
|
|
51
58
|
readonly stderr?: 'inherit' | 'ignore' | 'pipe';
|
|
59
|
+
/**
|
|
60
|
+
* Where the connection to the child logs its protocol faults, such as a
|
|
61
|
+
* response that matches no request. Default: this process's stderr.
|
|
62
|
+
*/
|
|
63
|
+
readonly logger?: ConnectionLogger;
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
/**
|
|
@@ -143,7 +155,7 @@ export function spawnDataServer<TTransfer extends TransferElement, TDiagnostic e
|
|
|
143
155
|
|
|
144
156
|
const reader = new StreamMessageReader(child.stdout);
|
|
145
157
|
const writer = new StreamMessageWriter(child.stdin);
|
|
146
|
-
const connection = createMessageConnection(reader, writer);
|
|
158
|
+
const connection = createMessageConnection(reader, writer, options.logger ?? STDERR_CONNECTION_LOGGER);
|
|
147
159
|
// Consume transport error / close so a child that dies mid-stream (its stdout
|
|
148
160
|
// closing, a write landing on a torn-down stdin) is observed here rather than
|
|
149
161
|
// escaping as an unhandled error — the death is reported via `whenTerminated`.
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { Logger as ConnectionLogger } from 'vscode-jsonrpc/node';
|
|
11
|
+
|
|
12
|
+
/** Every connection line goes to stderr: stdout carries the command's output or the protocol stream. */
|
|
13
|
+
export const STDERR_CONNECTION_LOGGER: ConnectionLogger = {
|
|
14
|
+
error: message => console.error(message),
|
|
15
|
+
warn: message => console.error(message),
|
|
16
|
+
info: message => console.error(message),
|
|
17
|
+
log: message => console.error(message)
|
|
18
|
+
};
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
import { DataServer } from '@hydranium/data-server';
|
|
22
22
|
import { makeTestServices } from '@hydranium/core/testing';
|
|
23
23
|
import type { AstNode, URI } from '@hydranium/langium';
|
|
24
|
-
import { StreamMessageReader, StreamMessageWriter, createMessageConnection } from 'vscode-jsonrpc/node';
|
|
24
|
+
import { StreamMessageReader, StreamMessageWriter, createMessageConnection, type ResponseMessage } from 'vscode-jsonrpc/node';
|
|
25
|
+
import { STDERR_CONNECTION_LOGGER } from '../stderr-connection-logger.js';
|
|
25
26
|
|
|
26
27
|
interface FakeRoot extends AstNode {
|
|
27
28
|
readonly $type: 'FakeRoot';
|
|
@@ -72,7 +73,14 @@ function main(): void {
|
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
const
|
|
76
|
+
const writer = new StreamMessageWriter(process.stdout);
|
|
77
|
+
const connection = createMessageConnection(new StreamMessageReader(process.stdin), writer, STDERR_CONNECTION_LOGGER);
|
|
78
|
+
|
|
79
|
+
if (process.argv.includes('--send-response-without-id')) {
|
|
80
|
+
// A response the parent cannot match to a request, for its connection to log.
|
|
81
|
+
const response: ResponseMessage = { jsonrpc: '2.0', id: null, result: null };
|
|
82
|
+
writer.write(response).catch((error: unknown) => STDERR_CONNECTION_LOGGER.error(String(error)));
|
|
83
|
+
}
|
|
76
84
|
|
|
77
85
|
if (process.argv.includes('--exit-on-request')) {
|
|
78
86
|
// Fail-fast fixture mode: read a full request (the reader parses the whole
|