@akala/pm 5.0.1 → 5.2.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 (169) hide show
  1. package/changelog.md +14 -1
  2. package/commands.json +22 -22
  3. package/dist/cli.js +4 -4
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/install.js +5 -5
  6. package/dist/commands/install.js.map +1 -1
  7. package/dist/commands/link.js +5 -5
  8. package/dist/commands/link.js.map +1 -1
  9. package/dist/commands/plugin/add.d.ts +2 -2
  10. package/dist/commands/plugin/remove.d.ts +2 -2
  11. package/dist/commands/start.js +4 -4
  12. package/dist/commands/start.js.map +1 -1
  13. package/dist/commands/update.js +5 -5
  14. package/dist/commands/update.js.map +1 -1
  15. package/dist/{cli-helper.d.ts → esm/cli-helper.d.ts} +1 -1
  16. package/dist/esm/cli-helper.js +17 -0
  17. package/dist/esm/cli-helper.js.map +1 -0
  18. package/dist/{cli.d.ts → esm/cli.d.ts} +0 -0
  19. package/dist/esm/cli.js +423 -0
  20. package/dist/esm/cli.js.map +1 -0
  21. package/dist/{commands → esm/commands}/$init.d.ts +2 -2
  22. package/dist/esm/commands/$init.js +113 -0
  23. package/dist/esm/commands/$init.js.map +1 -0
  24. package/dist/{commands → esm/commands}/bridge.d.ts +1 -1
  25. package/dist/esm/commands/bridge.js +11 -0
  26. package/dist/esm/commands/bridge.js.map +1 -0
  27. package/dist/{commands → esm/commands}/config.d.ts +1 -1
  28. package/dist/esm/commands/config.js +20 -0
  29. package/dist/esm/commands/config.js.map +1 -0
  30. package/dist/{commands → esm/commands}/connect.d.ts +1 -1
  31. package/dist/esm/commands/connect.js +26 -0
  32. package/dist/esm/commands/connect.js.map +1 -0
  33. package/dist/{commands → esm/commands}/discover.d.ts +3 -3
  34. package/dist/esm/commands/discover.js +72 -0
  35. package/dist/esm/commands/discover.js.map +1 -0
  36. package/dist/{commands → esm/commands}/install.d.ts +2 -2
  37. package/dist/esm/commands/install.js +13 -0
  38. package/dist/esm/commands/install.js.map +1 -0
  39. package/dist/{commands → esm/commands}/link.d.ts +2 -2
  40. package/dist/esm/commands/link.js +11 -0
  41. package/dist/esm/commands/link.js.map +1 -0
  42. package/dist/{commands → esm/commands}/log.d.ts +2 -2
  43. package/dist/esm/commands/log.js +15 -0
  44. package/dist/esm/commands/log.js.map +1 -0
  45. package/dist/{commands → esm/commands}/ls.d.ts +1 -1
  46. package/dist/esm/commands/ls.js +4 -0
  47. package/dist/esm/commands/ls.js.map +1 -0
  48. package/dist/{commands → esm/commands}/map.d.ts +1 -1
  49. package/dist/esm/commands/map.js +9 -0
  50. package/dist/esm/commands/map.js.map +1 -0
  51. package/dist/{commands → esm/commands}/name.d.ts +0 -0
  52. package/dist/esm/commands/name.js +604 -0
  53. package/dist/esm/commands/name.js.map +1 -0
  54. package/dist/esm/commands/plugin/add.d.ts +2 -0
  55. package/dist/esm/commands/plugin/add.js +5 -0
  56. package/dist/esm/commands/plugin/add.js.map +1 -0
  57. package/dist/esm/commands/plugin/remove.d.ts +2 -0
  58. package/dist/esm/commands/plugin/remove.js +7 -0
  59. package/dist/esm/commands/plugin/remove.js.map +1 -0
  60. package/dist/{commands → esm/commands}/proxy.d.ts +1 -1
  61. package/dist/esm/commands/proxy.js +19 -0
  62. package/dist/esm/commands/proxy.js.map +1 -0
  63. package/dist/{commands → esm/commands}/ready.d.ts +2 -2
  64. package/dist/esm/commands/ready.js +22 -0
  65. package/dist/esm/commands/ready.js.map +1 -0
  66. package/dist/{commands → esm/commands}/reload-metadata.d.ts +0 -0
  67. package/dist/esm/commands/reload-metadata.js +7 -0
  68. package/dist/esm/commands/reload-metadata.js.map +1 -0
  69. package/dist/{commands → esm/commands}/restart.d.ts +2 -2
  70. package/dist/esm/commands/restart.js +5 -0
  71. package/dist/esm/commands/restart.js.map +1 -0
  72. package/dist/{commands → esm/commands}/start.d.ts +3 -3
  73. package/dist/esm/commands/start.js +139 -0
  74. package/dist/esm/commands/start.js.map +1 -0
  75. package/dist/{commands → esm/commands}/status.d.ts +1 -1
  76. package/dist/esm/commands/status.js +7 -0
  77. package/dist/esm/commands/status.js.map +1 -0
  78. package/dist/{commands → esm/commands}/stop.d.ts +1 -1
  79. package/dist/esm/commands/stop.js +33 -0
  80. package/dist/esm/commands/stop.js.map +1 -0
  81. package/dist/{commands → esm/commands}/update.d.ts +1 -1
  82. package/dist/esm/commands/update.js +15 -0
  83. package/dist/esm/commands/update.js.map +1 -0
  84. package/dist/{commands → esm/commands}/version.d.ts +1 -1
  85. package/dist/esm/commands/version.js +14 -0
  86. package/dist/esm/commands/version.js.map +1 -0
  87. package/dist/esm/container.d.ts +48 -0
  88. package/dist/esm/container.js +2 -0
  89. package/dist/esm/container.js.map +1 -0
  90. package/dist/{fork.d.ts → esm/fork.d.ts} +0 -0
  91. package/dist/esm/fork.js +146 -0
  92. package/dist/esm/fork.js.map +1 -0
  93. package/dist/{index.d.ts → esm/index.d.ts} +4 -4
  94. package/dist/esm/index.js +43 -0
  95. package/dist/esm/index.js.map +1 -0
  96. package/dist/{ipc-adapter.d.ts → esm/ipc-adapter.d.ts} +2 -2
  97. package/dist/esm/ipc-adapter.js +60 -0
  98. package/dist/esm/ipc-adapter.js.map +1 -0
  99. package/dist/{new-line-prefixer.d.ts → esm/new-line-prefixer.d.ts} +2 -2
  100. package/dist/esm/new-line-prefixer.js +39 -0
  101. package/dist/esm/new-line-prefixer.js.map +1 -0
  102. package/dist/{npm-helper.d.ts → esm/npm-helper.d.ts} +0 -0
  103. package/dist/esm/npm-helper.js +20 -0
  104. package/dist/esm/npm-helper.js.map +1 -0
  105. package/dist/{sidecar.d.ts → esm/sidecar.d.ts} +2 -2
  106. package/dist/esm/sidecar.js +45 -0
  107. package/dist/esm/sidecar.js.map +1 -0
  108. package/dist/esm/standalone.d.ts +2 -0
  109. package/dist/esm/standalone.js +80 -0
  110. package/dist/esm/standalone.js.map +1 -0
  111. package/dist/{state.d.ts → esm/state.d.ts} +1 -1
  112. package/dist/esm/state.js +2 -0
  113. package/dist/esm/state.js.map +1 -0
  114. package/dist/{test → esm/test}/pwet.d.ts +0 -0
  115. package/dist/esm/test/pwet.js +7 -0
  116. package/dist/esm/test/pwet.js.map +1 -0
  117. package/dist/{yarn-helper.d.ts → esm/yarn-helper.d.ts} +0 -0
  118. package/dist/esm/yarn-helper.js +26 -0
  119. package/dist/esm/yarn-helper.js.map +1 -0
  120. package/dist/fork.js +8 -5
  121. package/dist/fork.js.map +1 -1
  122. package/dist/index.js +5 -5
  123. package/dist/index.js.map +1 -1
  124. package/dist/npm-helper.js +4 -4
  125. package/dist/npm-helper.js.map +1 -1
  126. package/dist/sidecar.js +4 -4
  127. package/dist/sidecar.js.map +1 -1
  128. package/dist/standalone.js +108 -0
  129. package/dist/standalone.js.map +1 -0
  130. package/dist/test/pwet.js +2 -2
  131. package/dist/test/pwet.js.map +1 -1
  132. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  133. package/dist/yarn-helper.js +4 -4
  134. package/dist/yarn-helper.js.map +1 -1
  135. package/package.json +24 -12
  136. package/src/cli.ts +4 -4
  137. package/src/commands/$init.ts +2 -2
  138. package/src/commands/bridge.ts +1 -1
  139. package/src/commands/config.ts +1 -1
  140. package/src/commands/connect.ts +1 -1
  141. package/src/commands/discover.ts +3 -3
  142. package/src/commands/install.ts +4 -4
  143. package/src/commands/link.ts +4 -4
  144. package/src/commands/log.ts +1 -1
  145. package/src/commands/ls.ts +1 -1
  146. package/src/commands/map.ts +1 -1
  147. package/src/commands/plugin/add.ts +1 -1
  148. package/src/commands/plugin/remove.ts +1 -1
  149. package/src/commands/proxy.ts +1 -1
  150. package/src/commands/ready.ts +2 -2
  151. package/src/commands/restart.ts +1 -1
  152. package/src/commands/start.ts +4 -4
  153. package/src/commands/status.ts +1 -1
  154. package/src/commands/stop.ts +1 -1
  155. package/src/commands/update.ts +3 -3
  156. package/src/commands/version.ts +1 -1
  157. package/src/container.ts +41 -41
  158. package/src/fork.ts +8 -4
  159. package/src/index.ts +4 -4
  160. package/src/npm-helper.ts +1 -1
  161. package/src/sidecar.ts +2 -2
  162. package/src/standalone.ts +106 -0
  163. package/src/test/pwet.ts +1 -1
  164. package/src/yarn-helper.ts +1 -1
  165. package/tsconfig.cjs.json +22 -0
  166. package/tsconfig.esm.json +22 -0
  167. package/tsconfig.tsbuildinfo +1 -1
  168. package/yarn-error.log +11177 -0
  169. package/dist/container.d.ts +0 -48
@@ -1 +1 @@
1
- {"version":3,"file":"yarn-helper.js","sourceRoot":"","sources":["../src/yarn-helper.ts"],"names":[],"mappings":";;;AAAA,2BAA8B;AAC9B,2BAA0B;AAC1B,+BAAiC;AACjC,6CAA0C;AAC1C,+BAA4B;AAG5B,oDAAoD;AACpD,IAAI;AAEJ,IAAI;AAEJ,SAAgB,OAAO,CAAC,IAAa;IAEjC,OAAO,IAAA,gBAAS,EAAC,SAAI,CAAC,CAAC,IAAA,WAAI,EAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;AAC5F,CAAC;AAHD,0BAGC;AAED,IAAI,GAAG,GAAG,MAAM,CAAC;AACjB,IAAI,IAAA,aAAQ,GAAE,IAAI,OAAO;IACrB,GAAG,GAAG,UAAU,CAAC;AAErB,kBACI;IACI,KAAK,CAAC,OAAO,CAAC,WAAmB,EAAE,IAAa;QAE5C,MAAM,IAAA,uBAAU,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,CAAC,CAAA;IAC5E,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,IAAa;QAE3C,MAAM,IAAA,uBAAU,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAA;IAChF,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,WAAmB,EAAE,IAAa;QAEzC,MAAM,IAAA,uBAAU,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAA;IAC7E,CAAC;CACJ,CAAA"}
1
+ {"version":3,"file":"yarn-helper.js","sourceRoot":"","sources":["../src/yarn-helper.ts"],"names":[],"mappings":";;;AAAA,2BAA8B;AAC9B,2BAA0B;AAC1B,+BAAiC;AACjC,mDAA6C;AAC7C,+BAA4B;AAG5B,oDAAoD;AACpD,IAAI;AAEJ,IAAI;AAEJ,SAAgB,OAAO,CAAC,IAAa;IAEjC,OAAO,IAAA,gBAAS,EAAC,SAAI,CAAC,CAAC,IAAA,WAAI,EAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;AAC5F,CAAC;AAHD,0BAGC;AAED,IAAI,GAAG,GAAG,MAAM,CAAC;AACjB,IAAI,IAAA,aAAQ,GAAE,IAAI,OAAO;IACrB,GAAG,GAAG,UAAU,CAAC;AAErB,kBACI;IACI,KAAK,CAAC,OAAO,CAAC,WAAmB,EAAE,IAAa;QAE5C,MAAM,IAAA,0BAAU,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,CAAC,CAAA;IAC5E,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,IAAa;QAE3C,MAAM,IAAA,0BAAU,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAA;IAChF,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,WAAmB,EAAE,IAAa;QAEzC,MAAM,IAAA,0BAAU,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAA;IAC7E,CAAC;CACJ,CAAA"}
package/package.json CHANGED
@@ -1,29 +1,31 @@
1
1
  {
2
2
  "name": "@akala/pm",
3
3
  "bin": {
4
- "pm": "dist/cli.js",
5
- "pm-fork": "dist/fork.js"
4
+ "pm": "dist/cjs/cli.js",
5
+ "pm-fork": "dist/cjs/fork.js"
6
6
  },
7
- "version": "5.0.1",
7
+ "version": "5.2.0",
8
8
  "scripts": {
9
9
  "test": "echo 1",
10
- "generate": "ac generate dist/commands commands.json",
10
+ "generate": "ac generate dist/esm/commands commands.json",
11
11
  "generate-metadata": "ac generate-metadata commands.json src/container.ts",
12
- "prepack": "tsc -p ."
12
+ "prepack": "tsc -p tsconfig.esm.json"
13
13
  },
14
14
  "funding": "https://github.com/npenin/akala?sponsor=1",
15
- "main": "dist/index.js",
15
+ "main": "dist/cjs/index.js",
16
+ "module": "dist/esm/index.js",
16
17
  "repository": {
17
18
  "type": "git",
18
19
  "url": "git+https://github.com/npenin/akala.git"
19
20
  },
20
21
  "homepage": "https://akala.js.org/pm",
22
+ "type": "module",
21
23
  "dependencies": {
22
- "@akala/cli": "^2.6.4",
23
- "@akala/commands": "^5.0.1",
24
- "@akala/config": "^2.0.1",
25
- "@akala/core": "^10.0.1",
26
- "@akala/json-rpc-ws": "^10.0.1",
24
+ "@akala/cli": "^2.8.0",
25
+ "@akala/commands": "^5.2.0",
26
+ "@akala/config": "^2.2.0",
27
+ "@akala/core": "^10.2.0",
28
+ "@akala/json-rpc-ws": "^10.2.0",
27
29
  "reflect-metadata": "^0.1.13",
28
30
  "source-map-support": "^0.5.21"
29
31
  },
@@ -35,5 +37,15 @@
35
37
  "@types/ws": "^8.5.4",
36
38
  "typescript": "^4.9.4"
37
39
  },
38
- "gitHead": "d92f6693ed8cca439c8e92d2045bb15c0a7dae43"
40
+ "gitHead": "d92f6693ed8cca439c8e92d2045bb15c0a7dae43",
41
+ "exports": {
42
+ ".": {
43
+ "require": "./dist/cjs/index.js",
44
+ "import": "./dist/esm/index.js",
45
+ "default": "./dist/cjs/index.js"
46
+ },
47
+ "./commands.json": {
48
+ "default": "./commands.json"
49
+ }
50
+ }
39
51
  }
package/src/cli.ts CHANGED
@@ -4,13 +4,13 @@ import { Processors, NetSocketAdapter, Metadata, Container, ICommandProcessor, p
4
4
  import { Socket } from 'net';
5
5
  import { TLSSocket } from 'tls';
6
6
  import { platform, homedir } from 'os';
7
- import start from './commands/start'
7
+ import start from './commands/start.js'
8
8
  import { Readable } from 'stream';
9
9
 
10
- import { spawnAsync } from './cli-helper';
11
- import State, { StateConfiguration } from './state';
10
+ import { spawnAsync } from './cli-helper.js';
11
+ import State, { StateConfiguration } from './state.js';
12
12
  import program, { buildCliContextFromProcess, CliContext, ErrorMessage, NamespaceMiddleware, unparse } from '@akala/cli';
13
- import { InteractError } from '.';
13
+ import { InteractError } from './index.js';
14
14
  import { Binding } from '@akala/core';
15
15
 
16
16
  const tableChars = {
@@ -1,8 +1,8 @@
1
- import State, { RunningContainer, StateConfiguration } from '../state'
1
+ import State, { RunningContainer, StateConfiguration } from '../state.js'
2
2
  import { homedir } from 'os';
3
3
  import fs from 'fs/promises';
4
4
  import { join } from 'path';
5
- import pmContainer from '../container';
5
+ import pmContainer from '../container.js';
6
6
  import { Container, Metadata, ignoredCommands, configure, SelfDefinedCommand } from '@akala/commands';
7
7
  import { PassThrough } from 'stream';
8
8
  import { EventEmitter } from 'events';
@@ -1,5 +1,5 @@
1
1
  import { SocketAdapter } from "@akala/json-rpc-ws";
2
- import State from "../state";
2
+ import State from "../state.js";
3
3
 
4
4
  export default function (this: State, connectionId: string, socket: SocketAdapter)
5
5
  {
@@ -1,6 +1,6 @@
1
1
  import * as cli from "@akala/cli";
2
2
  import { CliContext } from "@akala/cli";
3
- import State from '../state';
3
+ import State from '../state.js';
4
4
 
5
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
6
  {
@@ -1,7 +1,7 @@
1
1
  import { ErrorWithStatus } from "@akala/core";
2
2
  import { serveMetadata, ServeMetadata, ServeOptions } from "@akala/commands";
3
3
  import Configuration from "@akala/config";
4
- import State, { SidecarConfiguration } from '../state';
4
+ import State, { SidecarConfiguration } from '../state.js';
5
5
 
6
6
  export default async function connect(this: State, name: string): Promise<ServeMetadata>
7
7
  export default async function connect(this: State, name: string, context?: ServeOptions): Promise<void>
@@ -1,8 +1,8 @@
1
- import State from '../state';
1
+ import State from '../state.js';
2
2
  import { join, isAbsolute, basename, resolve } from "path";
3
3
  import { existsSync, promises as fs } from "fs";
4
- import pmContainer from '../container';
5
- import map from './map'
4
+ import pmContainer from '../container.js';
5
+ import map from './map.js'
6
6
  import { createRequire } from "module";
7
7
  import { logger } from "@akala/core";
8
8
 
@@ -1,8 +1,8 @@
1
- import State from '../state';
2
- import npmHelper from '../npm-helper';
3
- import yarnHelper, { hasYarn } from '../yarn-helper';
1
+ import State from '../state.js';
2
+ import npmHelper from '../npm-helper.js';
3
+ import yarnHelper, { hasYarn } from '../yarn-helper.js';
4
4
  import { Container } from "@akala/commands";
5
- import discover from './discover';
5
+ import discover from './discover.js';
6
6
 
7
7
  export default async function install(this: State, packageName: string, pm: Container<State>): ReturnType<typeof discover>
8
8
  {
@@ -1,8 +1,8 @@
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';
5
- import discover from './discover';
4
+ import yarnHelper, { hasYarn } from '../yarn-helper.js';
5
+ import discover from './discover.js';
6
6
 
7
7
  export default async function link(this: State, packageName: string, folder: string, pm: Container<State>): ReturnType<typeof discover>
8
8
  {
@@ -1,6 +1,6 @@
1
1
  import { PassThrough } from "stream";
2
2
  import { Readable } from "stream";
3
- import State from '../state';
3
+ import State from '../state.js';
4
4
 
5
5
  export default function log(this: State, name: string): Readable
6
6
  {
@@ -1,4 +1,4 @@
1
- import State from '../state';
1
+ import State from '../state.js';
2
2
 
3
3
  export default function ls(this: State): State['config']['containers']
4
4
  {
@@ -1,4 +1,4 @@
1
- import State from '../state';
1
+ import State from '../state.js';
2
2
  import { isAbsolute, resolve } from "path";
3
3
 
4
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]>
@@ -1,4 +1,4 @@
1
- import State from "../../state";
1
+ import State from "../../state.js";
2
2
 
3
3
  export default function (this: State, plugin: string)
4
4
  {
@@ -1,4 +1,4 @@
1
- import State from "../../state";
1
+ import State from "../../state.js";
2
2
 
3
3
  export default function (this: State, plugin: string)
4
4
  {
@@ -1,7 +1,7 @@
1
1
  import { ErrorWithStatus } from "@akala/core";
2
2
  import { SocketAdapter } from "@akala/json-rpc-ws";
3
3
  import { randomUUID } from "crypto";
4
- import State from "../state";
4
+ import State from "../state.js";
5
5
 
6
6
  export default async function (this: State, name: string, socket: SocketAdapter)
7
7
  {
@@ -1,6 +1,6 @@
1
1
  import { Container, Metadata, registerCommands, SelfDefinedCommand } from '@akala/commands';
2
- import pm from '../container';
3
- import State, { RunningContainer } from '../state';
2
+ import pm from '../container.js';
3
+ import State, { RunningContainer } from '../state.js';
4
4
 
5
5
  export default async function ready(this: State, pm: pm.container & Container<State>, container: RunningContainer, standaloneContainer: Container<void>): Promise<void>
6
6
  {
@@ -1,5 +1,5 @@
1
1
  import { StdioOptions } from "child_process";
2
- import pmContainer from '../container';
2
+ import pmContainer from '../container.js';
3
3
  import { CliContext } from "@akala/cli";
4
4
 
5
5
  export default async function restart(pm: pmContainer.container, 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 }>
@@ -1,14 +1,14 @@
1
1
  import { Container, Processors, Metadata, Cli, updateCommands } from "@akala/commands";
2
- import State, { RunningContainer, SidecarMetadata } from '../state';
2
+ import State, { RunningContainer, SidecarMetadata } from '../state.js';
3
3
  import { spawn, ChildProcess, StdioOptions } from "child_process";
4
- import pmContainer from '../container';
4
+ import pmContainer from '../container.js';
5
5
  import { Deferred, eachAsync } from "@akala/core";
6
6
  import { NewLinePrefixer } from "../new-line-prefixer.js";
7
7
  import { CliContext } from "@akala/cli";
8
8
  import { ErrorWithStatus } from "@akala/core";
9
- import getRandomName from "./name";
9
+ import getRandomName from "./name.js";
10
10
  import { ProxyConfiguration } from "@akala/config";
11
- import { IpcAdapter } from "../ipc-adapter";
11
+ import { IpcAdapter } from "../ipc-adapter.js";
12
12
 
13
13
  export default async function start(this: State, pm: pmContainer.container & Container<State>, name: string, context?: CliContext<{ new?: boolean, name: string, keepAttached?: boolean, inspect?: boolean, verbose?: boolean, wait?: boolean }>): Promise<void | { execPath: string, args: string[], cwd: string, stdio: StdioOptions, shell: boolean, windowsHide: boolean }>
14
14
  {
@@ -1,4 +1,4 @@
1
- import State from '../state';
1
+ import State from '../state.js';
2
2
 
3
3
  export default function status(this: State, name?: string): { name: string, filter: string, running: boolean, folder: string }[]
4
4
  {
@@ -1,5 +1,5 @@
1
1
  import { Container } from "@akala/commands";
2
- import State from '../state';
2
+ import State from '../state.js';
3
3
 
4
4
  export default async function stop(this: State, name: string, container: Container<State>): Promise<void>
5
5
  {
@@ -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
  {
@@ -1,4 +1,4 @@
1
- import State from '../state';
1
+ import State from '../state.js';
2
2
  import { join } from "path";
3
3
 
4
4
 
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 (cmd:'$init', ...args: [Argument1<typeof import('./commands/$init').default>]): ReturnType<typeof import('./commands/$init').default>
9
- dispatch (cmd:'bridge', ...args: [Argument0<typeof import('./commands/bridge').default>, Argument1<typeof import('./commands/bridge').default>]): ReturnType<typeof import('./commands/bridge').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:'name', ...args: [Argument0<typeof import('./commands/name').default>]): ReturnType<typeof import('./commands/name').default>
19
- dispatch (cmd:'proxy', ...args: [Argument0<typeof import('./commands/proxy').default>, Argument1<typeof import('./commands/proxy').default>]): ReturnType<typeof import('./commands/proxy').default>
20
- dispatch (cmd:'ready', ...args: []): ReturnType<typeof import('./commands/ready').default>
21
- dispatch (cmd:'reload-metadata', ...args: [Argument0<typeof import('./commands/reload-metadata').default>]): ReturnType<typeof import('./commands/reload-metadata').default>
22
- dispatch (cmd:'restart', ...args: [Argument1<typeof import('./commands/restart').default>, Argument2<typeof import('./commands/restart').default>]): ReturnType<typeof import('./commands/restart').default>
23
- dispatch (cmd:'start', ...args: [Argument1<typeof import('./commands/start').default>, Argument2<typeof import('./commands/start').default>]): ReturnType<typeof import('./commands/start').default>
24
- dispatch (cmd:'status', ...args: [Argument0<typeof import('./commands/status').default>]): ReturnType<typeof import('./commands/status').default>
25
- dispatch (cmd:'stop', ...args: [Argument0<typeof import('./commands/stop').default>]): ReturnType<typeof import('./commands/stop').default>
26
- dispatch (cmd:'update', ...args: [Argument0<typeof import('./commands/update').default>, Argument1<typeof import('./commands/update').default>]): ReturnType<typeof import('./commands/update').default>
27
- 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.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
- const initMiddleware = new NamespaceMiddleware<{ program: string, name: string, tls: boolean }>(null);
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
@@ -1,5 +1,5 @@
1
1
  import { platform } from "os";
2
- import { spawnAsync } from './cli-helper';
2
+ import { spawnAsync } from './cli-helper.js';
3
3
 
4
4
 
5
5
  // if (typeof (process.versions.pnp) != 'undefined')
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
@@ -1,4 +1,4 @@
1
- import interact from "..";
1
+ import interact from "../index.js";
2
2
 
3
3
  export default async function pwet(a: string): Promise<void>
4
4
  {
@@ -1,7 +1,7 @@
1
1
  import { platform } from "os";
2
2
  import { stat } from 'fs';
3
3
  import { promisify } from 'util';
4
- import { spawnAsync } from './cli-helper';
4
+ import { spawnAsync } from './cli-helper.js';
5
5
  import { join } from 'path';
6
6
 
7
7