@akala/pm 14.5.8 → 14.6.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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "pm": "dist/esm/cli.js",
5
5
  "pm-fork": "dist/esm/fork.js"
6
6
  },
7
- "version": "14.5.8",
7
+ "version": "14.6.1",
8
8
  "scripts": {
9
9
  "test": "echo 1",
10
10
  "generate": "ac generate dist/esm/commands commands.json --name pm && ac generate dist/esm/cli-commands cli-commands.json --name pm",
@@ -29,11 +29,11 @@
29
29
  "src/fork.ts"
30
30
  ],
31
31
  "dependencies": {
32
- "@akala/cli": "^5.6.2",
33
- "@akala/commands": "^14.0.5",
34
- "@akala/config": "^6.0.65",
35
- "@akala/core": "^39.0.1",
36
- "@akala/json-rpc-ws": "^11.0.76",
32
+ "@akala/cli": "^5.7.1",
33
+ "@akala/commands": "^14.1.1",
34
+ "@akala/config": "^6.0.67",
35
+ "@akala/core": "^39.1.0",
36
+ "@akala/json-rpc-ws": "^11.0.77",
37
37
  "reflect-metadata": "^0.2.2",
38
38
  "source-map-support": "^0.5.21"
39
39
  },
package/src/akala.mts CHANGED
@@ -6,7 +6,7 @@ import { Readable } from 'stream';
6
6
  import { spawnAsync } from '@akala/cli/cli-helper';
7
7
  import { StateConfiguration } from './state.js';
8
8
  import { CliContext, ErrorMessage, InteractError, NamespaceMiddleware, unparse } from '@akala/cli';
9
- import { eachAsync, logger, LogLevels, NotHandled, ObservableObject, Parser } from '@akala/core';
9
+ import { eachAsync, HttpStatusCode, logger, LogLevels, NotHandled, ObservableObject, Parser } from '@akala/core';
10
10
  import module from 'module'
11
11
  import commands from './container.js';
12
12
  import cliCommands from './cli-container.js';
@@ -97,7 +97,7 @@ export default async function (_config, program: NamespaceMiddleware<{ configFil
97
97
  {
98
98
  log.silly('failed to connect to ' + connectionString);
99
99
  log.silly(e)
100
- if (e.code == 'ENOENT' || e.code == 'ECONNREFUSED')
100
+ if (e.statusCode == HttpStatusCode.BadGateway || e.code == 'ENOENT' || e.code == 'ECONNREFUSED')
101
101
  return;
102
102
  log.error(e);
103
103
  throw e;
@@ -4,7 +4,7 @@ import { connect, Container } from "@akala/commands";
4
4
  import { platform } from "os";
5
5
  import { Triggers } from "@akala/commands";
6
6
  import { ProxyConfiguration } from "@akala/config";
7
- import { eachAsync } from "@akala/core";
7
+ import { eachAsync, HttpStatusCode } from "@akala/core";
8
8
  import commands from "../container.js";
9
9
 
10
10
  type CliOptions = { pmSock: string | number, tls: boolean };
@@ -43,7 +43,7 @@ export default async function (c: CliContext<CliOptions, ProxyConfiguration<{ pm
43
43
  {
44
44
  c.logger.silly('failed to connect to ' + connectionString);
45
45
  c.logger.silly(e)
46
- if (e.code == 'ENOENT' || e.code == 'ECONNREFUSED')
46
+ if (e.statusCode == HttpStatusCode.BadGateway || e.code == 'ENOENT' || e.code == 'ECONNREFUSED')
47
47
  return;
48
48
  c.logger.error(e);
49
49
  throw e;
@@ -0,0 +1,72 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/npenin/akala/main/packages/commands/command-schema.json",
3
+ "": {
4
+ "inject": [
5
+ "param.0",
6
+ "param.1"
7
+ ]
8
+ },
9
+ "cli": {
10
+ "options": {
11
+ "output": {
12
+ "aliases": [
13
+ "o"
14
+ ],
15
+ "needsValue": true,
16
+ "doc": "output as `table` if array otherwise falls back to standard node output"
17
+ },
18
+ "verbose": {
19
+ "aliases": [
20
+ "v"
21
+ ]
22
+ },
23
+ "tls": {
24
+ "doc": "enables tls connection to the `pmSock`"
25
+ },
26
+ "pmSock": {
27
+ "aliases": [
28
+ "pm-sock"
29
+ ],
30
+ "needsValue": true,
31
+ "doc": "path to the unix socket or destination in the form host:port"
32
+ },
33
+ "help": {
34
+ "doc": "displays this help message"
35
+ },
36
+ "keepAttached": {
37
+ "aliases": [
38
+ "keep-attached"
39
+ ],
40
+ "needsValue": false,
41
+ "doc": "keeps the process attached to the current terminal"
42
+ },
43
+ "wait": {
44
+ "aliases": [
45
+ "w"
46
+ ],
47
+ "needsValue": false,
48
+ "doc": "waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"
49
+ },
50
+ "inspect": {
51
+ "needsValue": false,
52
+ "doc": "starts the process with --inspect-brk parameter to help debugging"
53
+ },
54
+ "new": {
55
+ "needsValue": false
56
+ },
57
+ "name": {
58
+ "doc": "name to assign to the process",
59
+ "needsValue": true
60
+ },
61
+ "program": {
62
+ "doc": "program to start"
63
+ }
64
+ },
65
+ "inject": [
66
+ "options.program",
67
+ "options.name",
68
+ "context",
69
+ "options.pmSock"
70
+ ]
71
+ }
72
+ }
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+ import sms from 'source-map-support'
3
+ sms.install();
4
+ import path from 'path'
5
+ import pmDef from '../container.js';
6
+ import { IpcAdapter } from "../ipc-adapter.js";
7
+ import { module as coreModule } from '@akala/core';
8
+ import { CliContext } from '@akala/cli';
9
+ import { Processors, ServeMetadata, Cli, registerCommands, SelfDefinedCommand, StructuredParameters, Container, serveMetadata, connectByPreference, Metadata, $metadata, protocolHandlers } from '@akala/commands';
10
+ import { pathToFileURL } from 'url';
11
+ import commands from '../container.js';
12
+ import fsHandler, { Stats } from '@akala/fs';
13
+
14
+
15
+ export default async function run(program: string, name: string, c: CliContext, pmSocket?: string)
16
+ {
17
+ let folderOrFile: Stats;
18
+ if (!URL.canParse(program))
19
+ program = pathToFileURL(program).toString();
20
+ const fs = await fsHandler.process(new URL('./', program));
21
+ folderOrFile = await fs.stat(program);
22
+ if (folderOrFile.isFile && path.extname(program) === '.js')
23
+ return import(program);
24
+
25
+ const cliContainer = new Container(name, {});
26
+
27
+ const result = await protocolHandlers.process(new URL(program), { signal: c.abort.signal, container: cliContainer }, {});
28
+ cliContainer.processor.useMiddleware(20, result.processor);
29
+ const metaContainer = await result.getMetadata();
30
+ registerCommands(metaContainer.commands, result.processor, cliContainer);
31
+
32
+ const isPm = name === 'pm' && program === new URL('../../../commands.json', import.meta.url).toString();
33
+ const init = cliContainer.resolve('$init');
34
+
35
+ process.on('unhandledRejection', (x) =>
36
+ {
37
+ c.abort.abort(x)
38
+ return false;
39
+ });
40
+ process.on('uncaughtException', (x) =>
41
+ {
42
+ c.abort.abort(x)
43
+ return false;
44
+ });
45
+ process.on('SIGINT', () => c.abort.abort(null));
46
+
47
+ let pm: Container<unknown> & pmDef.container;
48
+ let pmConnectInfo: ServeMetadata;
49
+
50
+ if (!isPm)
51
+ {
52
+ //eslint-disable-next-line @typescript-eslint/no-var-requires
53
+ const pmMeta = commands.meta;
54
+ if (process.connected)
55
+ {
56
+ pm = new Container('pm', null, new Processors.JsonRpc(Processors.JsonRpc.getConnection(new IpcAdapter(process), cliContainer))) as Container<unknown> & pmDef.container;
57
+ registerCommands(pmMeta.commands, null, pm);
58
+ }
59
+ else
60
+ {
61
+ if (pmSocket)
62
+ pmConnectInfo = { [pmSocket]: {} };
63
+ else
64
+ pmConnectInfo = serveMetadata({ args: ['local'], options: { socketName: 'pm' } })
65
+ const x = await connectByPreference(pmConnectInfo, { metadata: pmMeta, signal: c.abort.signal, container: cliContainer });
66
+ // controller.signal.addEventListener('abort', () => x.processor)
67
+ pm = x.container as Container<unknown> & pmDef.container;
68
+ pm.processor.useMiddleware(20, x.processor);
69
+ const connect = pm.resolve('connect');
70
+ pm.unregister('connect');
71
+ pm.register(new SelfDefinedCommand((name: string, param: StructuredParameters<unknown[]>) =>
72
+ {
73
+ if (name == 'pm')
74
+ return pmConnectInfo;
75
+ return x.processor.handle(pm, connect, param).then(e => { throw e }, r => r);
76
+ }, 'connect', [
77
+ "param.0",
78
+ "$param"
79
+ ]));
80
+ }
81
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
82
+ pm.unregister(Cli.Metadata.name);
83
+ pm.register(Metadata.extractCommandMetadata(Cli.Metadata));
84
+ }
85
+ else
86
+ pm = cliContainer as pmDef.container & Container<unknown>;
87
+
88
+ coreModule('@akala/pm').register('container', pm);
89
+
90
+ cliContainer.register(new SelfDefinedCommand(async (connectionId: string) =>
91
+ {
92
+ if (!pmConnectInfo)
93
+ pmConnectInfo = await pm.dispatch('connect', 'pm');
94
+ var pm2 = await connectByPreference(pmConnectInfo, { metadata: await cliContainer.dispatch('$metadata'), container: cliContainer });
95
+ pm2.container.processor.useMiddleware(20, pm2.processor);
96
+ pm2.container.unregister($metadata.name);
97
+ pm2.container.register($metadata);
98
+ pm2.container.register(Metadata.extractCommandMetadata(pm.resolve('bridge')));
99
+ if (!await pm2.container.dispatch('bridge', connectionId))
100
+ throw new Error('connection could not be established');
101
+ }, '$bridge', ['param.0']));
102
+
103
+ if (init)
104
+ {
105
+ c.options.configFile += '#' + name
106
+ await cliContainer.dispatch(init, { logger: c.logger, options: c.options, param: c.args, _trigger: 'cli', pm: pm, context: c, signal: c.abort.signal });
107
+ }
108
+ try
109
+ {
110
+ const serveArgs = await pm.dispatch('connect', c.options.name);
111
+ // console.log(serveArgs)
112
+ // serveArgs.signal = controller.signal;
113
+ if (!serveArgs && (!('socketName' in c.options) || !c.options.socketName))
114
+ c.options['socketName'] = c.options.name;
115
+ await cliContainer.dispatch('$serve', serveArgs || c, c.abort.signal);
116
+ }
117
+ catch (e)
118
+ {
119
+ if (!e || e.statusCode !== 404)
120
+ throw e;
121
+ console.warn(e.message);
122
+ }
123
+
124
+ if (pm !== cliContainer)
125
+ await pm.dispatch('ready')
126
+
127
+ return new Promise(resolve => c.abort.signal.addEventListener('abort', resolve))
128
+ }
@@ -7,7 +7,7 @@ export default async function start(this: State, name: string, context?: CliCont
7
7
  {
8
8
  const args = [...context.args, ...unparseOptions({
9
9
  ...context.options,
10
- configFile: context.options.configFile + '#pm',
10
+ configFile: context.options.configFile,
11
11
  name: 'pm',
12
12
  program: new URL('../../../commands.json', import.meta.url).toString(),
13
13
  inspect: undefined, new: undefined, wait: undefined
@@ -16,6 +16,7 @@ namespace cliCommands
16
16
  dispatch (cmd:'log', ...args: [Argument0<typeof import('./cli-commands/log.js').default>]): ReturnType<typeof import('./cli-commands/log.js').default>
17
17
  dispatch (cmd:'ls', ...args: []): ReturnType<typeof import('./cli-commands/ls.js').default>
18
18
  dispatch (cmd:'map', ...args: [Argument0<typeof import('./cli-commands/map.js').default>, Argument1<typeof import('./cli-commands/map.js').default>, Argument2<typeof import('./cli-commands/map.js').default>, Argument3<typeof import('./cli-commands/map.js').default>]): ReturnType<typeof import('./cli-commands/map.js').default>
19
+ dispatch (cmd:'run', ...args: [Argument0<typeof import('./cli-commands/run.js').default>, Argument1<typeof import('./cli-commands/run.js').default>]): ReturnType<typeof import('./cli-commands/run.js').default>
19
20
  dispatch (cmd:'start', ...args: [Argument0<typeof import('./cli-commands/start.js').default>, Argument1<typeof import('./cli-commands/start.js').default>]): ReturnType<typeof import('./cli-commands/start.js').default>
20
21
  dispatch (cmd:'uninstall', ...args: [Argument0<typeof import('./cli-commands/uninstall.js').default>]): ReturnType<typeof import('./cli-commands/uninstall.js').default>
21
22
  dispatch (cmd:'update', ...args: [Argument0<typeof import('./cli-commands/update.js').default>, Argument1<typeof import('./cli-commands/update.js').default>, Argument2<typeof import('./cli-commands/update.js').default>]): ReturnType<typeof import('./cli-commands/update.js').default>
@@ -31,12 +32,13 @@ namespace cliCommands
31
32
  'log'(...args: [Argument0<typeof import('./cli-commands/log.js').default>]): ReturnType<typeof import('./cli-commands/log.js').default>
32
33
  'ls'(...args: []): ReturnType<typeof import('./cli-commands/ls.js').default>
33
34
  'map'(...args: [Argument0<typeof import('./cli-commands/map.js').default>, Argument1<typeof import('./cli-commands/map.js').default>, Argument2<typeof import('./cli-commands/map.js').default>, Argument3<typeof import('./cli-commands/map.js').default>]): ReturnType<typeof import('./cli-commands/map.js').default>
35
+ 'run'(...args: [Argument0<typeof import('./cli-commands/run.js').default>, Argument1<typeof import('./cli-commands/run.js').default>]): ReturnType<typeof import('./cli-commands/run.js').default>
34
36
  'start'(...args: [Argument0<typeof import('./cli-commands/start.js').default>, Argument1<typeof import('./cli-commands/start.js').default>]): ReturnType<typeof import('./cli-commands/start.js').default>
35
37
  'uninstall'(...args: [Argument0<typeof import('./cli-commands/uninstall.js').default>]): ReturnType<typeof import('./cli-commands/uninstall.js').default>
36
38
  'update'(...args: [Argument0<typeof import('./cli-commands/update.js').default>, Argument1<typeof import('./cli-commands/update.js').default>, Argument2<typeof import('./cli-commands/update.js').default>]): ReturnType<typeof import('./cli-commands/update.js').default>
37
39
  'version'(...args: [Argument0<typeof import('./cli-commands/version.js').default>, Argument1<typeof import('./cli-commands/version.js').default>]): ReturnType<typeof import('./cli-commands/version.js').default>
38
40
  }
39
- export const meta={"name":"pm","commands":[{"name":"$init-akala","config":{"fs":{"path":"dist/esm/cli-commands/$init-akala.js","source":"src/cli-commands/$init-akala.ts","inject":["param.0"]},"cli":{"inject":["context"],"options":{"pmSock":{"aliases":["pm-sock"],"needsValue":true}}},"":{"inject":["param.0"]}}},{"name":"connect","config":{"fs":{"path":"dist/esm/cli-commands/connect.js","source":"src/cli-commands/connect.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"usage":"connect <name>","inject":["options.name","context"],"options":{"tcpPort":{"needsValue":true,"aliases":["tcp-port"]},"port":{"needsValue":true},"key":{"needsValue":true},"cert":{"needsValue":true}}}}},{"name":"discover","config":{"fs":{"path":"dist/esm/cli-commands/discover.js","source":"src/cli-commands/discover.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"usage":"discover <name> <folder>","options":{"folder":{"normalize":true}},"inject":["options.name","options.folder","$container"]}}},{"name":"install","config":{"fs":{"path":"dist/esm/cli-commands/install.js","source":"src/cli-commands/install.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"link","config":{"fs":{"path":"dist/esm/cli-commands/link.js","source":"src/cli-commands/link.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"inject":["param.0","param.1","$container"]}}},{"name":"log","config":{"fs":{"path":"dist/esm/cli-commands/log.js","source":"src/cli-commands/log.ts","inject":["param.0"]},"":{"inject":["param.0"]},"cli":{"inject":["param.0"]}}},{"name":"ls","config":{"fs":{"path":"dist/esm/cli-commands/ls.js","source":"src/cli-commands/ls.ts","inject":[]},"":{"inject":[]},"cli":{"inject":[]},"html-form":{"inject":[]}}},{"name":"map","config":{"fs":{"path":"dist/esm/cli-commands/map.js","source":"src/cli-commands/map.ts","inject":["param.0","param.1","param.2","param.3"]},"":{"inject":["param.0","param.1","param.2","param.3"]},"cli":{"inject":["options.name","options.path","cwd","options"],"options":{"commandable":{"aliases":["c"],"needsValue":false},"stateless":{"aliases":["s"],"needsValue":false}},"usage":"map <name> <path>"}}},{"name":"start","config":{"fs":{"path":"dist/esm/cli-commands/start.js","source":"src/cli-commands/start.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"options":{"output":{"aliases":["o"],"needsValue":true,"doc":"output as `table` if array otherwise falls back to standard node output"},"verbose":{"aliases":["v"]},"tls":{"doc":"enables tls connection to the `pmSock`"},"pmSock":{"aliases":["pm-sock"],"needsValue":true,"doc":"path to the unix socket or destination in the form host:port"},"help":{"doc":"displays this help message"},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["options.program","context"],"usage":"start pm"}}},{"name":"uninstall","config":{"fs":{"path":"dist/esm/cli-commands/uninstall.js","source":"src/cli-commands/uninstall.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"update","config":{"fs":{"path":"dist/esm/cli-commands/update.js","source":"src/cli-commands/update.ts","inject":["param.0","param.1","param.2"]},"cli":{"inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","param.2"]}}},{"name":"version","config":{"fs":{"path":"dist/esm/cli-commands/version.js","source":"src/cli-commands/version.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"inject":["options.packageName","options.folder"],"usage":"version <packageName> [folder]"},"schema":{"inject":["param.0","param.1"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"string"}}}}}],"$schema":"https://raw.githubusercontent.com/npenin/akala/main/packages/commands/container-schema.json"} as Metadata.Container;
41
+ export const meta={"name":"pm","commands":[{"name":"$init-akala","config":{"fs":{"path":"dist/esm/cli-commands/$init-akala.js","source":"src/cli-commands/$init-akala.ts","inject":["param.0"]},"cli":{"inject":["context"],"options":{"pmSock":{"aliases":["pm-sock"],"needsValue":true}}},"":{"inject":["param.0"]}}},{"name":"connect","config":{"fs":{"path":"dist/esm/cli-commands/connect.js","source":"src/cli-commands/connect.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"usage":"connect <name>","inject":["options.name","context"],"options":{"tcpPort":{"needsValue":true,"aliases":["tcp-port"]},"port":{"needsValue":true},"key":{"needsValue":true},"cert":{"needsValue":true}}}}},{"name":"discover","config":{"fs":{"path":"dist/esm/cli-commands/discover.js","source":"src/cli-commands/discover.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"usage":"discover <name> <folder>","options":{"folder":{"normalize":true}},"inject":["options.name","options.folder","$container"]}}},{"name":"install","config":{"fs":{"path":"dist/esm/cli-commands/install.js","source":"src/cli-commands/install.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"link","config":{"fs":{"path":"dist/esm/cli-commands/link.js","source":"src/cli-commands/link.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"inject":["param.0","param.1","$container"]}}},{"name":"log","config":{"fs":{"path":"dist/esm/cli-commands/log.js","source":"src/cli-commands/log.ts","inject":["param.0"]},"":{"inject":["param.0"]},"cli":{"inject":["param.0"]}}},{"name":"ls","config":{"fs":{"path":"dist/esm/cli-commands/ls.js","source":"src/cli-commands/ls.ts","inject":[]},"":{"inject":[]},"cli":{"inject":[]},"html-form":{"inject":[]}}},{"name":"map","config":{"fs":{"path":"dist/esm/cli-commands/map.js","source":"src/cli-commands/map.ts","inject":["param.0","param.1","param.2","param.3"]},"":{"inject":["param.0","param.1","param.2","param.3"]},"cli":{"inject":["options.name","options.path","cwd","options"],"options":{"commandable":{"aliases":["c"],"needsValue":false},"stateless":{"aliases":["s"],"needsValue":false}},"usage":"map <name> <path>"}}},{"name":"run","config":{"fs":{"path":"dist/esm/cli-commands/run.js","source":"src/cli-commands/run.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"options":{"output":{"aliases":["o"],"needsValue":true,"doc":"output as `table` if array otherwise falls back to standard node output"},"verbose":{"aliases":["v"]},"tls":{"doc":"enables tls connection to the `pmSock`"},"pmSock":{"aliases":["pm-sock"],"needsValue":true,"doc":"path to the unix socket or destination in the form host:port"},"help":{"doc":"displays this help message"},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["options.program","options.name","context","options.pmSock"]}}},{"name":"start","config":{"fs":{"path":"dist/esm/cli-commands/start.js","source":"src/cli-commands/start.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"options":{"output":{"aliases":["o"],"needsValue":true,"doc":"output as `table` if array otherwise falls back to standard node output"},"verbose":{"aliases":["v"]},"tls":{"doc":"enables tls connection to the `pmSock`"},"pmSock":{"aliases":["pm-sock"],"needsValue":true,"doc":"path to the unix socket or destination in the form host:port"},"help":{"doc":"displays this help message"},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["options.program","context"],"usage":"start pm"}}},{"name":"uninstall","config":{"fs":{"path":"dist/esm/cli-commands/uninstall.js","source":"src/cli-commands/uninstall.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"update","config":{"fs":{"path":"dist/esm/cli-commands/update.js","source":"src/cli-commands/update.ts","inject":["param.0","param.1","param.2"]},"cli":{"inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","param.2"]}}},{"name":"version","config":{"fs":{"path":"dist/esm/cli-commands/version.js","source":"src/cli-commands/version.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"inject":["options.packageName","options.folder"],"usage":"version <packageName> [folder]"},"schema":{"inject":["param.0","param.1"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"string"}}}}}],"$schema":"https://raw.githubusercontent.com/npenin/akala/main/packages/commands/container-schema.json"} as Metadata.Container;
40
42
 
41
43
  export function connect(processor?:ICommandProcessor) {
42
44
  const container = new Container<void>("cliCommands", void 0);
@@ -52,8 +52,8 @@ export default async function start(this: State, pm: pmContainer.container & Con
52
52
  if (!def && name != 'pm')
53
53
  throw new ErrorWithStatus(404, `No mapping was found for ${name}. Did you want to run \`pm install ${name}\` or maybe are you missing the folder to ${name} ?`)
54
54
 
55
- if (options.configFile)
56
- options.configFile += '#' + options.name
55
+ // if (options.configFile)
56
+ // options.configFile += '#' + options.name
57
57
 
58
58
  args.unshift(...(context?.args || []), ...unparseOptions({ ...options, program: undefined, new: undefined, inspect: undefined }, { ignoreUndefined: true }));
59
59
  if (def && def.get('path'))
package/src/container.ts CHANGED
@@ -25,6 +25,7 @@ namespace commands
25
25
  dispatch (cmd:'log', ...args: [Argument0<typeof import('./cli-commands/log.js').default>]): ReturnType<typeof import('./cli-commands/log.js').default>
26
26
  dispatch (cmd:'ls', ...args: []): ReturnType<typeof import('./cli-commands/ls.js').default>
27
27
  dispatch (cmd:'map', ...args: [Argument0<typeof import('./cli-commands/map.js').default>, Argument1<typeof import('./cli-commands/map.js').default>, Argument2<typeof import('./cli-commands/map.js').default>, Argument3<typeof import('./cli-commands/map.js').default>]): ReturnType<typeof import('./cli-commands/map.js').default>
28
+ dispatch (cmd:'run', ...args: [Argument0<typeof import('./cli-commands/run.js').default>, Argument1<typeof import('./cli-commands/run.js').default>]): ReturnType<typeof import('./cli-commands/run.js').default>
28
29
  dispatch (cmd:'uninstall', ...args: [Argument0<typeof import('./cli-commands/uninstall.js').default>]): ReturnType<typeof import('./cli-commands/uninstall.js').default>
29
30
  dispatch (cmd:'update', ...args: [Argument0<typeof import('./cli-commands/update.js').default>, Argument1<typeof import('./cli-commands/update.js').default>, Argument2<typeof import('./cli-commands/update.js').default>]): ReturnType<typeof import('./cli-commands/update.js').default>
30
31
  dispatch (cmd:'version', ...args: [Argument0<typeof import('./cli-commands/version.js').default>, Argument1<typeof import('./cli-commands/version.js').default>]): ReturnType<typeof import('./cli-commands/version.js').default>
@@ -48,11 +49,12 @@ namespace commands
48
49
  'log'(...args: [Argument0<typeof import('./cli-commands/log.js').default>]): ReturnType<typeof import('./cli-commands/log.js').default>
49
50
  'ls'(...args: []): ReturnType<typeof import('./cli-commands/ls.js').default>
50
51
  'map'(...args: [Argument0<typeof import('./cli-commands/map.js').default>, Argument1<typeof import('./cli-commands/map.js').default>, Argument2<typeof import('./cli-commands/map.js').default>, Argument3<typeof import('./cli-commands/map.js').default>]): ReturnType<typeof import('./cli-commands/map.js').default>
52
+ 'run'(...args: [Argument0<typeof import('./cli-commands/run.js').default>, Argument1<typeof import('./cli-commands/run.js').default>]): ReturnType<typeof import('./cli-commands/run.js').default>
51
53
  'uninstall'(...args: [Argument0<typeof import('./cli-commands/uninstall.js').default>]): ReturnType<typeof import('./cli-commands/uninstall.js').default>
52
54
  'update'(...args: [Argument0<typeof import('./cli-commands/update.js').default>, Argument1<typeof import('./cli-commands/update.js').default>, Argument2<typeof import('./cli-commands/update.js').default>]): ReturnType<typeof import('./cli-commands/update.js').default>
53
55
  'version'(...args: [Argument0<typeof import('./cli-commands/version.js').default>, Argument1<typeof import('./cli-commands/version.js').default>]): ReturnType<typeof import('./cli-commands/version.js').default>
54
56
  }
55
- export const meta={"name":"pm","commands":[{"name":"$init","config":{"fs":{"disabled":true,"path":"dist/esm/commands/$init.js","source":"src/commands/$init.ts","inject":["$container","param.0"]},"":{"inject":["$container","param.0"]},"cli":{"inject":["$container","context"],"usage":"$init [...args]","options":{"configFile":{"needsValue":true,"aliases":["c"]},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"}}}}},{"name":"bridge","config":{"fs":{"path":"dist/esm/commands/bridge.js","source":"src/commands/bridge.ts","inject":["param.0","param.1"]},"jsonrpc":{"inject":["param.0","socket"]},"":{"inject":["param.0","param.1"]}}},{"name":"name","config":{"fs":{"path":"dist/esm/commands/name.js","source":"src/commands/name.ts","inject":["param.0"]},"":{"inject":["param.0"]}}},{"name":"proxy","config":{"fs":{"path":"dist/esm/commands/proxy.js","source":"src/commands/proxy.ts","inject":["param.0","param.1"]},"jsonrpc":{"inject":["param.0","socket"]},"":{"inject":["param.0","param.1"]}}},{"name":"ready","config":{"fs":{"path":"dist/esm/commands/ready.js","source":"src/commands/ready.ts","inject":["$container","ignore"]},"jsonrpc":{"inject":["$container","dummy","connectionAsContainer"]},"":{"inject":["$container","connectionAsContainer"]}}},{"name":"reload-metadata","config":{"fs":{"inject":["param.0"],"path":"dist/esm/commands/reload-metadata.js","source":"src/commands/reload-metadata.ts"},"jsonrpc":{"inject":["connectionAsContainer"]},"":{"inject":["param.0"]}}},{"name":"restart","config":{"fs":{"path":"dist/esm/commands/restart.js","source":"src/commands/restart.ts","inject":["$container","param.0","param.1"]},"":{"inject":["$container","param.0","param.1"]},"cli":{"options":{"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["$container","param.0","context"],"usage":"restart <program>"},"schema":{"inject":["$container","param.0","param.1"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"object","properties":{"wait":{"type":"boolean"}}}}},"html-form":{"inject":["$container","param.0","param.1"]}}},{"name":"start","config":{"fs":{"path":"dist/esm/commands/start.js","source":"src/commands/start.ts","inject":["$container","param.0","param.1","param.2"]},"":{"inject":["$container","param.0","param.1","param.2"]},"cli":{"options":{"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"},"autostart":{"doc":"start automatically when pm starts"}},"inject":["$container","options.program","options","context"],"usage":"start <program>"},"html-form":{"inject":["$container","param.0","param.1","param.2"]},"schema":{"inject":["$container","param.0","param.1","param.2"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"object","properties":{"wait":{"type":"boolean"},"inspect":{"type":"boolean"},"new":{"type":"boolean"},"name":{"type":"string"},"program":{"type":"string"}}},"param.2":{"type":"object","properties":{"args":{"type":"array","items":{"type":"string"}}}}}}}},{"name":"status","config":{"fs":{"path":"dist/esm/commands/status.js","source":"src/commands/status.ts","inject":["param.0"]},"":{"inject":["param.0"]},"cli":{"inject":["param.0"]},"html-form":{"inject":["param.0"]},"schema":{"inject":["param.0"],"$defs":{"param.0":{"type":"string","description":"The name of the container to get the status of"}}}}},{"name":"stop","config":{"fs":{"path":"dist/esm/commands/stop.js","source":"src/commands/stop.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["options.process","$container"],"options":{"process":{"doc":"process to stop. Stops all the processes otherwise (including pm)."}},"usage":"stop [process]"},"html-form":{"inject":["param.0","$container"]},"schema":{"inject":["param.0","$container"],"$defs":{"param.0":{"type":"string"}}}}},{"name":"$init-akala","config":{"fs":{"path":"dist/esm/cli-commands/$init-akala.js","source":"src/cli-commands/$init-akala.ts","inject":["param.0"]},"cli":{"inject":["context"],"options":{"pmSock":{"aliases":["pm-sock"],"needsValue":true}}},"":{"inject":["param.0"]}}},{"name":"connect","config":{"fs":{"path":"dist/esm/cli-commands/connect.js","source":"src/cli-commands/connect.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"usage":"connect <name>","inject":["options.name","context"],"options":{"tcpPort":{"needsValue":true,"aliases":["tcp-port"]},"port":{"needsValue":true},"key":{"needsValue":true},"cert":{"needsValue":true}}}}},{"name":"discover","config":{"fs":{"path":"dist/esm/cli-commands/discover.js","source":"src/cli-commands/discover.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"usage":"discover <name> <folder>","options":{"folder":{"normalize":true}},"inject":["options.name","options.folder","$container"]}}},{"name":"install","config":{"fs":{"path":"dist/esm/cli-commands/install.js","source":"src/cli-commands/install.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"link","config":{"fs":{"path":"dist/esm/cli-commands/link.js","source":"src/cli-commands/link.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"inject":["param.0","param.1","$container"]}}},{"name":"log","config":{"fs":{"path":"dist/esm/cli-commands/log.js","source":"src/cli-commands/log.ts","inject":["param.0"]},"":{"inject":["param.0"]},"cli":{"inject":["param.0"]}}},{"name":"ls","config":{"fs":{"path":"dist/esm/cli-commands/ls.js","source":"src/cli-commands/ls.ts","inject":[]},"":{"inject":[]},"cli":{"inject":[]},"html-form":{"inject":[]}}},{"name":"map","config":{"fs":{"path":"dist/esm/cli-commands/map.js","source":"src/cli-commands/map.ts","inject":["param.0","param.1","param.2","param.3"]},"":{"inject":["param.0","param.1","param.2","param.3"]},"cli":{"inject":["options.name","options.path","cwd","options"],"options":{"commandable":{"aliases":["c"],"needsValue":false},"stateless":{"aliases":["s"],"needsValue":false}},"usage":"map <name> <path>"}}},{"name":"uninstall","config":{"fs":{"path":"dist/esm/cli-commands/uninstall.js","source":"src/cli-commands/uninstall.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"update","config":{"fs":{"path":"dist/esm/cli-commands/update.js","source":"src/cli-commands/update.ts","inject":["param.0","param.1","param.2"]},"cli":{"inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","param.2"]}}},{"name":"version","config":{"fs":{"path":"dist/esm/cli-commands/version.js","source":"src/cli-commands/version.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"inject":["options.packageName","options.folder"],"usage":"version <packageName> [folder]"},"schema":{"inject":["param.0","param.1"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"string"}}}}}],"extends":["./cli-commands.json"],"$schema":"https://raw.githubusercontent.com/npenin/akala/main/packages/commands/container-schema.json"} as Metadata.Container;
57
+ export const meta={"name":"pm","commands":[{"name":"$init","config":{"fs":{"disabled":true,"path":"dist/esm/commands/$init.js","source":"src/commands/$init.ts","inject":["$container","param.0"]},"":{"inject":["$container","param.0"]},"cli":{"inject":["$container","context"],"usage":"$init [...args]","options":{"configFile":{"needsValue":true,"aliases":["c"]},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"}}}}},{"name":"bridge","config":{"fs":{"path":"dist/esm/commands/bridge.js","source":"src/commands/bridge.ts","inject":["param.0","param.1"]},"jsonrpc":{"inject":["param.0","socket"]},"":{"inject":["param.0","param.1"]}}},{"name":"name","config":{"fs":{"path":"dist/esm/commands/name.js","source":"src/commands/name.ts","inject":["param.0"]},"":{"inject":["param.0"]}}},{"name":"proxy","config":{"fs":{"path":"dist/esm/commands/proxy.js","source":"src/commands/proxy.ts","inject":["param.0","param.1"]},"jsonrpc":{"inject":["param.0","socket"]},"":{"inject":["param.0","param.1"]}}},{"name":"ready","config":{"fs":{"path":"dist/esm/commands/ready.js","source":"src/commands/ready.ts","inject":["$container","ignore"]},"jsonrpc":{"inject":["$container","dummy","connectionAsContainer"]},"":{"inject":["$container","connectionAsContainer"]}}},{"name":"reload-metadata","config":{"fs":{"inject":["param.0"],"path":"dist/esm/commands/reload-metadata.js","source":"src/commands/reload-metadata.ts"},"jsonrpc":{"inject":["connectionAsContainer"]},"":{"inject":["param.0"]}}},{"name":"restart","config":{"fs":{"path":"dist/esm/commands/restart.js","source":"src/commands/restart.ts","inject":["$container","param.0","param.1"]},"":{"inject":["$container","param.0","param.1"]},"cli":{"options":{"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["$container","param.0","context"],"usage":"restart <program>"},"schema":{"inject":["$container","param.0","param.1"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"object","properties":{"wait":{"type":"boolean"}}}}},"html-form":{"inject":["$container","param.0","param.1"]}}},{"name":"start","config":{"fs":{"path":"dist/esm/commands/start.js","source":"src/commands/start.ts","inject":["$container","param.0","param.1","param.2"]},"":{"inject":["$container","param.0","param.1","param.2"]},"cli":{"options":{"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"},"autostart":{"doc":"start automatically when pm starts"}},"inject":["$container","options.program","options","context"],"usage":"start <program>"},"html-form":{"inject":["$container","param.0","param.1","param.2"]},"schema":{"inject":["$container","param.0","param.1","param.2"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"object","properties":{"wait":{"type":"boolean"},"inspect":{"type":"boolean"},"new":{"type":"boolean"},"name":{"type":"string"},"program":{"type":"string"}}},"param.2":{"type":"object","properties":{"args":{"type":"array","items":{"type":"string"}}}}}}}},{"name":"status","config":{"fs":{"path":"dist/esm/commands/status.js","source":"src/commands/status.ts","inject":["param.0"]},"":{"inject":["param.0"]},"cli":{"inject":["param.0"]},"html-form":{"inject":["param.0"]},"schema":{"inject":["param.0"],"$defs":{"param.0":{"type":"string","description":"The name of the container to get the status of"}}}}},{"name":"stop","config":{"fs":{"path":"dist/esm/commands/stop.js","source":"src/commands/stop.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["options.process","$container"],"options":{"process":{"doc":"process to stop. Stops all the processes otherwise (including pm)."}},"usage":"stop [process]"},"html-form":{"inject":["param.0","$container"]},"schema":{"inject":["param.0","$container"],"$defs":{"param.0":{"type":"string"}}}}},{"name":"$init-akala","config":{"fs":{"path":"dist/esm/cli-commands/$init-akala.js","source":"src/cli-commands/$init-akala.ts","inject":["param.0"]},"cli":{"inject":["context"],"options":{"pmSock":{"aliases":["pm-sock"],"needsValue":true}}},"":{"inject":["param.0"]}}},{"name":"connect","config":{"fs":{"path":"dist/esm/cli-commands/connect.js","source":"src/cli-commands/connect.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"usage":"connect <name>","inject":["options.name","context"],"options":{"tcpPort":{"needsValue":true,"aliases":["tcp-port"]},"port":{"needsValue":true},"key":{"needsValue":true},"cert":{"needsValue":true}}}}},{"name":"discover","config":{"fs":{"path":"dist/esm/cli-commands/discover.js","source":"src/cli-commands/discover.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"usage":"discover <name> <folder>","options":{"folder":{"normalize":true}},"inject":["options.name","options.folder","$container"]}}},{"name":"install","config":{"fs":{"path":"dist/esm/cli-commands/install.js","source":"src/cli-commands/install.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"link","config":{"fs":{"path":"dist/esm/cli-commands/link.js","source":"src/cli-commands/link.ts","inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","$container"]},"cli":{"inject":["param.0","param.1","$container"]}}},{"name":"log","config":{"fs":{"path":"dist/esm/cli-commands/log.js","source":"src/cli-commands/log.ts","inject":["param.0"]},"":{"inject":["param.0"]},"cli":{"inject":["param.0"]}}},{"name":"ls","config":{"fs":{"path":"dist/esm/cli-commands/ls.js","source":"src/cli-commands/ls.ts","inject":[]},"":{"inject":[]},"cli":{"inject":[]},"html-form":{"inject":[]}}},{"name":"map","config":{"fs":{"path":"dist/esm/cli-commands/map.js","source":"src/cli-commands/map.ts","inject":["param.0","param.1","param.2","param.3"]},"":{"inject":["param.0","param.1","param.2","param.3"]},"cli":{"inject":["options.name","options.path","cwd","options"],"options":{"commandable":{"aliases":["c"],"needsValue":false},"stateless":{"aliases":["s"],"needsValue":false}},"usage":"map <name> <path>"}}},{"name":"run","config":{"fs":{"path":"dist/esm/cli-commands/run.js","source":"src/cli-commands/run.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"options":{"output":{"aliases":["o"],"needsValue":true,"doc":"output as `table` if array otherwise falls back to standard node output"},"verbose":{"aliases":["v"]},"tls":{"doc":"enables tls connection to the `pmSock`"},"pmSock":{"aliases":["pm-sock"],"needsValue":true,"doc":"path to the unix socket or destination in the form host:port"},"help":{"doc":"displays this help message"},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["options.program","options.name","context","options.pmSock"]}}},{"name":"uninstall","config":{"fs":{"path":"dist/esm/cli-commands/uninstall.js","source":"src/cli-commands/uninstall.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"update","config":{"fs":{"path":"dist/esm/cli-commands/update.js","source":"src/cli-commands/update.ts","inject":["param.0","param.1","param.2"]},"cli":{"inject":["param.0","param.1","$container"]},"":{"inject":["param.0","param.1","param.2"]}}},{"name":"version","config":{"fs":{"path":"dist/esm/cli-commands/version.js","source":"src/cli-commands/version.ts","inject":["param.0","param.1"]},"":{"inject":["param.0","param.1"]},"cli":{"inject":["options.packageName","options.folder"],"usage":"version <packageName> [folder]"},"schema":{"inject":["param.0","param.1"],"$defs":{"param.0":{"type":"string"},"param.1":{"type":"string"}}}}}],"extends":["./cli-commands.json"],"$schema":"https://raw.githubusercontent.com/npenin/akala/main/packages/commands/container-schema.json"} as Metadata.Container;
56
58
 
57
59
  export function connect(processor?:ICommandProcessor) {
58
60
  const container = new Container<void>("commands", void 0);