@shell-shock/preset-cli 0.9.33 → 0.9.35
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 +16 -7
- package/dist/command-entry-BCDDI3RN.mjs +548 -0
- package/dist/command-entry-BCDDI3RN.mjs.map +1 -0
- package/dist/command-entry-iZ5O5Iza.cjs +558 -0
- package/dist/components/banner-builtin.cjs +39 -14
- package/dist/components/banner-builtin.d.cts +1 -2
- package/dist/components/banner-builtin.d.cts.map +1 -1
- package/dist/components/banner-builtin.d.mts +1 -2
- package/dist/components/banner-builtin.mjs +6 -6
- package/dist/components/command-entry.cjs +2 -447
- package/dist/components/command-entry.d.cts +1 -2
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +1 -2
- package/dist/components/command-entry.mjs +2 -446
- package/dist/components/command-router.cjs +6 -6
- package/dist/components/command-router.d.cts +0 -1
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts +0 -1
- package/dist/components/command-router.mjs +3 -3
- package/dist/components/index.cjs +3 -4
- package/dist/components/index.mjs +1 -2
- package/dist/components/update-builtin.cjs +7 -7
- package/dist/components/update-builtin.d.cts +0 -1
- package/dist/components/update-builtin.d.cts.map +1 -1
- package/dist/components/update-builtin.d.mts +0 -1
- package/dist/components/update-builtin.mjs +5 -5
- package/dist/components/virtual-command-entry.cjs +2 -114
- package/dist/components/virtual-command-entry.d.cts +1 -2
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +1 -2
- package/dist/components/virtual-command-entry.mjs +2 -113
- package/dist/generator.cjs +158 -0
- package/dist/generator.d.cts +16 -0
- package/dist/generator.d.cts.map +1 -0
- package/dist/generator.d.mts +16 -0
- package/dist/generator.d.mts.map +1 -0
- package/dist/generator.mjs +156 -0
- package/dist/generator.mjs.map +1 -0
- package/dist/helpers/get-global-options.cjs +1 -0
- package/dist/helpers/get-global-options.d.cts +15 -0
- package/dist/helpers/get-global-options.d.cts.map +1 -0
- package/dist/helpers/get-global-options.d.mts +15 -0
- package/dist/helpers/get-global-options.d.mts.map +1 -0
- package/dist/helpers/get-global-options.mjs +4 -4
- package/dist/index.cjs +20 -130
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +25 -129
- package/dist/plugin-BUwcMpPx.d.mts +100 -0
- package/dist/plugin-BUwcMpPx.d.mts.map +1 -0
- package/dist/plugin-Bsdv5DH-.d.cts +100 -0
- package/dist/plugin-Bsdv5DH-.d.cts.map +1 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs +2 -0
- package/dist/types/plugin.d.cts +2 -101
- package/dist/types/plugin.d.mts +2 -101
- package/package.json +53 -25
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/components/command-entry.mjs.map +0 -1
- package/dist/components/virtual-command-entry.mjs.map +0 -1
- package/dist/types/plugin.d.cts.map +0 -1
- package/dist/types/plugin.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
<div align="center">
|
|
7
7
|
<picture>
|
|
8
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/shell-shock/banner-1280x640-dark.gif">
|
|
9
|
-
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/shell-shock/banner-1280x640-light.gif">
|
|
10
|
-
<img src="https://public.storm-cdn.com/shell-shock/banner-1280x640-dark.gif" width="100%" alt="Storm Software" />
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/shell-shock/media/banner-1280x640-dark.gif">
|
|
9
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/shell-shock/media/banner-1280x640-light.gif">
|
|
10
|
+
<img src="https://public.storm-cdn.com/shell-shock/media/banner-1280x640-dark.gif" width="100%" alt="Storm Software" />
|
|
11
11
|
</picture>
|
|
12
12
|
</div>
|
|
13
13
|
<br />
|
|
@@ -213,9 +213,9 @@ specification. Contributions of any kind welcome!
|
|
|
213
213
|
|
|
214
214
|
<div align="center">
|
|
215
215
|
<picture>
|
|
216
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x320-dark.webp">
|
|
217
|
-
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x320-light.webp">
|
|
218
|
-
<img src="https://public.storm-cdn.com/storm-software/banner-1280x320-dark.webp" width="100%" alt="Storm Software" />
|
|
216
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp">
|
|
217
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x320-light.webp">
|
|
218
|
+
<img src="https://public.storm-cdn.com/storm-software/media/banner-1280x320-dark.webp" width="100%" alt="Storm Software" />
|
|
219
219
|
</picture>
|
|
220
220
|
</div>
|
|
221
221
|
<br />
|
|
@@ -247,8 +247,17 @@ generation of development tools, please reach out on our
|
|
|
247
247
|
|
|
248
248
|
<br />
|
|
249
249
|
|
|
250
|
-
<div align="center"
|
|
250
|
+
<div align="center">
|
|
251
|
+
<a href="https://stormsoftware.com" target="_blank">
|
|
252
|
+
<picture>
|
|
253
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/icons/circle-dark.webp">
|
|
254
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/icons/circle-light.webp">
|
|
255
|
+
<img src="https://public.storm-cdn.com/storm-software/icons/circle-dark.webp" width="200px" alt="Storm Software" />
|
|
256
|
+
</picture>
|
|
257
|
+
</a>
|
|
258
|
+
</div>
|
|
251
259
|
<br />
|
|
260
|
+
|
|
252
261
|
<div align="center"><a href="https://stormsoftware.com" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/misc/text/visit-us-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/misc/text/visit-us-light.png"><img src="https://public.storm-cdn.com/misc/text/visit-us-dark.png" height="90px" alt="Visit us at stormsoftware.com" /></picture></a></div>
|
|
253
262
|
|
|
254
263
|
<br />
|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import { CommandRouter } from "./components/command-router.mjs";
|
|
2
|
+
import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
3
|
+
import { joinPaths } from "@stryke/path/join";
|
|
4
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
|
|
6
|
+
import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
|
|
7
|
+
import { Spacing } from "@power-plant/alloy-js/core/components";
|
|
8
|
+
import { Spacing as Spacing$1 } from "@power-plant/alloy-js/core/components/spacing";
|
|
9
|
+
import { EntryFile, usePowerlines } from "@shell-shock/core/contexts/power-plant";
|
|
10
|
+
import { defu } from "defu";
|
|
11
|
+
import { CommandValidationLogic } from "@shell-shock/core/components/command-validation-logic";
|
|
12
|
+
import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
|
|
13
|
+
import { findFilePath, relativePath } from "@stryke/path/find";
|
|
14
|
+
import { replaceExtension } from "@stryke/path/replace";
|
|
15
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
16
|
+
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
17
|
+
import { TypescriptFile } from "@power-plant/alloy-js/typescript/components/typescript-file";
|
|
18
|
+
import { VirtualCommandHandlerDeclaration } from "@shell-shock/preset-script/components/virtual-command-entry";
|
|
19
|
+
|
|
20
|
+
//#region src/components/virtual-command-entry.tsx
|
|
21
|
+
/**
|
|
22
|
+
* The virtual command entry point for the Shell Shock project.
|
|
23
|
+
*/
|
|
24
|
+
function VirtualCommandEntry(props) {
|
|
25
|
+
const { command, imports, builtinImports, ...rest } = props;
|
|
26
|
+
const context = usePowerlines();
|
|
27
|
+
const filePath = computed(() => joinPaths(context.entryPath, command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
|
|
28
|
+
return [createComponent(TypescriptFile, mergeProps(rest, {
|
|
29
|
+
get path() {
|
|
30
|
+
return filePath.value;
|
|
31
|
+
},
|
|
32
|
+
get imports() {
|
|
33
|
+
return defu(imports ?? {}, Object.entries(command.children).filter(([, child]) => child.virtual).reduce((ret, [name, child]) => {
|
|
34
|
+
ret[`./${child.name}`] = [{
|
|
35
|
+
name: "handler",
|
|
36
|
+
alias: `handle${pascalCase(name)}`
|
|
37
|
+
}];
|
|
38
|
+
return ret;
|
|
39
|
+
}, {}));
|
|
40
|
+
},
|
|
41
|
+
get builtinImports() {
|
|
42
|
+
return defu(builtinImports ?? {}, {
|
|
43
|
+
env: ["isDevelopment", "isDebug"],
|
|
44
|
+
console: [
|
|
45
|
+
"warn",
|
|
46
|
+
"error",
|
|
47
|
+
"info",
|
|
48
|
+
"help",
|
|
49
|
+
"table",
|
|
50
|
+
"writeLine",
|
|
51
|
+
"splitText",
|
|
52
|
+
"textColors",
|
|
53
|
+
"stripAnsi"
|
|
54
|
+
],
|
|
55
|
+
utils: [
|
|
56
|
+
"isMinimal",
|
|
57
|
+
"isUnicodeSupported",
|
|
58
|
+
"isInteractive",
|
|
59
|
+
"findSuggestions",
|
|
60
|
+
"sleep"
|
|
61
|
+
],
|
|
62
|
+
state: [
|
|
63
|
+
{
|
|
64
|
+
name: "GlobalOptions",
|
|
65
|
+
type: true
|
|
66
|
+
},
|
|
67
|
+
"useGlobal",
|
|
68
|
+
"useGlobalOptions",
|
|
69
|
+
"withCommand",
|
|
70
|
+
"useArgs",
|
|
71
|
+
"hasFlag",
|
|
72
|
+
"isHelp"
|
|
73
|
+
],
|
|
74
|
+
prompts: [
|
|
75
|
+
"text",
|
|
76
|
+
"numeric",
|
|
77
|
+
"toggle",
|
|
78
|
+
"select",
|
|
79
|
+
"isCancel"
|
|
80
|
+
],
|
|
81
|
+
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
|
|
82
|
+
[joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"]
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
get children() {
|
|
86
|
+
return [createComponent(Spacing, {}), createComponent(VirtualCommandHandlerDeclaration, {
|
|
87
|
+
command,
|
|
88
|
+
get children() {
|
|
89
|
+
return createComponent(CommandRouter, {
|
|
90
|
+
get segments() {
|
|
91
|
+
return command.segments;
|
|
92
|
+
},
|
|
93
|
+
get commands() {
|
|
94
|
+
return command.children;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
})];
|
|
99
|
+
}
|
|
100
|
+
})), createComponent(For, {
|
|
101
|
+
get each() {
|
|
102
|
+
return Object.values(command.children);
|
|
103
|
+
},
|
|
104
|
+
children: (child) => createComponent(Show, {
|
|
105
|
+
get when() {
|
|
106
|
+
return child.virtual;
|
|
107
|
+
},
|
|
108
|
+
get fallback() {
|
|
109
|
+
return createComponent(CommandEntry, { command: child });
|
|
110
|
+
},
|
|
111
|
+
get children() {
|
|
112
|
+
return createComponent(VirtualCommandEntry, { command: child });
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
})];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/components/command-entry.tsx
|
|
120
|
+
/**
|
|
121
|
+
* The command entry point for the Shell Shock project.
|
|
122
|
+
*/
|
|
123
|
+
function CommandEntry(props) {
|
|
124
|
+
const { command, imports, builtinImports, ...rest } = props;
|
|
125
|
+
const context = usePowerlines();
|
|
126
|
+
const filePath = computed(() => joinPaths(command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
|
|
127
|
+
const commandSourcePath = computed(() => replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file)));
|
|
128
|
+
const typeDefinition = computed(() => ({
|
|
129
|
+
...command.entry,
|
|
130
|
+
output: command.id
|
|
131
|
+
}));
|
|
132
|
+
return [createComponent(EntryFile, mergeProps(rest, {
|
|
133
|
+
get path() {
|
|
134
|
+
return filePath.value;
|
|
135
|
+
},
|
|
136
|
+
get typeDefinition() {
|
|
137
|
+
return typeDefinition.value;
|
|
138
|
+
},
|
|
139
|
+
get imports() {
|
|
140
|
+
return defu(imports ?? {}, { [commandSourcePath.value.startsWith(".") ? commandSourcePath.value : `./${commandSourcePath.value}`]: `handle${pascalCase(command.name)}` });
|
|
141
|
+
},
|
|
142
|
+
get builtinImports() {
|
|
143
|
+
return defu(builtinImports ?? {}, {
|
|
144
|
+
env: [
|
|
145
|
+
"env",
|
|
146
|
+
"isDevelopment",
|
|
147
|
+
"isDebug",
|
|
148
|
+
"paths"
|
|
149
|
+
],
|
|
150
|
+
console: [
|
|
151
|
+
"debug",
|
|
152
|
+
"info",
|
|
153
|
+
"help",
|
|
154
|
+
"warn",
|
|
155
|
+
"error",
|
|
156
|
+
"table",
|
|
157
|
+
"italic",
|
|
158
|
+
"cursor",
|
|
159
|
+
"stripAnsi",
|
|
160
|
+
"writeLine",
|
|
161
|
+
"splitText",
|
|
162
|
+
"textColors",
|
|
163
|
+
"createSpinner"
|
|
164
|
+
],
|
|
165
|
+
utils: [
|
|
166
|
+
"sleep",
|
|
167
|
+
"isMinimal",
|
|
168
|
+
"isInteractive",
|
|
169
|
+
"isUnicodeSupported"
|
|
170
|
+
],
|
|
171
|
+
state: [
|
|
172
|
+
{
|
|
173
|
+
name: "GlobalOptions",
|
|
174
|
+
type: true
|
|
175
|
+
},
|
|
176
|
+
"useGlobal",
|
|
177
|
+
"useGlobalOptions",
|
|
178
|
+
"withCommand",
|
|
179
|
+
"useArgs",
|
|
180
|
+
"hasFlag",
|
|
181
|
+
"isHelp"
|
|
182
|
+
],
|
|
183
|
+
prompts: [
|
|
184
|
+
"text",
|
|
185
|
+
"numeric",
|
|
186
|
+
"toggle",
|
|
187
|
+
"select",
|
|
188
|
+
"confirm",
|
|
189
|
+
"waitForKeyPress",
|
|
190
|
+
"isCancel"
|
|
191
|
+
],
|
|
192
|
+
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
|
|
193
|
+
[joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"],
|
|
194
|
+
update: ["executeUpdate"]
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
get children() {
|
|
198
|
+
return [createComponent(Spacing$1, {}), createComponent(CommandHandlerDeclaration, {
|
|
199
|
+
command,
|
|
200
|
+
banner: code`await showBanner();
|
|
201
|
+
await executeUpdate(); `,
|
|
202
|
+
get children() {
|
|
203
|
+
return [createComponent(IfStatement, {
|
|
204
|
+
condition: code`!isInteractive`,
|
|
205
|
+
get children() {
|
|
206
|
+
return createComponent(CommandValidationLogic, { command });
|
|
207
|
+
}
|
|
208
|
+
}), createComponent(Show, {
|
|
209
|
+
get when() {
|
|
210
|
+
return Object.values(command.options ?? {}).filter((option) => option.required).length > 0 || Object.values(command.args ?? {}).filter((arg) => arg.required).length > 0;
|
|
211
|
+
},
|
|
212
|
+
get children() {
|
|
213
|
+
return createComponent(ElseIfClause, {
|
|
214
|
+
get condition() {
|
|
215
|
+
return code`!isHelp() && (${Object.values(command.options ?? {}).filter((option) => option.required).map((option) => (option.type === "string" || option.type === "number") && option.variadic ? `(!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} || options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0)` : `options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} === undefined`).join(" || ")}${Object.values(command.options ?? {}).filter((option) => option.required).length > 0 && Object.values(command.args ?? {}).filter((arg) => arg.required).length > 0 ? " || " : ""}${Object.values(command.args ?? {}).filter((arg) => arg.required).map((arg) => (arg.type === "string" || arg.type === "number") && arg.variadic ? `(!${camelCase(arg.name)} || ${camelCase(arg.name)}.length === 0)` : `${camelCase(arg.name)} === undefined`).join(" || ")}) `;
|
|
216
|
+
},
|
|
217
|
+
get children() {
|
|
218
|
+
return [
|
|
219
|
+
code`writeLine(""); `,
|
|
220
|
+
createComponent(Spacing$1, {}),
|
|
221
|
+
createComponent(For, {
|
|
222
|
+
get each() {
|
|
223
|
+
return Object.values(command.options ?? {});
|
|
224
|
+
},
|
|
225
|
+
doubleHardline: true,
|
|
226
|
+
children: (option) => [createComponent(Show, {
|
|
227
|
+
get when() {
|
|
228
|
+
return option.required;
|
|
229
|
+
},
|
|
230
|
+
get children() {
|
|
231
|
+
return [createComponent(IfStatement, {
|
|
232
|
+
get condition() {
|
|
233
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
|
|
234
|
+
},
|
|
235
|
+
get children() {
|
|
236
|
+
return createComponent(Show, {
|
|
237
|
+
get when() {
|
|
238
|
+
return option.type === "boolean" || !option.choices || option.choices.length === 0;
|
|
239
|
+
},
|
|
240
|
+
get fallback() {
|
|
241
|
+
return code`const value = await select({
|
|
242
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`, ${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
243
|
+
` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${formatShortDescription(option.description)}\`` : ""} }`).join(", ")} ]
|
|
244
|
+
});
|
|
245
|
+
if (isCancel(value)) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
250
|
+
`;
|
|
251
|
+
},
|
|
252
|
+
get children() {
|
|
253
|
+
return createComponent(Switch, { get children() {
|
|
254
|
+
return [
|
|
255
|
+
createComponent(Match, {
|
|
256
|
+
get when() {
|
|
257
|
+
return option.type === "string";
|
|
258
|
+
},
|
|
259
|
+
get children() {
|
|
260
|
+
return code`
|
|
261
|
+
const value = await text({
|
|
262
|
+
message: \`Please provide a value for the \${italic("${option.name}")} option\`,
|
|
263
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
264
|
+
` : ""}validate(val) {
|
|
265
|
+
if (!val || val.trim() === "") {
|
|
266
|
+
return "A value must be provided for this option";
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (isCancel(value)) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
}),
|
|
280
|
+
createComponent(Match, {
|
|
281
|
+
get when() {
|
|
282
|
+
return option.type === "number";
|
|
283
|
+
},
|
|
284
|
+
get children() {
|
|
285
|
+
return code`
|
|
286
|
+
const value = await numeric({
|
|
287
|
+
message: \`Please provide a numeric value for the \${italic("${option.name}")} option\`,
|
|
288
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
289
|
+
` : ""}
|
|
290
|
+
});
|
|
291
|
+
if (isCancel(value)) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
}),
|
|
299
|
+
createComponent(Match, {
|
|
300
|
+
get when() {
|
|
301
|
+
return option.type === "boolean";
|
|
302
|
+
},
|
|
303
|
+
get children() {
|
|
304
|
+
return code`
|
|
305
|
+
const value = await toggle({
|
|
306
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`,
|
|
307
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
308
|
+
` : ""}
|
|
309
|
+
});
|
|
310
|
+
if (isCancel(value)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
315
|
+
`;
|
|
316
|
+
}
|
|
317
|
+
})
|
|
318
|
+
];
|
|
319
|
+
} });
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}), createComponent(Show, {
|
|
324
|
+
get when() {
|
|
325
|
+
return (option.type === "string" || option.type === "number") && option.variadic;
|
|
326
|
+
},
|
|
327
|
+
get children() {
|
|
328
|
+
return createComponent(ElseIfClause, {
|
|
329
|
+
get condition() {
|
|
330
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
|
|
331
|
+
},
|
|
332
|
+
get children() {
|
|
333
|
+
return code`
|
|
334
|
+
const value = await text({
|
|
335
|
+
message: \`Please provide one or more${option.type === "number" ? " numeric" : ""} values for the \${italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
336
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
337
|
+
` : ""}validate(val) {
|
|
338
|
+
if (!val || val.trim() === "") {
|
|
339
|
+
return "A value must be provided for this option";
|
|
340
|
+
}
|
|
341
|
+
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
342
|
+
return "At least one value must be provided for this option";
|
|
343
|
+
}
|
|
344
|
+
${option.type === "number" ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
345
|
+
if (invalidIndex !== -1) {
|
|
346
|
+
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
347
|
+
} ` : ""}
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
if (isCancel(value)) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.type === "number" ? `.map(Number)` : ""} ;
|
|
356
|
+
`;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
})];
|
|
361
|
+
}
|
|
362
|
+
})]
|
|
363
|
+
}),
|
|
364
|
+
createComponent(Spacing$1, {}),
|
|
365
|
+
createComponent(For, {
|
|
366
|
+
get each() {
|
|
367
|
+
return command.args;
|
|
368
|
+
},
|
|
369
|
+
doubleHardline: true,
|
|
370
|
+
children: (arg) => [createComponent(Show, {
|
|
371
|
+
get when() {
|
|
372
|
+
return arg.required;
|
|
373
|
+
},
|
|
374
|
+
get children() {
|
|
375
|
+
return [createComponent(IfStatement, {
|
|
376
|
+
get condition() {
|
|
377
|
+
return code`!${camelCase(arg.name)}`;
|
|
378
|
+
},
|
|
379
|
+
get children() {
|
|
380
|
+
return createComponent(Show, {
|
|
381
|
+
get when() {
|
|
382
|
+
return arg.type === "boolean" || !arg.choices || arg.choices.length === 0;
|
|
383
|
+
},
|
|
384
|
+
get fallback() {
|
|
385
|
+
return code`const value = await select({
|
|
386
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,${arg.description ? `description: \`${formatDescription(arg.description)}\`,
|
|
387
|
+
` : ""}
|
|
388
|
+
options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`` : ""} }`).join(", ")} ]
|
|
389
|
+
});
|
|
390
|
+
if (isCancel(value)) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
${camelCase(arg.name)} = value;
|
|
395
|
+
`;
|
|
396
|
+
},
|
|
397
|
+
get children() {
|
|
398
|
+
return createComponent(Switch, { get children() {
|
|
399
|
+
return [
|
|
400
|
+
createComponent(Match, {
|
|
401
|
+
get when() {
|
|
402
|
+
return arg.type === "string";
|
|
403
|
+
},
|
|
404
|
+
get children() {
|
|
405
|
+
return code`
|
|
406
|
+
const value = await text({
|
|
407
|
+
message: \`Please provide a value for the \${italic("${arg.name}")} argument\`,
|
|
408
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
409
|
+
` : ""}validate(val) {
|
|
410
|
+
if (!val || val.trim() === "") {
|
|
411
|
+
return "A value must be provided for this argument";
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
if (isCancel(value)) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
${camelCase(arg.name)} = value;
|
|
422
|
+
`;
|
|
423
|
+
}
|
|
424
|
+
}),
|
|
425
|
+
createComponent(Match, {
|
|
426
|
+
get when() {
|
|
427
|
+
return arg.type === "number";
|
|
428
|
+
},
|
|
429
|
+
get children() {
|
|
430
|
+
return code`
|
|
431
|
+
const value = await numeric({
|
|
432
|
+
message: \`Please provide a numeric value for the \${italic("${arg.name}")} argument\`,
|
|
433
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
434
|
+
` : ""}
|
|
435
|
+
});
|
|
436
|
+
if (isCancel(value)) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
${camelCase(arg.name)} = value;
|
|
441
|
+
`;
|
|
442
|
+
}
|
|
443
|
+
}),
|
|
444
|
+
createComponent(Match, {
|
|
445
|
+
get when() {
|
|
446
|
+
return arg.type === "boolean";
|
|
447
|
+
},
|
|
448
|
+
get children() {
|
|
449
|
+
return code`
|
|
450
|
+
const value = await toggle({
|
|
451
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,
|
|
452
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
453
|
+
` : ""}
|
|
454
|
+
});
|
|
455
|
+
if (isCancel(value)) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
${camelCase(arg.name)} = value;
|
|
460
|
+
`;
|
|
461
|
+
}
|
|
462
|
+
})
|
|
463
|
+
];
|
|
464
|
+
} });
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}), createComponent(Show, {
|
|
469
|
+
get when() {
|
|
470
|
+
return arg.variadic;
|
|
471
|
+
},
|
|
472
|
+
get children() {
|
|
473
|
+
return createComponent(ElseIfClause, {
|
|
474
|
+
get condition() {
|
|
475
|
+
return code`${camelCase(arg.name)}.length === 0`;
|
|
476
|
+
},
|
|
477
|
+
get children() {
|
|
478
|
+
return code`
|
|
479
|
+
const value = await text({
|
|
480
|
+
message: \`Please provide one or more${arg.type === "number" ? " numeric" : ""} values for the \${italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
481
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
482
|
+
` : ""}validate(val) {
|
|
483
|
+
if (!val || val.trim() === "") {
|
|
484
|
+
return "A value must be provided for this argument";
|
|
485
|
+
}
|
|
486
|
+
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
487
|
+
return "At least one value must be provided for this argument";
|
|
488
|
+
}
|
|
489
|
+
${arg.type === "number" ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
490
|
+
if (invalidIndex !== -1) {
|
|
491
|
+
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
492
|
+
} ` : ""}
|
|
493
|
+
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
if (isCancel(value)) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
${camelCase(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.type === "number" ? `.map(Number)` : arg.type === "boolean" ? `.map(Boolean)` : ""} ;
|
|
502
|
+
`;
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
})];
|
|
507
|
+
}
|
|
508
|
+
})]
|
|
509
|
+
}),
|
|
510
|
+
code`writeLine(""); `,
|
|
511
|
+
createComponent(Spacing$1, {}),
|
|
512
|
+
createComponent(CommandValidationLogic, { command }),
|
|
513
|
+
createComponent(IfStatement, {
|
|
514
|
+
condition: code`failures.length > 0`,
|
|
515
|
+
get children() {
|
|
516
|
+
return code`error(\`The following validation failures were found while processing the user provided input, and must be corrected before the \${italic("${command.title}")} command can be executed: \\n\\n\${failures.map(failure => " - " + failure).join("\\n")}\`);
|
|
517
|
+
options.help = true; `;
|
|
518
|
+
}
|
|
519
|
+
})
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
})];
|
|
525
|
+
}
|
|
526
|
+
})];
|
|
527
|
+
}
|
|
528
|
+
})), createComponent(For, {
|
|
529
|
+
get each() {
|
|
530
|
+
return Object.values(command.children);
|
|
531
|
+
},
|
|
532
|
+
children: (child) => createComponent(Show, {
|
|
533
|
+
get when() {
|
|
534
|
+
return child.virtual;
|
|
535
|
+
},
|
|
536
|
+
get fallback() {
|
|
537
|
+
return createComponent(CommandEntry, { command: child });
|
|
538
|
+
},
|
|
539
|
+
get children() {
|
|
540
|
+
return createComponent(VirtualCommandEntry, { command: child });
|
|
541
|
+
}
|
|
542
|
+
})
|
|
543
|
+
})];
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
//#endregion
|
|
547
|
+
export { VirtualCommandEntry as n, CommandEntry as t };
|
|
548
|
+
//# sourceMappingURL=command-entry-BCDDI3RN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-entry-BCDDI3RN.mjs","names":[],"sources":[],"mappings":""}
|