@shell-shock/preset-cli 0.7.13 → 0.8.0
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/dist/components/banner-function-declaration.d.cts +2 -2
- package/dist/components/banner-function-declaration.d.mts +2 -2
- package/dist/components/command-entry.cjs +103 -64
- package/dist/components/command-entry.d.cts +2 -2
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +2 -2
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +104 -65
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +2 -1
- package/dist/components/command-router.d.cts +3 -3
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts.map +1 -1
- package/dist/components/command-router.mjs +2 -1
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +2 -2
- package/package.json +8 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core1 from "@alloy-js/core";
|
|
2
2
|
import { BannerFunctionDeclarationProps } from "@shell-shock/preset-script/components/banner-function-declaration";
|
|
3
3
|
|
|
4
4
|
//#region src/components/banner-function-declaration.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A component to generate the `banner` function in the `shell-shock:console` builtin module.
|
|
7
7
|
*/
|
|
8
|
-
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps):
|
|
8
|
+
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps): _alloy_js_core1.Children;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { BannerFunctionDeclaration };
|
|
11
11
|
//# sourceMappingURL=banner-function-declaration.d.cts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core2 from "@alloy-js/core";
|
|
2
2
|
import { BannerFunctionDeclarationProps } from "@shell-shock/preset-script/components/banner-function-declaration";
|
|
3
3
|
|
|
4
4
|
//#region src/components/banner-function-declaration.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A component to generate the `banner` function in the `shell-shock:console` builtin module.
|
|
7
7
|
*/
|
|
8
|
-
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps):
|
|
8
|
+
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps): _alloy_js_core2.Children;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { BannerFunctionDeclaration };
|
|
11
11
|
//# sourceMappingURL=banner-function-declaration.d.mts.map
|
|
@@ -135,17 +135,34 @@ function CommandEntry(props) {
|
|
|
135
135
|
return __alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}`;
|
|
136
136
|
},
|
|
137
137
|
get children() {
|
|
138
|
-
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
139
|
+
get when() {
|
|
140
|
+
return option.kind === __shell_shock_core.CommandParameterKinds.boolean || !option.choices || option.choices.length === 0;
|
|
141
|
+
},
|
|
142
|
+
get fallback() {
|
|
143
|
+
return __alloy_js_core.code`const value = await select({
|
|
144
|
+
message: \`Please select a value for the \${colors.italic("${option.name}")} option\`, ${option.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
145
|
+
` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(option.description)}\`` : ""} }`).join(", ")} ]
|
|
146
|
+
});
|
|
147
|
+
if (isCancel(value)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = value;
|
|
152
|
+
`;
|
|
153
|
+
},
|
|
154
|
+
get children() {
|
|
155
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Switch, { get children() {
|
|
156
|
+
return [
|
|
157
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
158
|
+
get when() {
|
|
159
|
+
return option.kind === __shell_shock_core.CommandParameterKinds.string;
|
|
160
|
+
},
|
|
161
|
+
get children() {
|
|
162
|
+
return __alloy_js_core.code`
|
|
146
163
|
const value = await text({
|
|
147
164
|
message: \`Please provide a value for the \${colors.italic("${option.name}")} option\`,
|
|
148
|
-
${option.description ? `description:
|
|
165
|
+
${option.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
149
166
|
` : ""}validate(val) {
|
|
150
167
|
if (!val || val.trim() === "") {
|
|
151
168
|
return "A value must be provided for this option";
|
|
@@ -160,17 +177,17 @@ function CommandEntry(props) {
|
|
|
160
177
|
|
|
161
178
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = value;
|
|
162
179
|
`;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
183
|
+
get when() {
|
|
184
|
+
return option.kind === __shell_shock_core.CommandParameterKinds.number;
|
|
185
|
+
},
|
|
186
|
+
get children() {
|
|
187
|
+
return __alloy_js_core.code`
|
|
171
188
|
const value = await numeric({
|
|
172
189
|
message: \`Please provide a numeric value for the \${colors.italic("${option.name}")} option\`,
|
|
173
|
-
${option.description ? `description:
|
|
190
|
+
${option.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
174
191
|
` : ""}
|
|
175
192
|
});
|
|
176
193
|
if (isCancel(value)) {
|
|
@@ -179,17 +196,17 @@ function CommandEntry(props) {
|
|
|
179
196
|
|
|
180
197
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = value;
|
|
181
198
|
`;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
202
|
+
get when() {
|
|
203
|
+
return option.kind === __shell_shock_core.CommandParameterKinds.boolean;
|
|
204
|
+
},
|
|
205
|
+
get children() {
|
|
206
|
+
return __alloy_js_core.code`
|
|
190
207
|
const value = await toggle({
|
|
191
208
|
message: \`Please select a value for the \${colors.italic("${option.name}")} option\`,
|
|
192
|
-
${option.description ? `description:
|
|
209
|
+
${option.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
193
210
|
` : ""}
|
|
194
211
|
});
|
|
195
212
|
if (isCancel(value)) {
|
|
@@ -198,10 +215,12 @@ function CommandEntry(props) {
|
|
|
198
215
|
|
|
199
216
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = value;
|
|
200
217
|
`;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
];
|
|
221
|
+
} });
|
|
222
|
+
}
|
|
223
|
+
});
|
|
205
224
|
}
|
|
206
225
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
207
226
|
get when() {
|
|
@@ -216,7 +235,7 @@ function CommandEntry(props) {
|
|
|
216
235
|
return __alloy_js_core.code`
|
|
217
236
|
const value = await text({
|
|
218
237
|
message: \`Please provide one or more${option.kind === __shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
219
|
-
${option.description ? `description:
|
|
238
|
+
${option.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
220
239
|
` : ""}validate(val) {
|
|
221
240
|
if (!val || val.trim() === "") {
|
|
222
241
|
return "A value must be provided for this option";
|
|
@@ -260,17 +279,35 @@ function CommandEntry(props) {
|
|
|
260
279
|
return __alloy_js_core.code`!${(0, __stryke_string_format_camel_case.camelCase)(arg.name)}`;
|
|
261
280
|
},
|
|
262
281
|
get children() {
|
|
263
|
-
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
282
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
283
|
+
get when() {
|
|
284
|
+
return arg.kind === __shell_shock_core.CommandParameterKinds.boolean || !arg.choices || arg.choices.length === 0;
|
|
285
|
+
},
|
|
286
|
+
get fallback() {
|
|
287
|
+
return __alloy_js_core.code`const value = await select({
|
|
288
|
+
message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,${arg.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatDescription)(arg.description)}\`,
|
|
289
|
+
` : ""}
|
|
290
|
+
options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`` : ""} }`).join(", ")} ]
|
|
291
|
+
});
|
|
292
|
+
if (isCancel(value)) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value;
|
|
297
|
+
`;
|
|
298
|
+
},
|
|
299
|
+
get children() {
|
|
300
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Switch, { get children() {
|
|
301
|
+
return [
|
|
302
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
303
|
+
get when() {
|
|
304
|
+
return arg.kind === __shell_shock_core.CommandParameterKinds.string;
|
|
305
|
+
},
|
|
306
|
+
get children() {
|
|
307
|
+
return __alloy_js_core.code`
|
|
271
308
|
const value = await text({
|
|
272
309
|
message: \`Please provide a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
273
|
-
${arg.description ? `description:
|
|
310
|
+
${arg.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
274
311
|
` : ""}validate(val) {
|
|
275
312
|
if (!val || val.trim() === "") {
|
|
276
313
|
return "A value must be provided for this argument";
|
|
@@ -285,17 +322,17 @@ function CommandEntry(props) {
|
|
|
285
322
|
|
|
286
323
|
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value;
|
|
287
324
|
`;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
325
|
+
}
|
|
326
|
+
}),
|
|
327
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
328
|
+
get when() {
|
|
329
|
+
return arg.kind === __shell_shock_core.CommandParameterKinds.number;
|
|
330
|
+
},
|
|
331
|
+
get children() {
|
|
332
|
+
return __alloy_js_core.code`
|
|
296
333
|
const value = await numeric({
|
|
297
334
|
message: \`Please provide a numeric value for the \${colors.italic("${arg.name}")} argument\`,
|
|
298
|
-
${arg.description ? `description:
|
|
335
|
+
${arg.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
299
336
|
` : ""}
|
|
300
337
|
});
|
|
301
338
|
if (isCancel(value)) {
|
|
@@ -304,17 +341,17 @@ function CommandEntry(props) {
|
|
|
304
341
|
|
|
305
342
|
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value;
|
|
306
343
|
`;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
344
|
+
}
|
|
345
|
+
}),
|
|
346
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
347
|
+
get when() {
|
|
348
|
+
return arg.kind === __shell_shock_core.CommandParameterKinds.boolean;
|
|
349
|
+
},
|
|
350
|
+
get children() {
|
|
351
|
+
return __alloy_js_core.code`
|
|
315
352
|
const value = await toggle({
|
|
316
353
|
message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
317
|
-
${arg.description ? `description:
|
|
354
|
+
${arg.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
318
355
|
` : ""}
|
|
319
356
|
});
|
|
320
357
|
if (isCancel(value)) {
|
|
@@ -323,10 +360,12 @@ function CommandEntry(props) {
|
|
|
323
360
|
|
|
324
361
|
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value;
|
|
325
362
|
`;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
363
|
+
}
|
|
364
|
+
})
|
|
365
|
+
];
|
|
366
|
+
} });
|
|
367
|
+
}
|
|
368
|
+
});
|
|
330
369
|
}
|
|
331
370
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
332
371
|
get when() {
|
|
@@ -341,7 +380,7 @@ function CommandEntry(props) {
|
|
|
341
380
|
return __alloy_js_core.code`
|
|
342
381
|
const value = await text({
|
|
343
382
|
message: \`Please provide one or more${arg.kind === __shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
344
|
-
${arg.description ? `description:
|
|
383
|
+
${arg.description ? `description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
345
384
|
` : ""}validate(val) {
|
|
346
385
|
if (!val || val.trim() === "") {
|
|
347
386
|
return "A value must be provided for this argument";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
3
|
import { CommandTree } from "@shell-shock/core";
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinitio
|
|
|
9
9
|
/**
|
|
10
10
|
* The command entry point for the Shell Shock project.
|
|
11
11
|
*/
|
|
12
|
-
declare function CommandEntry(props: CommandEntryProps):
|
|
12
|
+
declare function CommandEntry(props: CommandEntryProps): _alloy_js_core0.Children;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { CommandEntry, CommandEntryProps };
|
|
15
15
|
//# sourceMappingURL=command-entry.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UAiDiB,iBAAA,SAA0B,KACzC;WAGS;;AAJX;;;AAA2C,iBAU3B,YAAA,CAV2B,KAAA,EAUP,iBAVO,CAAA,EAUU,eAAA,CAAA,QAVV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core3 from "@alloy-js/core";
|
|
2
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
3
|
import { CommandTree } from "@shell-shock/core";
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinitio
|
|
|
9
9
|
/**
|
|
10
10
|
* The command entry point for the Shell Shock project.
|
|
11
11
|
*/
|
|
12
|
-
declare function CommandEntry(props: CommandEntryProps):
|
|
12
|
+
declare function CommandEntry(props: CommandEntryProps): _alloy_js_core3.Children;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { CommandEntry, CommandEntryProps };
|
|
15
15
|
//# sourceMappingURL=command-entry.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UAiDiB,iBAAA,SAA0B,KACzC;WAGS;;AAJX;;;AAA2C,iBAU3B,YAAA,CAV2B,KAAA,EAUP,iBAVO,CAAA,EAUU,eAAA,CAAA,QAVV"}
|
|
@@ -5,7 +5,7 @@ import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
|
|
|
5
5
|
import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
|
|
6
6
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
7
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
-
import { isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
8
|
+
import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
9
9
|
import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
10
10
|
import { CommandParameterKinds } from "@shell-shock/core";
|
|
11
11
|
import { CommandHandlerDeclaration, CommandValidationLogic } from "@shell-shock/preset-script/components/command-entry";
|
|
@@ -133,17 +133,34 @@ function CommandEntry(props) {
|
|
|
133
133
|
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
|
|
134
134
|
},
|
|
135
135
|
get children() {
|
|
136
|
-
return createComponent(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
return createComponent(Show, {
|
|
137
|
+
get when() {
|
|
138
|
+
return option.kind === CommandParameterKinds.boolean || !option.choices || option.choices.length === 0;
|
|
139
|
+
},
|
|
140
|
+
get fallback() {
|
|
141
|
+
return code`const value = await select({
|
|
142
|
+
message: \`Please select a value for the \${colors.italic("${option.name}")} option\`, ${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
143
|
+
` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${formatShortDescription(option.description)}\`` : ""} }`).join(", ")} ]
|
|
144
|
+
});
|
|
145
|
+
if (isCancel(value)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
150
|
+
`;
|
|
151
|
+
},
|
|
152
|
+
get children() {
|
|
153
|
+
return createComponent(Switch, { get children() {
|
|
154
|
+
return [
|
|
155
|
+
createComponent(Match, {
|
|
156
|
+
get when() {
|
|
157
|
+
return option.kind === CommandParameterKinds.string;
|
|
158
|
+
},
|
|
159
|
+
get children() {
|
|
160
|
+
return code`
|
|
144
161
|
const value = await text({
|
|
145
162
|
message: \`Please provide a value for the \${colors.italic("${option.name}")} option\`,
|
|
146
|
-
${option.description ? `description:
|
|
163
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
147
164
|
` : ""}validate(val) {
|
|
148
165
|
if (!val || val.trim() === "") {
|
|
149
166
|
return "A value must be provided for this option";
|
|
@@ -158,17 +175,17 @@ function CommandEntry(props) {
|
|
|
158
175
|
|
|
159
176
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
160
177
|
`;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
createComponent(Match, {
|
|
181
|
+
get when() {
|
|
182
|
+
return option.kind === CommandParameterKinds.number;
|
|
183
|
+
},
|
|
184
|
+
get children() {
|
|
185
|
+
return code`
|
|
169
186
|
const value = await numeric({
|
|
170
187
|
message: \`Please provide a numeric value for the \${colors.italic("${option.name}")} option\`,
|
|
171
|
-
${option.description ? `description:
|
|
188
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
172
189
|
` : ""}
|
|
173
190
|
});
|
|
174
191
|
if (isCancel(value)) {
|
|
@@ -177,17 +194,17 @@ function CommandEntry(props) {
|
|
|
177
194
|
|
|
178
195
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
179
196
|
`;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
createComponent(Match, {
|
|
200
|
+
get when() {
|
|
201
|
+
return option.kind === CommandParameterKinds.boolean;
|
|
202
|
+
},
|
|
203
|
+
get children() {
|
|
204
|
+
return code`
|
|
188
205
|
const value = await toggle({
|
|
189
206
|
message: \`Please select a value for the \${colors.italic("${option.name}")} option\`,
|
|
190
|
-
${option.description ? `description:
|
|
207
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
191
208
|
` : ""}
|
|
192
209
|
});
|
|
193
210
|
if (isCancel(value)) {
|
|
@@ -196,10 +213,12 @@ function CommandEntry(props) {
|
|
|
196
213
|
|
|
197
214
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
198
215
|
`;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
];
|
|
219
|
+
} });
|
|
220
|
+
}
|
|
221
|
+
});
|
|
203
222
|
}
|
|
204
223
|
}), createComponent(Show, {
|
|
205
224
|
get when() {
|
|
@@ -214,7 +233,7 @@ function CommandEntry(props) {
|
|
|
214
233
|
return code`
|
|
215
234
|
const value = await text({
|
|
216
235
|
message: \`Please provide one or more${option.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
217
|
-
${option.description ? `description:
|
|
236
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
218
237
|
` : ""}validate(val) {
|
|
219
238
|
if (!val || val.trim() === "") {
|
|
220
239
|
return "A value must be provided for this option";
|
|
@@ -258,17 +277,35 @@ function CommandEntry(props) {
|
|
|
258
277
|
return code`!${camelCase(arg.name)}`;
|
|
259
278
|
},
|
|
260
279
|
get children() {
|
|
261
|
-
return createComponent(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
280
|
+
return createComponent(Show, {
|
|
281
|
+
get when() {
|
|
282
|
+
return arg.kind === CommandParameterKinds.boolean || !arg.choices || arg.choices.length === 0;
|
|
283
|
+
},
|
|
284
|
+
get fallback() {
|
|
285
|
+
return code`const value = await select({
|
|
286
|
+
message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,${arg.description ? `description: \`${formatDescription(arg.description)}\`,
|
|
287
|
+
` : ""}
|
|
288
|
+
options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`` : ""} }`).join(", ")} ]
|
|
289
|
+
});
|
|
290
|
+
if (isCancel(value)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
${camelCase(arg.name)} = value;
|
|
295
|
+
`;
|
|
296
|
+
},
|
|
297
|
+
get children() {
|
|
298
|
+
return createComponent(Switch, { get children() {
|
|
299
|
+
return [
|
|
300
|
+
createComponent(Match, {
|
|
301
|
+
get when() {
|
|
302
|
+
return arg.kind === CommandParameterKinds.string;
|
|
303
|
+
},
|
|
304
|
+
get children() {
|
|
305
|
+
return code`
|
|
269
306
|
const value = await text({
|
|
270
307
|
message: \`Please provide a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
271
|
-
${arg.description ? `description:
|
|
308
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
272
309
|
` : ""}validate(val) {
|
|
273
310
|
if (!val || val.trim() === "") {
|
|
274
311
|
return "A value must be provided for this argument";
|
|
@@ -283,17 +320,17 @@ function CommandEntry(props) {
|
|
|
283
320
|
|
|
284
321
|
${camelCase(arg.name)} = value;
|
|
285
322
|
`;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
323
|
+
}
|
|
324
|
+
}),
|
|
325
|
+
createComponent(Match, {
|
|
326
|
+
get when() {
|
|
327
|
+
return arg.kind === CommandParameterKinds.number;
|
|
328
|
+
},
|
|
329
|
+
get children() {
|
|
330
|
+
return code`
|
|
294
331
|
const value = await numeric({
|
|
295
332
|
message: \`Please provide a numeric value for the \${colors.italic("${arg.name}")} argument\`,
|
|
296
|
-
${arg.description ? `description:
|
|
333
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
297
334
|
` : ""}
|
|
298
335
|
});
|
|
299
336
|
if (isCancel(value)) {
|
|
@@ -302,17 +339,17 @@ function CommandEntry(props) {
|
|
|
302
339
|
|
|
303
340
|
${camelCase(arg.name)} = value;
|
|
304
341
|
`;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
342
|
+
}
|
|
343
|
+
}),
|
|
344
|
+
createComponent(Match, {
|
|
345
|
+
get when() {
|
|
346
|
+
return arg.kind === CommandParameterKinds.boolean;
|
|
347
|
+
},
|
|
348
|
+
get children() {
|
|
349
|
+
return code`
|
|
313
350
|
const value = await toggle({
|
|
314
351
|
message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
315
|
-
${arg.description ? `description:
|
|
352
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
316
353
|
` : ""}
|
|
317
354
|
});
|
|
318
355
|
if (isCancel(value)) {
|
|
@@ -321,10 +358,12 @@ function CommandEntry(props) {
|
|
|
321
358
|
|
|
322
359
|
${camelCase(arg.name)} = value;
|
|
323
360
|
`;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
];
|
|
364
|
+
} });
|
|
365
|
+
}
|
|
366
|
+
});
|
|
328
367
|
}
|
|
329
368
|
}), createComponent(Show, {
|
|
330
369
|
get when() {
|
|
@@ -339,7 +378,7 @@ function CommandEntry(props) {
|
|
|
339
378
|
return code`
|
|
340
379
|
const value = await text({
|
|
341
380
|
message: \`Please provide one or more${arg.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
342
|
-
${arg.description ? `description:
|
|
381
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
343
382
|
` : ""}validate(val) {
|
|
344
383
|
if (!val || val.trim() === "") {
|
|
345
384
|
return "A value must be provided for this argument";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseIfClause","IfStatement","Spacing","usePowerlines","EntryFile","CommandParameterKinds","isDynamicPathSegment","CommandHandlerDeclaration","CommandValidationLogic","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","pascalCase","defu","BannerFunctionDeclaration","VirtualCommandEntry","CommandEntry","props","command","imports","builtinImports","rest","context","filePath","segments","filter","segment","join","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$createComponent","_$mergeProps","path","name","prompts","env","console","utils","upgrade","children","_$createIntrinsic","banner","condition","when","Object","values","options","option","optional","length","args","arg","map","kind","string","number","variadic","includes","each","doubleHardline","description","boolean","child","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport {\n CommandHandlerDeclaration,\n CommandValidationLogic\n} from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )}`\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`,\n prompts: \"prompts\"\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n upgrade: [\"checkForUpdates\", \"isCheckForUpdatesRequired\", \"upgrade\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${option.name}\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \"${arg.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \"${arg.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \"${arg.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \"${arg.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgBwB,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUrB,eAAiC;CACjD,MAAMsB,WAAW9B,eACfgB,UACES,QAAQM,SACLC,QAAOC,YAAW,CAACtB,qBAAqBsB,QAAQ,CAAC,CACjDC,KAAK,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ACrBC,WAAQ;AAAA,WAAAlC,gBAAGrB,cAAY,EAACE,SAASmD,OAAK,CAAA;;GAAA,IAAAvB,WAAA;AAAA,WAAAT,gBACrCtB,qBAAmB,EAACG,SAASmD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseIfClause","IfStatement","Spacing","usePowerlines","EntryFile","CommandParameterKinds","formatDescription","formatShortDescription","isDynamicPathSegment","CommandHandlerDeclaration","CommandValidationLogic","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","pascalCase","defu","BannerFunctionDeclaration","VirtualCommandEntry","CommandEntry","props","command","imports","builtinImports","rest","context","filePath","segments","filter","segment","join","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$createComponent","_$mergeProps","path","name","prompts","env","console","utils","upgrade","children","_$createIntrinsic","banner","condition","when","Object","values","options","option","optional","length","args","arg","map","kind","string","number","variadic","includes","each","doubleHardline","boolean","choices","fallback","description","choice","JSON","stringify","child","isVirtual"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport {\n CommandHandlerDeclaration,\n CommandValidationLogic\n} from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )}`\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`,\n prompts: \"prompts\"\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n upgrade: [\"checkForUpdates\", \"isCheckForUpdatesRequired\", \"upgrade\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2DA,SAAgB0B,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUvB,eAAiC;CACjD,MAAMwB,WAAWhC,eACfkB,UACES,QAAQM,SACLC,QAAOC,YAAW,CAACtB,qBAAqBsB,QAAQ,CAAC,CACjDC,KAAK,IAAI,EACZ,WAEJ,CAAC;CACD,MAAMC,oBAAoBrC,eAEtB,KAAKmB,iBACHF,aACEC,UAAUa,QAAQO,WAAWtB,aAAagB,SAASO,MAAM,CAAC,EAC1DZ,QAAQa,MAAMC,OAAOC,QAAQf,QAAQa,MAAME,KAE/C,CAAC,GACJ;CACD,MAAMC,iBAAiB3C,gBAAgB;EACrC,GAAG2B,QAAQa;EACXI,QAAQjB,QAAQkB;EACjB,EAAE;AAEH,QAAA,CAAAC,gBAEKrC,WAASsC,WACJjB,MAAI;EAAA,IACRkB,OAAI;AAAA,UAAEhB,SAASO;;EAAK,IACpBI,iBAAc;AAAA,UAAEA,eAAeJ;;EAAK,IACpCX,UAAO;AAAA,UAAEN,KAAKM,WAAW,EAAE,EAAE;KAC1BS,kBAAkBE,QAAQ,SAASlB,WAAWM,QAAQsB,KAAK;IAC5DC,SAAS;IACV,CAAC;;EAAA,IACFrB,iBAAc;AAAA,UAAEP,KAAKO,kBAAkB,EAAE,EAAE;IACzCsB,KAAK;KAAC;KAAO;KAAiB;KAAW;KAAQ;IACjDC,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDC,OAAO;KACL;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDH,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDI,S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AA,gEACnBkB,IAAIE,SAAS3D,sBAAsB6D,SAC/B,iBACA,GAAE;;;iBAET,CAAA;;eAAA,CAAA,CAAA;;aAAA,CAAA,CAAA;YAKV,CAAA;WAEFxE,IAAI;WAAiB+C,gBACrBvC,SAAO,EAAA,CAAA;WAAA;;SAAA,CAAA;;OAAA,CAAA,CAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAuC,gBAKf7C,KAAG;EAAA,IAACyE,OAAI;AAAA,UAAEd,OAAOC,OAAOlC,QAAQ4B,SAAS;;EAAAA,WACvC4B,UAAKrC,gBACH3C,MAAI;GAAA,IACHwD,OAAI;AAAA,WAAEwB,MAAMC;;GAAS,IACrBN,WAAQ;AAAA,WAAAhC,gBAAGrB,cAAY,EAACE,SAASwD,OAAK,CAAA;;GAAA,IAAA5B,WAAA;AAAA,WAAAT,gBACrCtB,qBAAmB,EAACG,SAASwD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
|
|
@@ -3,6 +3,7 @@ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
3
3
|
let __alloy_js_core = require("@alloy-js/core");
|
|
4
4
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
5
|
let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
6
|
+
let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
6
7
|
let __shell_shock_preset_script_components = require("@shell-shock/preset-script/components");
|
|
7
8
|
|
|
8
9
|
//#region src/components/command-router.tsx
|
|
@@ -16,7 +17,7 @@ function CommandRouterSelectOptions(props) {
|
|
|
16
17
|
hardline: true,
|
|
17
18
|
children: (command) => command.isVirtual ? (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { get commands() {
|
|
18
19
|
return command.children ?? {};
|
|
19
|
-
} }) : __alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description:
|
|
20
|
+
} }) : __alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(command.description)}\`${command.icon ? `, icon: "${command.icon}"` : ""} }`
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core2 from "@alloy-js/core";
|
|
2
2
|
import { CommandTree } from "@shell-shock/core";
|
|
3
3
|
import { CommandRouterProps } from "@shell-shock/preset-script/components";
|
|
4
4
|
|
|
@@ -6,11 +6,11 @@ import { CommandRouterProps } from "@shell-shock/preset-script/components";
|
|
|
6
6
|
interface CommandRouterSelectOptionsProps {
|
|
7
7
|
commands?: Record<string, CommandTree>;
|
|
8
8
|
}
|
|
9
|
-
declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps):
|
|
9
|
+
declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps): _alloy_js_core2.Children;
|
|
10
10
|
/**
|
|
11
11
|
* A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.
|
|
12
12
|
*/
|
|
13
|
-
declare function CommandRouter(props: CommandRouterProps):
|
|
13
|
+
declare function CommandRouter(props: CommandRouterProps): _alloy_js_core2.Children;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps };
|
|
16
16
|
//# sourceMappingURL=command-router.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":[],"mappings":";;;;;UA6BiB,+BAAA;aACJ,eAAe;;AADX,iBAID,0BAAA,CAHY,KAAA,EAInB,+BAJU,CAAA,EAIqB,eAAA,CAAA,QAJrB;AAGnB;AA2BA;;iBAAgB,aAAA,QAAqB,qBAAkB,eAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":[],"mappings":";;;;;UA6BiB,+BAAA;aACJ,eAAe;;AADX,iBAID,0BAAA,CAHY,KAAA,EAInB,+BAJU,CAAA,EAIqB,eAAA,CAAA,QAJrB;AAGnB;AA2BA;;iBAAgB,aAAA,QAAqB,qBAAkB,eAAA,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
|
2
2
|
import { For, code } from "@alloy-js/core";
|
|
3
3
|
import { IfStatement } from "@alloy-js/typescript";
|
|
4
4
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
|
+
import { formatShortDescription } from "@shell-shock/core/plugin-utils";
|
|
5
6
|
import { CommandRouter as CommandRouter$1, CommandRouterBody } from "@shell-shock/preset-script/components";
|
|
6
7
|
|
|
7
8
|
//#region src/components/command-router.tsx
|
|
@@ -15,7 +16,7 @@ function CommandRouterSelectOptions(props) {
|
|
|
15
16
|
hardline: true,
|
|
16
17
|
children: (command) => command.isVirtual ? createComponent(CommandRouterSelectOptions, { get commands() {
|
|
17
18
|
return command.children ?? {};
|
|
18
|
-
} }) : code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description:
|
|
19
|
+
} }) : code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`${formatShortDescription(command.description)}\`${command.icon ? `, icon: "${command.icon}"` : ""} }`
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.mjs","names":["code","For","IfStatement","Spacing","CommandRouter","BaseCommandRouter","CommandRouterBody","CommandRouterSelectOptions","props","commands","_$createComponent","each","Object","values","joiner","hardline","children","command","isVirtual","segments","map","segment","join","title","description","icon","_$mergeProps","condition","_$memo","length"],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport type { CommandRouterProps } from \"@shell-shock/preset-script/components\";\nimport {\n CommandRouter as BaseCommandRouter,\n CommandRouterBody\n} from \"@shell-shock/preset-script/components\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n return (\n <For each={Object.values(commands ?? {})} joiner=\",\" hardline>\n {command =>\n command.isVirtual ? (\n <CommandRouterSelectOptions commands={command.children ?? {}} />\n ) : (\n code`{ value: [${command.segments\n .map(segment => `\"${segment}\"`)\n .join(\", \")}], label: \"${command.title}\", description:
|
|
1
|
+
{"version":3,"file":"command-router.mjs","names":["code","For","IfStatement","Spacing","formatShortDescription","CommandRouter","BaseCommandRouter","CommandRouterBody","CommandRouterSelectOptions","props","commands","_$createComponent","each","Object","values","joiner","hardline","children","command","isVirtual","segments","map","segment","join","title","description","icon","_$mergeProps","condition","_$memo","length"],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { formatShortDescription } from \"@shell-shock/core/plugin-utils\";\nimport type { CommandRouterProps } from \"@shell-shock/preset-script/components\";\nimport {\n CommandRouter as BaseCommandRouter,\n CommandRouterBody\n} from \"@shell-shock/preset-script/components\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n return (\n <For each={Object.values(commands ?? {})} joiner=\",\" hardline>\n {command =>\n command.isVirtual ? (\n <CommandRouterSelectOptions commands={command.children ?? {}} />\n ) : (\n code`{ value: [${command.segments\n .map(segment => `\"${segment}\"`)\n .join(\n \", \"\n )}], label: \"${command.title}\", description: \\`${formatShortDescription(\n command.description\n )}\\`${command.icon ? `, icon: \"${command.icon}\"` : \"\"} }`\n )\n }\n </For>\n );\n}\n\n/**\n * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands } = props;\n\n return (\n <>\n <BaseCommandRouter {...props} segments={segments} commands={commands} />\n <Spacing />\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`await banner();\n\n let segments = await select({\n message: \"Which command would you like to execute?\",\n options: [ `}\n <CommandRouterSelectOptions commands={commands} />\n {` ],\n });\n if (isCancel(segments)) {\n return;\n }\n\n let dynamics = {} as Record<string, string>;\n for (const dynamic of segments.filter(segment => segment.startsWith(\"[\") && segment.endsWith(\"]\"))) {\n const value = await text({\n message: \\`Please provide a value for \\${dynamic.replace(/^\\[+/, \"\").replace(/\\]+$/, \"\")}:\\`,\n });\n if (isCancel(value)) {\n return;\n }\n dynamics[dynamic] = value;\n }\n\n segments = segments.map(segment => dynamics[segment] || segment);\n const context = useApp();\n context.set(\"args\", [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${\n segments.length + 2\n })].filter(Boolean) as string[]);\n\n command = segments[0];\n args = context.get(\"args\"); `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;AAiCA,SAAgBQ,2BACdC,OACA;CACA,MAAM,EAAEC,aAAaD;AAErB,QAAAE,gBACGV,KAAG;EAAA,IAACW,OAAI;AAAA,UAAEC,OAAOC,OAAOJ,YAAY,EAAE,CAAC;;EAAEK,QAAM;EAAKC,UAAQ;EAAAC,WAC1DC,YACCA,QAAQC,YAASR,gBACdH,4BAA0B,EAAA,IAACE,WAAQ;AAAA,UAAEQ,QAAQD,YAAY,EAAE;KAAA,CAAA,GAE5DjB,IAAI,aAAakB,QAAQE,SACtBC,KAAIC,YAAW,IAAIA,QAAO,GAAI,CAC9BC,KACC,KACD,CAAA,aAAcL,QAAQM,MAAK,oBAAqBpB,uBACjDc,QAAQO,YACT,CAAA,IAAKP,QAAQQ,OAAO,YAAYR,QAAQQ,KAAI,KAAM,GAAE;EACtD,CAAA;;;;;AAST,SAAgBrB,cAAcI,OAA2B;CACvD,MAAM,EAAEW,UAAUV,aAAaD;AAE/B,QAAA;EAAAE,gBAEKL,iBAAiBqB,WAAKlB,OAAK;GAAYW;GAAoBV;GAAQ,CAAA,CAAA;EAAAC,gBACnER,SAAO,EAAA,CAAA;EAAAQ,gBACPT,aAAW;GAAC0B,WAAW5B,IAAI;GAA0B,IAAAiB,WAAA;AAAA,WAAA;KACnDjB,IAAI;;;;;KAISW,gBACbH,4BAA0B,EAAWE,UAAQ,CAAA;KAAAmB,WAC7C;;;;;;;;;;;;;;;;;;;wIAoBCT,SAASU,SAAS,EAAC;;;sCAIQ;KAAAnB,gBAC5BJ,mBAAiBoB,WAAKlB,OAAK;MAAYW;MAAoBV;MAAQ,CAAA,CAAA;KAAA;;GAAA,CAAA;EAAAC,gBAErER,SAAO,EAAA,CAAA;EAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core1 from "@alloy-js/core";
|
|
2
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
3
|
import { CommandTree } from "@shell-shock/core";
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ interface VirtualCommandEntryProps extends Omit<EntryFileProps, "path" | "typeDe
|
|
|
9
9
|
/**
|
|
10
10
|
* The virtual command entry point for the Shell Shock project.
|
|
11
11
|
*/
|
|
12
|
-
declare function VirtualCommandEntry(props: VirtualCommandEntryProps):
|
|
12
|
+
declare function VirtualCommandEntry(props: VirtualCommandEntryProps): _alloy_js_core1.Children;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { VirtualCommandEntry, VirtualCommandEntryProps };
|
|
15
15
|
//# sourceMappingURL=virtual-command-entry.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shell-shock/preset-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Shell Shock plugin to generate source code given a list design tokens.",
|
|
6
6
|
"keywords": [
|
|
@@ -170,12 +170,12 @@
|
|
|
170
170
|
"@powerlines/deepkit": "^0.6.90",
|
|
171
171
|
"@powerlines/plugin-alloy": "^0.24.2",
|
|
172
172
|
"@powerlines/plugin-plugin": "^0.12.262",
|
|
173
|
-
"@shell-shock/core": "^0.
|
|
174
|
-
"@shell-shock/plugin-console": "^0.1.
|
|
175
|
-
"@shell-shock/plugin-prompts": "^0.3.
|
|
176
|
-
"@shell-shock/plugin-theme": "^0.3.
|
|
177
|
-
"@shell-shock/plugin-upgrade": "^0.1.
|
|
178
|
-
"@shell-shock/preset-script": "^0.6.
|
|
173
|
+
"@shell-shock/core": "^0.12.0",
|
|
174
|
+
"@shell-shock/plugin-console": "^0.1.8",
|
|
175
|
+
"@shell-shock/plugin-prompts": "^0.3.9",
|
|
176
|
+
"@shell-shock/plugin-theme": "^0.3.12",
|
|
177
|
+
"@shell-shock/plugin-upgrade": "^0.1.14",
|
|
178
|
+
"@shell-shock/preset-script": "^0.6.23",
|
|
179
179
|
"@stryke/path": "^0.26.12",
|
|
180
180
|
"@stryke/string-format": "^0.14.8",
|
|
181
181
|
"cfonts": "^3.3.1",
|
|
@@ -210,5 +210,5 @@
|
|
|
210
210
|
"./package.json": "./package.json"
|
|
211
211
|
}
|
|
212
212
|
},
|
|
213
|
-
"gitHead": "
|
|
213
|
+
"gitHead": "c38d304433a296936fb8ca58aa138a0039918931"
|
|
214
214
|
}
|