@akala/pm 15.7.4 → 15.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +1 -1
- package/dist/esm/akala.mjs +2 -1
- package/dist/esm/akala.mjs.map +1 -1
- package/dist/esm/cli-commands/install.js +10 -18
- package/dist/esm/cli-commands/install.js.map +1 -1
- package/dist/esm/cli.js +2 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/runtimes/child_process.d.ts +3 -3
- package/dist/esm/runtimes/child_process.js +2 -1
- package/dist/esm/runtimes/child_process.js.map +1 -1
- package/dist/esm/runtimes/process.d.ts +3 -3
- package/dist/esm/runtimes/process.js +2 -1
- package/dist/esm/runtimes/process.js.map +1 -1
- package/dist/esm/runtimes/shared.d.ts +2 -1
- package/dist/esm/runtimes/worker.d.ts +3 -3
- package/dist/esm/runtimes/worker.js +2 -1
- package/dist/esm/runtimes/worker.js.map +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/akala.mts +2 -1
- package/src/cli-commands/install.ts +12 -20
- package/src/cli.ts +2 -1
- package/src/runtimes/child_process.ts +4 -3
- package/src/runtimes/process.ts +4 -3
- package/src/runtimes/shared.ts +2 -1
- package/src/runtimes/worker.ts +4 -3
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": "15.
|
|
7
|
+
"version": "15.8.1",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "echo 1",
|
|
10
10
|
"generate": "akala sdk generate dist/esm/commands commands.json --name pm && akala sdk 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.12.
|
|
33
|
-
"@akala/commands": "^17.6.
|
|
34
|
-
"@akala/config": "^6.1.
|
|
35
|
-
"@akala/core": "^41.9.
|
|
36
|
-
"@akala/json-rpc-ws": "^14.3.
|
|
32
|
+
"@akala/cli": "^5.12.13",
|
|
33
|
+
"@akala/commands": "^17.6.4",
|
|
34
|
+
"@akala/config": "^6.1.13",
|
|
35
|
+
"@akala/core": "^41.9.2",
|
|
36
|
+
"@akala/json-rpc-ws": "^14.3.2",
|
|
37
37
|
"reflect-metadata": "^0.2.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
package/src/akala.mts
CHANGED
|
@@ -10,6 +10,7 @@ import Configuration from '@akala/config';
|
|
|
10
10
|
import { IpcAdapter } from './ipc-adapter.js';
|
|
11
11
|
import { FSFileSystemProvider } from '@akala/fs';
|
|
12
12
|
import { containers, InitAkala } from '@akala/commands/akala';
|
|
13
|
+
import { JsonRpcSocketAdapter } from '@akala/json-rpc-ws';
|
|
13
14
|
|
|
14
15
|
const log = logger('akala:pm');
|
|
15
16
|
|
|
@@ -38,7 +39,7 @@ export const remotePm = new Container('proxy-pm', {}) as commands.container & Co
|
|
|
38
39
|
if (process.connected)
|
|
39
40
|
protocolHandlers.useProtocol('ipc', async (url, options) =>
|
|
40
41
|
{
|
|
41
|
-
const connection = Processors.JsonRpc.getConnection(new IpcAdapter(process), options.container);
|
|
42
|
+
const connection = Processors.JsonRpc.getConnection(new JsonRpcSocketAdapter(new IpcAdapter(process)), options.container);
|
|
42
43
|
|
|
43
44
|
return {
|
|
44
45
|
processor: new Processors.JsonRpc(connection),
|
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import type State from '../state.js';
|
|
2
|
-
import npmHelper from '@akala/cli/npm-helper';
|
|
3
|
-
import yarnHelper, { hasYarn } from '@akala/cli/yarn-helper';
|
|
4
2
|
import { Container } from "@akala/commands";
|
|
5
3
|
import discover from './discover.js';
|
|
4
|
+
import { xpm } from '@akala/cli';
|
|
6
5
|
|
|
7
6
|
export default async function install(this: State, packageName: string, pm: Container<State>): ReturnType<typeof discover>
|
|
8
7
|
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
await yarnHelper.install(packageName);
|
|
12
|
-
if (!this.config.has('setup'))
|
|
13
|
-
this.config.set('setup', { packages: [] })
|
|
14
|
-
if (!this.config.has('setup.packages'))
|
|
15
|
-
this.config.set('setup.packages', [])
|
|
8
|
+
const xPM = await xpm(process.cwd());
|
|
9
|
+
await xPM.install(packageName);
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return await pm.dispatch('discover', packageName, 'node_modules');
|
|
27
|
-
}
|
|
11
|
+
if (!this.config.has('setup'))
|
|
12
|
+
this.config.set('setup', { packages: [] })
|
|
13
|
+
if (!this.config.has('setup.packages'))
|
|
14
|
+
this.config.set('setup.packages', [])
|
|
15
|
+
|
|
16
|
+
if (this.config.setup.packages.indexOf(packageName) == -1)
|
|
17
|
+
this.config.setup.packages.push(packageName);
|
|
18
|
+
|
|
19
|
+
return await pm.dispatch('discover', packageName, !process.versions['pnp'] && 'node_modules' || undefined);
|
|
28
20
|
}
|
package/src/cli.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { StateConfiguration } from './state.js';
|
|
|
11
11
|
import { program, buildCliContextFromProcess, ErrorMessage, supportInteract } from '@akala/cli';
|
|
12
12
|
import { open } from 'fs/promises';
|
|
13
13
|
import { LogLevels } from '@akala/core';
|
|
14
|
+
import { JsonRpcSocketAdapter } from '@akala/json-rpc-ws';
|
|
14
15
|
|
|
15
16
|
const tableChars = {
|
|
16
17
|
'top': '─'
|
|
@@ -142,7 +143,7 @@ cli.preAction(async c =>
|
|
|
142
143
|
if (socket.readyState == 'open')
|
|
143
144
|
{
|
|
144
145
|
if (!processor)
|
|
145
|
-
processor = new Processors.JsonRpc(Processors.JsonRpc.getConnection(new NetSocketAdapter(socket)));
|
|
146
|
+
processor = new Processors.JsonRpc(Processors.JsonRpc.getConnection(new JsonRpcSocketAdapter(new NetSocketAdapter(socket))));
|
|
146
147
|
if (!metaContainer)
|
|
147
148
|
metaContainer = (await import(new URL('../../commands.json', import.meta.url).toString(), { assert: { type: 'json' } })).default;
|
|
148
149
|
if (!container)
|
|
@@ -3,8 +3,9 @@ import { Readable } from "stream";
|
|
|
3
3
|
import { IpcAdapter } from "../ipc-adapter.js";
|
|
4
4
|
import { NewLinePrefixer } from "../new-line-prefixer.js";
|
|
5
5
|
import type { RuntimeEventMap, RuntimeInstance } from "./shared.js";
|
|
6
|
-
import { EventEmitter, type IEvent } from "@akala/core";
|
|
6
|
+
import { EventEmitter, SocketAdapter, type IEvent } from "@akala/core";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
|
+
import { JsonRpcSocketAdapter, Payload } from "@akala/json-rpc-ws";
|
|
8
9
|
|
|
9
10
|
export type ChildProcessRuntimeEventMap = {
|
|
10
11
|
"close": IEvent<[code: number | null, signal: NodeJS.Signals | null], void>
|
|
@@ -23,7 +24,7 @@ export default class Runtime extends EventEmitter<ChildProcessRuntimeEventMap> i
|
|
|
23
24
|
public readonly runtime = Runtime;
|
|
24
25
|
public static readonly name = 'nodejs';
|
|
25
26
|
private readonly cp: ChildProcess;
|
|
26
|
-
public readonly adapter:
|
|
27
|
+
public readonly adapter: SocketAdapter<Payload<Readable>>;
|
|
27
28
|
private readonly stderrPrefixer: NewLinePrefixer;
|
|
28
29
|
private readonly stdoutPrefixer: NewLinePrefixer;
|
|
29
30
|
constructor(args: string[], options: ChildProcessRuntimeOptions, signal?: AbortSignal)
|
|
@@ -47,7 +48,7 @@ export default class Runtime extends EventEmitter<ChildProcessRuntimeEventMap> i
|
|
|
47
48
|
this.stdoutPrefixer?.unpipe();
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
this.adapter = new IpcAdapter(this.cp);
|
|
51
|
+
this.adapter = new JsonRpcSocketAdapter(new IpcAdapter(this.cp));
|
|
51
52
|
this.cp.on('exit', (code, signal) => { this.emit('exit', code, signal) });
|
|
52
53
|
this.cp.on('message', (message, sendHandle) => this.emit('message', message, sendHandle));
|
|
53
54
|
|
package/src/runtimes/process.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Readable, Writable } from "stream";
|
|
2
2
|
import { IpcAdapter } from "../ipc-adapter.js";
|
|
3
3
|
import type { RuntimeEventMap, RuntimeInstance } from "./shared.js";
|
|
4
|
-
import { EventEmitter } from "@akala/core";
|
|
4
|
+
import { EventEmitter, SocketAdapter } from "@akala/core";
|
|
5
|
+
import { JsonRpcSocketAdapter, Payload } from "@akala/json-rpc-ws";
|
|
5
6
|
|
|
6
7
|
export default class Runtime extends EventEmitter<RuntimeEventMap> implements RuntimeInstance
|
|
7
8
|
{
|
|
8
9
|
public static readonly name = 'self'
|
|
9
10
|
public readonly runtime = Runtime;
|
|
10
|
-
public readonly adapter:
|
|
11
|
+
public readonly adapter: SocketAdapter<Payload<Readable>>;
|
|
11
12
|
private stdio: { stderr: Readable, stdout: Readable, stdin: Writable }
|
|
12
13
|
constructor(stdio?: { stderr: Readable, stdout: Readable, stdin: Writable })
|
|
13
14
|
{
|
|
14
15
|
super();
|
|
15
|
-
this.adapter = new IpcAdapter(process);
|
|
16
|
+
this.adapter = new JsonRpcSocketAdapter(new IpcAdapter(process));
|
|
16
17
|
if (!stdio)
|
|
17
18
|
this.stdio = process;
|
|
18
19
|
}
|
package/src/runtimes/shared.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IEvent, EventBus, SpecialEvents, SocketAdapter } from "@akala/core";
|
|
2
|
+
import { Payload } from "@akala/json-rpc-ws";
|
|
2
3
|
import { Readable } from "stream";
|
|
3
4
|
|
|
4
5
|
export interface Runtime
|
|
@@ -17,7 +18,7 @@ export interface RuntimeInstance<T extends RuntimeEventMap = RuntimeEventMap> ex
|
|
|
17
18
|
{
|
|
18
19
|
runtime: Omit<Runtime, 'build'>;
|
|
19
20
|
stop(): Promise<number>;
|
|
20
|
-
get adapter(): SocketAdapter
|
|
21
|
+
get adapter(): SocketAdapter<Payload<Readable>>;
|
|
21
22
|
|
|
22
23
|
get stderr(): Readable;
|
|
23
24
|
get stdout(): Readable;
|
package/src/runtimes/worker.ts
CHANGED
|
@@ -4,14 +4,15 @@ import { NewLinePrefixer } from "../new-line-prefixer.js";
|
|
|
4
4
|
import { MessagePortAdapter } from "../messageport-adapter.js";
|
|
5
5
|
import type { RuntimeEventMap, RuntimeInstance } from "./shared.js";
|
|
6
6
|
import module from 'module'
|
|
7
|
-
import { EventEmitter } from "@akala/core";
|
|
7
|
+
import { EventEmitter, SocketAdapter } from "@akala/core";
|
|
8
|
+
import { JsonRpcSocketAdapter, Payload } from "@akala/json-rpc-ws";
|
|
8
9
|
const require = module.createRequire(import.meta.url);
|
|
9
10
|
|
|
10
11
|
export default class Runtime extends EventEmitter<RuntimeEventMap> implements RuntimeInstance
|
|
11
12
|
{
|
|
12
13
|
public readonly runtime = Runtime;
|
|
13
14
|
private readonly cp: Worker;
|
|
14
|
-
public readonly adapter:
|
|
15
|
+
public readonly adapter: SocketAdapter<Payload<Readable>>;
|
|
15
16
|
private _running: boolean;
|
|
16
17
|
constructor(args: string[], options: { new?: boolean, name: string, keepAttached?: boolean, inspect?: boolean, verbose?: number, wait?: boolean })
|
|
17
18
|
{
|
|
@@ -19,7 +20,7 @@ export default class Runtime extends EventEmitter<RuntimeEventMap> implements Ru
|
|
|
19
20
|
this.cp = new Worker(require.resolve('../fork'), { argv: args, stderr: true, stdout: true })
|
|
20
21
|
this.cp.stderr?.pipe(new NewLinePrefixer(options.name + ' ', { useColors: true })).pipe(process.stderr);
|
|
21
22
|
this.cp.stdout?.pipe(new NewLinePrefixer(options.name + ' ', { useColors: true })).pipe(process.stdout);
|
|
22
|
-
this.adapter = new MessagePortAdapter(this.cp);
|
|
23
|
+
this.adapter = new JsonRpcSocketAdapter(new MessagePortAdapter(this.cp));
|
|
23
24
|
this.cp.on('exit', () => { this._running = false; this.emit('runningChanged') })
|
|
24
25
|
}
|
|
25
26
|
stop(): Promise<number>
|