@akala/pm 2.7.2 → 3.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.
Files changed (48) hide show
  1. package/changelog.md +13 -2
  2. package/commands.json +28 -41
  3. package/dist/commands/$init.d.ts +5 -2
  4. package/dist/commands/$init.js +15 -24
  5. package/dist/commands/$init.js.map +1 -1
  6. package/dist/commands/config.d.ts +1 -1
  7. package/dist/commands/config.js +7 -5
  8. package/dist/commands/config.js.map +1 -1
  9. package/dist/commands/connect.d.ts +1 -1
  10. package/dist/commands/connect.js +5 -5
  11. package/dist/commands/connect.js.map +1 -1
  12. package/dist/commands/discover.js +2 -2
  13. package/dist/commands/discover.js.map +1 -1
  14. package/dist/commands/log.js +2 -3
  15. package/dist/commands/log.js.map +1 -1
  16. package/dist/commands/map.d.ts +1 -1
  17. package/dist/commands/map.js +3 -3
  18. package/dist/commands/map.js.map +1 -1
  19. package/dist/commands/ready.js +1 -2
  20. package/dist/commands/ready.js.map +1 -1
  21. package/dist/commands/start.d.ts +1 -1
  22. package/dist/commands/start.js +42 -32
  23. package/dist/commands/start.js.map +1 -1
  24. package/dist/container.d.ts +0 -2
  25. package/dist/index.d.ts +2 -0
  26. package/dist/index.js +2 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/new-line-prefixer.js +3 -2
  29. package/dist/new-line-prefixer.js.map +1 -1
  30. package/dist/state.d.ts +23 -13
  31. package/package.json +7 -7
  32. package/src/commands/$init.json +6 -11
  33. package/src/commands/$init.ts +17 -29
  34. package/src/commands/config.ts +11 -7
  35. package/src/commands/connect.ts +6 -6
  36. package/src/commands/map.json +20 -3
  37. package/src/commands/map.ts +3 -3
  38. package/src/commands/start.ts +42 -29
  39. package/src/container.ts +16 -18
  40. package/src/index.ts +3 -0
  41. package/src/state.ts +26 -10
  42. package/tsconfig.json +3 -0
  43. package/tsconfig.tsbuildinfo +1 -1
  44. package/dist/commands/alias.d.ts +0 -4
  45. package/dist/commands/alias.js +0 -10
  46. package/dist/commands/alias.js.map +0 -1
  47. package/src/commands/alias.json +0 -14
  48. package/src/commands/alias.ts +0 -9
@@ -2,7 +2,6 @@ import { Argument0, Argument1, Argument2, Argument3 } from '@akala/core';
2
2
  declare namespace commands {
3
3
  interface container {
4
4
  dispatch(cmd: '$init', ...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>;
5
- dispatch(cmd: 'alias', ...args: [Argument0<typeof import('./commands/alias').default>, Argument1<typeof import('./commands/alias').default>]): ReturnType<typeof import('./commands/alias').default>;
6
5
  dispatch(cmd: 'config', ...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>;
7
6
  dispatch(cmd: 'connect', ...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>;
8
7
  dispatch(cmd: 'discover', ...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>;
@@ -20,7 +19,6 @@ declare namespace commands {
20
19
  }
21
20
  interface proxy {
22
21
  '$init'(...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>;
23
- 'alias'(...args: [Argument0<typeof import('./commands/alias').default>, Argument1<typeof import('./commands/alias').default>]): ReturnType<typeof import('./commands/alias').default>;
24
22
  'config'(...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>;
25
23
  'connect'(...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>;
26
24
  'discover'(...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import { Container, Metadata, ServeMetadata, ConnectionPreference } from "@akala
2
2
  import definition from './container';
3
3
  declare type pmContainer = definition.container;
4
4
  export { pmContainer as Container };
5
+ import State from './state';
6
+ export { State };
5
7
  export declare class InteractError extends Error {
6
8
  as?: string;
7
9
  readonly code = "INTERACT";
package/dist/index.js CHANGED
@@ -8,10 +8,11 @@ const commands_1 = require("@akala/commands");
8
8
  const net_1 = require("net");
9
9
  const core_1 = require("@akala/core");
10
10
  class InteractError extends Error {
11
+ as;
12
+ code = 'INTERACT';
11
13
  constructor(message, as) {
12
14
  super(message);
13
15
  this.as = as;
14
- this.code = 'INTERACT';
15
16
  }
16
17
  toJSON() {
17
18
  return { code: this.code, message: this.message, as: this.as };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAqK;AACrK,6BAA6B;AAC7B,sCAAqC;AAOrC,MAAa,aAAc,SAAQ,KAAK;IAIpC,YAAY,OAAe,EAAS,EAAW;QAE3C,KAAK,CAAC,OAAO,CAAC,CAAC;QAFiB,OAAE,GAAF,EAAE,CAAS;QAF/B,SAAI,GAAG,UAAU,CAAC;IAKlC,CAAC;IAEM,MAAM;QAET,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IACnE,CAAC;CACJ;AAbD,sCAaC;AAED,SAAwB,QAAQ,CAAC,OAAe,EAAE,EAAW;IAEzD,MAAM,IAAI,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAHD,2BAGC;AAEM,KAAK,UAAU,EAAE,CAAC,UAAmB;IAExC,IAAI,UAAU,EACd;QACI,MAAM,QAAQ,GAAG,IAAI,YAAM,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,IAAI,oBAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,qBAAU,CAAC,OAAO,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AAS,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;oCACrH,CAAC;iCACJ,CAAC,CAAC;gCACH,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gCACxD,OAAO,CAAC,CAAC;6BACZ;4BACD,MAAM,CAAC,CAAC;yBACX;oBACL,CAAC,CAAC;iBACL,CAAC,CAAC;YACP,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;KACJ,CAAC,CAAC;AACP,CAAC;AA9CD,0BA8CC;AAeD,2DAA4C;AACnC,wBADF,cAAa,CACE"}
@@ -12,18 +12,19 @@ function selectColor(namespace) {
12
12
  return colors[Math.abs(hash) % colors.length];
13
13
  }
14
14
  class NewLinePrefixer extends stream_1.Transform {
15
+ prefix;
15
16
  constructor(prefix, options) {
16
17
  super();
17
18
  this.prefix = prefix;
18
- this.blankNewLine = true;
19
19
  this.setDefaultEncoding('utf8');
20
20
  this.setEncoding('utf8');
21
- if (options === null || options === void 0 ? void 0 : options.useColors) {
21
+ if (options?.useColors) {
22
22
  const c = selectColor(prefix);
23
23
  const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
24
24
  this.prefix = ` ${colorCode};1m${prefix} \u001B[0m`;
25
25
  }
26
26
  }
27
+ blankNewLine = true;
27
28
  _transform(chunk, encoding, callback) {
28
29
  if (Buffer.isBuffer(chunk)) {
29
30
  if (encoding == 'buffer')
@@ -1 +1 @@
1
- {"version":3,"file":"new-line-prefixer.js","sourceRoot":"","sources":["../src/new-line-prefixer.ts"],"names":[],"mappings":";;;AAAA,mCAAsD;AAOtD,MA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ANGED
@@ -1,30 +1,40 @@
1
1
  /// <reference types="node" />
2
2
  import { Container } from "@akala/commands";
3
3
  import { ChildProcess } from "child_process";
4
- import { Deferred } from "@akala/json-rpc-ws";
4
+ import { Deferred, SerializableObject } from "@akala/json-rpc-ws";
5
5
  import { ServeMetadata } from "@akala/commands";
6
+ import { ProxyConfiguration } from "@akala/config";
6
7
  export default interface State {
7
8
  processes: {
8
9
  [key: string]: RunningContainer;
9
10
  };
10
11
  isDaemon: boolean;
11
- config: {
12
- containers: {
13
- [key: string]: string[];
14
- };
15
- mapping: {
16
- [key: string]: Pick<RunningContainer, 'path' | 'dependencies' | 'connect' | 'commandable'>;
17
- };
18
- save(): Promise<void>;
19
- externals?: string[];
12
+ config: ProxyConfiguration<StateConfiguration>;
13
+ }
14
+ export interface StateConfiguration {
15
+ containers: {
16
+ [key: string]: SidecarMetadata;
17
+ };
18
+ mapping: {
19
+ [key: string]: SidecarConfiguration;
20
20
  };
21
21
  }
22
- export interface RunningContainer extends Container<unknown> {
22
+ export interface SidecarMetadata {
23
23
  path: string;
24
- process: ChildProcess;
25
24
  dependencies?: string[];
25
+ commandable: boolean;
26
+ stateless: boolean;
27
+ type?: 'nodejs';
28
+ }
29
+ export interface SidecarConfiguration<T extends string | SerializableObject = ProxyConfiguration<SerializableObject>> {
30
+ cli?: string[];
31
+ container: string;
26
32
  connect?: ServeMetadata;
33
+ cwd?: string;
34
+ config?: T;
35
+ }
36
+ export interface RunningContainer<T extends string | SerializableObject = any> extends Container<unknown>, SidecarConfiguration<T>, SidecarMetadata {
37
+ process: ChildProcess;
27
38
  running?: boolean;
28
- commandable?: boolean;
29
39
  ready?: Deferred<void>;
30
40
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "pm": "dist/cli.js",
5
5
  "pm-fork": "dist/fork.js"
6
6
  },
7
- "version": "2.7.2",
7
+ "version": "3.0.0",
8
8
  "scripts": {
9
9
  "test": "echo 1",
10
10
  "generate": "ac generate dist/commands commands.json",
@@ -18,10 +18,10 @@
18
18
  },
19
19
  "homepage": "https://akala.js.org/pm",
20
20
  "dependencies": {
21
- "@akala/cli": "1.6.4",
22
- "@akala/commands": "2.9.4",
23
- "@akala/core": "7.5.14",
24
- "@akala/json-rpc-ws": "9.3.6",
21
+ "@akala/cli": "2.0.0",
22
+ "@akala/commands": "2.10.0",
23
+ "@akala/core": "8.0.0",
24
+ "@akala/json-rpc-ws": "9.4.0",
25
25
  "debug": "^4.3.3",
26
26
  "reflect-metadata": "^0.1.13",
27
27
  "source-map-support": "^0.5.21"
@@ -29,9 +29,9 @@
29
29
  "devDependencies": {
30
30
  "@types/debug": "^4.1.7",
31
31
  "@types/mock-require": "^2.0.1",
32
- "@types/node": "^14.18.10",
32
+ "@types/node": "^14.18.12",
33
33
  "@types/source-map-support": "^0.5.4",
34
- "@types/ws": "^7.4.7",
34
+ "@types/ws": "^8.5.1",
35
35
  "typescript": "^4.5.5"
36
36
  },
37
37
  "gitHead": "d92f6693ed8cca439c8e92d2045bb15c0a7dae43"
@@ -11,18 +11,13 @@
11
11
  "$container",
12
12
  "context"
13
13
  ],
14
+ "usage": "cmd [config]",
14
15
  "options": {
15
- "tcpPort": {
16
- "needsValue": true
17
- },
18
- "port": {
19
- "needsValue": true
20
- },
21
- "key": {
22
- "needsValue": true
23
- },
24
- "cert": {
25
- "needsValue": true
16
+ "config": {
17
+ "needsValue": true,
18
+ "aliases": [
19
+ "c"
20
+ ]
26
21
  }
27
22
  }
28
23
  }
@@ -1,4 +1,4 @@
1
- import State, { RunningContainer } from '../state'
1
+ import State, { RunningContainer, StateConfiguration } from '../state'
2
2
  import { homedir } from 'os';
3
3
  import fs from 'fs/promises';
4
4
  import { join } from 'path';
@@ -7,6 +7,8 @@ import { Container, Metadata, ignoredCommands, configure, ServeOptions, SelfDefi
7
7
  import { eachAsync } from '@akala/core';
8
8
  import { PassThrough, Readable } from 'stream';
9
9
  import { EventEmitter } from 'events';
10
+ import { CliContext } from '@akala/cli';
11
+ import Configuration, { ProxyConfiguration } from '@akala/config';
10
12
 
11
13
  export async function metadata(container: Container<unknown>, deep?: boolean): Promise<Metadata.Container>
12
14
  {
@@ -40,7 +42,7 @@ export function isRunningContainer(c: Container<any>): c is RunningContainer
40
42
  return 'running' in c;
41
43
  }
42
44
 
43
- export default async function (this: State, container: RunningContainer & pmContainer.container, options: ServeOptions): Promise<void>
45
+ export default async function (this: State, container: RunningContainer & pmContainer.container, context: CliContext<{ config: string }>): Promise<void>
44
46
  {
45
47
  this.isDaemon = true;
46
48
  this.processes = {};
@@ -73,36 +75,22 @@ export default async function (this: State, container: RunningContainer & pmCont
73
75
  , killed: false
74
76
  });
75
77
 
76
- const configPath = join(homedir(), './.pm.config.json');
77
- try
78
- {
79
- this.config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
80
- process.chdir(this.config.containers.pm[0]);
81
- }
82
- catch (e)
83
- {
84
- if (e.code === 'ENOENT')
85
- this.config = {
86
- containers: { pm: [process.cwd()] },
87
- mapping: {}
88
- } as unknown as State['config'];
89
- else
90
- throw e;
91
- }
78
+ const configPath = context.options.config || join(homedir(), './.pm.config.json');
79
+ this.config = await Configuration.load<StateConfiguration>(configPath);
92
80
 
93
- this.config.save = function ()
81
+ if (this.config)
94
82
  {
95
- return fs.writeFile(configPath, JSON.stringify(this, null, 4), 'utf-8').then(() => console.log('config saved'))
83
+ if (this.config.mapping.pm.cwd)
84
+ process.chdir(this.config.mapping.pm.cwd);
96
85
  }
86
+ else
87
+ this.config = Configuration.new<StateConfiguration>(configPath, {
88
+ containers: { pm: { commandable: true, path: require.resolve('../../commands.json'), stateless: false } },
89
+ mapping: { pm: { cwd: process.cwd(), container: 'pm' } }
90
+ }) as State['config'];
97
91
 
98
- if (!this.config.externals)
99
- this.config.externals = [];
100
-
101
- if (!this.config.mapping['pm'])
102
- await container.dispatch('map', 'pm', join(__dirname, '../../commands.json'), true);
103
-
104
- if (options && options.args.length)
105
- await container.dispatch('connect', 'pm', options);
92
+ if (context && context.args.length)
93
+ await container.dispatch('connect', 'pm', context);
106
94
  else
107
95
  {
108
96
  const connectOptions = await container.dispatch('connect', 'pm');
@@ -110,7 +98,7 @@ export default async function (this: State, container: RunningContainer & pmCont
110
98
  await container.dispatch('connect', 'pm', { args: ['local'] });
111
99
  }
112
100
 
113
- await this.config.save();
101
+ await this.config.commit();
114
102
  container.name = 'pm';
115
103
  const config = container.resolve<Metadata.Configurations>('$metadata.config');
116
104
  container.unregister('$metadata');
@@ -1,26 +1,30 @@
1
1
  import * as cli from "@akala/cli";
2
2
  import { CliContext } from "@akala/cli";
3
3
  import State from '../state';
4
+ import Configuration from "@akala/config";
4
5
 
5
- export default async function config(this: State, name: string, options: CliContext['options']): Promise<string[] | State['config']>
6
+ 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
  {
7
8
  // debugger;
8
9
  if (options)
9
10
  {
10
11
  const args = cli.unparseOptions(options);
11
- if (args[1] && args[1] == 'set')
12
- {
13
- this.config.containers[name] = args.slice(2);
14
- await this.config.save();
15
- }
16
12
 
17
13
  if (typeof name == 'undefined')
18
14
  return this.config;
19
15
 
16
+ if (args[1] && args[1] == 'set')
17
+ {
18
+ this.config.mapping[name].cli = args.slice(2);
19
+ await this.config.commit();
20
+ }
21
+
20
22
  return this.config.containers[name];
21
23
  }
22
- else
24
+ else if (typeof name !== 'undefined')
23
25
  return this.config.containers[name];
26
+ else
27
+ return this.config;
24
28
  }
25
29
 
26
30
  exports.default.$inject = ['param.0', 'options']
@@ -4,24 +4,24 @@ import { serveMetadata } from "@akala/commands";
4
4
  import State from '../state';
5
5
 
6
6
  export default async function connect(this: State, name: string): Promise<ServeMetadata>
7
- export default async function connect(this: State, name: string, options?: ServeOptions): Promise<void>
8
- export default async function connect(this: State, name: string, options?: ServeOptions): Promise<ServeMetadata | void>
7
+ export default async function connect(this: State, name: string, context?: ServeOptions): Promise<void>
8
+ export default async function connect(this: State, name: string, context?: ServeOptions): Promise<ServeMetadata | void>
9
9
  {
10
10
  let mapping = this.config.mapping[name];
11
11
  if (!mapping)
12
- mapping = Object.values(this.config.mapping).find(m => m.path === name);
12
+ mapping = Object.values(this.config.mapping).find(m => m.container === name);
13
13
  if (!mapping)
14
14
  mapping = this.processes[name];
15
15
  // console.log(name);
16
16
  // console.log(mapping);
17
17
  // console.log(options);
18
- if (options && options.args.length > 0)
19
- mapping.connect = serveMetadata(name, options);
18
+ if (context && context.args.length > 0)
19
+ mapping.connect = serveMetadata(name, context);
20
20
  else
21
21
  {
22
22
  if (!mapping)
23
23
  throw new ErrorWithStatus(404, `Mapping ${name} could not be found`);
24
24
  return mapping.connect;
25
25
  }
26
- await this.config.save()
26
+ await this.config.commit()
27
27
  }
@@ -5,7 +5,8 @@
5
5
  "param.0",
6
6
  "param.1",
7
7
  "param.2",
8
- "param.3"
8
+ "param.3",
9
+ "param.4"
9
10
  ]
10
11
  },
11
12
  "cli": {
@@ -13,7 +14,23 @@
13
14
  "param.0",
14
15
  "param.1",
15
16
  "cwd",
16
- "options.c"
17
- ]
17
+ "options.c",
18
+ "options.s"
19
+ ],
20
+ "options": {
21
+ "commandable": {
22
+ "aliases": [
23
+ "c"
24
+ ],
25
+ "needsValue": false
26
+ },
27
+ "stateless": {
28
+ "aliases": [
29
+ "s",
30
+ "state-less"
31
+ ],
32
+ "needsValue": false
33
+ }
34
+ }
18
35
  }
19
36
  }
@@ -1,11 +1,11 @@
1
1
  import State from '../state';
2
2
  import { isAbsolute, resolve } from "path";
3
3
 
4
- export default async function map<TName extends string>(this: State, name: TName, targetPath: string, cwd?: string, commandable?: boolean): Promise<State['config']['mapping'][TName]>
4
+ export default async function map<TName extends string>(this: State, name: TName, targetPath: string, cwd?: string, commandable?: boolean, stateless?: boolean): Promise<State['config']['mapping'][TName]>
5
5
  {
6
6
  if (!isAbsolute(targetPath))
7
7
  targetPath = resolve(cwd || process.cwd(), targetPath);
8
- this.config.mapping[name] = { path: targetPath, commandable: !!commandable, connect: {} };
9
- await this.config.save();
8
+ this.config.containers[name] = { path: targetPath, commandable: !!commandable, stateless: !!commandable && !!stateless };
9
+ await this.config.commit();
10
10
  return this.config.mapping[name]
11
11
  }
@@ -1,5 +1,5 @@
1
1
  import { Container, Processors, Metadata, registerCommands, Cli } from "@akala/commands";
2
- import State, { RunningContainer } from '../state';
2
+ import State, { RunningContainer, SidecarMetadata } from '../state';
3
3
  import { spawn, ChildProcess, StdioOptions } from "child_process";
4
4
  import pmContainer from '../container';
5
5
  import * as jsonrpc from '@akala/json-rpc-ws'
@@ -10,19 +10,26 @@ import { SocketAdapterEventMap } from "@akala/json-rpc-ws";
10
10
  import { CliContext, ErrorWithStatus } from "@akala/cli";
11
11
  import getRandomName from "./name";
12
12
 
13
- export default async function start(this: State, pm: pmContainer.container & Container<State>, name: string, options?: CliContext<{ new?: boolean, name: string, inspect?: boolean, verbose?: boolean, wait?: boolean }>): Promise<void | { execPath: string, args: string[], cwd: string, stdio: StdioOptions, shell: boolean, windowsHide: boolean }>
13
+ export default async function start(this: State, pm: pmContainer.container & Container<State>, name: string, context?: CliContext<{ new?: boolean, name: string, inspect?: boolean, verbose?: boolean, wait?: boolean }>): Promise<void | { execPath: string, args: string[], cwd: string, stdio: StdioOptions, shell: boolean, windowsHide: boolean }>
14
14
  {
15
15
  let args: string[];
16
16
 
17
- if (!options.options.name && options.options.new)
18
- options.options.name = getRandomName();
19
- else if (!options.options.name)
20
- options.options.name = name;
17
+ if (!context.options.name && context.options.new)
18
+ context.options.name = getRandomName();
19
+ else if (!context.options.name)
20
+ context.options.name = name;
21
+
22
+ var instanceConfig = this.config.mapping[context.options.name];
23
+ var def: SidecarMetadata;
24
+ if (typeof instanceConfig == 'undefined')
25
+ def = this.config.containers[name];
26
+ else
27
+ def = this.config.containers[instanceConfig.container];
21
28
 
22
29
  if (this.isDaemon)
23
30
  {
24
31
  // eslint-disable-next-line no-var
25
- var container = this.processes[options.options.name];
32
+ var container = this.processes[context.options.name];
26
33
  if (container && container.running)
27
34
  throw new Error(container.name + ' is already started');
28
35
  args = await pm.dispatch('config', name) as string[];
@@ -31,15 +38,15 @@ export default async function start(this: State, pm: pmContainer.container & Con
31
38
  else
32
39
  args = [];
33
40
 
34
- if (!this.config.mapping[name] && name != 'pm')
41
+ if (!def && name != 'pm')
35
42
  {
36
- require.resolve(name);
37
- // throw new ErrorWithStatus(44, `No mapping was found for ${name}. Did you want to run \`pm install ${name}\` or maybe are you missing the folder to ${name} ?`)
43
+ // require.resolve(name);
44
+ 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} ?`)
38
45
  }
39
46
 
40
- args.unshift(...options.args, ...Object.entries(options.options).filter(e => e[0] != 'program' && e[0] != 'new' && e[0] != 'inspect').map(entries => ['--' + entries[0] + '=' + entries[1]]).flat());
41
- if (this.config && this.config.mapping[name] && this.config.mapping[name].path)
42
- args.unshift('--program=' + this.config.mapping[name].path);
47
+ args.unshift(...context.args, ...Object.entries(context.options).filter(e => e[0] != 'program' && e[0] != 'new' && e[0] != 'inspect').map(entries => ['--' + entries[0] + '=' + entries[1]]).flat());
48
+ if (def && def.path)
49
+ args.unshift('--program=' + def.path);
43
50
  else
44
51
  args.unshift('--program=' + name);
45
52
  }
@@ -48,20 +55,20 @@ export default async function start(this: State, pm: pmContainer.container & Con
48
55
  if (name != 'pm')
49
56
  throw new ErrorWithStatus(40, 'this command needs to run through daemon process');
50
57
 
51
- args = [...options.args, ...Object.entries(options.options).map(entries => ['--' + entries[0] + '=' + entries[1]]).flat()];
58
+ args = [...context.args, ...Object.entries(context.options).map(entries => ['--' + entries[0] + '=' + entries[1]]).flat()];
52
59
  }
53
60
 
54
61
  args.unshift(require.resolve('../fork'))
55
62
 
56
- if (options.options && options.options.inspect)
63
+ if (context.options && context.options.inspect)
57
64
  args.unshift('--inspect-brk');
58
65
 
59
66
  args.unshift(...process.execArgv);
60
67
 
61
- if (options.options && options.options.verbose)
68
+ if (context.options && context.options.verbose)
62
69
  args.push('-v')
63
70
 
64
- const log = debug('akala:pm:' + options.options.name);
71
+ const log = debug('akala:pm:' + context.options.name);
65
72
  let cp: ChildProcess;
66
73
  if (!this.isDaemon)
67
74
  {
@@ -87,12 +94,18 @@ export default async function start(this: State, pm: pmContainer.container & Con
87
94
  }
88
95
  else
89
96
  {
90
- if (!container && this.config.mapping[name]?.dependencies?.length)
91
- await eachAsync(this.config.mapping[name].dependencies, (dep) => pm.dispatch('start', dep, { wait: true }));
97
+ if (!container && this.config.containers[name]?.dependencies?.length)
98
+ {
99
+ var missingDeps = def.dependencies.filter(d => !this.config.mapping[d]);
100
+ if (missingDeps.length > 0)
101
+ throw new ErrorWithStatus(404, `Some dependencies are missing to start ${context.options.name}:\n\t-${missingDeps.join('\n\t-')}`);
102
+
103
+ await eachAsync(def.dependencies, (dep) => pm.dispatch('start', dep, { name: context.options.name + '-' + dep, wait: true }));
104
+ }
92
105
 
93
106
  cp = spawn(process.execPath, args, { cwd: process.cwd(), env: Object.assign({ DEBUG_COLORS: true }, process.env), stdio: ['ignore', 'pipe', 'pipe', 'ipc'], shell: false, windowsHide: true });
94
- cp.stderr?.pipe(new NewLinePrefixer(options.options.name + ' ', { useColors: true })).pipe(process.stderr);
95
- cp.stdout?.pipe(new NewLinePrefixer(options.options.name + ' ', { useColors: true })).pipe(process.stdout);
107
+ cp.stderr?.pipe(new NewLinePrefixer(context.options.name + ' ', { useColors: true })).pipe(process.stderr);
108
+ cp.stdout?.pipe(new NewLinePrefixer(context.options.name + ' ', { useColors: true })).pipe(process.stdout);
96
109
 
97
110
  if (!container || !container.running)
98
111
  {
@@ -124,24 +137,23 @@ export default async function start(this: State, pm: pmContainer.container & Con
124
137
  }
125
138
  , disconnected()
126
139
  {
127
- console.warn(`${options.options.name} has disconnected`);
140
+ console.warn(`${context.options.name} has disconnected`);
128
141
  container.running = null;
129
142
  }
130
143
  }), true);
131
144
 
132
145
  if (container)
133
- container = new Container(options.options.name, null, processor) as RunningContainer;
146
+ container = new Container(context.options.name, null, processor) as RunningContainer;
134
147
  else
135
- container = new Container(options.options.name, null, processor) as RunningContainer;
148
+ container = new Container(context.options.name, null, processor) as RunningContainer;
136
149
 
137
- if (this.config.mapping[name]?.commandable)
150
+ if (def?.commandable)
138
151
  pm.register(container);
139
152
 
140
- this.processes[options.options.name] = container;
153
+ this.processes[context.options.name] = container;
141
154
  }
142
155
  container.process = cp;
143
- container.path = name;
144
- container.commandable = this.config.mapping[name].commandable;
156
+ Object.assign(container, def, instanceConfig);
145
157
  container.ready = new jsonrpc.Deferred();
146
158
  if (container.commandable)
147
159
  {
@@ -164,8 +176,9 @@ export default async function start(this: State, pm: pmContainer.container & Con
164
176
  {
165
177
  (container as RunningContainer).running = false;
166
178
  pm.unregister(container.name);
179
+ container.ready.reject(new Error('program stopped'));
167
180
  });
168
- if (options.options.wait && container.commandable)
181
+ if (context.options.wait && container.commandable)
169
182
  await container.ready;
170
183
  return { execPath: process.execPath, args: args, cwd: process.cwd(), stdio: ['inherit', 'inherit', 'inherit', 'ipc'], shell: false, windowsHide: true };
171
184
  }
package/src/container.ts CHANGED
@@ -1,31 +1,29 @@
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 (cmd:'$init', ...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>
9
- dispatch (cmd:'alias', ...args: [Argument0<typeof import('./commands/alias').default>, Argument1<typeof import('./commands/alias').default>]): ReturnType<typeof import('./commands/alias').default>
10
- dispatch (cmd:'config', ...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
11
- dispatch (cmd:'connect', ...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
12
- dispatch (cmd:'discover', ...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>
13
- dispatch (cmd:'install', ...args: [Argument0<typeof import('./commands/install').default>]): ReturnType<typeof import('./commands/install').default>
14
- dispatch (cmd:'link', ...args: [Argument0<typeof import('./commands/link').default>, Argument1<typeof import('./commands/link').default>]): ReturnType<typeof import('./commands/link').default>
15
- dispatch (cmd:'log', ...args: [Argument0<typeof import('./commands/log').default>]): ReturnType<typeof import('./commands/log').default>
16
- dispatch (cmd:'ls', ...args: []): ReturnType<typeof import('./commands/ls').default>
17
- dispatch (cmd:'map', ...args: [Argument0<typeof import('./commands/map').default>, Argument1<typeof import('./commands/map').default>, Argument2<typeof import('./commands/map').default>, Argument3<typeof import('./commands/map').default>]): ReturnType<typeof import('./commands/map').default>
18
- dispatch (cmd:'ready', ...args: []): ReturnType<typeof import('./commands/ready').default>
19
- dispatch (cmd:'start', ...args: [Argument1<typeof import('./commands/start').default>, Argument2<typeof import('./commands/start').default>]): ReturnType<typeof import('./commands/start').default>
20
- dispatch (cmd:'status', ...args: [Argument0<typeof import('./commands/status').default>]): ReturnType<typeof import('./commands/status').default>
21
- dispatch (cmd:'stop', ...args: [Argument0<typeof import('./commands/stop').default>]): ReturnType<typeof import('./commands/stop').default>
22
- dispatch (cmd:'update', ...args: [Argument0<typeof import('./commands/update').default>, Argument1<typeof import('./commands/update').default>]): ReturnType<typeof import('./commands/update').default>
23
- dispatch (cmd:'version', ...args: [Argument0<typeof import('./commands/version').default>, Argument1<typeof import('./commands/version').default>]): ReturnType<typeof import('./commands/version').default>
8
+ dispatch(cmd: '$init', ...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>
9
+ dispatch(cmd: 'config', ...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
10
+ dispatch(cmd: 'connect', ...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
11
+ dispatch(cmd: 'discover', ...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>
12
+ dispatch(cmd: 'install', ...args: [Argument0<typeof import('./commands/install').default>]): ReturnType<typeof import('./commands/install').default>
13
+ dispatch(cmd: 'link', ...args: [Argument0<typeof import('./commands/link').default>, Argument1<typeof import('./commands/link').default>]): ReturnType<typeof import('./commands/link').default>
14
+ dispatch(cmd: 'log', ...args: [Argument0<typeof import('./commands/log').default>]): ReturnType<typeof import('./commands/log').default>
15
+ dispatch(cmd: 'ls', ...args: []): ReturnType<typeof import('./commands/ls').default>
16
+ dispatch(cmd: 'map', ...args: [Argument0<typeof import('./commands/map').default>, Argument1<typeof import('./commands/map').default>, Argument2<typeof import('./commands/map').default>, Argument3<typeof import('./commands/map').default>]): ReturnType<typeof import('./commands/map').default>
17
+ dispatch(cmd: 'ready', ...args: []): ReturnType<typeof import('./commands/ready').default>
18
+ dispatch(cmd: 'start', ...args: [Argument1<typeof import('./commands/start').default>, Argument2<typeof import('./commands/start').default>]): ReturnType<typeof import('./commands/start').default>
19
+ dispatch(cmd: 'status', ...args: [Argument0<typeof import('./commands/status').default>]): ReturnType<typeof import('./commands/status').default>
20
+ dispatch(cmd: 'stop', ...args: [Argument0<typeof import('./commands/stop').default>]): ReturnType<typeof import('./commands/stop').default>
21
+ dispatch(cmd: 'update', ...args: [Argument0<typeof import('./commands/update').default>, Argument1<typeof import('./commands/update').default>]): ReturnType<typeof import('./commands/update').default>
22
+ dispatch(cmd: 'version', ...args: [Argument0<typeof import('./commands/version').default>, Argument1<typeof import('./commands/version').default>]): ReturnType<typeof import('./commands/version').default>
24
23
  }
25
24
  export interface proxy
26
25
  {
27
26
  '$init'(...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>
28
- 'alias'(...args: [Argument0<typeof import('./commands/alias').default>, Argument1<typeof import('./commands/alias').default>]): ReturnType<typeof import('./commands/alias').default>
29
27
  'config'(...args: [Argument0<typeof import('./commands/config').default>, Argument1<typeof import('./commands/config').default>]): ReturnType<typeof import('./commands/config').default>
30
28
  'connect'(...args: [Argument0<typeof import('./commands/connect').default>, Argument1<typeof import('./commands/connect').default>]): ReturnType<typeof import('./commands/connect').default>
31
29
  'discover'(...args: [Argument0<typeof import('./commands/discover').default>, Argument1<typeof import('./commands/discover').default>]): ReturnType<typeof import('./commands/discover').default>