@akala/pm 5.2.40 → 6.0.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.
@@ -50,7 +50,7 @@ export function isRunningContainer(c: Container<unknown>): c is RunningContainer
50
50
  return 'running' in c;
51
51
  }
52
52
 
53
- export default async function (this: State, container: RunningContainer & pmContainer.container, context: CliContext<{ config: string, keepAttached: boolean, args: string[] }>): Promise<void>
53
+ export default async function (this: State, container: RunningContainer & pmContainer.container, context: CliContext<{ configFile: string, keepAttached: boolean, args: string[] }>): Promise<void>
54
54
  {
55
55
  this.isDaemon = true;
56
56
  this.processes = {};
@@ -86,7 +86,7 @@ export default async function (this: State, container: RunningContainer & pmCont
86
86
  , killed: false
87
87
  });
88
88
 
89
- const configPath = context.options.config || join(homedir(), './.pm.config.json');
89
+ const configPath = context.options.configFile || join(homedir(), './.pm.config.json');
90
90
  this.config = await Configuration.load<StateConfiguration>(configPath, true);
91
91
 
92
92
  if (this.config?.mapping?.pm)
@@ -95,11 +95,11 @@ export default async function (this: State, container: RunningContainer & pmCont
95
95
  process.chdir(this.config.mapping.pm.cwd);
96
96
  }
97
97
  else
98
- this.config = Configuration.new<StateConfiguration>(configPath, {
99
- containers: { pm: { commandable: true, stateless: false, path: fileURLToPath(new URL('../../../commands.json', import.meta.url)) } },
100
- mapping: { pm: { cwd: process.cwd(), container: 'pm' } },
101
- plugins: []
102
- }) as State['config'];
98
+ {
99
+ this.config.set('containers', { pm: { commandable: true, stateless: false, path: fileURLToPath(new URL('../../../commands.json', import.meta.url)) } });
100
+ this.config.set('mapping', { pm: { cwd: process.cwd(), container: 'pm' } })
101
+ this.config.set('plugins', [])
102
+ }
103
103
 
104
104
  this.config.mapping['pm'].set('connect', serveMetadata('pm', { options: context.options, args: context.options.args } as unknown as ServeOptions));
105
105
 
@@ -99,6 +99,4 @@ export default async function discover(this: State, packageName: string, folder:
99
99
  return pm.dispatch('map', packageName, commandsJsonFile, path, { commandable: true });
100
100
 
101
101
  return pm.dispatch('map', packageName, moduleRequire.resolve('./' + packageConfig.main), path, { commandable: false });
102
- }
103
-
104
- exports.default.$inject = ['param.0', 'param.1', '$container']
102
+ }
@@ -1,11 +1,11 @@
1
1
  import State from '../state.js';
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, options?: { commandable?: boolean, stateless?: boolean }): Promise<State['config']['mapping'][TName]>
4
+ export default async function map<TName extends string>(this: State, name: TName, targetPath: string, cwd?: string, options?: { commandable?: boolean }): Promise<State['config']['mapping'][TName]>
5
5
  {
6
6
  if (!isAbsolute(targetPath))
7
7
  targetPath = resolve(cwd || process.cwd(), targetPath);
8
- this.config.containers.set(name, { path: targetPath, commandable: !!options?.commandable, stateless: !!options?.stateless });
8
+ this.config.containers.set(name, { path: targetPath, commandable: !!options?.commandable });
9
9
  await this.config.commit();
10
10
  return this.config.mapping[name]
11
11
  }
@@ -4,7 +4,7 @@ import { spawn, ChildProcess, StdioOptions } from "child_process";
4
4
  import pmContainer from '../container.js';
5
5
  import { Deferred, eachAsync } from "@akala/core";
6
6
  import { NewLinePrefixer } from "../new-line-prefixer.js";
7
- import { CliContext } from "@akala/cli";
7
+ import { CliContext, unparseOptions } from "@akala/cli";
8
8
  import { ErrorWithStatus } from "@akala/core";
9
9
  import getRandomName from "./name.js";
10
10
  import { ProxyConfiguration } from "@akala/config";
@@ -47,7 +47,7 @@ export default async function start(this: State, pm: pmContainer.container & Con
47
47
  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} ?`)
48
48
  }
49
49
 
50
- 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());
50
+ args.unshift(...context.args, ...unparseOptions({ ...context.options, program: undefined, new: undefined, inspect: undefined }, { ignoreUndefined: true }));
51
51
  if (def && def.get('path'))
52
52
  args.unshift('--program=' + def.get('path'));
53
53
  else
@@ -58,11 +58,14 @@ export default async function start(this: State, pm: pmContainer.container & Con
58
58
  if (name != 'pm')
59
59
  throw new ErrorWithStatus(40, 'this command needs to run through daemon process');
60
60
 
61
- args = [...context.args, ...Object.entries(context.options).filter(p => ['inspect'].indexOf(p[0]) == -1).map(entries => ['--' + entries[0] + '=' + entries[1]]).flat()];
61
+ args = [...context.args, ...unparseOptions({ ...context.options, inspect: undefined })];
62
62
  }
63
63
 
64
64
  if (!def?.type || def.type == 'nodejs')
65
+ {
66
+
65
67
  args.unshift(path.resolve(_dirname, '../fork'))
68
+ }
66
69
 
67
70
  if (context.options && context.options.inspect)
68
71
  args.unshift('--inspect-brk');
@@ -153,6 +156,7 @@ export default async function start(this: State, pm: pmContainer.container & Con
153
156
  {
154
157
  // console.log(metaContainer);
155
158
  updateCommands(metaContainer.commands, null, container);
159
+ container.stateless = metaContainer.stateless;
156
160
  pm.register(name, container, true);
157
161
  });
158
162
  }, () =>
package/src/fork.ts CHANGED
@@ -36,6 +36,7 @@ const controller = new AbortController();
36
36
  program.option<string, 'program'>('program', { needsValue: true, normalize: true, positional: true, position: 0 }).
37
37
  option<string, 'name'>('name', { needsValue: true, positional: true, position: 1, optional: true }).
38
38
  option<boolean, 'tls'>('tls', { needsValue: false }).
39
+ option<string, 'configFile'>('configFile', { needsValue: false }).
39
40
  options<{
40
41
  port?: number,
41
42
  tcpPort?: string,