mushroom-cli 1.2.0-alpha.6.1 → 1.2.0-alpha.7.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/README.md +10 -0
- package/common.js +36 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -88,6 +88,16 @@ Disable checking for update:
|
|
|
88
88
|
|
|
89
89
|
## Version
|
|
90
90
|
|
|
91
|
+
### 1.2.0-alpha.7
|
|
92
|
+
|
|
93
|
+
New features:
|
|
94
|
+
|
|
95
|
+
* init netcore: Support some new set-functions: `ToLowerCase`, `ToUpperCase`, `Trim`, `Replace`
|
|
96
|
+
|
|
97
|
+
Changes:
|
|
98
|
+
|
|
99
|
+
* init netcore: Operating fail if unknown command or set-function found
|
|
100
|
+
|
|
91
101
|
### 1.2.0-alpha.6
|
|
92
102
|
|
|
93
103
|
New features:
|
package/common.js
CHANGED
|
@@ -12,7 +12,7 @@ function ensureFolder(path, isFolder) {
|
|
|
12
12
|
return;
|
|
13
13
|
|
|
14
14
|
if (!fs.existsSync(path)) {
|
|
15
|
-
fs.mkdirSync(path, { recursive: true, mode:
|
|
15
|
+
fs.mkdirSync(path, { recursive: true, mode: 0o755 });
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -160,6 +160,8 @@ function processCommand(command, basePath, variables) {
|
|
|
160
160
|
case "replace":
|
|
161
161
|
processReplaceCommand(command, basePath, variables);
|
|
162
162
|
return;
|
|
163
|
+
default:
|
|
164
|
+
throw new Error(`Unknown command: ${command.command}`);
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
|
|
@@ -181,9 +183,24 @@ function processSetCommand(command, variables) {
|
|
|
181
183
|
case "New-GUID":
|
|
182
184
|
processSetGuidCommand(command.variable, variables);
|
|
183
185
|
break;
|
|
186
|
+
case "ToLowerCase":
|
|
187
|
+
toLowerCommand(command.variable, variables, command.input);
|
|
188
|
+
break;
|
|
189
|
+
case "ToUpperCase":
|
|
190
|
+
toUpperCaseCommand(command.variable, variables, command.input);
|
|
191
|
+
break;
|
|
192
|
+
case "Trim":
|
|
193
|
+
trimCommand(command.variable, variables, command.input);
|
|
194
|
+
break;
|
|
195
|
+
case "Replace":
|
|
196
|
+
replaceCommand(command.variable, variables, command.input, command.replacement, command.pattern, command.mode);
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
throw new Error(`Unknown set-command: ${command["function"]}`);
|
|
184
200
|
}
|
|
185
201
|
}
|
|
186
202
|
|
|
203
|
+
//#region set-commands
|
|
187
204
|
function processSetGuidCommand(variable, variables) {
|
|
188
205
|
variables[variable] = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
189
206
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
@@ -191,6 +208,24 @@ function processSetGuidCommand(variable, variables) {
|
|
|
191
208
|
}).toUpperCase();
|
|
192
209
|
}
|
|
193
210
|
|
|
211
|
+
function toLowerCommand(variable, variables, input) {
|
|
212
|
+
variables[variable] = (variables[input] || "").toLowerCase();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function toUpperCaseCommand(variable, variables, input) {
|
|
216
|
+
variables[variable] = (variables[input] || "").toUpperCase();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function trimCommand(variable, variables, input) {
|
|
220
|
+
variables[variable] = (variables[input] || "").trim();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function replaceCommand(variable, variables, input, replacement, pattern, mode) {
|
|
224
|
+
var regex = new RegExp(pattern, mode);
|
|
225
|
+
variables[variable] = (variables[input] || "").replace(regex, replacement === undefined || replacement === null ? "" : replacement);
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
|
|
194
229
|
function processRenameCommand(command, basePath, variables) {
|
|
195
230
|
const input = replaceVariables(command.input, variables);
|
|
196
231
|
const output = replaceVariables(command.output, variables);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mushroom-cli",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.7.1",
|
|
4
4
|
"description": "Mushroom CLI",
|
|
5
5
|
"main": "mr.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
},
|
|
17
17
|
"author": "suco2007",
|
|
18
18
|
"license": "ISC",
|
|
19
|
+
"dependencies-comments": "node-fetch: 2.x; open: 8.x",
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"jsdom": "^
|
|
21
|
+
"jsdom": "^22.1.0",
|
|
21
22
|
"json5": "^2.2.3",
|
|
22
|
-
"node-fetch": "^2.6.
|
|
23
|
-
"open": "^8.4.
|
|
23
|
+
"node-fetch": "^2.6.11",
|
|
24
|
+
"open": "^8.4.2",
|
|
24
25
|
"readline-sync": "^1.4.10",
|
|
25
26
|
"targz": "^1.0.1"
|
|
26
27
|
}
|