@akala/pm 11.0.7 → 12.0.0
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 +11 -1
- package/cli-commands.json +42 -12
- package/commands.json +0 -56
- package/dist/esm/akala.d.mts +1 -1
- package/dist/esm/akala.mjs +5 -5
- package/dist/esm/akala.mjs.map +1 -1
- package/dist/esm/cli-commands/$init-akala.d.ts +11 -0
- package/dist/esm/cli-commands/$init-akala.js +27 -0
- package/dist/esm/cli-commands/$init-akala.js.map +1 -0
- package/dist/esm/cli-commands/connect.d.ts +2 -2
- package/dist/esm/cli-commands/connect.js.map +1 -1
- package/dist/esm/cli-commands/install.js +2 -0
- package/dist/esm/cli-commands/install.js.map +1 -1
- package/dist/esm/cli-commands/uninstall.d.ts +3 -0
- package/dist/esm/cli-commands/uninstall.js +18 -0
- package/dist/esm/cli-commands/uninstall.js.map +1 -0
- package/dist/esm/cli.js +2 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/$init.js +11 -0
- package/dist/esm/commands/$init.js.map +1 -1
- package/dist/esm/container.d.ts +4 -6
- package/dist/esm/container.js +1 -1
- package/dist/esm/container.js.map +1 -1
- package/dist/esm/npm-helper.d.ts +1 -0
- package/dist/esm/npm-helper.js +6 -3
- package/dist/esm/npm-helper.js.map +1 -1
- package/dist/esm/state.d.ts +5 -2
- package/dist/esm/yarn-helper.d.ts +1 -0
- package/dist/esm/yarn-helper.js +3 -0
- package/dist/esm/yarn-helper.js.map +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/akala.mts +5 -5
- package/src/cli-commands/$init-akala.json +16 -0
- package/src/cli-commands/$init-akala.ts +37 -0
- package/src/cli-commands/connect.json +2 -1
- package/src/cli-commands/connect.ts +3 -3
- package/src/cli-commands/install.ts +2 -0
- package/src/cli-commands/uninstall.json +15 -0
- package/src/cli-commands/uninstall.ts +26 -0
- package/src/cli.ts +2 -1
- package/src/commands/$init.ts +15 -0
- package/src/container.ts +5 -7
- package/src/npm-helper.ts +7 -3
- package/src/state.ts +3 -2
- package/src/yarn-helper.ts +4 -0
- package/dist/esm/cli-commands/config.d.ts +0 -3
- package/dist/esm/cli-commands/config.js +0 -20
- package/dist/esm/cli-commands/config.js.map +0 -1
- package/dist/esm/commands/plugin/add.d.ts +0 -2
- package/dist/esm/commands/plugin/add.js +0 -5
- package/dist/esm/commands/plugin/add.js.map +0 -1
- package/dist/esm/commands/plugin/remove.d.ts +0 -2
- package/dist/esm/commands/plugin/remove.js +0 -7
- package/dist/esm/commands/plugin/remove.js.map +0 -1
- package/src/cli-commands/config.json +0 -14
- package/src/cli-commands/config.ts +0 -29
- package/src/commands/plugin/add.json +0 -24
- package/src/commands/plugin/add.ts +0 -7
- package/src/commands/plugin/remove.json +0 -24
- package/src/commands/plugin/remove.ts +0 -9
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": "
|
7
|
+
"version": "12.0.0",
|
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": "^3.0.
|
33
|
-
"@akala/commands": "^
|
34
|
-
"@akala/config": "^5.0.
|
35
|
-
"@akala/core": "^19.0.
|
36
|
-
"@akala/json-rpc-ws": "^11.0.
|
32
|
+
"@akala/cli": "^3.0.11",
|
33
|
+
"@akala/commands": "^10.0.0",
|
34
|
+
"@akala/config": "^5.0.17",
|
35
|
+
"@akala/core": "^19.0.11",
|
36
|
+
"@akala/json-rpc-ws": "^11.0.11",
|
37
37
|
"reflect-metadata": "^0.2.2",
|
38
38
|
"source-map-support": "^0.5.21"
|
39
39
|
},
|
package/src/akala.mts
CHANGED
@@ -35,7 +35,7 @@ const tableChars = {
|
|
35
35
|
const truncate = '…';
|
36
36
|
|
37
37
|
type CliOptions = { output: string, verbose: boolean, pmSock: string | number, tls: boolean, help: boolean };
|
38
|
-
export default function (_config, program: NamespaceMiddleware<{ configFile: string, verbose: boolean }>)
|
38
|
+
export default async function (_config, program: NamespaceMiddleware<{ configFile: string, verbose: boolean }>)
|
39
39
|
{
|
40
40
|
const cli = program.command('pm').state<{ pm?: StateConfiguration }>().options<CliOptions>({
|
41
41
|
output: { aliases: ['o'], needsValue: true, doc: 'output as `table` if array otherwise falls back to standard node output' },
|
@@ -89,10 +89,10 @@ export default function (_config, program: NamespaceMiddleware<{ configFile: str
|
|
89
89
|
{
|
90
90
|
try
|
91
91
|
{
|
92
|
-
if (c.state?.pm)
|
93
|
-
|
94
|
-
else
|
95
|
-
|
92
|
+
// if (c.state?.pm)
|
93
|
+
// netsocket.connect(c.state.pm.mapping.pm.connect.socket[0]);
|
94
|
+
// else
|
95
|
+
netsocket.destroy(Object.assign(new Error(), { code: 'ENOENT' }))
|
96
96
|
}
|
97
97
|
catch (e)
|
98
98
|
{
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://raw.githubusercontent.com/npenin/akala/main/packages/commands/command-schema.json",
|
3
|
+
"cli": {
|
4
|
+
"inject": [
|
5
|
+
"options.pmSock"
|
6
|
+
],
|
7
|
+
"options": {
|
8
|
+
"pmSock": {
|
9
|
+
"aliases": [
|
10
|
+
"pm-sock"
|
11
|
+
],
|
12
|
+
"needsValue": true
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import program, { CliContext } from "@akala/cli";
|
2
|
+
import { StateConfiguration } from "../state.js";
|
3
|
+
import { connect, Container } from "@akala/commands";
|
4
|
+
import { platform } from "os";
|
5
|
+
import { Triggers } from "@akala/commands";
|
6
|
+
import { ProxyConfiguration } from "@akala/config";
|
7
|
+
import { ErrorWithStatus, HttpStatusCode } from "@akala/core";
|
8
|
+
|
9
|
+
type CliOptions = { pmSock: string | number, tls: boolean };
|
10
|
+
|
11
|
+
export default async function (c: CliContext<CliOptions, ProxyConfiguration<{ pm?: StateConfiguration }>>)
|
12
|
+
{
|
13
|
+
let container: Container<unknown>;
|
14
|
+
|
15
|
+
process.stdin.pause();
|
16
|
+
process.stdin.setEncoding('utf8');
|
17
|
+
|
18
|
+
if (typeof c.options.pmSock == 'string' && URL.canParse(c.options.pmSock))
|
19
|
+
container = await connect(c.options.pmSock)
|
20
|
+
else if (typeof c.options.pmSock == 'number')
|
21
|
+
container = await connect("tcp://localhost:" + c.options.pmSock);
|
22
|
+
else if (typeof c.options.pmSock == 'string')
|
23
|
+
container = await connect("tcp://" + c.options.pmSock);
|
24
|
+
else if (platform() == 'win32')
|
25
|
+
container = await connect('unix://\\\\?\\pipe\\pm')
|
26
|
+
else
|
27
|
+
{
|
28
|
+
const connectOptions = c.state?.pm?.mapping?.pm?.connect?.extract();
|
29
|
+
if (connectOptions)
|
30
|
+
container = await connect(Object.keys(connectOptions)[0]);
|
31
|
+
}
|
32
|
+
|
33
|
+
if (!container)
|
34
|
+
throw new ErrorWithStatus(HttpStatusCode.BadGateway, 'no connection option specified');
|
35
|
+
|
36
|
+
await container.attach(Triggers.cli, program.command('pm'));
|
37
|
+
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { ErrorWithStatus } from "@akala/core";
|
2
|
-
import { serveMetadata,
|
2
|
+
import { serveMetadata, ServeOptions } from "@akala/commands";
|
3
3
|
import State from '../state.js';
|
4
4
|
|
5
|
-
export default async function connect(this: State, name: string): Promise<
|
5
|
+
export default async function connect(this: State, name: string): Promise<Record<string, object>>
|
6
6
|
export default async function connect(this: State, name: string, context?: ServeOptions): Promise<void>
|
7
|
-
export default async function connect(this: State, name: string, context?: ServeOptions): Promise<
|
7
|
+
export default async function connect(this: State, name: string, context?: ServeOptions): Promise<Record<string, object> | void>
|
8
8
|
{
|
9
9
|
let mapping = this.config.mapping[name];
|
10
10
|
if (!mapping)
|
@@ -9,11 +9,13 @@ export default async function install(this: State, packageName: string, pm: Cont
|
|
9
9
|
if (process.versions['pnp'] || await hasYarn())
|
10
10
|
{
|
11
11
|
await yarnHelper.install(packageName);
|
12
|
+
this.config.setup.packages.push(packageName);
|
12
13
|
return await pm.dispatch('discover', packageName, !process.versions['pnp'] && 'node_modules' || undefined);
|
13
14
|
}
|
14
15
|
else
|
15
16
|
{
|
16
17
|
await npmHelper.install(packageName);
|
18
|
+
this.config.setup.packages.push(packageName);
|
17
19
|
return await pm.dispatch('discover', packageName, 'node_modules');
|
18
20
|
}
|
19
21
|
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import State from '../state.js';
|
2
|
+
import npmHelper from '../npm-helper.js';
|
3
|
+
import yarnHelper, { hasYarn } from '../yarn-helper.js';
|
4
|
+
import { Container } from "@akala/commands";
|
5
|
+
|
6
|
+
export default async function uninstall(this: State, packageName: string, pm: Container<State>): Promise<void>
|
7
|
+
{
|
8
|
+
|
9
|
+
const config = this.config.extract();
|
10
|
+
const containers = Object.entries(config.containers);
|
11
|
+
const removedContainers = containers.filter(e => !e[1].path.includes('node_modules/' + packageName));
|
12
|
+
config.containers = Object.fromEntries(containers.filter(e => !e[1].path.includes('node_modules/' + packageName)))
|
13
|
+
this.config.set('containers', config.containers);
|
14
|
+
|
15
|
+
const mappings = Object.entries(this.config.mapping.extract()).filter(e => !removedContainers.find(c => e[1].container == c[0]));
|
16
|
+
this.config.set('mapping', Object.entries(mappings));
|
17
|
+
|
18
|
+
this.config.setup.set('packages', this.config.setup.packages.filter(p => p != packageName))
|
19
|
+
|
20
|
+
if (process.versions['pnp'] || await hasYarn())
|
21
|
+
await yarnHelper.uninstall(packageName);
|
22
|
+
else
|
23
|
+
await npmHelper.uninstall(packageName);
|
24
|
+
|
25
|
+
await this.config.commit();
|
26
|
+
}
|
package/src/cli.ts
CHANGED
@@ -83,7 +83,8 @@ cli.preAction(async c =>
|
|
83
83
|
{
|
84
84
|
d.readFile({ encoding: 'utf-8' }).then(d => JSON.parse(d)).then((config: StateConfiguration) =>
|
85
85
|
{
|
86
|
-
|
86
|
+
const connectOptions = Object.keys(config.mapping.pm.connect)
|
87
|
+
netsocket.connect(connectOptions[0]);
|
87
88
|
}).finally(() => d.close());
|
88
89
|
}, e =>
|
89
90
|
{
|
package/src/commands/$init.ts
CHANGED
@@ -100,6 +100,7 @@ export default async function (this: State, container: RunningContainer & pmCont
|
|
100
100
|
{
|
101
101
|
this.config.set('containers', { pm: { commandable: true, stateless: false, path: fileURLToPath(new URL('../../../commands.json', import.meta.url)) } });
|
102
102
|
this.config.set('mapping', { pm: { cwd: process.cwd(), container: 'pm' } })
|
103
|
+
this.config.set('setup', { packages: [] })
|
103
104
|
this.config.set('plugins', [])
|
104
105
|
}
|
105
106
|
|
@@ -122,6 +123,20 @@ export default async function (this: State, container: RunningContainer & pmCont
|
|
122
123
|
container.unregister('$metadata');
|
123
124
|
container.register(configure(config)(new SelfDefinedCommand(metadata, '$metadata', ['$container', 'param.0'])));
|
124
125
|
|
126
|
+
if (this.config.setup.packages.length > 0)
|
127
|
+
{
|
128
|
+
for (const pkg of this.config.setup.packages)
|
129
|
+
{
|
130
|
+
await container.dispatch('install', pkg);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
if (this.config.setup.packages.length > 0)
|
134
|
+
{
|
135
|
+
for (const pkg of this.config.setup.packages)
|
136
|
+
{
|
137
|
+
await container.dispatch('install', pkg);
|
138
|
+
}
|
139
|
+
}
|
125
140
|
|
126
141
|
this.processes[container.name] = container;
|
127
142
|
container.running = true;
|
package/src/container.ts
CHANGED
@@ -10,8 +10,6 @@ namespace commands
|
|
10
10
|
{
|
11
11
|
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>
|
12
12
|
dispatch (cmd:'name', ...args: [Argument0<typeof import('./commands/name.js').default>]): ReturnType<typeof import('./commands/name.js').default>
|
13
|
-
dispatch (cmd:'plugin.add', ...args: [Argument0<typeof import('./commands/plugin/add.js').default>]): ReturnType<typeof import('./commands/plugin/add.js').default>
|
14
|
-
dispatch (cmd:'plugin.remove', ...args: [Argument0<typeof import('./commands/plugin/remove.js').default>]): ReturnType<typeof import('./commands/plugin/remove.js').default>
|
15
13
|
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>
|
16
14
|
dispatch (cmd:'ready', ...args: []): ReturnType<typeof import('./commands/ready.js').default>
|
17
15
|
dispatch (cmd:'reload-metadata', ...args: [Argument0<typeof import('./commands/reload-metadata.js').default>]): ReturnType<typeof import('./commands/reload-metadata.js').default>
|
@@ -19,7 +17,7 @@ namespace commands
|
|
19
17
|
dispatch (cmd:'start', ...args: [Argument1<typeof import('./commands/start.js').default>, Argument2<typeof import('./commands/start.js').default>, Argument3<typeof import('./commands/start.js').default>]): ReturnType<typeof import('./commands/start.js').default>
|
20
18
|
dispatch (cmd:'status', ...args: [Argument0<typeof import('./commands/status.js').default>]): ReturnType<typeof import('./commands/status.js').default>
|
21
19
|
dispatch (cmd:'stop', ...args: [Argument0<typeof import('./commands/stop.js').default>]): ReturnType<typeof import('./commands/stop.js').default>
|
22
|
-
dispatch (cmd:'
|
20
|
+
dispatch (cmd:'$init-akala', ...args: [Argument0<typeof import('./cli-commands/$init-akala.js').default>]): ReturnType<typeof import('./cli-commands/$init-akala.js').default>
|
23
21
|
dispatch (cmd:'connect', ...args: [Argument0<typeof import('./cli-commands/connect.js').default>, Argument1<typeof import('./cli-commands/connect.js').default>]): ReturnType<typeof import('./cli-commands/connect.js').default>
|
24
22
|
dispatch (cmd:'discover', ...args: [Argument0<typeof import('./cli-commands/discover.js').default>, Argument1<typeof import('./cli-commands/discover.js').default>]): ReturnType<typeof import('./cli-commands/discover.js').default>
|
25
23
|
dispatch (cmd:'install', ...args: [Argument0<typeof import('./cli-commands/install.js').default>]): ReturnType<typeof import('./cli-commands/install.js').default>
|
@@ -27,6 +25,7 @@ namespace commands
|
|
27
25
|
dispatch (cmd:'log', ...args: [Argument0<typeof import('./cli-commands/log.js').default>]): ReturnType<typeof import('./cli-commands/log.js').default>
|
28
26
|
dispatch (cmd:'ls', ...args: []): ReturnType<typeof import('./cli-commands/ls.js').default>
|
29
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:'uninstall', ...args: [Argument0<typeof import('./cli-commands/uninstall.js').default>]): ReturnType<typeof import('./cli-commands/uninstall.js').default>
|
30
29
|
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
30
|
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>
|
32
31
|
}
|
@@ -34,8 +33,6 @@ namespace commands
|
|
34
33
|
{
|
35
34
|
'bridge'(...args: [Argument0<typeof import('./commands/bridge.js').default>, Argument1<typeof import('./commands/bridge.js').default>]): ReturnType<typeof import('./commands/bridge.js').default>
|
36
35
|
'name'(...args: [Argument0<typeof import('./commands/name.js').default>]): ReturnType<typeof import('./commands/name.js').default>
|
37
|
-
'plugin.add'(...args: [Argument0<typeof import('./commands/plugin/add.js').default>]): ReturnType<typeof import('./commands/plugin/add.js').default>
|
38
|
-
'plugin.remove'(...args: [Argument0<typeof import('./commands/plugin/remove.js').default>]): ReturnType<typeof import('./commands/plugin/remove.js').default>
|
39
36
|
'proxy'(...args: [Argument0<typeof import('./commands/proxy.js').default>, Argument1<typeof import('./commands/proxy.js').default>]): ReturnType<typeof import('./commands/proxy.js').default>
|
40
37
|
'ready'(...args: []): ReturnType<typeof import('./commands/ready.js').default>
|
41
38
|
'reload-metadata'(...args: [Argument0<typeof import('./commands/reload-metadata.js').default>]): ReturnType<typeof import('./commands/reload-metadata.js').default>
|
@@ -43,7 +40,7 @@ namespace commands
|
|
43
40
|
'start'(...args: [Argument1<typeof import('./commands/start.js').default>, Argument2<typeof import('./commands/start.js').default>, Argument3<typeof import('./commands/start.js').default>]): ReturnType<typeof import('./commands/start.js').default>
|
44
41
|
'status'(...args: [Argument0<typeof import('./commands/status.js').default>]): ReturnType<typeof import('./commands/status.js').default>
|
45
42
|
'stop'(...args: [Argument0<typeof import('./commands/stop.js').default>]): ReturnType<typeof import('./commands/stop.js').default>
|
46
|
-
'
|
43
|
+
'$init-akala'(...args: [Argument0<typeof import('./cli-commands/$init-akala.js').default>]): ReturnType<typeof import('./cli-commands/$init-akala.js').default>
|
47
44
|
'connect'(...args: [Argument0<typeof import('./cli-commands/connect.js').default>, Argument1<typeof import('./cli-commands/connect.js').default>]): ReturnType<typeof import('./cli-commands/connect.js').default>
|
48
45
|
'discover'(...args: [Argument0<typeof import('./cli-commands/discover.js').default>, Argument1<typeof import('./cli-commands/discover.js').default>]): ReturnType<typeof import('./cli-commands/discover.js').default>
|
49
46
|
'install'(...args: [Argument0<typeof import('./cli-commands/install.js').default>]): ReturnType<typeof import('./cli-commands/install.js').default>
|
@@ -51,10 +48,11 @@ namespace commands
|
|
51
48
|
'log'(...args: [Argument0<typeof import('./cli-commands/log.js').default>]): ReturnType<typeof import('./cli-commands/log.js').default>
|
52
49
|
'ls'(...args: []): ReturnType<typeof import('./cli-commands/ls.js').default>
|
53
50
|
'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>
|
51
|
+
'uninstall'(...args: [Argument0<typeof import('./cli-commands/uninstall.js').default>]): ReturnType<typeof import('./cli-commands/uninstall.js').default>
|
54
52
|
'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>
|
55
53
|
'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>
|
56
54
|
}
|
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":{"needsValue":true}}}}},{"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":"
|
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":{"needsValue":true}}}}},{"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"}},"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":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/$init-akala.js","source":"/home/nicolas/dev/akala/packages/pm/src/cli-commands/$init-akala.ts","inject":["param.0"]},"cli":{"inject":["options.pmSock"],"options":{"pmSock":{"aliases":["pm-sock"],"needsValue":true}}},"":{"inject":["param.0"]}}},{"name":"connect","config":{"fs":{"path":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/connect.js","source":"/home/nicolas/dev/akala/packages/pm/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":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/discover.js","source":"/home/nicolas/dev/akala/packages/pm/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":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/install.js","source":"/home/nicolas/dev/akala/packages/pm/src/cli-commands/install.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"link","config":{"fs":{"path":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/link.js","source":"/home/nicolas/dev/akala/packages/pm/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":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/log.js","source":"/home/nicolas/dev/akala/packages/pm/src/cli-commands/log.ts","inject":["param.0"]},"":{"inject":["param.0"]},"cli":{"inject":["param.0"]}}},{"name":"ls","config":{"fs":{"path":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/ls.js","source":"/home/nicolas/dev/akala/packages/pm/src/cli-commands/ls.ts","inject":[]},"":{"inject":[]},"cli":{"inject":[]},"html-form":{"inject":[]}}},{"name":"map","config":{"fs":{"path":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/map.js","source":"/home/nicolas/dev/akala/packages/pm/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":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/uninstall.js","source":"/home/nicolas/dev/akala/packages/pm/src/cli-commands/uninstall.ts","inject":["param.0","$container"]},"":{"inject":["param.0","$container"]},"cli":{"inject":["param.0","$container"]}}},{"name":"update","config":{"fs":{"path":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/update.js","source":"/home/nicolas/dev/akala/packages/pm/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":"/home/nicolas/dev/akala/packages/pm/dist/esm/cli-commands/version.js","source":"/home/nicolas/dev/akala/packages/pm/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;
|
58
56
|
|
59
57
|
export function connect(processor?:ICommandProcessor) {
|
60
58
|
const container = new Container<void>("commands", void 0);
|
package/src/npm-helper.ts
CHANGED
@@ -15,14 +15,18 @@ export default
|
|
15
15
|
{
|
16
16
|
async install(packageName: string, path?: string): Promise<void>
|
17
17
|
{
|
18
|
-
await spawnAsync(npm, {}, 'i', packageName, '--prefix', path || process.cwd()
|
18
|
+
await spawnAsync(npm, { env: { NODE_ENV: 'production' } }, 'i', packageName, '--prefix', path || process.cwd());
|
19
|
+
},
|
20
|
+
async uninstall(packageName: string, path?: string): Promise<void>
|
21
|
+
{
|
22
|
+
await spawnAsync(npm, {}, 'uninstall', packageName, '--prefix', path || process.cwd(), '--production');
|
19
23
|
},
|
20
24
|
async update(packageName: string, path?: string): Promise<void>
|
21
25
|
{
|
22
|
-
await spawnAsync(npm, {}, 'up', packageName, '--prefix', path || process.cwd(), '--production');
|
26
|
+
await spawnAsync(npm, { env: { NODE_ENV: 'production' } }, 'up', packageName, '--prefix', path || process.cwd(), '--production');
|
23
27
|
},
|
24
28
|
async link(packageName: string, path?: string): Promise<void>
|
25
29
|
{
|
26
|
-
await spawnAsync(npm, { cwd: path || process.cwd() }, 'link', packageName)
|
30
|
+
await spawnAsync(npm, { env: { NODE_ENV: 'production' }, cwd: path || process.cwd() }, 'link', packageName)
|
27
31
|
}
|
28
32
|
}
|
package/src/state.ts
CHANGED
@@ -2,7 +2,6 @@ import { Container } from "@akala/commands";
|
|
2
2
|
import { ChildProcess } from "child_process";
|
3
3
|
import { Event, SerializableObject } from "@akala/core";
|
4
4
|
import { SocketAdapter } from "@akala/json-rpc-ws";
|
5
|
-
import { ServeMetadata } from "@akala/commands";
|
6
5
|
import { ProxyConfiguration } from "@akala/config";
|
7
6
|
|
8
7
|
export default interface State
|
@@ -18,6 +17,7 @@ export interface StateConfiguration
|
|
18
17
|
containers: { [key: string]: SidecarMetadata }
|
19
18
|
mapping: { [key: string]: SidecarConfiguration }
|
20
19
|
plugins: string[];
|
20
|
+
setup: { packages: string[] };
|
21
21
|
}
|
22
22
|
|
23
23
|
export interface SidecarMetadata
|
@@ -33,9 +33,10 @@ export interface SidecarConfiguration<T extends string | SerializableObject = Se
|
|
33
33
|
{
|
34
34
|
cli?: string[];
|
35
35
|
container: string;
|
36
|
-
connect?:
|
36
|
+
connect?: Record<string, object>;
|
37
37
|
cwd?: string;
|
38
38
|
config?: T;
|
39
|
+
autostart?: boolean
|
39
40
|
}
|
40
41
|
|
41
42
|
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/src/yarn-helper.ts
CHANGED
@@ -25,6 +25,10 @@ export default
|
|
25
25
|
{
|
26
26
|
await spawnAsync(npm, { cwd: path }, 'add', packageName)
|
27
27
|
},
|
28
|
+
async uninstall(packageName: string, path?: string): Promise<void>
|
29
|
+
{
|
30
|
+
await spawnAsync(npm, { cwd: path }, 'remove', packageName)
|
31
|
+
},
|
28
32
|
async update(packageName: string, path?: string): Promise<void>
|
29
33
|
{
|
30
34
|
await spawnAsync(npm, { cwd: path }, 'upgrade', packageName)
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { CliContext } from "@akala/cli";
|
2
|
-
import State from '../state.js';
|
3
|
-
export default function config(this: State, name: string | undefined | void, options: CliContext['options'] | undefined | void): Promise<string[] | State['config'] | State['config']['containers']['']>;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import * as cli from "@akala/cli";
|
2
|
-
export default async function config(name, options) {
|
3
|
-
// debugger;
|
4
|
-
if (options) {
|
5
|
-
const args = cli.unparseOptions(options);
|
6
|
-
if (typeof name == 'undefined')
|
7
|
-
return this.config;
|
8
|
-
if (args[1] && args[1] == 'set') {
|
9
|
-
this.config.mapping[name].set('cli', args.slice(2));
|
10
|
-
await this.config.commit();
|
11
|
-
}
|
12
|
-
return this.config.containers[name];
|
13
|
-
}
|
14
|
-
else if (typeof name !== 'undefined')
|
15
|
-
return this.config.containers[name];
|
16
|
-
else
|
17
|
-
return this.config;
|
18
|
-
}
|
19
|
-
exports.default.$inject = ['param.0', 'options'];
|
20
|
-
//# sourceMappingURL=config.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/cli-commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAIlC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,MAAM,CAAc,IAA+B,EAAE,OAAiD;IAEhI,YAAY;IACZ,IAAI,OAAO,EACX,CAAC;QACG,MAAM,IAAI,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,OAAO,IAAI,IAAI,WAAW;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC;QAEvB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,EAC/B,CAAC;YACG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;SACI,IAAI,OAAO,IAAI,KAAK,WAAW;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;;QAEpC,OAAO,IAAI,CAAC,MAAM,CAAC;AAC3B,CAAC;AAED,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../src/commands/plugin/add.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAwB,MAAc;IAEhD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;AAChC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/commands/plugin/remove.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAwB,MAAc;IAEhD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,aAAa,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;AAChC,CAAC"}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import * as cli from "@akala/cli";
|
2
|
-
import { CliContext } from "@akala/cli";
|
3
|
-
import State from '../state.js';
|
4
|
-
|
5
|
-
export default async function config(this: State, name: string | undefined | void, options: CliContext['options'] | undefined | void): Promise<string[] | State['config'] | State['config']['containers']['']>
|
6
|
-
{
|
7
|
-
// debugger;
|
8
|
-
if (options)
|
9
|
-
{
|
10
|
-
const args = cli.unparseOptions(options);
|
11
|
-
|
12
|
-
if (typeof name == 'undefined')
|
13
|
-
return this.config;
|
14
|
-
|
15
|
-
if (args[1] && args[1] == 'set')
|
16
|
-
{
|
17
|
-
this.config.mapping[name].set('cli', args.slice(2));
|
18
|
-
await this.config.commit();
|
19
|
-
}
|
20
|
-
|
21
|
-
return this.config.containers[name];
|
22
|
-
}
|
23
|
-
else if (typeof name !== 'undefined')
|
24
|
-
return this.config.containers[name];
|
25
|
-
else
|
26
|
-
return this.config;
|
27
|
-
}
|
28
|
-
|
29
|
-
exports.default.$inject = ['param.0', 'options']
|
@@ -1,24 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://raw.githubusercontent.com/npenin/akala/main/packages/commands/command-schema.json",
|
3
|
-
"fs": {
|
4
|
-
"inject": [
|
5
|
-
"param.0"
|
6
|
-
]
|
7
|
-
},
|
8
|
-
"": {
|
9
|
-
"inject": [
|
10
|
-
"param.0"
|
11
|
-
]
|
12
|
-
},
|
13
|
-
"cli": {
|
14
|
-
"usage": "add <plugin>",
|
15
|
-
"inject": [
|
16
|
-
"options.plugin"
|
17
|
-
],
|
18
|
-
"options": {
|
19
|
-
"plugin": {
|
20
|
-
"normalize": true
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://raw.githubusercontent.com/npenin/akala/main/packages/commands/command-schema.json",
|
3
|
-
"fs": {
|
4
|
-
"inject": [
|
5
|
-
"param.0"
|
6
|
-
]
|
7
|
-
},
|
8
|
-
"": {
|
9
|
-
"inject": [
|
10
|
-
"param.0"
|
11
|
-
]
|
12
|
-
},
|
13
|
-
"cli": {
|
14
|
-
"usage": "remove <plugin>",
|
15
|
-
"inject": [
|
16
|
-
"options.plugin"
|
17
|
-
],
|
18
|
-
"options": {
|
19
|
-
"plugin": {
|
20
|
-
"normalize": true
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import State from "../../state.js";
|
2
|
-
|
3
|
-
export default function (this: State, plugin: string)
|
4
|
-
{
|
5
|
-
const indexOfPlugin = this.config.plugins.indexOf(plugin);
|
6
|
-
if (indexOfPlugin > -1)
|
7
|
-
this.config.plugins.splice(indexOfPlugin);
|
8
|
-
return this.config.commit();
|
9
|
-
}
|