@nu-art/commando 0.401.0 → 0.401.2
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/{shell/core → core}/BaseCommando.d.ts +37 -6
- package/{shell/core → core}/BaseCommando.js +40 -6
- package/core/CliError.d.ts +49 -0
- package/core/CliError.js +58 -0
- package/{shell/core → core}/CommandBuilder.d.ts +27 -2
- package/{shell/core → core}/CommandBuilder.js +32 -3
- package/core/CommandoPool.d.ts +42 -0
- package/core/CommandoPool.js +48 -0
- package/core/class-merger.d.ts +39 -0
- package/core/class-merger.js +50 -0
- package/index.d.ts +11 -0
- package/index.js +16 -0
- package/{shell/interactive → interactive}/CommandoInteractive.d.ts +67 -7
- package/{shell/interactive → interactive}/CommandoInteractive.js +69 -6
- package/{shell/interactive → interactive}/InteractiveShell.d.ts +38 -0
- package/{shell/interactive → interactive}/InteractiveShell.js +25 -0
- package/package.json +24 -15
- package/plugins/basic.d.ts +140 -0
- package/plugins/basic.js +179 -0
- package/plugins/git.d.ts +169 -0
- package/plugins/git.js +219 -0
- package/plugins/nvm.d.ts +59 -0
- package/{shell/plugins → plugins}/nvm.js +47 -0
- package/plugins/pnpm.d.ts +42 -0
- package/{shell/plugins → plugins}/pnpm.js +31 -0
- package/{shell/plugins → plugins}/programming.d.ts +23 -3
- package/{shell/plugins → plugins}/programming.js +23 -3
- package/plugins/python.d.ts +41 -0
- package/plugins/python.js +58 -0
- package/services/nvm.d.ts +76 -0
- package/{shell/services → services}/nvm.js +67 -6
- package/services/pnpm.d.ts +67 -0
- package/{shell/services → services}/pnpm.js +41 -0
- package/simple/Commando.d.ts +92 -0
- package/simple/Commando.js +122 -0
- package/simple/SimpleShell.d.ts +48 -0
- package/{shell/simple → simple}/SimpleShell.js +32 -2
- package/tools.d.ts +33 -0
- package/tools.js +47 -0
- package/types.d.ts +17 -0
- package/cli-params/CLIParamsResolver.d.ts +0 -27
- package/cli-params/CLIParamsResolver.js +0 -97
- package/cli-params/consts.d.ts +0 -6
- package/cli-params/consts.js +0 -27
- package/cli-params/types.d.ts +0 -28
- package/shell/core/CliError.d.ts +0 -14
- package/shell/core/CliError.js +0 -23
- package/shell/core/CommandoPool.d.ts +0 -9
- package/shell/core/CommandoPool.js +0 -14
- package/shell/core/class-merger.d.ts +0 -20
- package/shell/core/class-merger.js +0 -35
- package/shell/index.d.ts +0 -2
- package/shell/index.js +0 -2
- package/shell/plugins/basic.d.ts +0 -59
- package/shell/plugins/basic.js +0 -98
- package/shell/plugins/git.d.ts +0 -54
- package/shell/plugins/git.js +0 -104
- package/shell/plugins/nvm.d.ts +0 -12
- package/shell/plugins/pnpm.d.ts +0 -11
- package/shell/plugins/python.d.ts +0 -10
- package/shell/plugins/python.js +0 -26
- package/shell/services/nvm.d.ts +0 -18
- package/shell/services/pnpm.d.ts +0 -26
- package/shell/simple/Commando.d.ts +0 -17
- package/shell/simple/Commando.js +0 -47
- package/shell/simple/SimpleShell.d.ts +0 -21
- package/shell/tools.d.ts +0 -3
- package/shell/tools.js +0 -17
- package/shell/types.d.ts +0 -3
- package/shell/types.js +0 -1
- /package/{cli-params/types.js → types.js} +0 -0
package/plugins/git.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Commando_Programming } from './programming.js';
|
|
2
|
+
import { Commando_Basic } from './basic.js';
|
|
3
|
+
import { BaseCommando } from '../core/BaseCommando.js';
|
|
4
|
+
declare const Super: import("@nu-art/ts-common").Constructor<BaseCommando & Commando_Programming & Commando_Basic>;
|
|
5
|
+
type GitCloneParams = {
|
|
6
|
+
outputFolder?: string;
|
|
7
|
+
branch?: string;
|
|
8
|
+
recursive?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type GitPushParams = {
|
|
11
|
+
remote: string;
|
|
12
|
+
branch: string;
|
|
13
|
+
tags?: boolean;
|
|
14
|
+
force?: boolean;
|
|
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
|
+
*/
|
|
33
|
+
export declare class Commando_Git extends Super {
|
|
34
|
+
git(): {
|
|
35
|
+
clone: (url: string, options?: GitCloneParams) => this;
|
|
36
|
+
checkout: (branch: string) => this;
|
|
37
|
+
createTag: (tagName: string) => this;
|
|
38
|
+
gitCommit: (commitMessage: string) => this;
|
|
39
|
+
add: (file: string) => this;
|
|
40
|
+
addAll: () => this;
|
|
41
|
+
addAndCommit: (commitMessage: string) => this;
|
|
42
|
+
push: (options?: GitPushParams) => this;
|
|
43
|
+
pushTags: () => this;
|
|
44
|
+
fetch: () => this;
|
|
45
|
+
resetHard: (tag?: string) => this;
|
|
46
|
+
getCurrentBranch: () => this;
|
|
47
|
+
pull: (params: string) => this;
|
|
48
|
+
merge: (mergeFrom: string) => this;
|
|
49
|
+
createBranch: (branch: string) => this;
|
|
50
|
+
gsui: (modules?: string) => this;
|
|
51
|
+
status: () => this;
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
88
|
+
git_add(file: string): this;
|
|
89
|
+
/**
|
|
90
|
+
* Stages all files in the current directory.
|
|
91
|
+
*
|
|
92
|
+
* @returns This instance for method chaining
|
|
93
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
108
|
+
git_push(options?: GitPushParams): this;
|
|
109
|
+
/**
|
|
110
|
+
* Pushes all tags to remote (force).
|
|
111
|
+
*
|
|
112
|
+
* @returns This instance for method chaining
|
|
113
|
+
*/
|
|
114
|
+
git_pushTags(): this;
|
|
115
|
+
/**
|
|
116
|
+
* Fetches from remote.
|
|
117
|
+
*
|
|
118
|
+
* @returns This instance for method chaining
|
|
119
|
+
*/
|
|
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
|
+
*/
|
|
127
|
+
git_resetHard(tag?: string): this;
|
|
128
|
+
/**
|
|
129
|
+
* Gets the current branch name.
|
|
130
|
+
*
|
|
131
|
+
* @returns This instance for method chaining
|
|
132
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
161
|
+
git_gsui(modules?: string): this;
|
|
162
|
+
/**
|
|
163
|
+
* Shows git status.
|
|
164
|
+
*
|
|
165
|
+
* @returns This instance for method chaining
|
|
166
|
+
*/
|
|
167
|
+
git_status(): this;
|
|
168
|
+
}
|
|
169
|
+
export {};
|
package/plugins/git.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { Commando_Programming } from './programming.js';
|
|
2
|
+
import { Commando_Basic } from './basic.js';
|
|
3
|
+
import { MergeClass } from '../core/class-merger.js';
|
|
4
|
+
import { BaseCommando } from '../core/BaseCommando.js';
|
|
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
|
+
*/
|
|
23
|
+
export class Commando_Git extends Super {
|
|
24
|
+
git() {
|
|
25
|
+
return {
|
|
26
|
+
clone: this.git_clone,
|
|
27
|
+
checkout: this.git_checkout,
|
|
28
|
+
createTag: this.git_createTag,
|
|
29
|
+
gitCommit: this.git_gitCommit,
|
|
30
|
+
add: this.git_add,
|
|
31
|
+
addAll: this.git_addAll,
|
|
32
|
+
addAndCommit: this.git_addAndCommit,
|
|
33
|
+
push: this.git_push,
|
|
34
|
+
pushTags: this.git_pushTags,
|
|
35
|
+
fetch: this.git_fetch,
|
|
36
|
+
resetHard: this.git_resetHard,
|
|
37
|
+
getCurrentBranch: this.git_getCurrentBranch,
|
|
38
|
+
pull: this.git_pull,
|
|
39
|
+
merge: this.git_merge,
|
|
40
|
+
createBranch: this.git_createBranch,
|
|
41
|
+
gsui: this.git_gsui,
|
|
42
|
+
status: this.git_status,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
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
|
+
*/
|
|
53
|
+
git_clone(url, options) {
|
|
54
|
+
const branch = `${options?.branch ? ` -b ${options?.branch}` : ''}`;
|
|
55
|
+
const recursive = `${options?.recursive ? ` --recursive` : ''}`;
|
|
56
|
+
const outputFolder = `${options?.outputFolder ? ` ${options.outputFolder}` : ''}`;
|
|
57
|
+
const command = `git clone${recursive}${branch} ${url}${outputFolder}`;
|
|
58
|
+
return this.append(command);
|
|
59
|
+
}
|
|
60
|
+
// git_cloneAssert(url: string, options?: GitCloneParams) {
|
|
61
|
+
// return new Promise<void>((resolve, reject) => {
|
|
62
|
+
// const branch = `${options?.branch ? ` -b ${options?.branch}` : ''}`;
|
|
63
|
+
// const recursive = `${options?.recursive ? ` --recursive` : ''}`;
|
|
64
|
+
// const outputFolder = `${options?.outputFolder ? ` ${options.outputFolder}` : ''}`;
|
|
65
|
+
// const command = `git clone${recursive}${branch} ${url}${outputFolder}`;
|
|
66
|
+
// this.echo(command);
|
|
67
|
+
// this.append(command)
|
|
68
|
+
// .execute((stdout: string, stderr: string, exitCode: number) => {
|
|
69
|
+
// if (exitCode === 0)
|
|
70
|
+
// return resolve();
|
|
71
|
+
//
|
|
72
|
+
// if (exitCode === 128)
|
|
73
|
+
// return reject(new Error(`No access to repo: ${url}`));
|
|
74
|
+
//
|
|
75
|
+
// return reject(new Error(`Got unexpected exit code(${exitCode}) while cloning: ${url}`));
|
|
76
|
+
// });
|
|
77
|
+
// });
|
|
78
|
+
// }
|
|
79
|
+
/**
|
|
80
|
+
* Checks out a branch.
|
|
81
|
+
*
|
|
82
|
+
* @param branch - Branch name to checkout
|
|
83
|
+
* @returns This instance for method chaining
|
|
84
|
+
*/
|
|
85
|
+
git_checkout(branch) {
|
|
86
|
+
return this.append(`git checkout ${branch}`);
|
|
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
|
+
*/
|
|
94
|
+
git_createTag(tagName) {
|
|
95
|
+
return this.append(`git tag -f ${tagName}`);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Commits changes with a message.
|
|
99
|
+
*
|
|
100
|
+
* @param commitMessage - Commit message
|
|
101
|
+
* @returns This instance for method chaining
|
|
102
|
+
*/
|
|
103
|
+
git_gitCommit(commitMessage) {
|
|
104
|
+
return this.append(`git commit -m "${commitMessage}"`);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Stages a specific file.
|
|
108
|
+
*
|
|
109
|
+
* @param file - File path to stage
|
|
110
|
+
* @returns This instance for method chaining
|
|
111
|
+
*/
|
|
112
|
+
git_add(file) {
|
|
113
|
+
return this.append(`git add "${file}"`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Stages all files in the current directory.
|
|
117
|
+
*
|
|
118
|
+
* @returns This instance for method chaining
|
|
119
|
+
*/
|
|
120
|
+
git_addAll() {
|
|
121
|
+
return this.append(`git add .`);
|
|
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
|
+
*/
|
|
129
|
+
git_addAndCommit(commitMessage) {
|
|
130
|
+
return this.append(`git commit -am "${commitMessage}"`);
|
|
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
|
+
*/
|
|
138
|
+
git_push(options) {
|
|
139
|
+
return this.append(`git push ${options?.remote ?? ''} ${options?.branch ?? ''}`);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Pushes all tags to remote (force).
|
|
143
|
+
*
|
|
144
|
+
* @returns This instance for method chaining
|
|
145
|
+
*/
|
|
146
|
+
git_pushTags() {
|
|
147
|
+
return this.append('git push --tags --force');
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Fetches from remote.
|
|
151
|
+
*
|
|
152
|
+
* @returns This instance for method chaining
|
|
153
|
+
*/
|
|
154
|
+
git_fetch() {
|
|
155
|
+
return this.append('git fetch');
|
|
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
|
+
*/
|
|
163
|
+
git_resetHard(tag = '') {
|
|
164
|
+
return this.append(`git reset --hard ${tag}`);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the current branch name.
|
|
168
|
+
*
|
|
169
|
+
* @returns This instance for method chaining
|
|
170
|
+
*/
|
|
171
|
+
git_getCurrentBranch() {
|
|
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
|
+
*/
|
|
180
|
+
git_pull(params) {
|
|
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
|
+
*/
|
|
189
|
+
git_merge(mergeFrom) {
|
|
190
|
+
return this.append(`git merge ${mergeFrom}`);
|
|
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
|
+
*/
|
|
198
|
+
git_createBranch(branch) {
|
|
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
|
+
*/
|
|
208
|
+
git_gsui(modules = '') {
|
|
209
|
+
return this.append(`git submodule update --recursive --init ${modules}`);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Shows git status.
|
|
213
|
+
*
|
|
214
|
+
* @returns This instance for method chaining
|
|
215
|
+
*/
|
|
216
|
+
git_status() {
|
|
217
|
+
return this.append('git status');
|
|
218
|
+
}
|
|
219
|
+
}
|
package/plugins/nvm.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseCommando } from '../core/BaseCommando.js';
|
|
2
|
+
import { Commando_Programming } from './programming.js';
|
|
3
|
+
import { Commando_Basic } from './basic.js';
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
57
|
+
getInstalledNodeVersions: () => Promise<(string | undefined)[]>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -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);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BaseCommando } from '../core/BaseCommando.js';
|
|
2
|
+
import { Commando_Basic } from './basic.js';
|
|
3
|
+
import { Commando_Programming } from './programming.js';
|
|
4
|
+
import { Commando_NVM } from './nvm.js';
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
40
|
+
getVersion(): Promise<string>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
}
|