@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.
- package/cli-params/CLIParamsResolver.d.ts +56 -3
- package/cli-params/CLIParamsResolver.js +61 -4
- package/cli-params/consts.d.ts +37 -0
- package/cli-params/consts.js +38 -1
- package/cli-params/types.d.ts +29 -1
- package/package.json +23 -11
- package/shell/core/BaseCommando.d.ts +36 -6
- package/shell/core/BaseCommando.js +36 -6
- package/shell/core/CliError.d.ts +35 -0
- package/shell/core/CliError.js +36 -1
- package/shell/core/CommandBuilder.d.ts +27 -2
- package/shell/core/CommandBuilder.js +32 -3
- package/shell/core/CommandoPool.d.ts +33 -0
- package/shell/core/CommandoPool.js +34 -0
- package/shell/core/class-merger.d.ts +29 -10
- package/shell/core/class-merger.js +23 -8
- package/shell/interactive/CommandoInteractive.d.ts +66 -6
- package/shell/interactive/CommandoInteractive.js +69 -6
- package/shell/interactive/InteractiveShell.d.ts +38 -0
- package/shell/interactive/InteractiveShell.js +25 -0
- package/shell/plugins/basic.d.ts +90 -9
- package/shell/plugins/basic.js +90 -9
- package/shell/plugins/git.d.ts +115 -0
- package/shell/plugins/git.js +124 -9
- package/shell/plugins/nvm.d.ts +47 -0
- package/shell/plugins/nvm.js +47 -0
- package/shell/plugins/pnpm.d.ts +31 -0
- package/shell/plugins/pnpm.js +31 -0
- package/shell/plugins/programming.d.ts +23 -3
- package/shell/plugins/programming.js +23 -3
- package/shell/plugins/python.d.ts +31 -0
- package/shell/plugins/python.js +32 -0
- package/shell/services/nvm.d.ts +59 -1
- package/shell/services/nvm.js +67 -6
- package/shell/services/pnpm.d.ts +41 -0
- package/shell/services/pnpm.js +41 -0
- package/shell/simple/Commando.d.ts +75 -0
- package/shell/simple/Commando.js +75 -0
- package/shell/simple/SimpleShell.d.ts +29 -2
- package/shell/simple/SimpleShell.js +32 -2
- package/shell/tools.d.ts +30 -0
- package/shell/tools.js +30 -0
- package/shell/types.d.ts +14 -0
package/shell/plugins/basic.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { BaseCommando } from '../core/BaseCommando.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Basic shell command plugin for Commando.
|
|
4
|
+
*
|
|
5
|
+
* Provides common file system and shell operations:
|
|
6
|
+
* - Directory navigation (`cd`, `pwd`)
|
|
7
|
+
* - File operations (`ls`, `cat`, `mkdir`, `rm`, `rmdir`, `cpdir`)
|
|
8
|
+
* - Variable assignment
|
|
9
|
+
* - Echo with options (escape sequences, file output)
|
|
10
|
+
*
|
|
11
|
+
* **Usage**: Merge with BaseCommando or other Commando classes to add
|
|
12
|
+
* these methods. Typically included via `CommandoPool.allocateCommando()`.
|
|
4
13
|
*/
|
|
5
14
|
export class Commando_Basic extends BaseCommando {
|
|
6
15
|
/**
|
|
7
|
-
* Changes directory and optionally executes
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
16
|
+
* Changes directory and optionally executes commands in that directory.
|
|
17
|
+
*
|
|
18
|
+
* **Behavior**:
|
|
19
|
+
* - Changes to the specified directory
|
|
20
|
+
* - Increases indentation (for script readability)
|
|
21
|
+
* - If `toRun` provided, executes the block and returns to previous directory
|
|
22
|
+
* - If `toRun` not provided, caller must call `cd_()` to return
|
|
23
|
+
*
|
|
24
|
+
* **Note**: Uses `cd -` to return to previous directory (OLDPWD).
|
|
25
|
+
*
|
|
26
|
+
* @param folderName - Directory path to change to
|
|
27
|
+
* @param toRun - Optional command block to execute in the directory
|
|
28
|
+
* @returns This instance for method chaining
|
|
11
29
|
*/
|
|
12
30
|
cd(folderName, toRun) {
|
|
13
31
|
this.append(`cd ${folderName}`);
|
|
@@ -18,6 +36,15 @@ export class Commando_Basic extends BaseCommando {
|
|
|
18
36
|
}
|
|
19
37
|
return this;
|
|
20
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Appends a custom command string.
|
|
41
|
+
*
|
|
42
|
+
* Allows adding arbitrary shell commands that aren't covered by
|
|
43
|
+
* the built-in methods.
|
|
44
|
+
*
|
|
45
|
+
* @param command - Custom shell command to append
|
|
46
|
+
* @returns This instance for method chaining
|
|
47
|
+
*/
|
|
21
48
|
custom(command) {
|
|
22
49
|
this.append(command);
|
|
23
50
|
return this;
|
|
@@ -40,10 +67,25 @@ export class Commando_Basic extends BaseCommando {
|
|
|
40
67
|
this.append(`ls ${params}`);
|
|
41
68
|
return this;
|
|
42
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a directory (with parent directories if needed).
|
|
72
|
+
*
|
|
73
|
+
* Uses `mkdir -p` to create directory and all parent directories.
|
|
74
|
+
*
|
|
75
|
+
* @param dirName - Directory path to create
|
|
76
|
+
* @returns This instance for method chaining
|
|
77
|
+
*/
|
|
43
78
|
mkdir(dirName) {
|
|
44
79
|
this.append(`mkdir -p ${dirName}`);
|
|
45
80
|
return this;
|
|
46
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Removes a file or directory.
|
|
84
|
+
*
|
|
85
|
+
* @param dirPath - Path to remove
|
|
86
|
+
* @param options - Optional force flag
|
|
87
|
+
* @returns This instance for method chaining
|
|
88
|
+
*/
|
|
47
89
|
rm(dirPath, options) {
|
|
48
90
|
let command = 'rm';
|
|
49
91
|
if (options?.force)
|
|
@@ -51,6 +93,13 @@ export class Commando_Basic extends BaseCommando {
|
|
|
51
93
|
this.append(`${command} ${dirPath}`);
|
|
52
94
|
return this;
|
|
53
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Removes a directory recursively.
|
|
98
|
+
*
|
|
99
|
+
* @param dirPath - Directory path to remove
|
|
100
|
+
* @param options - Optional force flag
|
|
101
|
+
* @returns This instance for method chaining
|
|
102
|
+
*/
|
|
54
103
|
rmdir(dirPath, options) {
|
|
55
104
|
let command = 'rm -r';
|
|
56
105
|
if (options?.force)
|
|
@@ -58,6 +107,14 @@ export class Commando_Basic extends BaseCommando {
|
|
|
58
107
|
this.append(`${command} ${dirPath}`);
|
|
59
108
|
return this;
|
|
60
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Copies a directory.
|
|
112
|
+
*
|
|
113
|
+
* @param srcPath - Source directory path
|
|
114
|
+
* @param destPath - Destination directory path
|
|
115
|
+
* @param options - Optional contentOnly flag (copies contents, not directory itself)
|
|
116
|
+
* @returns This instance for method chaining
|
|
117
|
+
*/
|
|
61
118
|
cpdir(srcPath, destPath, options) {
|
|
62
119
|
let command = `cp -r ${srcPath}`;
|
|
63
120
|
if (options?.contentOnly)
|
|
@@ -66,10 +123,31 @@ export class Commando_Basic extends BaseCommando {
|
|
|
66
123
|
this.append(command);
|
|
67
124
|
return this;
|
|
68
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Displays file contents.
|
|
128
|
+
*
|
|
129
|
+
* @param fileName - File path to display
|
|
130
|
+
* @returns This instance for method chaining
|
|
131
|
+
*/
|
|
69
132
|
cat(fileName) {
|
|
70
133
|
this.append(`cat ${fileName}`);
|
|
71
134
|
return this;
|
|
72
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Echoes text with optional escape sequences and file output.
|
|
138
|
+
*
|
|
139
|
+
* **Escape Sequences**: When `escape` is true, enables interpretation
|
|
140
|
+
* of backslash escapes (e.g., `\n`, `\t`).
|
|
141
|
+
*
|
|
142
|
+
* **File Output**: Can append or overwrite to a file.
|
|
143
|
+
*
|
|
144
|
+
* **Escaping**: Automatically escapes backslashes, newlines, and tabs
|
|
145
|
+
* in the log string for safe shell execution.
|
|
146
|
+
*
|
|
147
|
+
* @param log - Text to echo
|
|
148
|
+
* @param options - Optional echo configuration
|
|
149
|
+
* @returns This instance for method chaining
|
|
150
|
+
*/
|
|
73
151
|
echo(log, options) {
|
|
74
152
|
const _escape = options?.escape ? '-e' : '';
|
|
75
153
|
const _toFile = options?.toFile ? `>${options.toFile.append ? '>' : ''} ${options.toFile.name}` : '';
|
|
@@ -86,10 +164,13 @@ export class Commando_Basic extends BaseCommando {
|
|
|
86
164
|
return this;
|
|
87
165
|
}
|
|
88
166
|
/**
|
|
89
|
-
* Assigns a value to a variable
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
167
|
+
* Assigns a value to a shell variable (array or scalar).
|
|
168
|
+
*
|
|
169
|
+
* Creates a bash array if value is an array, otherwise creates a scalar variable.
|
|
170
|
+
*
|
|
171
|
+
* @param varName - Variable name
|
|
172
|
+
* @param value - Value(s) to assign (string or array of strings)
|
|
173
|
+
* @returns This instance for method chaining
|
|
93
174
|
*/
|
|
94
175
|
assignVar(varName, value) {
|
|
95
176
|
this.append(`${varName}=(${Array.isArray(value) ? value : [value].join(' ')})`);
|
package/shell/plugins/git.d.ts
CHANGED
|
@@ -13,6 +13,23 @@ type GitPushParams = {
|
|
|
13
13
|
tags?: boolean;
|
|
14
14
|
force?: boolean;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Git operations plugin for Commando.
|
|
18
|
+
*
|
|
19
|
+
* Provides Git command methods via a fluent API. Extends Commando_Programming
|
|
20
|
+
* and Commando_Basic (merged via class-merger).
|
|
21
|
+
*
|
|
22
|
+
* **Usage**: Access via `git()` method which returns an object with all
|
|
23
|
+
* Git operations. Methods build commands but don't execute them until
|
|
24
|
+
* `execute()` is called.
|
|
25
|
+
*
|
|
26
|
+
* **Operations**:
|
|
27
|
+
* - Repository operations: clone, fetch, pull, push
|
|
28
|
+
* - Branch operations: checkout, create, merge, get current
|
|
29
|
+
* - Commit operations: add, commit, addAndCommit
|
|
30
|
+
* - Tag operations: create, push
|
|
31
|
+
* - Utility: status, resetHard, gsui (git status UI)
|
|
32
|
+
*/
|
|
16
33
|
export declare class Commando_Git extends Super {
|
|
17
34
|
git(): {
|
|
18
35
|
clone: (url: string, options?: GitCloneParams) => this;
|
|
@@ -33,22 +50,120 @@ export declare class Commando_Git extends Super {
|
|
|
33
50
|
gsui: (modules?: string) => this;
|
|
34
51
|
status: () => this;
|
|
35
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Clones a Git repository.
|
|
55
|
+
*
|
|
56
|
+
* @param url - Repository URL to clone
|
|
57
|
+
* @param options - Optional clone parameters (branch, recursive, output folder)
|
|
58
|
+
* @returns This instance for method chaining
|
|
59
|
+
*/
|
|
36
60
|
git_clone(url: string, options?: GitCloneParams): this;
|
|
61
|
+
/**
|
|
62
|
+
* Checks out a branch.
|
|
63
|
+
*
|
|
64
|
+
* @param branch - Branch name to checkout
|
|
65
|
+
* @returns This instance for method chaining
|
|
66
|
+
*/
|
|
37
67
|
git_checkout(branch: string): this;
|
|
68
|
+
/**
|
|
69
|
+
* Creates or updates a tag (force).
|
|
70
|
+
*
|
|
71
|
+
* @param tagName - Tag name to create/update
|
|
72
|
+
* @returns This instance for method chaining
|
|
73
|
+
*/
|
|
38
74
|
git_createTag(tagName: string): this;
|
|
75
|
+
/**
|
|
76
|
+
* Commits changes with a message.
|
|
77
|
+
*
|
|
78
|
+
* @param commitMessage - Commit message
|
|
79
|
+
* @returns This instance for method chaining
|
|
80
|
+
*/
|
|
39
81
|
git_gitCommit(commitMessage: string): this;
|
|
82
|
+
/**
|
|
83
|
+
* Stages a specific file.
|
|
84
|
+
*
|
|
85
|
+
* @param file - File path to stage
|
|
86
|
+
* @returns This instance for method chaining
|
|
87
|
+
*/
|
|
40
88
|
git_add(file: string): this;
|
|
89
|
+
/**
|
|
90
|
+
* Stages all files in the current directory.
|
|
91
|
+
*
|
|
92
|
+
* @returns This instance for method chaining
|
|
93
|
+
*/
|
|
41
94
|
git_addAll(): this;
|
|
95
|
+
/**
|
|
96
|
+
* Stages all files and commits with a message.
|
|
97
|
+
*
|
|
98
|
+
* @param commitMessage - Commit message
|
|
99
|
+
* @returns This instance for method chaining
|
|
100
|
+
*/
|
|
42
101
|
git_addAndCommit(commitMessage: string): this;
|
|
102
|
+
/**
|
|
103
|
+
* Pushes to a remote branch.
|
|
104
|
+
*
|
|
105
|
+
* @param options - Push parameters (remote, branch, tags, force)
|
|
106
|
+
* @returns This instance for method chaining
|
|
107
|
+
*/
|
|
43
108
|
git_push(options?: GitPushParams): this;
|
|
109
|
+
/**
|
|
110
|
+
* Pushes all tags to remote (force).
|
|
111
|
+
*
|
|
112
|
+
* @returns This instance for method chaining
|
|
113
|
+
*/
|
|
44
114
|
git_pushTags(): this;
|
|
115
|
+
/**
|
|
116
|
+
* Fetches from remote.
|
|
117
|
+
*
|
|
118
|
+
* @returns This instance for method chaining
|
|
119
|
+
*/
|
|
45
120
|
git_fetch(): this;
|
|
121
|
+
/**
|
|
122
|
+
* Resets repository to a specific tag/commit (hard reset).
|
|
123
|
+
*
|
|
124
|
+
* @param tag - Optional tag or commit hash (default: empty string)
|
|
125
|
+
* @returns This instance for method chaining
|
|
126
|
+
*/
|
|
46
127
|
git_resetHard(tag?: string): this;
|
|
128
|
+
/**
|
|
129
|
+
* Gets the current branch name.
|
|
130
|
+
*
|
|
131
|
+
* @returns This instance for method chaining
|
|
132
|
+
*/
|
|
47
133
|
git_getCurrentBranch(): this;
|
|
134
|
+
/**
|
|
135
|
+
* Pulls from remote with optional parameters.
|
|
136
|
+
*
|
|
137
|
+
* @param params - Optional pull parameters
|
|
138
|
+
* @returns This instance for method chaining
|
|
139
|
+
*/
|
|
48
140
|
git_pull(params: string): this;
|
|
141
|
+
/**
|
|
142
|
+
* Merges a branch into the current branch.
|
|
143
|
+
*
|
|
144
|
+
* @param mergeFrom - Branch to merge from
|
|
145
|
+
* @returns This instance for method chaining
|
|
146
|
+
*/
|
|
49
147
|
git_merge(mergeFrom: string): this;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a new branch and sets upstream.
|
|
150
|
+
*
|
|
151
|
+
* @param branch - Branch name to create
|
|
152
|
+
* @returns This instance for method chaining
|
|
153
|
+
*/
|
|
50
154
|
git_createBranch(branch: string): this;
|
|
155
|
+
/**
|
|
156
|
+
* Updates git submodules (recursive, init if needed).
|
|
157
|
+
*
|
|
158
|
+
* @param modules - Optional module paths (default: empty string)
|
|
159
|
+
* @returns This instance for method chaining
|
|
160
|
+
*/
|
|
51
161
|
git_gsui(modules?: string): this;
|
|
162
|
+
/**
|
|
163
|
+
* Shows git status.
|
|
164
|
+
*
|
|
165
|
+
* @returns This instance for method chaining
|
|
166
|
+
*/
|
|
52
167
|
git_status(): this;
|
|
53
168
|
}
|
|
54
169
|
export {};
|
package/shell/plugins/git.js
CHANGED
|
@@ -3,6 +3,23 @@ import { Commando_Basic } from './basic.js';
|
|
|
3
3
|
import { MergeClass } from '../core/class-merger.js';
|
|
4
4
|
import { BaseCommando } from '../core/BaseCommando.js';
|
|
5
5
|
const Super = MergeClass(BaseCommando, Commando_Programming, Commando_Basic);
|
|
6
|
+
/**
|
|
7
|
+
* Git operations plugin for Commando.
|
|
8
|
+
*
|
|
9
|
+
* Provides Git command methods via a fluent API. Extends Commando_Programming
|
|
10
|
+
* and Commando_Basic (merged via class-merger).
|
|
11
|
+
*
|
|
12
|
+
* **Usage**: Access via `git()` method which returns an object with all
|
|
13
|
+
* Git operations. Methods build commands but don't execute them until
|
|
14
|
+
* `execute()` is called.
|
|
15
|
+
*
|
|
16
|
+
* **Operations**:
|
|
17
|
+
* - Repository operations: clone, fetch, pull, push
|
|
18
|
+
* - Branch operations: checkout, create, merge, get current
|
|
19
|
+
* - Commit operations: add, commit, addAndCommit
|
|
20
|
+
* - Tag operations: create, push
|
|
21
|
+
* - Utility: status, resetHard, gsui (git status UI)
|
|
22
|
+
*/
|
|
6
23
|
export class Commando_Git extends Super {
|
|
7
24
|
git() {
|
|
8
25
|
return {
|
|
@@ -26,6 +43,13 @@ export class Commando_Git extends Super {
|
|
|
26
43
|
};
|
|
27
44
|
}
|
|
28
45
|
;
|
|
46
|
+
/**
|
|
47
|
+
* Clones a Git repository.
|
|
48
|
+
*
|
|
49
|
+
* @param url - Repository URL to clone
|
|
50
|
+
* @param options - Optional clone parameters (branch, recursive, output folder)
|
|
51
|
+
* @returns This instance for method chaining
|
|
52
|
+
*/
|
|
29
53
|
git_clone(url, options) {
|
|
30
54
|
const branch = `${options?.branch ? ` -b ${options?.branch}` : ''}`;
|
|
31
55
|
const recursive = `${options?.recursive ? ` --recursive` : ''}`;
|
|
@@ -52,52 +76,143 @@ export class Commando_Git extends Super {
|
|
|
52
76
|
// });
|
|
53
77
|
// });
|
|
54
78
|
// }
|
|
79
|
+
/**
|
|
80
|
+
* Checks out a branch.
|
|
81
|
+
*
|
|
82
|
+
* @param branch - Branch name to checkout
|
|
83
|
+
* @returns This instance for method chaining
|
|
84
|
+
*/
|
|
55
85
|
git_checkout(branch) {
|
|
56
86
|
return this.append(`git checkout ${branch}`);
|
|
57
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates or updates a tag (force).
|
|
90
|
+
*
|
|
91
|
+
* @param tagName - Tag name to create/update
|
|
92
|
+
* @returns This instance for method chaining
|
|
93
|
+
*/
|
|
58
94
|
git_createTag(tagName) {
|
|
59
95
|
return this.append(`git tag -f ${tagName}`);
|
|
60
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Commits changes with a message.
|
|
99
|
+
*
|
|
100
|
+
* @param commitMessage - Commit message
|
|
101
|
+
* @returns This instance for method chaining
|
|
102
|
+
*/
|
|
61
103
|
git_gitCommit(commitMessage) {
|
|
62
104
|
return this.append(`git commit -m "${commitMessage}"`);
|
|
63
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Stages a specific file.
|
|
108
|
+
*
|
|
109
|
+
* @param file - File path to stage
|
|
110
|
+
* @returns This instance for method chaining
|
|
111
|
+
*/
|
|
64
112
|
git_add(file) {
|
|
65
113
|
return this.append(`git add "${file}"`);
|
|
66
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Stages all files in the current directory.
|
|
117
|
+
*
|
|
118
|
+
* @returns This instance for method chaining
|
|
119
|
+
*/
|
|
67
120
|
git_addAll() {
|
|
68
121
|
return this.append(`git add .`);
|
|
69
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Stages all files and commits with a message.
|
|
125
|
+
*
|
|
126
|
+
* @param commitMessage - Commit message
|
|
127
|
+
* @returns This instance for method chaining
|
|
128
|
+
*/
|
|
70
129
|
git_addAndCommit(commitMessage) {
|
|
71
130
|
return this.append(`git commit -am "${commitMessage}"`);
|
|
72
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Pushes to a remote branch.
|
|
134
|
+
*
|
|
135
|
+
* @param options - Push parameters (remote, branch, tags, force)
|
|
136
|
+
* @returns This instance for method chaining
|
|
137
|
+
*/
|
|
73
138
|
git_push(options) {
|
|
74
139
|
return this.append(`git push ${options?.remote ?? ''} ${options?.branch ?? ''}`);
|
|
75
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Pushes all tags to remote (force).
|
|
143
|
+
*
|
|
144
|
+
* @returns This instance for method chaining
|
|
145
|
+
*/
|
|
76
146
|
git_pushTags() {
|
|
77
147
|
return this.append('git push --tags --force');
|
|
78
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Fetches from remote.
|
|
151
|
+
*
|
|
152
|
+
* @returns This instance for method chaining
|
|
153
|
+
*/
|
|
79
154
|
git_fetch() {
|
|
80
155
|
return this.append('git fetch');
|
|
81
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Resets repository to a specific tag/commit (hard reset).
|
|
159
|
+
*
|
|
160
|
+
* @param tag - Optional tag or commit hash (default: empty string)
|
|
161
|
+
* @returns This instance for method chaining
|
|
162
|
+
*/
|
|
82
163
|
git_resetHard(tag = '') {
|
|
83
|
-
return this.append(
|
|
164
|
+
return this.append(`git reset --hard ${tag}`);
|
|
84
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the current branch name.
|
|
168
|
+
*
|
|
169
|
+
* @returns This instance for method chaining
|
|
170
|
+
*/
|
|
85
171
|
git_getCurrentBranch() {
|
|
86
|
-
return this.append(
|
|
87
|
-
}
|
|
172
|
+
return this.append(`git status | grep "On branch" | sed -E "s/On branch //"`);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Pulls from remote with optional parameters.
|
|
176
|
+
*
|
|
177
|
+
* @param params - Optional pull parameters
|
|
178
|
+
* @returns This instance for method chaining
|
|
179
|
+
*/
|
|
88
180
|
git_pull(params) {
|
|
89
|
-
return this.append(
|
|
90
|
-
}
|
|
181
|
+
return this.append(`git pull ${params}`);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Merges a branch into the current branch.
|
|
185
|
+
*
|
|
186
|
+
* @param mergeFrom - Branch to merge from
|
|
187
|
+
* @returns This instance for method chaining
|
|
188
|
+
*/
|
|
91
189
|
git_merge(mergeFrom) {
|
|
92
190
|
return this.append(`git merge ${mergeFrom}`);
|
|
93
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Creates a new branch and sets upstream.
|
|
194
|
+
*
|
|
195
|
+
* @param branch - Branch name to create
|
|
196
|
+
* @returns This instance for method chaining
|
|
197
|
+
*/
|
|
94
198
|
git_createBranch(branch) {
|
|
95
|
-
return this.append(`git checkout -
|
|
96
|
-
.append(`git push--
|
|
97
|
-
}
|
|
199
|
+
return this.append(`git checkout -b ${branch}`)
|
|
200
|
+
.append(`git push --set-upstream origin ${branch}`);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Updates git submodules (recursive, init if needed).
|
|
204
|
+
*
|
|
205
|
+
* @param modules - Optional module paths (default: empty string)
|
|
206
|
+
* @returns This instance for method chaining
|
|
207
|
+
*/
|
|
98
208
|
git_gsui(modules = '') {
|
|
99
|
-
return this.append(
|
|
209
|
+
return this.append(`git submodule update --recursive --init ${modules}`);
|
|
100
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Shows git status.
|
|
213
|
+
*
|
|
214
|
+
* @returns This instance for method chaining
|
|
215
|
+
*/
|
|
101
216
|
git_status() {
|
|
102
217
|
return this.append('git status');
|
|
103
218
|
}
|
package/shell/plugins/nvm.d.ts
CHANGED
|
@@ -2,11 +2,58 @@ 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
|
+
* NVM (Node Version Manager) plugin for Commando.
|
|
7
|
+
*
|
|
8
|
+
* Provides NVM operations for managing Node.js versions:
|
|
9
|
+
* - Install NVM
|
|
10
|
+
* - Apply NVM to shell session
|
|
11
|
+
* - Install specific Node.js versions
|
|
12
|
+
* - Get installed Node.js versions
|
|
13
|
+
*
|
|
14
|
+
* Extends Commando_Programming and Commando_Basic (merged).
|
|
15
|
+
*/
|
|
5
16
|
export declare class Commando_NVM extends Super {
|
|
17
|
+
/**
|
|
18
|
+
* Applies NVM to the shell session.
|
|
19
|
+
*
|
|
20
|
+
* Exports NVM_DIR, sources nvm.sh, and runs `nvm use`.
|
|
21
|
+
* Must be called before using NVM commands in an interactive shell.
|
|
22
|
+
*
|
|
23
|
+
* @returns This instance for method chaining
|
|
24
|
+
*/
|
|
6
25
|
applyNVM(): this;
|
|
26
|
+
/**
|
|
27
|
+
* Installs NVM by downloading and executing the install script.
|
|
28
|
+
*
|
|
29
|
+
* @param version - NVM version to install
|
|
30
|
+
* @returns This instance for method chaining
|
|
31
|
+
* @throws Exception if installation fails (non-zero exit code)
|
|
32
|
+
*/
|
|
7
33
|
install(version: string): Promise<this>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the installed NVM version.
|
|
36
|
+
*
|
|
37
|
+
* Only executes if NVM is available (checks with `command -v nvm`).
|
|
38
|
+
*
|
|
39
|
+
* @returns Promise resolving to NVM version string
|
|
40
|
+
*/
|
|
8
41
|
getVersion(): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Installs a specific Node.js version via NVM.
|
|
44
|
+
*
|
|
45
|
+
* @param requiredVersion - Node.js version to install (e.g., '18.0.0')
|
|
46
|
+
* @returns This instance for method chaining
|
|
47
|
+
*/
|
|
9
48
|
installNodeVersion(requiredVersion: string): Promise<this>;
|
|
49
|
+
/**
|
|
50
|
+
* Gets all installed Node.js versions.
|
|
51
|
+
*
|
|
52
|
+
* Parses `nvm ls` output to extract version numbers, removing ANSI codes
|
|
53
|
+
* and filtering out invalid entries.
|
|
54
|
+
*
|
|
55
|
+
* @returns Promise resolving to array of version strings (without 'v' prefix)
|
|
56
|
+
*/
|
|
10
57
|
getInstalledNodeVersions: () => Promise<(string | undefined)[]>;
|
|
11
58
|
}
|
|
12
59
|
export {};
|
package/shell/plugins/nvm.js
CHANGED
|
@@ -5,13 +5,39 @@ import { Commando_Basic } from './basic.js';
|
|
|
5
5
|
import { Exception, filterDuplicates } from '@nu-art/ts-common';
|
|
6
6
|
import { removeAnsiCodes } from '../tools.js';
|
|
7
7
|
const Super = MergeClass(BaseCommando, Commando_Programming, Commando_Basic);
|
|
8
|
+
/**
|
|
9
|
+
* NVM (Node Version Manager) plugin for Commando.
|
|
10
|
+
*
|
|
11
|
+
* Provides NVM operations for managing Node.js versions:
|
|
12
|
+
* - Install NVM
|
|
13
|
+
* - Apply NVM to shell session
|
|
14
|
+
* - Install specific Node.js versions
|
|
15
|
+
* - Get installed Node.js versions
|
|
16
|
+
*
|
|
17
|
+
* Extends Commando_Programming and Commando_Basic (merged).
|
|
18
|
+
*/
|
|
8
19
|
export class Commando_NVM extends Super {
|
|
20
|
+
/**
|
|
21
|
+
* Applies NVM to the shell session.
|
|
22
|
+
*
|
|
23
|
+
* Exports NVM_DIR, sources nvm.sh, and runs `nvm use`.
|
|
24
|
+
* Must be called before using NVM commands in an interactive shell.
|
|
25
|
+
*
|
|
26
|
+
* @returns This instance for method chaining
|
|
27
|
+
*/
|
|
9
28
|
applyNVM() {
|
|
10
29
|
this.append('export NVM_DIR="$HOME/.nvm"')
|
|
11
30
|
.append('[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm')
|
|
12
31
|
.append('nvm use');
|
|
13
32
|
return this;
|
|
14
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Installs NVM by downloading and executing the install script.
|
|
36
|
+
*
|
|
37
|
+
* @param version - NVM version to install
|
|
38
|
+
* @returns This instance for method chaining
|
|
39
|
+
* @throws Exception if installation fails (non-zero exit code)
|
|
40
|
+
*/
|
|
15
41
|
async install(version) {
|
|
16
42
|
this.append(`curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${version}/install.sh" | bash`);
|
|
17
43
|
await this.execute((stdout, stderr, exitCode) => {
|
|
@@ -20,16 +46,37 @@ export class Commando_NVM extends Super {
|
|
|
20
46
|
});
|
|
21
47
|
return this;
|
|
22
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the installed NVM version.
|
|
51
|
+
*
|
|
52
|
+
* Only executes if NVM is available (checks with `command -v nvm`).
|
|
53
|
+
*
|
|
54
|
+
* @returns Promise resolving to NVM version string
|
|
55
|
+
*/
|
|
23
56
|
async getVersion() {
|
|
24
57
|
return this.if('[[ -x "$(command -v nvm)" ]]', (commando) => {
|
|
25
58
|
commando.append('nvm --version');
|
|
26
59
|
}).execute((stdout) => stdout);
|
|
27
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Installs a specific Node.js version via NVM.
|
|
63
|
+
*
|
|
64
|
+
* @param requiredVersion - Node.js version to install (e.g., '18.0.0')
|
|
65
|
+
* @returns This instance for method chaining
|
|
66
|
+
*/
|
|
28
67
|
async installNodeVersion(requiredVersion) {
|
|
29
68
|
await this.append(`nvm install ${requiredVersion}`)
|
|
30
69
|
.execute();
|
|
31
70
|
return this;
|
|
32
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Gets all installed Node.js versions.
|
|
74
|
+
*
|
|
75
|
+
* Parses `nvm ls` output to extract version numbers, removing ANSI codes
|
|
76
|
+
* and filtering out invalid entries.
|
|
77
|
+
*
|
|
78
|
+
* @returns Promise resolving to array of version strings (without 'v' prefix)
|
|
79
|
+
*/
|
|
33
80
|
getInstalledNodeVersions = async () => {
|
|
34
81
|
function extractInstalledVersions(rawOutput) {
|
|
35
82
|
const cleanedOutput = removeAnsiCodes(rawOutput);
|
package/shell/plugins/pnpm.d.ts
CHANGED
|
@@ -3,9 +3,40 @@ import { Commando_Basic } from './basic.js';
|
|
|
3
3
|
import { Commando_Programming } from './programming.js';
|
|
4
4
|
import { Commando_NVM } from './nvm.js';
|
|
5
5
|
declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando & Commando_Programming & Commando_Basic & Commando_NVM>;
|
|
6
|
+
/**
|
|
7
|
+
* PNPM package manager plugin for Commando.
|
|
8
|
+
*
|
|
9
|
+
* Provides PNPM operations:
|
|
10
|
+
* - Install PNPM
|
|
11
|
+
* - Get PNPM version
|
|
12
|
+
* - Install packages (with store prune and force flags)
|
|
13
|
+
*
|
|
14
|
+
* Extends Commando_NVM, Commando_Programming, and Commando_Basic (merged).
|
|
15
|
+
* Requires NVM for Node.js version management.
|
|
16
|
+
*/
|
|
6
17
|
export declare class Commando_PNPM extends Super {
|
|
18
|
+
/**
|
|
19
|
+
* Installs packages using PNPM.
|
|
20
|
+
*
|
|
21
|
+
* Prunes the store, then installs with force flag and no frozen lockfile.
|
|
22
|
+
*
|
|
23
|
+
* @returns This instance for method chaining
|
|
24
|
+
*/
|
|
7
25
|
installPackages(): Promise<this>;
|
|
26
|
+
/**
|
|
27
|
+
* Installs PNPM by downloading and executing the install script.
|
|
28
|
+
*
|
|
29
|
+
* @param version - PNPM version to install
|
|
30
|
+
* @returns This instance for method chaining
|
|
31
|
+
*/
|
|
8
32
|
install(version: string): Promise<this>;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the installed PNPM version.
|
|
35
|
+
*
|
|
36
|
+
* Only executes if PNPM is available (checks with `command -v pnpm`).
|
|
37
|
+
*
|
|
38
|
+
* @returns Promise resolving to PNPM version string (trimmed)
|
|
39
|
+
*/
|
|
9
40
|
getVersion(): Promise<string>;
|
|
10
41
|
}
|
|
11
42
|
export {};
|