@akala/pm 3.3.3 → 3.4.1
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/changelog.md +6 -1
- package/commands.json +137 -88
- package/dist/commands/bridge.d.ts +3 -0
- package/dist/commands/bridge.js +8 -0
- package/dist/commands/bridge.js.map +1 -0
- package/dist/commands/proxy.d.ts +3 -0
- package/dist/commands/proxy.js +14 -0
- package/dist/commands/proxy.js.map +1 -0
- package/dist/commands/reload-metadata.js +1 -1
- package/dist/commands/reload-metadata.js.map +1 -1
- package/dist/commands/start.d.ts +1 -13
- package/dist/commands/start.js +2 -45
- package/dist/commands/start.js.map +1 -1
- package/dist/container.d.ts +16 -12
- package/dist/fork.js +32 -19
- package/dist/fork.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/ipc-adapter.d.ts +15 -0
- package/dist/ipc-adapter.js +51 -0
- package/dist/ipc-adapter.js.map +1 -0
- package/dist/state.d.ts +4 -1
- package/package.json +6 -6
- package/src/commands/bridge.json +18 -0
- package/src/commands/bridge.ts +9 -0
- package/src/commands/proxy.json +15 -0
- package/src/commands/proxy.ts +14 -0
- package/src/commands/reload-metadata.ts +1 -1
- package/src/commands/start.ts +1 -67
- package/src/container.ts +16 -12
- package/src/fork.ts +39 -24
- package/src/index.ts +1 -1
- package/src/ipc-adapter.ts +65 -0
- package/src/state.ts +2 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/fork.js
CHANGED
@@ -32,11 +32,12 @@ source_map_support_1.default.install();
|
|
32
32
|
const path = __importStar(require("path"));
|
33
33
|
const ac = __importStar(require("@akala/commands"));
|
34
34
|
const promises_1 = require("fs/promises");
|
35
|
-
const
|
35
|
+
const ipc_adapter_1 = require("./ipc-adapter");
|
36
36
|
const net_1 = require("net");
|
37
37
|
const core_1 = require("@akala/core");
|
38
38
|
const cli_1 = __importStar(require("@akala/cli"));
|
39
39
|
const commands_1 = require("@akala/commands");
|
40
|
+
const serve_metadata_1 = require("@akala/commands/src/serve-metadata");
|
40
41
|
var isPm = false;
|
41
42
|
cli_1.default.useMiddleware({
|
42
43
|
handle: async (c) => {
|
@@ -59,7 +60,7 @@ logMiddleware.preAction(async (c) => {
|
|
59
60
|
await ac.Processors.FileSystem.discoverCommands(c.options.program, cliContainer, { processor: processor, isDirectory: folderOrFile.isDirectory() });
|
60
61
|
});
|
61
62
|
const initMiddleware = new cli_1.NamespaceMiddleware(null);
|
62
|
-
cli_1.default.option('program', { needsValue: true }).option('name', { needsValue: true }).
|
63
|
+
cli_1.default.option('program', { needsValue: true }).option('name', { needsValue: true }).option('tls', { needsValue: false }).
|
63
64
|
use(async (c) => //If pure js file
|
64
65
|
{
|
65
66
|
folderOrFile = await (0, promises_1.lstat)(c.options.program);
|
@@ -87,28 +88,34 @@ cli_1.default.option('program', { needsValue: true }).option('name', { needsValu
|
|
87
88
|
ac.Triggers.addCliOptions(init, initMiddleware);
|
88
89
|
initMiddleware.option('pmSocket', { aliases: ['pm-socket', 'pm-sock'] }).action(async (c) => {
|
89
90
|
let pm;
|
91
|
+
let pmConnectInfo;
|
90
92
|
if (!isPm) {
|
91
93
|
if (process.connected) {
|
92
|
-
pm = new ac.Container('pm', null, new ac.Processors.JsonRpc(ac.Processors.JsonRpc.getConnection(new
|
94
|
+
pm = new ac.Container('pm', null, new ac.Processors.JsonRpc(ac.Processors.JsonRpc.getConnection(new ipc_adapter_1.IpcAdapter(process), cliContainer), true));
|
93
95
|
}
|
94
96
|
else {
|
95
97
|
const pmSocket = new net_1.Socket();
|
96
|
-
await
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
98
|
+
const x = await ac.connectByPreference(pmConnectInfo = (0, serve_metadata_1.parseMetadata)(c.options.pmSocket, c.options.tls), { container: cliContainer });
|
99
|
+
pm = x.container;
|
100
|
+
// await new Promise<void>((resolve, reject) =>
|
101
|
+
// {
|
102
|
+
// pmSocket.on('error', reject)
|
103
|
+
// const remote = /^(?:([^:]+):)?(\d+)$/.exec(c.options.pmSocket);
|
104
|
+
// if (!remote)
|
105
|
+
// {
|
106
|
+
// pmSocket.connect(c.options.pmSocket, resolve);
|
107
|
+
// }
|
108
|
+
// else
|
109
|
+
// {
|
110
|
+
// const host = remote[1];
|
111
|
+
// const port = remote[2];
|
112
|
+
// if (host)
|
113
|
+
// pmSocket.connect(Number(port), host, resolve);
|
114
|
+
// else
|
115
|
+
// pmSocket.connect(Number(port), resolve);
|
116
|
+
// }
|
117
|
+
// })
|
118
|
+
// pm = new ac.Container('pm', null, new ac.Processors.JsonRpc(ac.Processors.JsonRpc.getConnection(new ac.NetSocketAdapter(pmSocket), cliContainer), true));
|
112
119
|
}
|
113
120
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
114
121
|
(0, commands_1.registerCommands)(require('../commands.json').commands.map(ac.Metadata.extractCommandMetadata), null, pm);
|
@@ -118,6 +125,12 @@ cli_1.default.option('program', { needsValue: true }).option('name', { needsValu
|
|
118
125
|
else
|
119
126
|
pm = cliContainer;
|
120
127
|
(0, core_1.module)('@akala/pm').register('container', pm);
|
128
|
+
cliContainer.register(new commands_1.SelfDefinedCommand(async (connectionId) => {
|
129
|
+
if (!pmConnectInfo)
|
130
|
+
pmConnectInfo = await pm.dispatch('connect', 'pm');
|
131
|
+
var pm2 = await ac.connectByPreference(pmConnectInfo, { container: cliContainer });
|
132
|
+
await pm2.container.dispatch('bridge', connectionId);
|
133
|
+
}, '$bridge'));
|
121
134
|
if (init)
|
122
135
|
await cliContainer.dispatch(init, { options: c.options, param: c.args, _trigger: 'cli', pm: pm, context: c });
|
123
136
|
let stop;
|
package/dist/fork.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fork.js","sourceRoot":"","sources":["../src/fork.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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C,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC;KACD,aAAa,CAAC,cAAc,CAAC,CAAC;AAEnC,IAAI,OAAO,CAAC,IAAI,IAAI,MAAM;IACtB,aAAO,CAAC,OAAO,CAAC,IAAA,gCAA0B,GAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QAEpD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
@@ -64,7 +64,7 @@ function sidecar(options, noCache) {
|
|
64
64
|
catch (e) {
|
65
65
|
if (e && e.statusCode == 404 || !meta.connect) {
|
66
66
|
var c = new commands_1.Container(meta.container.name, null, (0, core_1.module)('@akala/pm').resolve('container').processor);
|
67
|
-
c.processor.useMiddleware(
|
67
|
+
c.processor.useMiddleware(0, {
|
68
68
|
handle(origin, cmd, param) {
|
69
69
|
if (cmd.name.startsWith(meta.container.name + '.'))
|
70
70
|
return undefined;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="webpack-env" />
|
3
|
+
import { ChildProcess } from "child_process";
|
4
|
+
import * as jsonrpc from '@akala/json-rpc-ws';
|
5
|
+
import { SocketAdapterEventMap } from "@akala/json-rpc-ws";
|
6
|
+
export declare class IpcAdapter implements jsonrpc.SocketAdapter {
|
7
|
+
private cp;
|
8
|
+
get open(): boolean;
|
9
|
+
pipe(socket: jsonrpc.SocketAdapter<unknown>): void;
|
10
|
+
close(): void;
|
11
|
+
send(data: string): void;
|
12
|
+
on<K extends keyof SocketAdapterEventMap>(event: K, handler: (ev: SocketAdapterEventMap[K]) => void): void;
|
13
|
+
once<K extends keyof SocketAdapterEventMap>(event: K, handler: (ev: SocketAdapterEventMap[K]) => void): void;
|
14
|
+
constructor(cp: ChildProcess | NodeJS.Process);
|
15
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.IpcAdapter = void 0;
|
4
|
+
class IpcAdapter {
|
5
|
+
cp;
|
6
|
+
get open() { return !!this.cp.pid; }
|
7
|
+
pipe(socket) {
|
8
|
+
this.on('message', (message) => socket.send(message));
|
9
|
+
this.on('close', () => socket.close());
|
10
|
+
}
|
11
|
+
close() {
|
12
|
+
this.cp.disconnect();
|
13
|
+
}
|
14
|
+
send(data) {
|
15
|
+
if (this.cp.send)
|
16
|
+
this.cp.send(data + '\n');
|
17
|
+
else
|
18
|
+
console.warn(`process ${this.cp.pid} does not support send over IPC`);
|
19
|
+
}
|
20
|
+
on(event, handler) {
|
21
|
+
switch (event) {
|
22
|
+
case 'message':
|
23
|
+
this.cp.on('message', handler);
|
24
|
+
break;
|
25
|
+
case 'open':
|
26
|
+
handler(null);
|
27
|
+
break;
|
28
|
+
case 'close':
|
29
|
+
this.cp.on('disconnect', handler);
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
once(event, handler) {
|
34
|
+
switch (event) {
|
35
|
+
case 'message':
|
36
|
+
this.cp.once('message', handler);
|
37
|
+
break;
|
38
|
+
case 'open':
|
39
|
+
handler(null);
|
40
|
+
break;
|
41
|
+
case 'close':
|
42
|
+
this.cp.once('disconnect', () => handler(null));
|
43
|
+
break;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
constructor(cp) {
|
47
|
+
this.cp = cp;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
exports.IpcAdapter = IpcAdapter;
|
51
|
+
//# sourceMappingURL=ipc-adapter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ipc-adapter.js","sourceRoot":"","sources":["../src/ipc-adapter.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IAuDC;IArDpB,IAAI,IAAI,KAAc,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;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AAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBAChD,MAAM;SACb;IACL,CAAC;IAED,YAAoB,EAAiC;QAAjC,OAAE,GAAF,EAAE,CAA+B;IAErD,CAAC;CAEJ;AA3DD,gCA2DC"}
|
package/dist/state.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { Container } from "@akala/commands";
|
3
3
|
import { ChildProcess } from "child_process";
|
4
|
-
import { Deferred, SerializableObject } from "@akala/json-rpc-ws";
|
4
|
+
import { Deferred, SerializableObject, SocketAdapter } from "@akala/json-rpc-ws";
|
5
5
|
import { ServeMetadata } from "@akala/commands";
|
6
6
|
import { ProxyConfiguration } from "@akala/config";
|
7
7
|
export default interface State {
|
@@ -10,6 +10,9 @@ export default interface State {
|
|
10
10
|
};
|
11
11
|
isDaemon: boolean;
|
12
12
|
config: ProxyConfiguration<StateConfiguration>;
|
13
|
+
bridges: {
|
14
|
+
[key: string]: SocketAdapter;
|
15
|
+
};
|
13
16
|
}
|
14
17
|
export interface StateConfiguration {
|
15
18
|
containers: {
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"pm": "dist/cli.js",
|
5
5
|
"pm-fork": "dist/fork.js"
|
6
6
|
},
|
7
|
-
"version": "3.
|
7
|
+
"version": "3.4.1",
|
8
8
|
"scripts": {
|
9
9
|
"test": "echo 1",
|
10
10
|
"generate": "ac generate dist/commands commands.json",
|
@@ -19,11 +19,11 @@
|
|
19
19
|
},
|
20
20
|
"homepage": "https://akala.js.org/pm",
|
21
21
|
"dependencies": {
|
22
|
-
"@akala/cli": "^2.1.
|
23
|
-
"@akala/commands": "^3.
|
24
|
-
"@akala/config": "^1.1.
|
25
|
-
"@akala/core": "^9.0.
|
26
|
-
"@akala/json-rpc-ws": "^9.
|
22
|
+
"@akala/cli": "^2.1.8",
|
23
|
+
"@akala/commands": "^3.2.0",
|
24
|
+
"@akala/config": "^1.1.19",
|
25
|
+
"@akala/core": "^9.0.4",
|
26
|
+
"@akala/json-rpc-ws": "^9.5.0",
|
27
27
|
"reflect-metadata": "^0.1.13",
|
28
28
|
"source-map-support": "^0.5.21"
|
29
29
|
},
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://raw.githubusercontent.com/npenin/akala/master/packages/commands/command-schema.json",
|
3
|
+
"fs": {
|
4
|
+
"inject": [
|
5
|
+
"param.0",
|
6
|
+
"param.1"
|
7
|
+
]
|
8
|
+
},
|
9
|
+
"jsonrpc": {
|
10
|
+
"inject": [
|
11
|
+
"param.0",
|
12
|
+
"socket"
|
13
|
+
]
|
14
|
+
},
|
15
|
+
"": {
|
16
|
+
"inject": []
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Container } from "@akala/commands";
|
2
|
+
import { SocketAdapter } from "@akala/json-rpc-ws";
|
3
|
+
import State from "../state";
|
4
|
+
|
5
|
+
export default function (this: State, connectionId: string, socket: SocketAdapter)
|
6
|
+
{
|
7
|
+
this.bridges[connectionId].pipe(socket);
|
8
|
+
socket.pipe(this.bridges[connectionId]);
|
9
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ErrorWithStatus } from "@akala/cli";
|
2
|
+
import { SocketAdapter } from "@akala/json-rpc-ws";
|
3
|
+
import { randomUUID } from "crypto";
|
4
|
+
import State from "../state";
|
5
|
+
|
6
|
+
export default async function (this: State, name: string, socket: SocketAdapter)
|
7
|
+
{
|
8
|
+
var cp = this.processes[name];
|
9
|
+
if (!cp)
|
10
|
+
throw new ErrorWithStatus(404, `There is no such process with name ${name}`);
|
11
|
+
const connectionId = randomUUID();
|
12
|
+
this.bridges[connectionId] = socket;
|
13
|
+
await cp.dispatch('$bridge', connectionId);
|
14
|
+
}
|
@@ -2,7 +2,7 @@ import { Container, Metadata, updateCommands } from "@akala/commands";
|
|
2
2
|
|
3
3
|
export default async function (remoteContainer: Container<void>)
|
4
4
|
{
|
5
|
-
const metadata: Metadata.Container = await remoteContainer.dispatch('$metadata');
|
5
|
+
const metadata: Metadata.Container = await remoteContainer.dispatch('$metadata', true);
|
6
6
|
remoteContainer.name = metadata.name;
|
7
7
|
updateCommands(metadata.commands, null, remoteContainer);
|
8
8
|
}
|
package/src/commands/start.ts
CHANGED
@@ -5,10 +5,10 @@ import pmContainer from '../container';
|
|
5
5
|
import * as jsonrpc from '@akala/json-rpc-ws'
|
6
6
|
import { eachAsync, logger } from "@akala/core";
|
7
7
|
import { NewLinePrefixer } from "../new-line-prefixer.js";
|
8
|
-
import { SocketAdapterEventMap } from "@akala/json-rpc-ws";
|
9
8
|
import { CliContext, ErrorWithStatus } from "@akala/cli";
|
10
9
|
import getRandomName from "./name";
|
11
10
|
import { ProxyConfiguration } from "@akala/config";
|
11
|
+
import { IpcAdapter } from "../ipc-adapter";
|
12
12
|
|
13
13
|
export default async function start(this: State, pm: pmContainer.container & Container<State>, name: string, context?: CliContext<{ new?: boolean, name: string, inspect?: boolean, verbose?: boolean, wait?: boolean }>): Promise<void | { execPath: string, args: string[], cwd: string, stdio: StdioOptions, shell: boolean, windowsHide: boolean }>
|
14
14
|
{
|
@@ -182,70 +182,4 @@ export default async function start(this: State, pm: pmContainer.container & Con
|
|
182
182
|
}
|
183
183
|
}
|
184
184
|
|
185
|
-
export class IpcAdapter implements jsonrpc.SocketAdapter
|
186
|
-
{
|
187
|
-
get open(): boolean { return !!this.cp.pid }
|
188
|
-
close(): void
|
189
|
-
{
|
190
|
-
this.cp.disconnect();
|
191
|
-
}
|
192
|
-
send(data: string): void
|
193
|
-
{
|
194
|
-
if (this.cp.send)
|
195
|
-
this.cp.send(data + '\n');
|
196
|
-
else
|
197
|
-
console.warn(`process ${this.cp.pid} does not support send over IPC`);
|
198
|
-
}
|
199
|
-
on<K extends keyof SocketAdapterEventMap>(event: K, handler: (ev: SocketAdapterEventMap[K]) => void): void
|
200
|
-
{
|
201
|
-
switch (event)
|
202
|
-
{
|
203
|
-
case 'message':
|
204
|
-
this.cp.on('message', handler);
|
205
|
-
break;
|
206
|
-
case 'open':
|
207
|
-
handler(null);
|
208
|
-
break;
|
209
|
-
case 'close':
|
210
|
-
this.cp.on('disconnect', handler);
|
211
|
-
break;
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
once<K extends keyof SocketAdapterEventMap>(event: K, handler: (ev: SocketAdapterEventMap[K]) => void): void
|
216
|
-
{
|
217
|
-
switch (event)
|
218
|
-
{
|
219
|
-
case 'message':
|
220
|
-
this.cp.once('message', handler);
|
221
|
-
break;
|
222
|
-
case 'open':
|
223
|
-
handler(null);
|
224
|
-
break;
|
225
|
-
case 'close':
|
226
|
-
this.cp.once('disconnect', () => handler(null));
|
227
|
-
break;
|
228
|
-
}
|
229
|
-
}
|
230
|
-
|
231
|
-
constructor(private cp: ChildProcess | NodeJS.Process)
|
232
|
-
{
|
233
|
-
}
|
234
|
-
|
235
|
-
// _write(chunk: string | Buffer, encoding: string, callback: (error?: any) => void)
|
236
|
-
// {
|
237
|
-
// // The underlying source only deals with strings.
|
238
|
-
// if (Buffer.isBuffer(chunk))
|
239
|
-
// chunk = chunk.toString('utf8');
|
240
|
-
// if (this.cp.send)
|
241
|
-
// this.cp.send(chunk + '\n', callback);
|
242
|
-
// else
|
243
|
-
// callback(new Error('there is no send method on this process'));
|
244
|
-
// }
|
245
|
-
|
246
|
-
// _read()
|
247
|
-
// {
|
248
|
-
// }
|
249
|
-
}
|
250
|
-
|
251
185
|
start.$inject = ['$container', 'param.0', 'options']
|
package/src/container.ts
CHANGED
@@ -5,18 +5,20 @@ namespace commands
|
|
5
5
|
{
|
6
6
|
export interface container
|
7
7
|
{
|
8
|
-
dispatch (cmd:'connect', ...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
|
9
|
-
dispatch (cmd:'config', ...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
|
10
|
-
dispatch (cmd:'install', ...args: [Argument0<typeof import('./commands/install').default>]): ReturnType<typeof import('./commands/install').default>
|
11
8
|
dispatch (cmd:'$init', ...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>
|
9
|
+
dispatch (cmd:'bridge', ...args: [Argument0<typeof import('./commands/bridge').default>, Argument1<typeof import('./commands/bridge').default>]): ReturnType<typeof import('./commands/bridge').default>
|
10
|
+
dispatch (cmd:'config', ...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
|
11
|
+
dispatch (cmd:'connect', ...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
|
12
12
|
dispatch (cmd:'discover', ...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>
|
13
|
+
dispatch (cmd:'install', ...args: [Argument0<typeof import('./commands/install').default>]): ReturnType<typeof import('./commands/install').default>
|
13
14
|
dispatch (cmd:'link', ...args: [Argument0<typeof import('./commands/link').default>, Argument1<typeof import('./commands/link').default>]): ReturnType<typeof import('./commands/link').default>
|
14
|
-
dispatch (cmd:'ls', ...args: []): ReturnType<typeof import('./commands/ls').default>
|
15
|
-
dispatch (cmd:'name', ...args: [Argument0<typeof import('./commands/name').default>]): ReturnType<typeof import('./commands/name').default>
|
16
15
|
dispatch (cmd:'log', ...args: [Argument0<typeof import('./commands/log').default>]): ReturnType<typeof import('./commands/log').default>
|
17
|
-
dispatch (cmd:'
|
16
|
+
dispatch (cmd:'ls', ...args: []): ReturnType<typeof import('./commands/ls').default>
|
18
17
|
dispatch (cmd:'map', ...args: [Argument0<typeof import('./commands/map').default>, Argument1<typeof import('./commands/map').default>, Argument2<typeof import('./commands/map').default>, Argument3<typeof import('./commands/map').default>]): ReturnType<typeof import('./commands/map').default>
|
18
|
+
dispatch (cmd:'name', ...args: [Argument0<typeof import('./commands/name').default>]): ReturnType<typeof import('./commands/name').default>
|
19
|
+
dispatch (cmd:'proxy', ...args: [Argument0<typeof import('./commands/proxy').default>, Argument1<typeof import('./commands/proxy').default>]): ReturnType<typeof import('./commands/proxy').default>
|
19
20
|
dispatch (cmd:'ready', ...args: []): ReturnType<typeof import('./commands/ready').default>
|
21
|
+
dispatch (cmd:'reload-metadata', ...args: [Argument0<typeof import('./commands/reload-metadata').default>]): ReturnType<typeof import('./commands/reload-metadata').default>
|
20
22
|
dispatch (cmd:'start', ...args: [Argument1<typeof import('./commands/start').default>, Argument2<typeof import('./commands/start').default>]): ReturnType<typeof import('./commands/start').default>
|
21
23
|
dispatch (cmd:'status', ...args: [Argument0<typeof import('./commands/status').default>]): ReturnType<typeof import('./commands/status').default>
|
22
24
|
dispatch (cmd:'stop', ...args: [Argument0<typeof import('./commands/stop').default>]): ReturnType<typeof import('./commands/stop').default>
|
@@ -25,18 +27,20 @@ namespace commands
|
|
25
27
|
}
|
26
28
|
export interface proxy
|
27
29
|
{
|
28
|
-
'connect'(...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
|
29
|
-
'config'(...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
|
30
|
-
'install'(...args: [Argument0<typeof import('./commands/install').default>]): ReturnType<typeof import('./commands/install').default>
|
31
30
|
'$init'(...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>
|
31
|
+
'bridge'(...args: [Argument0<typeof import('./commands/bridge').default>, Argument1<typeof import('./commands/bridge').default>]): ReturnType<typeof import('./commands/bridge').default>
|
32
|
+
'config'(...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
|
33
|
+
'connect'(...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
|
32
34
|
'discover'(...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>
|
35
|
+
'install'(...args: [Argument0<typeof import('./commands/install').default>]): ReturnType<typeof import('./commands/install').default>
|
33
36
|
'link'(...args: [Argument0<typeof import('./commands/link').default>, Argument1<typeof import('./commands/link').default>]): ReturnType<typeof import('./commands/link').default>
|
34
|
-
'ls'(...args: []): ReturnType<typeof import('./commands/ls').default>
|
35
|
-
'name'(...args: [Argument0<typeof import('./commands/name').default>]): ReturnType<typeof import('./commands/name').default>
|
36
37
|
'log'(...args: [Argument0<typeof import('./commands/log').default>]): ReturnType<typeof import('./commands/log').default>
|
37
|
-
'
|
38
|
+
'ls'(...args: []): ReturnType<typeof import('./commands/ls').default>
|
38
39
|
'map'(...args: [Argument0<typeof import('./commands/map').default>, Argument1<typeof import('./commands/map').default>, Argument2<typeof import('./commands/map').default>, Argument3<typeof import('./commands/map').default>]): ReturnType<typeof import('./commands/map').default>
|
40
|
+
'name'(...args: [Argument0<typeof import('./commands/name').default>]): ReturnType<typeof import('./commands/name').default>
|
41
|
+
'proxy'(...args: [Argument0<typeof import('./commands/proxy').default>, Argument1<typeof import('./commands/proxy').default>]): ReturnType<typeof import('./commands/proxy').default>
|
39
42
|
'ready'(...args: []): ReturnType<typeof import('./commands/ready').default>
|
43
|
+
'reload-metadata'(...args: [Argument0<typeof import('./commands/reload-metadata').default>]): ReturnType<typeof import('./commands/reload-metadata').default>
|
40
44
|
'start'(...args: [Argument1<typeof import('./commands/start').default>, Argument2<typeof import('./commands/start').default>]): ReturnType<typeof import('./commands/start').default>
|
41
45
|
'status'(...args: [Argument0<typeof import('./commands/status').default>]): ReturnType<typeof import('./commands/status').default>
|
42
46
|
'stop'(...args: [Argument0<typeof import('./commands/stop').default>]): ReturnType<typeof import('./commands/stop').default>
|
package/src/fork.ts
CHANGED
@@ -4,12 +4,13 @@ sms.install();
|
|
4
4
|
import * as path from 'path'
|
5
5
|
import * as ac from '@akala/commands';
|
6
6
|
import { lstat } from 'fs/promises';
|
7
|
-
import { IpcAdapter } from
|
7
|
+
import { IpcAdapter } from "./ipc-adapter";
|
8
8
|
import { Socket } from 'net';
|
9
9
|
import { logger, Logger, module as coreModule } from '@akala/core';
|
10
10
|
import program, { buildCliContextFromProcess, NamespaceMiddleware } from '@akala/cli';
|
11
11
|
import { Stats } from 'fs';
|
12
|
-
import { registerCommands } from '@akala/commands';
|
12
|
+
import { registerCommands, SelfDefinedCommand } from '@akala/commands';
|
13
|
+
import { parseMetadata } from '@akala/commands/src/serve-metadata';
|
13
14
|
|
14
15
|
var isPm = false;
|
15
16
|
|
@@ -25,7 +26,7 @@ let folderOrFile: Stats;
|
|
25
26
|
let cliContainer: ac.Container<unknown>;
|
26
27
|
let processor: ac.CommandProcessor;
|
27
28
|
let log: Logger;
|
28
|
-
const logMiddleware = new NamespaceMiddleware<{ program: string, name: string }>(null).option<string, 'verbose'>('verbose', { aliases: ['v',] });
|
29
|
+
const logMiddleware = new NamespaceMiddleware<{ program: string, name: string, tls: boolean }>(null).option<string, 'verbose'>('verbose', { aliases: ['v',] });
|
29
30
|
logMiddleware.preAction(async c =>
|
30
31
|
{
|
31
32
|
if (c.options.verbose)
|
@@ -37,8 +38,8 @@ logMiddleware.preAction(async c =>
|
|
37
38
|
|
38
39
|
await ac.Processors.FileSystem.discoverCommands(c.options.program, cliContainer, { processor: processor, isDirectory: folderOrFile.isDirectory() });
|
39
40
|
});
|
40
|
-
const initMiddleware = new NamespaceMiddleware<{ program: string, name: string }>(null);
|
41
|
-
program.option<string, 'program'>('program', { needsValue: true }).option<string, 'name'>('name', { needsValue: true }).
|
41
|
+
const initMiddleware = new NamespaceMiddleware<{ program: string, name: string, tls: boolean }>(null);
|
42
|
+
program.option<string, 'program'>('program', { needsValue: true }).option<string, 'name'>('name', { needsValue: true }).option<boolean, 'tls'>('tls', { needsValue: false }).
|
42
43
|
use(async c => //If pure js file
|
43
44
|
{
|
44
45
|
folderOrFile = await lstat(c.options.program);
|
@@ -71,7 +72,10 @@ program.option<string, 'program'>('program', { needsValue: true }).option<string
|
|
71
72
|
|
72
73
|
initMiddleware.option<string, 'pmSocket'>('pmSocket', { aliases: ['pm-socket', 'pm-sock'] }).action(async c =>
|
73
74
|
{
|
75
|
+
|
74
76
|
let pm: ac.Container<unknown>;
|
77
|
+
let pmConnectInfo: ac.ServeMetadata;
|
78
|
+
|
75
79
|
if (!isPm)
|
76
80
|
{
|
77
81
|
if (process.connected)
|
@@ -81,25 +85,27 @@ program.option<string, 'program'>('program', { needsValue: true }).option<string
|
|
81
85
|
else
|
82
86
|
{
|
83
87
|
const pmSocket = new Socket();
|
84
|
-
await
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
88
|
+
const x = await ac.connectByPreference(pmConnectInfo = parseMetadata(c.options.pmSocket, c.options.tls), { container: cliContainer });
|
89
|
+
pm = x.container;
|
90
|
+
// await new Promise<void>((resolve, reject) =>
|
91
|
+
// {
|
92
|
+
// pmSocket.on('error', reject)
|
93
|
+
// const remote = /^(?:([^:]+):)?(\d+)$/.exec(c.options.pmSocket);
|
94
|
+
// if (!remote)
|
95
|
+
// {
|
96
|
+
// pmSocket.connect(c.options.pmSocket, resolve);
|
97
|
+
// }
|
98
|
+
// else
|
99
|
+
// {
|
100
|
+
// const host = remote[1];
|
101
|
+
// const port = remote[2];
|
102
|
+
// if (host)
|
103
|
+
// pmSocket.connect(Number(port), host, resolve);
|
104
|
+
// else
|
105
|
+
// pmSocket.connect(Number(port), resolve);
|
106
|
+
// }
|
107
|
+
// })
|
108
|
+
// pm = new ac.Container('pm', null, new ac.Processors.JsonRpc(ac.Processors.JsonRpc.getConnection(new ac.NetSocketAdapter(pmSocket), cliContainer), true));
|
103
109
|
}
|
104
110
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
105
111
|
registerCommands(require('../commands.json').commands.map(ac.Metadata.extractCommandMetadata), null, pm);
|
@@ -112,6 +118,15 @@ program.option<string, 'program'>('program', { needsValue: true }).option<string
|
|
112
118
|
|
113
119
|
coreModule('@akala/pm').register('container', pm);
|
114
120
|
|
121
|
+
cliContainer.register(new SelfDefinedCommand(async (connectionId: string) =>
|
122
|
+
{
|
123
|
+
if (!pmConnectInfo)
|
124
|
+
pmConnectInfo = await pm.dispatch('connect', 'pm');
|
125
|
+
var pm2 = await ac.connectByPreference(pmConnectInfo, { container: cliContainer });
|
126
|
+
await pm2.container.dispatch('bridge', connectionId);
|
127
|
+
}, '$bridge'));
|
128
|
+
|
129
|
+
|
115
130
|
if (init)
|
116
131
|
await cliContainer.dispatch(init, { options: c.options, param: c.args, _trigger: 'cli', pm: pm, context: c });
|
117
132
|
|
package/src/index.ts
CHANGED
@@ -86,7 +86,7 @@ export function sidecar(options?: Omit<ConnectionPreference, 'metadata'> | SideC
|
|
86
86
|
if (e && e.statusCode == 404 || !meta.connect)
|
87
87
|
{
|
88
88
|
var c = new Container(meta.container.name, null, module('@akala/pm').resolve('container').processor);
|
89
|
-
c.processor.useMiddleware(
|
89
|
+
c.processor.useMiddleware(0, {
|
90
90
|
handle(origin, cmd, param)
|
91
91
|
{
|
92
92
|
if (cmd.name.startsWith(meta.container.name + '.'))
|