@nu-art/commando 0.400.14 → 0.401.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 (43) hide show
  1. package/cli-params/CLIParamsResolver.d.ts +56 -3
  2. package/cli-params/CLIParamsResolver.js +61 -4
  3. package/cli-params/consts.d.ts +37 -0
  4. package/cli-params/consts.js +38 -1
  5. package/cli-params/types.d.ts +29 -1
  6. package/package.json +23 -11
  7. package/shell/core/BaseCommando.d.ts +36 -6
  8. package/shell/core/BaseCommando.js +36 -6
  9. package/shell/core/CliError.d.ts +35 -0
  10. package/shell/core/CliError.js +36 -1
  11. package/shell/core/CommandBuilder.d.ts +27 -2
  12. package/shell/core/CommandBuilder.js +32 -3
  13. package/shell/core/CommandoPool.d.ts +33 -0
  14. package/shell/core/CommandoPool.js +34 -0
  15. package/shell/core/class-merger.d.ts +29 -10
  16. package/shell/core/class-merger.js +23 -8
  17. package/shell/interactive/CommandoInteractive.d.ts +66 -6
  18. package/shell/interactive/CommandoInteractive.js +69 -6
  19. package/shell/interactive/InteractiveShell.d.ts +38 -0
  20. package/shell/interactive/InteractiveShell.js +25 -0
  21. package/shell/plugins/basic.d.ts +90 -9
  22. package/shell/plugins/basic.js +90 -9
  23. package/shell/plugins/git.d.ts +115 -0
  24. package/shell/plugins/git.js +124 -9
  25. package/shell/plugins/nvm.d.ts +47 -0
  26. package/shell/plugins/nvm.js +47 -0
  27. package/shell/plugins/pnpm.d.ts +31 -0
  28. package/shell/plugins/pnpm.js +31 -0
  29. package/shell/plugins/programming.d.ts +23 -3
  30. package/shell/plugins/programming.js +23 -3
  31. package/shell/plugins/python.d.ts +31 -0
  32. package/shell/plugins/python.js +32 -0
  33. package/shell/services/nvm.d.ts +59 -1
  34. package/shell/services/nvm.js +67 -6
  35. package/shell/services/pnpm.d.ts +41 -0
  36. package/shell/services/pnpm.js +41 -0
  37. package/shell/simple/Commando.d.ts +75 -0
  38. package/shell/simple/Commando.js +75 -0
  39. package/shell/simple/SimpleShell.d.ts +29 -2
  40. package/shell/simple/SimpleShell.js +32 -2
  41. package/shell/tools.d.ts +30 -0
  42. package/shell/tools.js +30 -0
  43. package/shell/types.d.ts +14 -0
@@ -4,7 +4,25 @@ import { Commando_Basic } from './basic.js';
4
4
  import { Commando_Programming } from './programming.js';
5
5
  import { Commando_NVM } from './nvm.js';
6
6
  const Super = MergeClass(BaseCommando, Commando_Programming, Commando_Basic, Commando_NVM);
7
+ /**
8
+ * PNPM package manager plugin for Commando.
9
+ *
10
+ * Provides PNPM operations:
11
+ * - Install PNPM
12
+ * - Get PNPM version
13
+ * - Install packages (with store prune and force flags)
14
+ *
15
+ * Extends Commando_NVM, Commando_Programming, and Commando_Basic (merged).
16
+ * Requires NVM for Node.js version management.
17
+ */
7
18
  export class Commando_PNPM extends Super {
19
+ /**
20
+ * Installs packages using PNPM.
21
+ *
22
+ * Prunes the store, then installs with force flag and no frozen lockfile.
23
+ *
24
+ * @returns This instance for method chaining
25
+ */
8
26
  async installPackages() {
9
27
  await this
10
28
  .append(`pnpm store prune`)
@@ -12,12 +30,25 @@ export class Commando_PNPM extends Super {
12
30
  .execute();
13
31
  return this;
14
32
  }
33
+ /**
34
+ * Installs PNPM by downloading and executing the install script.
35
+ *
36
+ * @param version - PNPM version to install
37
+ * @returns This instance for method chaining
38
+ */
15
39
  async install(version) {
16
40
  await this
17
41
  .append(`curl -fsSL "https://get.pnpm.io/install.sh" | env PNPM_VERSION=${version} bash -`)
18
42
  .execute();
19
43
  return this;
20
44
  }
45
+ /**
46
+ * Gets the installed PNPM version.
47
+ *
48
+ * Only executes if PNPM is available (checks with `command -v pnpm`).
49
+ *
50
+ * @returns Promise resolving to PNPM version string (trimmed)
51
+ */
21
52
  async getVersion() {
22
53
  return this.if('[[ -x "$(command -v pnpm)" ]]', (commando) => {
23
54
  commando.append('pnpm --version');
@@ -1,5 +1,16 @@
1
1
  import { BaseCommando } from '../core/BaseCommando.js';
2
2
  import { CliBlock } from '../types.js';
3
+ /**
4
+ * Programming constructs plugin for Commando.
5
+ *
6
+ * Provides control flow structures for building shell scripts:
7
+ * - Conditionals (`if`/`else`)
8
+ * - Loops (`for`, `while`)
9
+ * - Functions
10
+ *
11
+ * These methods build shell script structures with proper indentation
12
+ * and syntax, allowing programmatic construction of complex shell scripts.
13
+ */
3
14
  export declare class Commando_Programming extends BaseCommando {
4
15
  /**
5
16
  * Constructs an if-else conditional command structure.
@@ -19,17 +30,26 @@ export declare class Commando_Programming extends BaseCommando {
19
30
  for(varName: string, arrayNameOrValues: string | string[], loop: CliBlock<this>): this;
20
31
  /**
21
32
  * Appends a 'continue' command for loop control.
22
- * @returns {this} - The Cli instance for method chaining.
33
+ *
34
+ * Skips to the next iteration of the innermost loop.
35
+ *
36
+ * @returns This instance for method chaining
23
37
  */
24
38
  continue(): this;
25
39
  /**
26
40
  * Appends a 'break' command for loop control.
27
- * @returns {this} - The Cli instance for method chaining.
41
+ *
42
+ * Exits the innermost loop.
43
+ *
44
+ * @returns This instance for method chaining
28
45
  */
29
46
  break(): this;
30
47
  /**
31
48
  * Appends a 'return' command for exiting a function or script.
32
- * @returns {this} - The Cli instance for method chaining.
49
+ *
50
+ * Exits the current function or script with optional exit code.
51
+ *
52
+ * @returns This instance for method chaining
33
53
  */
34
54
  return(): this;
35
55
  }
@@ -1,4 +1,15 @@
1
1
  import { BaseCommando } from '../core/BaseCommando.js';
2
+ /**
3
+ * Programming constructs plugin for Commando.
4
+ *
5
+ * Provides control flow structures for building shell scripts:
6
+ * - Conditionals (`if`/`else`)
7
+ * - Loops (`for`, `while`)
8
+ * - Functions
9
+ *
10
+ * These methods build shell script structures with proper indentation
11
+ * and syntax, allowing programmatic construction of complex shell scripts.
12
+ */
2
13
  export class Commando_Programming extends BaseCommando {
3
14
  /**
4
15
  * Constructs an if-else conditional command structure.
@@ -46,7 +57,10 @@ export class Commando_Programming extends BaseCommando {
46
57
  }
47
58
  /**
48
59
  * Appends a 'continue' command for loop control.
49
- * @returns {this} - The Cli instance for method chaining.
60
+ *
61
+ * Skips to the next iteration of the innermost loop.
62
+ *
63
+ * @returns This instance for method chaining
50
64
  */
51
65
  continue() {
52
66
  this.append('continue');
@@ -54,7 +68,10 @@ export class Commando_Programming extends BaseCommando {
54
68
  }
55
69
  /**
56
70
  * Appends a 'break' command for loop control.
57
- * @returns {this} - The Cli instance for method chaining.
71
+ *
72
+ * Exits the innermost loop.
73
+ *
74
+ * @returns This instance for method chaining
58
75
  */
59
76
  break() {
60
77
  this.append('break');
@@ -62,7 +79,10 @@ export class Commando_Programming extends BaseCommando {
62
79
  }
63
80
  /**
64
81
  * Appends a 'return' command for exiting a function or script.
65
- * @returns {this} - The Cli instance for method chaining.
82
+ *
83
+ * Exits the current function or script with optional exit code.
84
+ *
85
+ * @returns This instance for method chaining
66
86
  */
67
87
  return() {
68
88
  this.append('return');
@@ -2,9 +2,40 @@ import { BaseCommando } from '../core/BaseCommando.js';
2
2
  import { Commando_Programming } from './programming.js';
3
3
  import { Commando_Basic } from './basic.js';
4
4
  declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando & Commando_Programming & Commando_Basic>;
5
+ /**
6
+ * Python 3 plugin for Commando.
7
+ *
8
+ * Provides Python virtual environment operations:
9
+ * - Create virtual environments
10
+ * - Activate virtual environments
11
+ * - Install requirements from requirements.txt
12
+ *
13
+ * Extends Commando_Programming and Commando_Basic (merged).
14
+ */
5
15
  export declare class Commando_Python3 extends Super {
16
+ /**
17
+ * Activates a Python virtual environment.
18
+ *
19
+ * Sources the activation script for the virtual environment.
20
+ *
21
+ * @param venvFolder - Virtual environment folder path (default: '.venv')
22
+ * @returns This instance for method chaining
23
+ */
6
24
  sourceVenv(venvFolder?: string): this;
25
+ /**
26
+ * Creates a Python virtual environment.
27
+ *
28
+ * @param venvFolder - Virtual environment folder path (default: '.venv')
29
+ * @returns This instance for method chaining
30
+ * @throws Exception if virtual environment creation fails
31
+ */
7
32
  installVenv(venvFolder?: string): Promise<this>;
33
+ /**
34
+ * Installs Python packages from a requirements file.
35
+ *
36
+ * @param pathToRequirementsFile - Path to requirements.txt file (default: './requirements.txt')
37
+ * @returns This instance for method chaining
38
+ */
8
39
  installRequirements(pathToRequirementsFile?: string): Promise<this>;
9
40
  }
10
41
  export {};
@@ -4,12 +4,38 @@ import { MergeClass } from '../core/class-merger.js';
4
4
  import { Commando_Basic } from './basic.js';
5
5
  import { Exception } from '@nu-art/ts-common';
6
6
  const Super = MergeClass(BaseCommando, Commando_Programming, Commando_Basic);
7
+ /** Default virtual environment folder name */
7
8
  const DefaultVenvFolder = '.venv';
9
+ /**
10
+ * Python 3 plugin for Commando.
11
+ *
12
+ * Provides Python virtual environment operations:
13
+ * - Create virtual environments
14
+ * - Activate virtual environments
15
+ * - Install requirements from requirements.txt
16
+ *
17
+ * Extends Commando_Programming and Commando_Basic (merged).
18
+ */
8
19
  export class Commando_Python3 extends Super {
20
+ /**
21
+ * Activates a Python virtual environment.
22
+ *
23
+ * Sources the activation script for the virtual environment.
24
+ *
25
+ * @param venvFolder - Virtual environment folder path (default: '.venv')
26
+ * @returns This instance for method chaining
27
+ */
9
28
  sourceVenv(venvFolder = DefaultVenvFolder) {
10
29
  this.append(`source ${venvFolder}/bin/activate`);
11
30
  return this;
12
31
  }
32
+ /**
33
+ * Creates a Python virtual environment.
34
+ *
35
+ * @param venvFolder - Virtual environment folder path (default: '.venv')
36
+ * @returns This instance for method chaining
37
+ * @throws Exception if virtual environment creation fails
38
+ */
13
39
  async installVenv(venvFolder = DefaultVenvFolder) {
14
40
  this.append(`python3 -m venv ${venvFolder}`);
15
41
  await this.execute((stdout, stderr, exitCode) => {
@@ -18,6 +44,12 @@ export class Commando_Python3 extends Super {
18
44
  });
19
45
  return this;
20
46
  }
47
+ /**
48
+ * Installs Python packages from a requirements file.
49
+ *
50
+ * @param pathToRequirementsFile - Path to requirements.txt file (default: './requirements.txt')
51
+ * @returns This instance for method chaining
52
+ */
21
53
  async installRequirements(pathToRequirementsFile = './requirements.txt') {
22
54
  await this.append(`pip3 install -r ${pathToRequirementsFile}`)
23
55
  .execute();
@@ -1,5 +1,17 @@
1
1
  import { Logger } from '@nu-art/ts-common';
2
2
  import { Commando_NVM } from '../plugins/nvm.js';
3
+ /**
4
+ * NVM (Node Version Manager) service for managing Node.js installations.
5
+ *
6
+ * Handles installation, version management, and configuration of NVM.
7
+ * Works with Commando_NVM plugin to execute NVM commands.
8
+ *
9
+ * **Features**:
10
+ * - Install/uninstall NVM
11
+ * - Configure shell RC files (.bashrc, .zshrc)
12
+ * - Version management
13
+ * - Integration with .nvmrc files
14
+ */
3
15
  export declare class Cli_NVM extends Logger {
4
16
  private _expectedVersion;
5
17
  private _homeEnvVar;
@@ -8,11 +20,57 @@ export declare class Cli_NVM extends Logger {
8
20
  set homeEnvVar(value: string);
9
21
  get expectedVersion(): string;
10
22
  set expectedVersion(value: string);
11
- install: (commando: Commando_NVM) => Promise<boolean | this | undefined>;
23
+ /**
24
+ * Installs NVM and configures shell RC files.
25
+ *
26
+ * **Behavior**:
27
+ * - Checks if NVM is already installed with expected version
28
+ * - Uninstalls if version mismatch
29
+ * - Installs NVM via Commando_NVM
30
+ * - Configures .bashrc with NVM initialization (if not already present)
31
+ *
32
+ *
33
+ * @param commando - Commando_NVM instance to use for installation
34
+ * @returns This instance for method chaining
35
+ */
36
+ install: (commando: Commando_NVM) => Promise<this | undefined>;
37
+ /**
38
+ * Checks if NVM is installed.
39
+ *
40
+ * Verifies both environment variable and directory existence.
41
+ *
42
+ * @returns True if NVM is installed
43
+ */
12
44
  isInstalled: () => boolean;
45
+ /**
46
+ * Reads the required Node.js version from .nvmrc file.
47
+ *
48
+ * @returns Promise resolving to version string from .nvmrc
49
+ * @throws Error if .nvmrc file doesn't exist
50
+ */
13
51
  getRequiredNode_Version: () => Promise<string>;
52
+ /**
53
+ * Installs required Node.js version if not already installed.
54
+ *
55
+ * Reads .nvmrc, checks installed versions, and installs if missing.
56
+ *
57
+ * @param commando - Commando_NVM instance to use
58
+ * @returns True if version was installed, false if already present
59
+ */
14
60
  installRequiredVersionIfNeeded: (commando: Commando_NVM) => Promise<boolean>;
61
+ /**
62
+ * Uninstalls NVM by removing its directory.
63
+ *
64
+ * @returns Promise that resolves when uninstall completes
65
+ */
15
66
  uninstall: () => Promise<void>;
67
+ /**
68
+ * Installs a specific Node.js version via NVM.
69
+ *
70
+ * @param commando - Commando_NVM instance to use
71
+ * @param requiredVersion - Optional version (defaults to .nvmrc value)
72
+ * @returns Promise that resolves when installation completes
73
+ */
16
74
  private installVersion;
17
75
  }
18
76
  export declare const NVM: Cli_NVM;
@@ -3,6 +3,18 @@ import { promises as _fs } from 'fs';
3
3
  import * as path from 'path';
4
4
  import { Logger, LogLevel } from '@nu-art/ts-common';
5
5
  const CONST__FILE_NVMRC = '.nvmrc';
6
+ /**
7
+ * NVM (Node Version Manager) service for managing Node.js installations.
8
+ *
9
+ * Handles installation, version management, and configuration of NVM.
10
+ * Works with Commando_NVM plugin to execute NVM commands.
11
+ *
12
+ * **Features**:
13
+ * - Install/uninstall NVM
14
+ * - Configure shell RC files (.bashrc, .zshrc)
15
+ * - Version management
16
+ * - Integration with .nvmrc files
17
+ */
6
18
  export class Cli_NVM extends Logger {
7
19
  _expectedVersion = '0.39.7';
8
20
  _homeEnvVar = '$NVM_DIR';
@@ -22,6 +34,19 @@ export class Cli_NVM extends Logger {
22
34
  set expectedVersion(value) {
23
35
  this._expectedVersion = value;
24
36
  }
37
+ /**
38
+ * Installs NVM and configures shell RC files.
39
+ *
40
+ * **Behavior**:
41
+ * - Checks if NVM is already installed with expected version
42
+ * - Uninstalls if version mismatch
43
+ * - Installs NVM via Commando_NVM
44
+ * - Configures .bashrc with NVM initialization (if not already present)
45
+ *
46
+ *
47
+ * @param commando - Commando_NVM instance to use for installation
48
+ * @returns This instance for method chaining
49
+ */
25
50
  install = async (commando) => {
26
51
  if (this.isInstalled()) {
27
52
  const version = (await commando.getVersion()).trim();
@@ -34,18 +59,34 @@ export class Cli_NVM extends Logger {
34
59
  let rcFileContent = '';
35
60
  if (fs.existsSync(rcFile)) {
36
61
  rcFileContent = await _fs.readFile(rcFile, { encoding: 'utf8' });
37
- return rcFileContent.includes('NVM_DIR');
62
+ // If NVM is already configured, don't add it again
63
+ if (rcFileContent.includes('NVM_DIR'))
64
+ return this;
38
65
  }
39
- rcFileContent = `${rcFileContent}\n${rcFileContent.endsWith('\n') ? '' : '\n'}`;
66
+ // Append NVM initialization to the end of the file
67
+ rcFileContent = `${rcFileContent}${rcFileContent.endsWith('\n') ? '' : '\n'}`;
40
68
  rcFileContent += `# generated NVM - start\n`;
41
- rcFileContent += `echo 'export NVM_DIR="$HOME/.nvm"'\n`;
42
- rcFileContent += `echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm'\n`;
43
- rcFileContent += `echo '[ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion" # This loads nvm bash_completion'\n`;
69
+ rcFileContent += `export NVM_DIR="$HOME/.nvm"\n`;
70
+ rcFileContent += `[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm\n`;
71
+ rcFileContent += `[ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion" # This loads nvm bash_completion\n`;
44
72
  rcFileContent += `# generated NVM - end\n`;
45
73
  await _fs.writeFile(rcFile, rcFileContent, { encoding: 'utf8' });
46
74
  return this;
47
75
  };
76
+ /**
77
+ * Checks if NVM is installed.
78
+ *
79
+ * Verifies both environment variable and directory existence.
80
+ *
81
+ * @returns True if NVM is installed
82
+ */
48
83
  isInstalled = () => !!process.env[this._homeEnvVar] && fs.existsSync(process.env[this._homeEnvVar]);
84
+ /**
85
+ * Reads the required Node.js version from .nvmrc file.
86
+ *
87
+ * @returns Promise resolving to version string from .nvmrc
88
+ * @throws Error if .nvmrc file doesn't exist
89
+ */
49
90
  getRequiredNode_Version = async () => {
50
91
  const absolutePathToNvmrcFile = path.resolve(CONST__FILE_NVMRC);
51
92
  if (!fs.existsSync(absolutePathToNvmrcFile))
@@ -53,6 +94,14 @@ export class Cli_NVM extends Logger {
53
94
  const content = await _fs.readFile(absolutePathToNvmrcFile, { encoding: 'utf-8' });
54
95
  return content.trim();
55
96
  };
97
+ /**
98
+ * Installs required Node.js version if not already installed.
99
+ *
100
+ * Reads .nvmrc, checks installed versions, and installs if missing.
101
+ *
102
+ * @param commando - Commando_NVM instance to use
103
+ * @returns True if version was installed, false if already present
104
+ */
56
105
  installRequiredVersionIfNeeded = async (commando) => {
57
106
  const requiredVersion = await this.getRequiredNode_Version();
58
107
  const installedVersions = await commando.getInstalledNodeVersions();
@@ -62,13 +111,25 @@ export class Cli_NVM extends Logger {
62
111
  await this.installVersion(commando, requiredVersion);
63
112
  return true;
64
113
  };
114
+ /**
115
+ * Uninstalls NVM by removing its directory.
116
+ *
117
+ * @returns Promise that resolves when uninstall completes
118
+ */
65
119
  uninstall = async () => {
66
- this.logDebug('Uninstalling PNPM');
120
+ this.logDebug('Uninstalling NVM');
67
121
  const absolutePathToNVM_Home = process.env[this._homeEnvVar];
68
122
  if (!absolutePathToNVM_Home)
69
123
  return;
70
124
  fs.rmSync(absolutePathToNVM_Home, { recursive: true, force: true });
71
125
  };
126
+ /**
127
+ * Installs a specific Node.js version via NVM.
128
+ *
129
+ * @param commando - Commando_NVM instance to use
130
+ * @param requiredVersion - Optional version (defaults to .nvmrc value)
131
+ * @returns Promise that resolves when installation completes
132
+ */
72
133
  installVersion = async (commando, requiredVersion) => {
73
134
  requiredVersion ??= await this.getRequiredNode_Version();
74
135
  this.logDebug(`Installing version: ${requiredVersion}`);
@@ -1,5 +1,17 @@
1
1
  import { Logger } from '@nu-art/ts-common';
2
2
  import { Commando_PNPM } from '../plugins/pnpm.js';
3
+ /**
4
+ * PNPM package manager service for managing PNPM installations.
5
+ *
6
+ * Handles installation, version management, and package operations.
7
+ * Works with Commando_PNPM plugin to execute PNPM commands.
8
+ *
9
+ * **Features**:
10
+ * - Install/uninstall PNPM
11
+ * - Version management
12
+ * - Package installation
13
+ * - Environment variable configuration
14
+ */
3
15
  export declare class Cli_PNPM extends Logger {
4
16
  private _expectedVersion;
5
17
  private _homeEnvVar;
@@ -8,9 +20,38 @@ export declare class Cli_PNPM extends Logger {
8
20
  set homeEnvVar(value: string);
9
21
  get expectedVersion(): string;
10
22
  set expectedVersion(value: string);
23
+ /**
24
+ * Installs PNPM with the expected version.
25
+ *
26
+ * Checks if PNPM is already installed with the expected version.
27
+ * Uninstalls and reinstalls if version mismatch.
28
+ *
29
+ * @param commando - Commando_PNPM instance to use for installation
30
+ * @returns This instance for method chaining
31
+ */
11
32
  install: (commando: Commando_PNPM) => Promise<this | undefined>;
33
+ /**
34
+ * Checks if PNPM is installed.
35
+ *
36
+ * Verifies environment variable is set.
37
+ *
38
+ * @returns True if PNPM_HOME environment variable is set
39
+ */
12
40
  isInstalled: () => boolean;
41
+ /**
42
+ * Installs packages using PNPM.
43
+ *
44
+ * Delegates to Commando_PNPM.installPackages().
45
+ *
46
+ * @param commando - Commando_PNPM instance to use
47
+ * @returns Promise that resolves when packages are installed
48
+ */
13
49
  installPackages: (commando: Commando_PNPM) => Promise<Commando_PNPM>;
50
+ /**
51
+ * Uninstalls PNPM by removing its home directory.
52
+ *
53
+ * @returns Promise that resolves when uninstall completes
54
+ */
14
55
  uninstall: () => Promise<void>;
15
56
  /**
16
57
  * Asynchronously creates a workspace file with a list of packages.
@@ -1,6 +1,18 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { Logger, LogLevel } from '@nu-art/ts-common';
3
3
  import { convertToFullPath } from '../tools.js';
4
+ /**
5
+ * PNPM package manager service for managing PNPM installations.
6
+ *
7
+ * Handles installation, version management, and package operations.
8
+ * Works with Commando_PNPM plugin to execute PNPM commands.
9
+ *
10
+ * **Features**:
11
+ * - Install/uninstall PNPM
12
+ * - Version management
13
+ * - Package installation
14
+ * - Environment variable configuration
15
+ */
4
16
  export class Cli_PNPM extends Logger {
5
17
  _expectedVersion = '10.7.0';
6
18
  _homeEnvVar = 'PNPM_HOME';
@@ -20,6 +32,15 @@ export class Cli_PNPM extends Logger {
20
32
  set expectedVersion(value) {
21
33
  this._expectedVersion = value;
22
34
  }
35
+ /**
36
+ * Installs PNPM with the expected version.
37
+ *
38
+ * Checks if PNPM is already installed with the expected version.
39
+ * Uninstalls and reinstalls if version mismatch.
40
+ *
41
+ * @param commando - Commando_PNPM instance to use for installation
42
+ * @returns This instance for method chaining
43
+ */
23
44
  install = async (commando) => {
24
45
  if (this.isInstalled()) {
25
46
  const version = (await commando.getVersion());
@@ -31,10 +52,30 @@ export class Cli_PNPM extends Logger {
31
52
  await commando.install(this._expectedVersion);
32
53
  return this;
33
54
  };
55
+ /**
56
+ * Checks if PNPM is installed.
57
+ *
58
+ * Verifies environment variable is set.
59
+ *
60
+ * @returns True if PNPM_HOME environment variable is set
61
+ */
34
62
  isInstalled = () => !!process.env[this._homeEnvVar];
63
+ /**
64
+ * Installs packages using PNPM.
65
+ *
66
+ * Delegates to Commando_PNPM.installPackages().
67
+ *
68
+ * @param commando - Commando_PNPM instance to use
69
+ * @returns Promise that resolves when packages are installed
70
+ */
35
71
  installPackages = async (commando) => {
36
72
  return await commando.installPackages();
37
73
  };
74
+ /**
75
+ * Uninstalls PNPM by removing its home directory.
76
+ *
77
+ * @returns Promise that resolves when uninstall completes
78
+ */
38
79
  uninstall = async () => {
39
80
  this.logDebug('Uninstalling PNPM');
40
81
  const absolutePathToPNPM_Home = process.env[this._homeEnvVar];
@@ -1,17 +1,92 @@
1
1
  import { Constructor } from '@nu-art/ts-common';
2
2
  import { BaseCommando } from '../core/BaseCommando.js';
3
+ /**
4
+ * Simple shell command executor extending BaseCommando.
5
+ *
6
+ * Provides a straightforward way to build and execute shell commands
7
+ * using SimpleShell. Supports file execution and remote file execution.
8
+ *
9
+ * **Features**:
10
+ * - Command building via BaseCommando fluent API
11
+ * - File execution with optional interpreter
12
+ * - Remote file execution via curl
13
+ * - Error handling with CliError
14
+ * - UID tagging for log identification
15
+ *
16
+ * **Error Handling**:
17
+ * - Catches CliError and calls callback with error details
18
+ * - Throws ThisShouldNotHappenException for unexpected errors
19
+ * - Always calls callback (even on error) if provided
20
+ */
3
21
  export declare class Commando extends BaseCommando {
22
+ /** Optional unique identifier for log tagging */
4
23
  private uid?;
24
+ /**
25
+ * Creates a Commando instance with plugins.
26
+ *
27
+ * @template T - Array of plugin constructor types
28
+ * @param plugins - Plugin classes to merge
29
+ * @returns Merged Commando instance with plugins
30
+ */
5
31
  static create<T extends Constructor<any>[]>(...plugins: T): (import("../core/class-merger.js").MergeTypes<[typeof BaseCommando, typeof Commando, ...T]> & BaseCommando) & Commando;
6
32
  constructor();
33
+ /**
34
+ * Sets a unique identifier for this commando instance.
35
+ *
36
+ * Used for log tagging to identify which commando instance
37
+ * generated log messages.
38
+ *
39
+ * @param uid - Unique identifier string
40
+ * @returns This instance for method chaining
41
+ */
7
42
  setUID(uid: string): this;
43
+ /**
44
+ * Executes a local file with an optional interpreter.
45
+ *
46
+ * If an interpreter is provided, prefixes the file path with it.
47
+ * Otherwise executes the file directly (must be executable).
48
+ *
49
+ * @param filePath - Path to file to execute
50
+ * @param interpreter - Optional interpreter (e.g., 'node', 'python3')
51
+ * @returns Promise resolving to command output
52
+ */
8
53
  executeFile(filePath: string, interpreter?: string): Promise<{
9
54
  stdout: string;
10
55
  stderr: string;
11
56
  }>;
57
+ /**
58
+ * Executes a remote file by downloading and piping to interpreter.
59
+ *
60
+ * Uses curl to download the file and pipes it directly to the interpreter.
61
+ * Does not save the file locally.
62
+ *
63
+ * **Security Note**: Executes remote code without verification.
64
+ *
65
+ * @param pathToFile - URL to remote file
66
+ * @param interpreter - Interpreter to execute the file (e.g., 'bash', 'node')
67
+ * @returns Promise resolving to command output
68
+ */
12
69
  executeRemoteFile(pathToFile: string, interpreter: string): Promise<{
13
70
  stdout: string;
14
71
  stderr: string;
15
72
  }>;
73
+ /**
74
+ * Executes the accumulated commands and optionally processes output.
75
+ *
76
+ * **Behavior**:
77
+ * - Resets the command builder (gets accumulated command)
78
+ * - Creates a new SimpleShell instance with debug mode
79
+ * - Executes the command
80
+ * - On success: calls callback with stdout, stderr, exitCode=0
81
+ * - On error: catches CliError, calls callback with error details, returns result
82
+ * - On unexpected error: throws ThisShouldNotHappenException
83
+ *
84
+ * **Note**: The callback is always called if provided, even on error.
85
+ * This allows handling errors without try/catch.
86
+ *
87
+ * @template T - Return type of callback
88
+ * @param callback - Optional function to process command output
89
+ * @returns Promise resolving to callback result or void
90
+ */
16
91
  execute<T>(callback?: (stdout: string, stderr: string, exitCode: number) => T): Promise<T | void>;
17
92
  }