@akala/pm 5.0.1 → 5.1.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/dist/cli-helper.d.ts +1 -1
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/$init.d.ts +2 -2
- package/dist/commands/bridge.d.ts +1 -1
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/connect.d.ts +1 -1
- package/dist/commands/discover.d.ts +3 -3
- package/dist/commands/install.d.ts +2 -2
- package/dist/commands/install.js +5 -5
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/link.d.ts +2 -2
- package/dist/commands/link.js +5 -5
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/log.d.ts +2 -2
- package/dist/commands/ls.d.ts +1 -1
- package/dist/commands/map.d.ts +1 -1
- package/dist/commands/plugin/add.d.ts +1 -1
- package/dist/commands/plugin/remove.d.ts +1 -1
- package/dist/commands/proxy.d.ts +1 -1
- package/dist/commands/ready.d.ts +2 -2
- package/dist/commands/restart.d.ts +2 -2
- package/dist/commands/start.d.ts +3 -3
- package/dist/commands/start.js +4 -4
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/stop.d.ts +1 -1
- package/dist/commands/update.d.ts +1 -1
- package/dist/commands/update.js +5 -5
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/version.d.ts +1 -1
- package/dist/container.d.ts +40 -40
- package/dist/fork.js +8 -5
- package/dist/fork.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/ipc-adapter.d.ts +2 -2
- package/dist/new-line-prefixer.d.ts +2 -2
- package/dist/npm-helper.js +4 -4
- package/dist/npm-helper.js.map +1 -1
- package/dist/sidecar.d.ts +2 -2
- package/dist/sidecar.js +4 -4
- package/dist/sidecar.js.map +1 -1
- package/dist/standalone.d.ts +2 -0
- package/dist/standalone.js +108 -0
- package/dist/standalone.js.map +1 -0
- package/dist/state.d.ts +1 -1
- package/dist/test/pwet.js +2 -2
- package/dist/test/pwet.js.map +1 -1
- package/dist/yarn-helper.js +4 -4
- package/dist/yarn-helper.js.map +1 -1
- package/package.json +7 -6
- package/src/cli.ts +4 -4
- package/src/commands/$init.ts +2 -2
- package/src/commands/bridge.ts +1 -1
- package/src/commands/config.ts +1 -1
- package/src/commands/connect.ts +1 -1
- package/src/commands/discover.ts +3 -3
- package/src/commands/install.ts +4 -4
- package/src/commands/link.ts +4 -4
- package/src/commands/log.ts +1 -1
- package/src/commands/ls.ts +1 -1
- package/src/commands/map.ts +1 -1
- package/src/commands/plugin/add.ts +1 -1
- package/src/commands/plugin/remove.ts +1 -1
- package/src/commands/proxy.ts +1 -1
- package/src/commands/ready.ts +2 -2
- package/src/commands/restart.ts +1 -1
- package/src/commands/start.ts +4 -4
- package/src/commands/status.ts +1 -1
- package/src/commands/stop.ts +1 -1
- package/src/commands/update.ts +3 -3
- package/src/commands/version.ts +1 -1
- package/src/container.ts +41 -41
- package/src/fork.ts +8 -4
- package/src/index.ts +4 -4
- package/src/npm-helper.ts +1 -1
- package/src/sidecar.ts +2 -2
- package/src/standalone.ts +106 -0
- package/src/test/pwet.ts +1 -1
- package/src/yarn-helper.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/commands/stop.ts
CHANGED
package/src/commands/update.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import State from '../state';
|
2
|
-
import npmHelper from '../npm-helper';
|
1
|
+
import State from '../state.js';
|
2
|
+
import npmHelper from '../npm-helper.js';
|
3
3
|
import { Container } from "@akala/commands";
|
4
|
-
import yarnHelper, { hasYarn } from '../yarn-helper';
|
4
|
+
import yarnHelper, { hasYarn } from '../yarn-helper.js';
|
5
5
|
|
6
6
|
export default async function update(this: State, packageName: string, folder: string, pm: Container<State>): Promise<string>
|
7
7
|
{
|
package/src/commands/version.ts
CHANGED
package/src/container.ts
CHANGED
@@ -1,53 +1,53 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2
|
-
import {Arguments, Argument0, Argument1, Argument2, Argument3, Argument4, Argument5, Argument6, Argument7, Argument8, Argument9, Argument10, Argument11, Argument12, Argument13, Argument14, Argument15, Argument16, Argument17 } from '@akala/core';
|
2
|
+
import { Arguments, Argument0, Argument1, Argument2, Argument3, Argument4, Argument5, Argument6, Argument7, Argument8, Argument9, Argument10, Argument11, Argument12, Argument13, Argument14, Argument15, Argument16, Argument17 } from '@akala/core';
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
4
4
|
namespace commands
|
5
5
|
{
|
6
6
|
export interface container
|
7
7
|
{
|
8
|
-
dispatch
|
9
|
-
dispatch
|
10
|
-
dispatch
|
11
|
-
dispatch
|
12
|
-
dispatch
|
13
|
-
dispatch
|
14
|
-
dispatch
|
15
|
-
dispatch
|
16
|
-
dispatch
|
17
|
-
dispatch
|
18
|
-
dispatch
|
19
|
-
dispatch
|
20
|
-
dispatch
|
21
|
-
dispatch
|
22
|
-
dispatch
|
23
|
-
dispatch
|
24
|
-
dispatch
|
25
|
-
dispatch
|
26
|
-
dispatch
|
27
|
-
dispatch
|
8
|
+
dispatch(cmd: '$init', ...args: [Argument1<typeof import('./commands/$init.js').default>]): ReturnType<typeof import('./commands/$init.js').default>
|
9
|
+
dispatch(cmd: 'bridge', ...args: [Argument0<typeof import('./commands/bridge.js').default>, Argument1<typeof import('./commands/bridge.js').default>]): ReturnType<typeof import('./commands/bridge.js').default>
|
10
|
+
dispatch(cmd: 'config', ...args: [Argument0<typeof import('./commands/config.js').default>, Argument1<typeof import('./commands/config.js').default>]): ReturnType<typeof import('./commands/config.js').default>
|
11
|
+
dispatch(cmd: 'connect', ...args: [Argument0<typeof import('./commands/connect.js').default>, Argument1<typeof import('./commands/connect.js').default>]): ReturnType<typeof import('./commands/connect.js').default>
|
12
|
+
dispatch(cmd: 'discover', ...args: [Argument0<typeof import('./commands/discover.js').default>, Argument1<typeof import('./commands/discover.js').default>]): ReturnType<typeof import('./commands/discover.js').default>
|
13
|
+
dispatch(cmd: 'install', ...args: [Argument0<typeof import('./commands/install.js').default>]): ReturnType<typeof import('./commands/install.js').default>
|
14
|
+
dispatch(cmd: 'link', ...args: [Argument0<typeof import('./commands/link.js').default>, Argument1<typeof import('./commands/link.js').default>]): ReturnType<typeof import('./commands/link.js').default>
|
15
|
+
dispatch(cmd: 'log', ...args: [Argument0<typeof import('./commands/log.js').default>]): ReturnType<typeof import('./commands/log.js').default>
|
16
|
+
dispatch(cmd: 'ls', ...args: []): ReturnType<typeof import('./commands/ls.js').default>
|
17
|
+
dispatch(cmd: 'map', ...args: [Argument0<typeof import('./commands/map.js').default>, Argument1<typeof import('./commands/map.js').default>, Argument2<typeof import('./commands/map.js').default>, Argument3<typeof import('./commands/map.js').default>]): ReturnType<typeof import('./commands/map.js').default>
|
18
|
+
dispatch(cmd: 'name', ...args: [Argument0<typeof import('./commands/name.js').default>]): ReturnType<typeof import('./commands/name.js').default>
|
19
|
+
dispatch(cmd: 'proxy', ...args: [Argument0<typeof import('./commands/proxy.js').default>, Argument1<typeof import('./commands/proxy.js').default>]): ReturnType<typeof import('./commands/proxy.js').default>
|
20
|
+
dispatch(cmd: 'ready', ...args: []): ReturnType<typeof import('./commands/ready.js').default>
|
21
|
+
dispatch(cmd: 'reload-metadata', ...args: [Argument0<typeof import('./commands/reload-metadata.js').default>]): ReturnType<typeof import('./commands/reload-metadata.js').default>
|
22
|
+
dispatch(cmd: 'restart', ...args: [Argument1<typeof import('./commands/restart.js').default>, Argument2<typeof import('./commands/restart.js').default>]): ReturnType<typeof import('./commands/restart.js').default>
|
23
|
+
dispatch(cmd: 'start', ...args: [Argument1<typeof import('./commands/start.js').default>, Argument2<typeof import('./commands/start.js').default>]): ReturnType<typeof import('./commands/start.js').default>
|
24
|
+
dispatch(cmd: 'status', ...args: [Argument0<typeof import('./commands/status.js').default>]): ReturnType<typeof import('./commands/status.js').default>
|
25
|
+
dispatch(cmd: 'stop', ...args: [Argument0<typeof import('./commands/stop.js').default>]): ReturnType<typeof import('./commands/stop.js').default>
|
26
|
+
dispatch(cmd: 'update', ...args: [Argument0<typeof import('./commands/update.js').default>, Argument1<typeof import('./commands/update.js').default>]): ReturnType<typeof import('./commands/update.js').default>
|
27
|
+
dispatch(cmd: 'version', ...args: [Argument0<typeof import('./commands/version.js').default>, Argument1<typeof import('./commands/version.js').default>]): ReturnType<typeof import('./commands/version.js').default>
|
28
28
|
}
|
29
29
|
export interface proxy
|
30
30
|
{
|
31
|
-
'$init'(...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>
|
32
|
-
'bridge'(...args: [Argument0<typeof import('./commands/bridge').default>, Argument1<typeof import('./commands/bridge').default>]): ReturnType<typeof import('./commands/bridge').default>
|
33
|
-
'config'(...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
|
34
|
-
'connect'(...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
|
35
|
-
'discover'(...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>
|
36
|
-
'install'(...args: [Argument0<typeof import('./commands/install').default>]): ReturnType<typeof import('./commands/install').default>
|
37
|
-
'link'(...args: [Argument0<typeof import('./commands/link').default>, Argument1<typeof import('./commands/link').default>]): ReturnType<typeof import('./commands/link').default>
|
38
|
-
'log'(...args: [Argument0<typeof import('./commands/log').default>]): ReturnType<typeof import('./commands/log').default>
|
39
|
-
'ls'(...args: []): ReturnType<typeof import('./commands/ls').default>
|
40
|
-
'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>
|
41
|
-
'name'(...args: [Argument0<typeof import('./commands/name').default>]): ReturnType<typeof import('./commands/name').default>
|
42
|
-
'proxy'(...args: [Argument0<typeof import('./commands/proxy').default>, Argument1<typeof import('./commands/proxy').default>]): ReturnType<typeof import('./commands/proxy').default>
|
43
|
-
'ready'(...args: []): ReturnType<typeof import('./commands/ready').default>
|
44
|
-
'reload-metadata'(...args: [Argument0<typeof import('./commands/reload-metadata').default>]): ReturnType<typeof import('./commands/reload-metadata').default>
|
45
|
-
'restart'(...args: [Argument1<typeof import('./commands/restart').default>, Argument2<typeof import('./commands/restart').default>]): ReturnType<typeof import('./commands/restart').default>
|
46
|
-
'start'(...args: [Argument1<typeof import('./commands/start').default>, Argument2<typeof import('./commands/start').default>]): ReturnType<typeof import('./commands/start').default>
|
47
|
-
'status'(...args: [Argument0<typeof import('./commands/status').default>]): ReturnType<typeof import('./commands/status').default>
|
48
|
-
'stop'(...args: [Argument0<typeof import('./commands/stop').default>]): ReturnType<typeof import('./commands/stop').default>
|
49
|
-
'update'(...args: [Argument0<typeof import('./commands/update').default>, Argument1<typeof import('./commands/update').default>]): ReturnType<typeof import('./commands/update').default>
|
50
|
-
'version'(...args: [Argument0<typeof import('./commands/version').default>, Argument1<typeof import('./commands/version').default>]): ReturnType<typeof import('./commands/version').default>
|
31
|
+
'$init'(...args: [Argument1<typeof import('./commands/$init.js').default>]): ReturnType<typeof import('./commands/$init.js').default>
|
32
|
+
'bridge'(...args: [Argument0<typeof import('./commands/bridge.js').default>, Argument1<typeof import('./commands/bridge.js').default>]): ReturnType<typeof import('./commands/bridge.js').default>
|
33
|
+
'config'(...args: [Argument0<typeof import('./commands/config.js').default>, Argument1<typeof import('./commands/config.js').default>]): ReturnType<typeof import('./commands/config.js').default>
|
34
|
+
'connect'(...args: [Argument0<typeof import('./commands/connect.js').default>, Argument1<typeof import('./commands/connect.js').default>]): ReturnType<typeof import('./commands/connect.js').default>
|
35
|
+
'discover'(...args: [Argument0<typeof import('./commands/discover.js').default>, Argument1<typeof import('./commands/discover.js').default>]): ReturnType<typeof import('./commands/discover.js').default>
|
36
|
+
'install'(...args: [Argument0<typeof import('./commands/install.js').default>]): ReturnType<typeof import('./commands/install.js').default>
|
37
|
+
'link'(...args: [Argument0<typeof import('./commands/link.js').default>, Argument1<typeof import('./commands/link.js').default>]): ReturnType<typeof import('./commands/link.js').default>
|
38
|
+
'log'(...args: [Argument0<typeof import('./commands/log.js').default>]): ReturnType<typeof import('./commands/log.js').default>
|
39
|
+
'ls'(...args: []): ReturnType<typeof import('./commands/ls.js').default>
|
40
|
+
'map'(...args: [Argument0<typeof import('./commands/map.js').default>, Argument1<typeof import('./commands/map.js').default>, Argument2<typeof import('./commands/map.js').default>, Argument3<typeof import('./commands/map.js').default>]): ReturnType<typeof import('./commands/map.js').default>
|
41
|
+
'name'(...args: [Argument0<typeof import('./commands/name.js').default>]): ReturnType<typeof import('./commands/name.js').default>
|
42
|
+
'proxy'(...args: [Argument0<typeof import('./commands/proxy.js').default>, Argument1<typeof import('./commands/proxy.js').default>]): ReturnType<typeof import('./commands/proxy.js').default>
|
43
|
+
'ready'(...args: []): ReturnType<typeof import('./commands/ready.js').default>
|
44
|
+
'reload-metadata'(...args: [Argument0<typeof import('./commands/reload-metadata.js').default>]): ReturnType<typeof import('./commands/reload-metadata.js').default>
|
45
|
+
'restart'(...args: [Argument1<typeof import('./commands/restart.js').default>, Argument2<typeof import('./commands/restart.js').default>]): ReturnType<typeof import('./commands/restart.js').default>
|
46
|
+
'start'(...args: [Argument1<typeof import('./commands/start.js').default>, Argument2<typeof import('./commands/start.js').default>]): ReturnType<typeof import('./commands/start.js').default>
|
47
|
+
'status'(...args: [Argument0<typeof import('./commands/status.js').default>]): ReturnType<typeof import('./commands/status.js').default>
|
48
|
+
'stop'(...args: [Argument0<typeof import('./commands/stop.js').default>]): ReturnType<typeof import('./commands/stop.js').default>
|
49
|
+
'update'(...args: [Argument0<typeof import('./commands/update.js').default>, Argument1<typeof import('./commands/update.js').default>]): ReturnType<typeof import('./commands/update.js').default>
|
50
|
+
'version'(...args: [Argument0<typeof import('./commands/version.js').default>, Argument1<typeof import('./commands/version.js').default>]): ReturnType<typeof import('./commands/version.js').default>
|
51
51
|
}
|
52
52
|
}
|
53
53
|
|
package/src/fork.ts
CHANGED
@@ -4,8 +4,8 @@ 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 pmDef from './container';
|
8
|
-
import { IpcAdapter } from "./ipc-adapter";
|
7
|
+
import pmDef from './container.js';
|
8
|
+
import { IpcAdapter } from "./ipc-adapter.js";
|
9
9
|
import { logger, Logger, MiddlewareComposite, module as coreModule } from '@akala/core';
|
10
10
|
import program, { buildCliContextFromProcess, ErrorMessage, NamespaceMiddleware } from '@akala/cli';
|
11
11
|
import { Stats } from 'fs';
|
@@ -30,7 +30,7 @@ logMiddleware.preAction(async c =>
|
|
30
30
|
|
31
31
|
await ac.Processors.FileSystem.discoverCommands(c.options.program, cliContainer, { processor: processor, isDirectory: folderOrFile.isDirectory() });
|
32
32
|
});
|
33
|
-
|
33
|
+
let initMiddleware = new NamespaceMiddleware<{ program: string, name: string, tls: boolean }>(null);
|
34
34
|
const controller = new AbortController();
|
35
35
|
|
36
36
|
program.option<string, 'program'>('program', { needsValue: true, normalize: true }).
|
@@ -70,7 +70,11 @@ program.option<string, 'program'>('program', { needsValue: true, normalize: true
|
|
70
70
|
isPm = c.options.name === 'pm' && c.options.program === require.resolve('../commands.json');
|
71
71
|
const init = cliContainer.resolve('$init');
|
72
72
|
if (init && init.config && init.config.cli && init.config.cli.options)
|
73
|
+
{
|
74
|
+
if (init.config.cli.usage)
|
75
|
+
initMiddleware = initMiddleware.command(init.config.cli.usage, init.config?.doc?.description)
|
73
76
|
ac.Triggers.addCliOptions(init, initMiddleware);
|
77
|
+
}
|
74
78
|
|
75
79
|
process.on('unhandledRejection', (x) =>
|
76
80
|
{
|
@@ -143,7 +147,7 @@ program.option<string, 'program'>('program', { needsValue: true, normalize: true
|
|
143
147
|
|
144
148
|
if (init)
|
145
149
|
{
|
146
|
-
await cliContainer.dispatch(init, { options: c.options, param: c.args, _trigger: 'cli', pm: pm, context: c });
|
150
|
+
await cliContainer.dispatch(init, { options: c.options, param: c.args, _trigger: 'cli', pm: pm, context: c, signal: controller.signal });
|
147
151
|
}
|
148
152
|
|
149
153
|
|
package/src/index.ts
CHANGED
@@ -2,12 +2,12 @@ import { Container, Metadata, NetSocketAdapter, Processors, registerCommands, Se
|
|
2
2
|
import { Socket } from "net";
|
3
3
|
import { module } from "@akala/core";
|
4
4
|
|
5
|
-
import definition from './container';
|
5
|
+
import definition from './container.js';
|
6
6
|
|
7
7
|
type pmContainer = definition.container
|
8
8
|
export { pmContainer as Container };
|
9
9
|
|
10
|
-
import State from './state'
|
10
|
+
import State from './state.js'
|
11
11
|
export { State }
|
12
12
|
|
13
13
|
export class InteractError extends Error
|
@@ -75,7 +75,7 @@ export interface SidecarMap
|
|
75
75
|
}
|
76
76
|
|
77
77
|
|
78
|
-
import getRandomName from './commands/name';
|
79
|
-
import sidecarSingleton, { sidecar } from "./sidecar";
|
78
|
+
import getRandomName from './commands/name.js';
|
79
|
+
import sidecarSingleton, { sidecar } from "./sidecar.js";
|
80
80
|
export { sidecar, sidecarSingleton };
|
81
81
|
export { getRandomName };
|
package/src/npm-helper.ts
CHANGED
package/src/sidecar.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { connectByPreference, ConnectionPreference, Container, updateCommands } from "@akala/commands";
|
2
|
-
import { SideCarConnectionPreference, Sidecar, defaultOrders, connect } from "./index";
|
2
|
+
import { SideCarConnectionPreference, Sidecar, defaultOrders, connect } from "./index.js";
|
3
3
|
import * as ac from '@akala/commands'
|
4
|
-
import pm from './container'
|
4
|
+
import pm from './container.js'
|
5
5
|
|
6
6
|
let instance: Sidecar;
|
7
7
|
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import sms from 'source-map-support'
|
3
|
+
sms.install();
|
4
|
+
import * as path from 'path'
|
5
|
+
import * as ac from '@akala/commands';
|
6
|
+
import { lstat } from 'fs/promises';
|
7
|
+
import { logger, Logger, MiddlewareComposite, module as coreModule } from '@akala/core';
|
8
|
+
import program, { buildCliContextFromProcess, ErrorMessage, NamespaceMiddleware } from '@akala/cli';
|
9
|
+
import { Stats } from 'fs';
|
10
|
+
|
11
|
+
program.option('help')
|
12
|
+
let folderOrFile: Stats;
|
13
|
+
let cliContainer: ac.Container<unknown>;
|
14
|
+
let processor: ac.CommandProcessor;
|
15
|
+
let log: Logger;
|
16
|
+
const logMiddleware = new NamespaceMiddleware<{ program: string, name: string, tls: boolean }>(null).option<string, 'verbose'>('verbose', { aliases: ['v',] });
|
17
|
+
logMiddleware.preAction(async c =>
|
18
|
+
{
|
19
|
+
if (c.options.verbose)
|
20
|
+
processor = new ac.Processors.LogProcessor(processor, (cmd, params) =>
|
21
|
+
{
|
22
|
+
log.verbose({ cmd, params });
|
23
|
+
return Promise.resolve();
|
24
|
+
});
|
25
|
+
|
26
|
+
await ac.Processors.FileSystem.discoverCommands(c.options.program, cliContainer, { processor: processor, isDirectory: folderOrFile.isDirectory() });
|
27
|
+
});
|
28
|
+
const initMiddleware = new NamespaceMiddleware<{ program: string, name: string, tls: boolean }>(null);
|
29
|
+
const controller = new AbortController();
|
30
|
+
|
31
|
+
program.option<string, 'program'>('program', { needsValue: true, normalize: true }).
|
32
|
+
option<string, 'name'>('name', { needsValue: true }).
|
33
|
+
option<boolean, 'tls'>('tls', { needsValue: false }).
|
34
|
+
options<{
|
35
|
+
port?: number,
|
36
|
+
tcpPort?: string,
|
37
|
+
cert?: string,
|
38
|
+
key?: string,
|
39
|
+
}>({
|
40
|
+
port: { needsValue: true, doc: 'http/ws port\n(default: 80 if http, 443 is certificate and key are provided)', aliases: ['p'], optional: true, caseSensitive: false },
|
41
|
+
tcpPort: { needsValue: true, doc: 'tcp port', aliases: ['tcp-port'], optional: true, caseSensitive: false },
|
42
|
+
cert: { needsValue: true, doc: 'public certificate', aliases: ['certificate'], optional: true, caseSensitive: false },
|
43
|
+
key: { needsValue: true, doc: 'private certificate key. Requires public certificate', aliases: ['certificate-key'], optional: true, caseSensitive: false }
|
44
|
+
}).
|
45
|
+
preAction(async c => //If pure js file
|
46
|
+
{
|
47
|
+
folderOrFile = await lstat(c.options.program);
|
48
|
+
if (folderOrFile.isFile() && path.extname(c.options.program) === '.js')
|
49
|
+
return require(c.options.program);
|
50
|
+
|
51
|
+
log = logger(c.options.name);
|
52
|
+
|
53
|
+
cliContainer = new ac.Container('cli', {});
|
54
|
+
|
55
|
+
if (folderOrFile.isFile())
|
56
|
+
processor = new ac.Processors.FileSystem(path.dirname(c.options.program));
|
57
|
+
else
|
58
|
+
processor = new ac.Processors.FileSystem(c.options.program);
|
59
|
+
}).
|
60
|
+
useMiddleware(null, MiddlewareComposite.new(logMiddleware,
|
61
|
+
{
|
62
|
+
handle: async c =>
|
63
|
+
{
|
64
|
+
cliContainer.name = c.options.name;
|
65
|
+
const init = cliContainer.resolve('$init');
|
66
|
+
if (init && init.config && init.config.cli && init.config.cli.options)
|
67
|
+
ac.Triggers.addCliOptions(init, initMiddleware);
|
68
|
+
|
69
|
+
process.on('unhandledRejection', (x) =>
|
70
|
+
{
|
71
|
+
controller.abort(x)
|
72
|
+
return false;
|
73
|
+
});
|
74
|
+
process.on('uncaughtException', (x) =>
|
75
|
+
{
|
76
|
+
controller.abort(x)
|
77
|
+
return false;
|
78
|
+
});
|
79
|
+
process.on('SIGINT', () => controller.abort(null));
|
80
|
+
|
81
|
+
initMiddleware.action(async c =>
|
82
|
+
{
|
83
|
+
if (init)
|
84
|
+
await cliContainer.dispatch(init, { options: c.options, param: c.args, _trigger: 'cli', context: c });
|
85
|
+
});
|
86
|
+
}
|
87
|
+
},
|
88
|
+
initMiddleware));
|
89
|
+
|
90
|
+
controller.signal.addEventListener('abort', function ()
|
91
|
+
{
|
92
|
+
if (this.reason)
|
93
|
+
{
|
94
|
+
process.exitCode = 1;
|
95
|
+
if (this.reason instanceof ErrorMessage)
|
96
|
+
console.error(this.reason.message);
|
97
|
+
else
|
98
|
+
console.error(this.reason);
|
99
|
+
}
|
100
|
+
})
|
101
|
+
|
102
|
+
if (require.main == module)
|
103
|
+
program.process(buildCliContextFromProcess()).catch(e =>
|
104
|
+
{
|
105
|
+
setImmediate(() => controller.abort(e));
|
106
|
+
});
|
package/src/test/pwet.ts
CHANGED