@nu-art/commando 0.300.8 → 0.400.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.
Files changed (72) hide show
  1. package/cli-params/CLIParamsResolver.d.ts +1 -1
  2. package/cli-params/CLIParamsResolver.js +30 -31
  3. package/cli-params/CLIParamsResolver.js.map +1 -0
  4. package/cli-params/consts.d.ts +1 -1
  5. package/cli-params/consts.js +11 -15
  6. package/cli-params/consts.js.map +1 -0
  7. package/cli-params/types.d.ts +1 -0
  8. package/cli-params/types.js +2 -2
  9. package/cli-params/types.js.map +1 -0
  10. package/package.json +17 -13
  11. package/shell/core/BaseCommando.d.ts +2 -2
  12. package/shell/core/BaseCommando.js +12 -14
  13. package/shell/core/BaseCommando.js.map +1 -0
  14. package/shell/core/CliError.js +10 -8
  15. package/shell/core/CliError.js.map +1 -0
  16. package/shell/core/CommandBuilder.js +41 -40
  17. package/shell/core/CommandBuilder.js.map +1 -0
  18. package/shell/core/CommandoPool.d.ts +9 -0
  19. package/shell/core/CommandoPool.js +15 -0
  20. package/shell/core/CommandoPool.js.map +1 -0
  21. package/shell/core/class-merger.js +3 -6
  22. package/shell/core/class-merger.js.map +1 -0
  23. package/shell/index.d.ts +2 -2
  24. package/shell/index.js +3 -18
  25. package/shell/index.js.map +1 -0
  26. package/shell/interactive/CommandoInteractive.d.ts +12 -15
  27. package/shell/interactive/CommandoInteractive.js +88 -72
  28. package/shell/interactive/CommandoInteractive.js.map +1 -0
  29. package/shell/interactive/InteractiveShell.d.ts +14 -16
  30. package/shell/interactive/InteractiveShell.js +135 -88
  31. package/shell/interactive/InteractiveShell.js.map +1 -0
  32. package/shell/plugins/basic.d.ts +2 -2
  33. package/shell/plugins/basic.js +8 -11
  34. package/shell/plugins/basic.js.map +1 -0
  35. package/shell/plugins/git.d.ts +3 -3
  36. package/shell/plugins/git.js +30 -36
  37. package/shell/plugins/git.js.map +1 -0
  38. package/shell/plugins/nvm.d.ts +3 -3
  39. package/shell/plugins/nvm.js +22 -28
  40. package/shell/plugins/nvm.js.map +1 -0
  41. package/shell/plugins/pnpm.d.ts +4 -4
  42. package/shell/plugins/pnpm.js +8 -11
  43. package/shell/plugins/pnpm.js.map +1 -0
  44. package/shell/plugins/programming.d.ts +2 -2
  45. package/shell/plugins/programming.js +3 -6
  46. package/shell/plugins/programming.js.map +1 -0
  47. package/shell/plugins/python.d.ts +3 -3
  48. package/shell/plugins/python.js +9 -12
  49. package/shell/plugins/python.js.map +1 -0
  50. package/shell/services/nvm.d.ts +1 -1
  51. package/shell/services/nvm.js +62 -88
  52. package/shell/services/nvm.js.map +1 -0
  53. package/shell/services/pnpm.d.ts +3 -3
  54. package/shell/services/pnpm.js +54 -56
  55. package/shell/services/pnpm.js.map +1 -0
  56. package/shell/simple/Commando.d.ts +2 -2
  57. package/shell/simple/Commando.js +15 -18
  58. package/shell/simple/Commando.js.map +1 -0
  59. package/shell/simple/SimpleShell.js +34 -33
  60. package/shell/simple/SimpleShell.js.map +1 -0
  61. package/shell/tools.js +4 -30
  62. package/shell/tools.js.map +1 -0
  63. package/shell/types.d.ts +1 -1
  64. package/shell/types.js +2 -2
  65. package/shell/types.js.map +1 -0
  66. package/console/ConsoleContainer.d.ts +0 -89
  67. package/console/ConsoleContainer.js +0 -145
  68. package/console/ConsoleScreen.d.ts +0 -21
  69. package/console/ConsoleScreen.js +0 -21
  70. package/console/types.d.ts +0 -61
  71. package/console/types.js +0 -72
  72. package/tsconfig.json +0 -23
@@ -1,6 +1,7 @@
1
1
  import { Constructor, LogLevel } from '@nu-art/ts-common';
2
- import { LogTypes } from '../types';
3
- import { BaseCommando } from '../core/BaseCommando';
2
+ import { ShellLogProcessor, ShellPidListener } from './InteractiveShell.js';
3
+ import { LogTypes } from '../types.js';
4
+ import { BaseCommando } from '../core/BaseCommando.js';
4
5
  export declare class CommandoInteractive extends BaseCommando {
5
6
  private shell;
6
7
  /**
@@ -8,7 +9,7 @@ export declare class CommandoInteractive extends BaseCommando {
8
9
  * @param {Constructor<any>[]} plugins - The plugins to merge with CommandoInteractive.
9
10
  * @returns {CommandoInteractive} - The new instance of CommandoInteractive merged with the plugins.
10
11
  */
11
- static create<T extends Constructor<any>[]>(...plugins: T): import("../core/class-merger").MergeTypes<[typeof BaseCommando, typeof CommandoInteractive, ...T]> & BaseCommando & CommandoInteractive;
12
+ static create<T extends Constructor<any>[]>(...plugins: T): import("../core/class-merger.js").MergeTypes<[typeof BaseCommando, typeof CommandoInteractive, ...T]> & BaseCommando & CommandoInteractive;
12
13
  /**
13
14
  * Constructs a CommandoInteractive instance.
14
15
  */
@@ -35,26 +36,19 @@ export declare class CommandoInteractive extends BaseCommando {
35
36
  * @param {NodeJS.Signals | number} [signal] - The signal to send to the process.
36
37
  * @returns {boolean} - Whether the kill signal was successfully sent.
37
38
  */
38
- kill(signal?: NodeJS.Signals | number): boolean | undefined;
39
+ kill(signal?: NodeJS.Signals): Promise<void>;
39
40
  /**
40
41
  * Gracefully kills a process by its PID.
41
42
  * @param {number} [pid] - The PID of the process to kill.
43
+ * @param signal
42
44
  */
43
- gracefullyKill(pid?: number): Promise<void>;
45
+ killSubprocess(pid: number, signal?: NodeJS.Signals): Promise<void>;
44
46
  /**
45
47
  * Waits for a log entry that matches a specified pattern, then executes a callback.
46
48
  * @param {string | RegExp} filter - The pattern to match in log entries.
47
49
  * @param {(match: RegExpMatchArray) => any} callback - The callback to execute when a match is found.
48
50
  */
49
51
  onLog(filter: string | RegExp, callback: (match: RegExpMatchArray) => any): this;
50
- /**
51
- * Executes commands asynchronously and listens for the PID.
52
- *
53
- * @param {Function} pidListener - A listener function to handle the PID.
54
- * @param {Function} [callback] - A callback function to handle the command output.
55
- * @returns {Promise<T>} - The result of the callback function.
56
- */
57
- executeAsync<T>(pidListener: (pid: number) => void, callback?: (stdout: string, stderr: string, exitCode: number) => T): Promise<T>;
58
52
  /**
59
53
  * Executes commands and processes logs to extract exit code.
60
54
  * @param {Function} [callback] - A callback function to handle the command output.
@@ -64,20 +58,23 @@ export declare class CommandoInteractive extends BaseCommando {
64
58
  /**
65
59
  * Adds a log processor to the shell.
66
60
  * @param {Function} processor - The log processor function to add.
61
+ * @param index
67
62
  * @returns {this} - The CommandoInteractive instance for method chaining.
68
63
  */
69
- addLogProcessor(processor: (log: string, std: LogTypes) => boolean): this;
64
+ addLogProcessor(processor: ShellLogProcessor, index?: number): this;
70
65
  setLogLevelFilter(processor: (log: string, std: LogTypes) => LogLevel | undefined): this;
71
66
  /**
72
67
  * Removes a log processor from the shell.
73
68
  * @param {Function} processor - The log processor function to remove.
74
69
  * @returns {this} - The CommandoInteractive instance for method chaining.
75
70
  */
76
- removeLogProcessor(processor: (log: string, std: LogTypes) => boolean): this;
71
+ removeLogProcessor(processor: ShellLogProcessor): this;
77
72
  /**
78
73
  * Appends a command to the command list.
79
74
  * @param {string} command - The command to append.
80
75
  * @returns {this} - The CommandoInteractive instance for method chaining.
81
76
  */
82
77
  append(command: string): this;
78
+ appendAsync(command: string, pidListener?: ShellPidListener): this;
79
+ getCommand(): string;
83
80
  }
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommandoInteractive = void 0;
4
- const ts_common_1 = require("@nu-art/ts-common");
5
- const InteractiveShell_1 = require("./InteractiveShell");
6
- const BaseCommando_1 = require("../core/BaseCommando");
7
- class CommandoInteractive extends BaseCommando_1.BaseCommando {
1
+ import { generateHex } from '@nu-art/ts-common';
2
+ import { InteractiveShell } from './InteractiveShell.js';
3
+ import { BaseCommando } from '../core/BaseCommando.js';
4
+ export class CommandoInteractive extends BaseCommando {
5
+ shell;
8
6
  /**
9
7
  * Creates a new instance of CommandoInteractive merged with the provided plugins.
10
8
  * @param {Constructor<any>[]} plugins - The plugins to merge with CommandoInteractive.
11
9
  * @returns {CommandoInteractive} - The new instance of CommandoInteractive merged with the plugins.
12
10
  */
13
11
  static create(...plugins) {
14
- const _commando = BaseCommando_1.BaseCommando._create(CommandoInteractive, ...plugins);
12
+ const _commando = BaseCommando._create(CommandoInteractive, ...plugins);
15
13
  const commando = _commando;
16
- commando.shell = new InteractiveShell_1.InteractiveShell();
17
- commando.shell.setMinLevel(ts_common_1.LogLevel.Verbose);
14
+ commando.shell = new InteractiveShell();
18
15
  return commando;
19
16
  }
20
17
  /**
@@ -22,7 +19,7 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
22
19
  */
23
20
  constructor() {
24
21
  super();
25
- this.shell = new InteractiveShell_1.InteractiveShell();
22
+ this.shell = new InteractiveShell();
26
23
  }
27
24
  /**
28
25
  * Toggles or sets the debug mode.
@@ -60,9 +57,10 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
60
57
  /**
61
58
  * Gracefully kills a process by its PID.
62
59
  * @param {number} [pid] - The PID of the process to kill.
60
+ * @param signal
63
61
  */
64
- async gracefullyKill(pid) {
65
- return this.shell.gracefullyKill(pid);
62
+ async killSubprocess(pid, signal) {
63
+ return this.shell.killSubprocess(pid, signal);
66
64
  }
67
65
  /**
68
66
  * Waits for a log entry that matches a specified pattern, then executes a callback.
@@ -81,77 +79,74 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
81
79
  this.addLogProcessor(logFilter);
82
80
  return this;
83
81
  }
84
- /**
85
- * Executes commands asynchronously and listens for the PID.
86
- *
87
- * @param {Function} pidListener - A listener function to handle the PID.
88
- * @param {Function} [callback] - A callback function to handle the command output.
89
- * @returns {Promise<T>} - The result of the callback function.
90
- */
91
- async executeAsync(pidListener, callback) {
92
- const pidUniqueKey = (0, ts_common_1.generateHex)(16);
93
- const regexp = new RegExp(`${pidUniqueKey}=(\\d+)`);
94
- const functionContent = this.builder.reset().trim() + ' &';
95
- const pidLogProcessor = (log) => {
96
- const match = log.match(regexp);
97
- if (!match)
98
- return true;
99
- const pid = +match[1];
100
- pidListener(pid);
101
- return false;
102
- };
103
- return await this
104
- .append(functionContent)
105
- .append('pid=$!')
106
- .append(`echo "${pidUniqueKey}=\${pid}"`)
107
- .append(`wait \$pid`)
108
- .addLogProcessor(pidLogProcessor)
109
- .execute(callback);
110
- }
111
82
  /**
112
83
  * Executes commands and processes logs to extract exit code.
113
84
  * @param {Function} [callback] - A callback function to handle the command output.
114
85
  * @returns {Promise<T>} - The result of the callback function.
115
86
  */
116
87
  async execute(callback) {
117
- return await new Promise((resolve, reject) => {
118
- const uniqueKey = (0, ts_common_1.generateHex)(16);
119
- const regexp = new RegExp(`${uniqueKey}=(\\d+)`);
120
- let _stderr = '';
121
- let _stdout = '';
122
- const logProcessor = (log, type) => {
123
- if (type === 'err')
124
- _stderr += `${log}\n`;
125
- else
126
- _stdout += `${log}\n`;
127
- if (!log.includes(uniqueKey))
88
+ let logProcessor;
89
+ let stdLogProcessor;
90
+ let onCloseListener;
91
+ try {
92
+ return await new Promise((resolve, reject) => {
93
+ const uniqueKey = generateHex(16);
94
+ const regexp = new RegExp(`${uniqueKey}=(\\d+)`);
95
+ let _stderr = '';
96
+ let _stdout = '';
97
+ stdLogProcessor = (log, type) => {
98
+ if (type === 'err')
99
+ _stderr += `${log}\n`;
100
+ else
101
+ _stdout += `${log}\n`;
128
102
  return true;
129
- const match = log.match(regexp);
130
- if (!match)
131
- return true;
132
- const exitCode = match === null || match === void 0 ? void 0 : match[1];
133
- this.removeLogProcessor(logProcessor);
134
- try {
135
- resolve(callback === null || callback === void 0 ? void 0 : callback(_stdout, _stderr, +exitCode));
136
- }
137
- catch (err) {
138
- reject(err);
139
- }
140
- return false;
141
- };
142
- this.builder.append(`echo ${uniqueKey}=$?`);
143
- const command = this.builder.reset();
144
- this.shell.addLogProcessor(logProcessor);
145
- this.shell.execute(command);
146
- });
103
+ };
104
+ let uidCounter = 0;
105
+ let exitCode = -1;
106
+ logProcessor = (log, type) => {
107
+ if (!log.includes(uniqueKey))
108
+ return true;
109
+ const match = log.match(regexp);
110
+ if (!match)
111
+ return false;
112
+ uidCounter++;
113
+ if (type === 'out')
114
+ exitCode = +(match[1]);
115
+ if (uidCounter !== 2)
116
+ return false;
117
+ try {
118
+ resolve(callback?.(_stdout, _stderr, +exitCode));
119
+ }
120
+ catch (err) {
121
+ reject(err);
122
+ }
123
+ return false;
124
+ };
125
+ onCloseListener = (exitCode) => {
126
+ resolve(callback?.(_stdout, _stderr, exitCode));
127
+ };
128
+ this.builder.append(`echo ${uniqueKey}=$? && echo ${uniqueKey}=$? 1>&2`);
129
+ const command = this.builder.reset();
130
+ this.shell.addLogProcessor(logProcessor, 0);
131
+ this.shell.addLogProcessor(stdLogProcessor);
132
+ this.shell.addOnCloseListener(onCloseListener);
133
+ this.shell.execute(command);
134
+ });
135
+ }
136
+ finally {
137
+ this.shell.removeLogProcessor(logProcessor);
138
+ this.shell.removeLogProcessor(stdLogProcessor);
139
+ this.shell.removeOnCloseListener(onCloseListener);
140
+ }
147
141
  }
148
142
  /**
149
143
  * Adds a log processor to the shell.
150
144
  * @param {Function} processor - The log processor function to add.
145
+ * @param index
151
146
  * @returns {this} - The CommandoInteractive instance for method chaining.
152
147
  */
153
- addLogProcessor(processor) {
154
- this.shell.addLogProcessor(processor);
148
+ addLogProcessor(processor, index) {
149
+ this.shell.addLogProcessor(processor, index);
155
150
  return this;
156
151
  }
157
152
  setLogLevelFilter(processor) {
@@ -176,5 +171,26 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
176
171
  this.builder.append(command);
177
172
  return this;
178
173
  }
174
+ appendAsync(command, pidListener) {
175
+ const pidUniqueKey = generateHex(16);
176
+ const regexp = new RegExp(`${pidUniqueKey}=(\\d+)`);
177
+ const pidLogProcessor = async (log) => {
178
+ const match = log.match(regexp);
179
+ if (!match)
180
+ return true;
181
+ const pid = +match[1];
182
+ await pidListener?.(pid);
183
+ return false;
184
+ };
185
+ this.append(`${command} &`)
186
+ .append('pid=$!')
187
+ .append(`echo "${pidUniqueKey}=\${pid}"`)
188
+ .append(`wait \$pid`)
189
+ .addLogProcessor(pidLogProcessor, 0);
190
+ return this;
191
+ }
192
+ getCommand() {
193
+ return this.builder.getCommand();
194
+ }
179
195
  }
180
- exports.CommandoInteractive = CommandoInteractive;
196
+ //# sourceMappingURL=CommandoInteractive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandoInteractive.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/commando/src/main/","sources":["shell/interactive/CommandoInteractive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,WAAW,EAAW,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAsC,MAAM,uBAAuB,CAAC;AAE5F,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAGrD,MAAM,OAAO,mBACZ,SAAQ,YAAY;IACZ,KAAK,CAAmB;IAEhC;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAA+B,GAAG,OAAU;QACxD,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,OAAO,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,SAAmD,CAAC;QACrE,QAAQ,CAAC,KAAK,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACH;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAe;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,KAAK;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;IACpC,CAAC;IAED;;;;OA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AC,GAAG,YAAY,SAAS,CAAC,CAAC;QAEpD,MAAM,eAAe,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;YAC7C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,KAAK;gBACT,OAAO,IAAI,CAAC;YAEb,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,IAAI,CAAC;aACzB,MAAM,CAAC,QAAQ,CAAC;aAChB,MAAM,CAAC,SAAS,YAAY,WAAW,CAAC;aACxC,MAAM,CAAC,YAAY,CAAC;aACpB,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;QAEtC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,UAAU;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;CACD"}
@@ -1,9 +1,12 @@
1
1
  import { Logger, LogLevel } from '@nu-art/ts-common';
2
- import { LogTypes } from '../types';
3
- type LogProcessor = (log: string, std: LogTypes) => boolean;
2
+ import { LogTypes } from '../types.js';
3
+ export type ShellLogProcessor = (log: string, std: LogTypes) => (Promise<boolean> | boolean);
4
+ export type ShellPidListener = (pid: number) => (Promise<any> | any);
5
+ type OnCloseListener = (exitCode: number) => void;
4
6
  export declare class InteractiveShell extends Logger {
5
7
  private _debug;
6
8
  private logProcessors;
9
+ private onCloseListeners;
7
10
  private shell;
8
11
  private alive;
9
12
  private logLevelFilter;
@@ -26,31 +29,26 @@ export declare class InteractiveShell extends Logger {
26
29
  * Awaits for the end of the interactive shell session.
27
30
  */
28
31
  endInteractive: () => Promise<void>;
29
- /**
30
- * Sends a signal to terminate the shell process.
31
- * @param {NodeJS.Signals | number} [signal] - The signal to send to the shell process.
32
- * @returns {boolean | undefined} - The result of the kill operation.
33
- */
34
- kill: (signal?: NodeJS.Signals | number) => boolean | undefined;
35
- /**
36
- * Attempts to gracefully terminate the shell process.
37
- * @param {number} [pid] - Process ID of the shell to terminate.
38
- * @returns {Promise<void>} - Resolves when the shell process is gracefully killed.
39
- */
40
- gracefullyKill: (pid?: number) => Promise<void>;
32
+ isAlive: (pid: number) => boolean;
33
+ waitForExit: (pid: number, timeout?: number, sampleInterval?: number) => Promise<void>;
34
+ kill: (signal?: NodeJS.Signals, timeout?: number) => Promise<void>;
35
+ killSubprocess: (pid: number, signal?: NodeJS.Signals, timeout?: number) => Promise<void>;
41
36
  /**
42
37
  * Adds a log processor to handle log messages.
43
38
  * @param {(log: string, std: LogTypes) => boolean} processor - The log processor function.
39
+ * @param index -
44
40
  * @returns {this} - The InteractiveShell instance for method chaining.
45
41
  */
46
- addLogProcessor(processor: LogProcessor): this;
42
+ addLogProcessor(processor: ShellLogProcessor, index?: number): this;
47
43
  setLogLevelFilter(logLevelFilter: (log: string, std: LogTypes) => LogLevel | undefined): this;
44
+ addOnCloseListener(listener: OnCloseListener): this;
45
+ removeOnCloseListener(listener: OnCloseListener): this;
48
46
  /**
49
47
  * Removes a log processor from handling log messages.
50
48
  * @param {(log: string, std: LogTypes) => boolean} processor - The log processor function to remove.
51
49
  * @returns {this} - The InteractiveShell instance for method chaining.
52
50
  */
53
- removeLogProcessor(processor: LogProcessor): this;
51
+ removeLogProcessor(processor: ShellLogProcessor): this;
54
52
  /**
55
53
  * Sets a unique identifier for the shell session.
56
54
  * @param {string} uid - The unique identifier.
@@ -1,95 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InteractiveShell = void 0;
4
- const ts_common_1 = require("@nu-art/ts-common");
5
- const node_child_process_1 = require("node:child_process");
6
- const defaultLogLevelFilter = (log, std) => std === 'err' ? ts_common_1.LogLevel.Error : ts_common_1.LogLevel.Info;
7
- class InteractiveShell extends ts_common_1.Logger {
1
+ import { addItemToArrayAtIndex, currentTimeMillis, generateHex, Logger, LogLevel, removeItemFromArray } from '@nu-art/ts-common';
2
+ import { spawn } from 'node:child_process';
3
+ const defaultLogLevelFilter = (log, std) => std === 'err' ? LogLevel.Error : LogLevel.Info;
4
+ export class InteractiveShell extends Logger {
5
+ _debug = false;
6
+ logProcessors = [];
7
+ onCloseListeners = [];
8
+ shell;
9
+ alive;
10
+ logLevelFilter = defaultLogLevelFilter;
8
11
  /**
9
12
  * Constructs an InteractiveShell instance, initializes a detached shell session, and sets up log processors.
10
13
  */
11
14
  constructor() {
12
- var _a, _b;
13
15
  super();
14
- this._debug = false;
15
- this.logProcessors = [];
16
- this.logLevelFilter = defaultLogLevelFilter;
17
- /**
18
- * Executes a command in the interactive shell.
19
- * @param {string} command - The command to execute.
20
- */
21
- this.execute = (command) => {
22
- var _a;
23
- if (this._debug)
24
- this.logDebug(`executing: `, `"""\n${command}\n"""`);
25
- (_a = this.shell.stdin) === null || _a === void 0 ? void 0 : _a.write(command + '\n', 'utf-8', (err) => {
26
- if (err)
27
- this.logError(`error`, err);
28
- });
29
- };
30
- /**
31
- * Awaits for the end of the interactive shell session.
32
- */
33
- this.endInteractive = () => {
34
- return new Promise(resolve => {
35
- var _a;
36
- (_a = this.shell.stdin) === null || _a === void 0 ? void 0 : _a.end(resolve);
37
- });
38
- };
39
- /**
40
- * Sends a signal to terminate the shell process.
41
- * @param {NodeJS.Signals | number} [signal] - The signal to send to the shell process.
42
- * @returns {boolean | undefined} - The result of the kill operation.
43
- */
44
- this.kill = (signal) => {
45
- if (!this.alive)
46
- return;
47
- this.logWarning(`Killing......`);
48
- // return this.gracefullyKill(this.shell.pid);
49
- return this.shell.emit('exit', 2);
50
- };
51
- /**
52
- * Attempts to gracefully terminate the shell process.
53
- * @param {number} [pid] - Process ID of the shell to terminate.
54
- * @returns {Promise<void>} - Resolves when the shell process is gracefully killed.
55
- */
56
- this.gracefullyKill = async (pid) => {
57
- if (!this.alive)
58
- return;
59
- return new Promise((resolve, reject) => {
60
- this.logWarning('Killing process');
61
- this.shell.on('exit', async (code, signal) => {
62
- this.logWarning(`Process Killed ${signal}`);
63
- resolve();
64
- });
65
- if (pid) {
66
- this.logWarning(`KILLING PID: ${pid}`);
67
- process.kill(pid, 'SIGINT');
68
- }
69
- else {
70
- this.logWarning(`KILLING SHELL WITH SIGINT`);
71
- this.shell.kill('SIGINT');
72
- }
73
- });
74
- };
75
- this.shell = (0, node_child_process_1.spawn)('/bin/bash', {
16
+ this.setTag(`${this.constructor['name']}(${generateHex(4)})`);
17
+ this.shell = spawn('/bin/bash', {
76
18
  detached: true, // This is important to make the process a session leader
77
- shell: true
19
+ shell: true,
20
+ env: {
21
+ ...process.env,
22
+ NODE_OPTIONS: '' // Remove any --inspect flags
23
+ }
78
24
  });
79
25
  this.alive = true;
80
- const printer = (std) => (data) => {
81
- var _a;
26
+ const printer = (std) => async (data) => {
82
27
  const messages = data.toString().trim().split('\n');
83
28
  if (!messages.length)
84
29
  return;
85
30
  for (const message of messages) {
86
31
  try {
87
- const toPrint = this.logProcessors.length === 0 || this.logProcessors.reduce((toPrint, processor) => {
88
- const filter = processor(message, std);
89
- return toPrint && filter;
90
- }, true);
91
- if (toPrint) {
92
- const logLevel = (_a = this.logLevelFilter(message, std)) !== null && _a !== void 0 ? _a : defaultLogLevelFilter(message, std);
32
+ let consumed = false;
33
+ for (const processor of this.logProcessors) {
34
+ const result = await processor(message, std);
35
+ if (!result) {
36
+ consumed = true;
37
+ break;
38
+ }
39
+ }
40
+ if (!consumed) {
41
+ const logLevel = this.logLevelFilter(message, std) ?? defaultLogLevelFilter(message, std);
93
42
  this.log(logLevel, false, [message]);
94
43
  }
95
44
  }
@@ -98,12 +47,18 @@ class InteractiveShell extends ts_common_1.Logger {
98
47
  }
99
48
  }
100
49
  };
101
- (_a = this.shell.stdout) === null || _a === void 0 ? void 0 : _a.on('data', printer('out'));
102
- (_b = this.shell.stderr) === null || _b === void 0 ? void 0 : _b.on('data', printer('err'));
50
+ const stdoutPrinter = printer('out');
51
+ const stderrPrinter = printer('err');
52
+ this.shell.stdout?.on('data', stdoutPrinter);
53
+ this.shell.stderr?.on('data', stderrPrinter);
103
54
  // Handle shell exit
104
- this.shell.on('close', (code) => {
55
+ this.shell.on('close', async (code) => {
105
56
  this.alive = false;
106
- this.logInfo(`child process exited with code ${code}`);
57
+ code = code === null ? -1 : code;
58
+ this.onCloseListeners.forEach(listener => listener(code === null ? -1 : code));
59
+ const printer = code === 0 ? stdoutPrinter : stderrPrinter;
60
+ const string = `Process exited with code: ${code}`;
61
+ printer(Buffer.from(string));
107
62
  });
108
63
  }
109
64
  /**
@@ -112,29 +67,121 @@ class InteractiveShell extends ts_common_1.Logger {
112
67
  * @returns {boolean} - The current state of debug mode.
113
68
  */
114
69
  debug(debug) {
115
- this._debug = debug !== null && debug !== void 0 ? debug : !this._debug;
70
+ this._debug = debug ?? !this._debug;
116
71
  return this;
117
72
  }
73
+ /**
74
+ * Executes a command in the interactive shell.
75
+ * @param {string} command - The command to execute.
76
+ */
77
+ execute = (command) => {
78
+ this.logVerbose(`executing: `, `"""\n${command}\n"""`);
79
+ this.shell.stdin?.write(command + '\n', 'utf-8', (err) => {
80
+ if (err)
81
+ this.logError(`error`, err);
82
+ });
83
+ };
84
+ /**
85
+ * Awaits for the end of the interactive shell session.
86
+ */
87
+ endInteractive = () => {
88
+ return new Promise(resolve => {
89
+ this.shell.stdin?.end(resolve);
90
+ });
91
+ };
92
+ // Check if a given PID is alive
93
+ isAlive = (pid) => {
94
+ try {
95
+ process.kill(pid, 0); // Non-intrusive check
96
+ return true;
97
+ }
98
+ catch {
99
+ return false;
100
+ }
101
+ };
102
+ // Poll until a PID is no longer alive or timeout is hit
103
+ waitForExit = (pid, timeout = 10000, sampleInterval = 100) => {
104
+ const startTime = currentTimeMillis();
105
+ return new Promise((resolve, reject) => {
106
+ const check = () => {
107
+ if (!this.isAlive(pid))
108
+ return resolve();
109
+ if (currentTimeMillis() - startTime > timeout) {
110
+ this.logWarning(`PID ${pid} did not exit in time. Sending 'SIGTERM'.`);
111
+ try {
112
+ process.kill(pid, 'SIGTERM');
113
+ }
114
+ catch (e) {
115
+ this.logError(`Failed to send 'SIGTERM' to PID ${pid}`, e);
116
+ }
117
+ return reject(new Error(`PID ${pid} did not exit after ${timeout}ms`));
118
+ }
119
+ setTimeout(check, sampleInterval);
120
+ };
121
+ check();
122
+ });
123
+ };
124
+ // Kill the main shell process (interactive shell)
125
+ kill = async (signal = 'SIGINT', timeout = 10000) => {
126
+ if (!this.alive)
127
+ return;
128
+ this.logWarning(`Sending ${signal} to shell PID: ${this.shell.pid}`);
129
+ try {
130
+ this.shell.kill(signal);
131
+ }
132
+ catch (e) {
133
+ this.logError(`Failed to send ${signal} to shell`, e);
134
+ throw e;
135
+ }
136
+ await this.waitForExit(this.shell.pid, timeout);
137
+ this.logWarning(`Shell process PID ${this.shell.pid} terminated`);
138
+ };
139
+ // Kill a background subprocess PID without affecting the shell
140
+ killSubprocess = async (pid, signal = 'SIGINT', timeout = 10000) => {
141
+ if (!this.isAlive(pid)) {
142
+ this.logDebug(`Subprocess PID ${pid} already exited`);
143
+ return;
144
+ }
145
+ this.logWarning(`Sending ${signal} to subprocess PID: ${pid}`);
146
+ try {
147
+ process.kill(pid, signal);
148
+ }
149
+ catch (e) {
150
+ this.logError(`Failed to send ${signal} to subprocess`, e);
151
+ throw e;
152
+ }
153
+ await this.waitForExit(pid, timeout);
154
+ this.logWarning(`Subprocess PID ${pid} terminated`);
155
+ };
118
156
  /**
119
157
  * Adds a log processor to handle log messages.
120
158
  * @param {(log: string, std: LogTypes) => boolean} processor - The log processor function.
159
+ * @param index -
121
160
  * @returns {this} - The InteractiveShell instance for method chaining.
122
161
  */
123
- addLogProcessor(processor) {
124
- this.logProcessors.push(processor);
162
+ addLogProcessor(processor, index = this.logProcessors.length) {
163
+ addItemToArrayAtIndex(this.logProcessors, processor, index);
125
164
  return this;
126
165
  }
127
166
  setLogLevelFilter(logLevelFilter) {
128
167
  this.logLevelFilter = logLevelFilter;
129
168
  return this;
130
169
  }
170
+ addOnCloseListener(listener) {
171
+ this.onCloseListeners.push(listener);
172
+ return this;
173
+ }
174
+ removeOnCloseListener(listener) {
175
+ removeItemFromArray(this.onCloseListeners, listener);
176
+ return this;
177
+ }
131
178
  /**
132
179
  * Removes a log processor from handling log messages.
133
180
  * @param {(log: string, std: LogTypes) => boolean} processor - The log processor function to remove.
134
181
  * @returns {this} - The InteractiveShell instance for method chaining.
135
182
  */
136
183
  removeLogProcessor(processor) {
137
- (0, ts_common_1.removeItemFromArray)(this.logProcessors, processor);
184
+ removeItemFromArray(this.logProcessors, processor);
138
185
  return this;
139
186
  }
140
187
  /**
@@ -147,4 +194,4 @@ class InteractiveShell extends ts_common_1.Logger {
147
194
  return this;
148
195
  }
149
196
  }
150
- exports.InteractiveShell = InteractiveShell;
197
+ //# sourceMappingURL=InteractiveShell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractiveShell.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/commando/src/main/","sources":["shell/interactive/InteractiveShell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC/H,OAAO,EAA+C,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAQvF,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,GAAa,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAI7G,MAAM,OAAO,gBACZ,SAAQ,MAAM;IAEN,MAAM,GAAY,KAAK,CAAC;IACxB,aAAa,GAA0B,EAAE,CAAC;IAC1C,gBAAgB,GAAwB,EAAE,CAAC;IAC3C,KAAK,CAAgD;IACrD,KA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C,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IACb,CAAC;IAGD;;;;OAIG;IACH,kBAAkB,CAAC,SAA4B;QAC9C,mBAAmB,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QACjB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
@@ -1,5 +1,5 @@
1
- import { BaseCommando } from '../core/BaseCommando';
2
- import { CliBlock } from '../types';
1
+ import { BaseCommando } from '../core/BaseCommando.js';
2
+ import { CliBlock } from '../types.js';
3
3
  type Cli_EchoOptions = {
4
4
  escape?: boolean;
5
5
  toFile?: {