@shell-shock/preset-cli 0.8.4 → 0.8.6

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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/components/{banner-function-declaration.cjs → banner-builtin.cjs} +47 -36
  3. package/dist/components/banner-builtin.d.cts +23 -0
  4. package/dist/components/banner-builtin.d.cts.map +1 -0
  5. package/dist/components/banner-builtin.d.mts +23 -0
  6. package/dist/components/banner-builtin.d.mts.map +1 -0
  7. package/dist/components/banner-builtin.mjs +88 -0
  8. package/dist/components/banner-builtin.mjs.map +1 -0
  9. package/dist/components/command-entry.cjs +182 -186
  10. package/dist/components/command-entry.d.cts +1 -1
  11. package/dist/components/command-entry.d.cts.map +1 -1
  12. package/dist/components/command-entry.d.mts.map +1 -1
  13. package/dist/components/command-entry.mjs +182 -186
  14. package/dist/components/command-entry.mjs.map +1 -1
  15. package/dist/components/command-router.cjs +1 -1
  16. package/dist/components/command-router.mjs +1 -1
  17. package/dist/components/command-router.mjs.map +1 -1
  18. package/dist/components/index.cjs +3 -2
  19. package/dist/components/index.d.cts +2 -2
  20. package/dist/components/index.d.mts +2 -2
  21. package/dist/components/index.mjs +2 -2
  22. package/dist/components/virtual-command-entry.cjs +18 -22
  23. package/dist/components/virtual-command-entry.d.cts +1 -1
  24. package/dist/components/virtual-command-entry.d.cts.map +1 -1
  25. package/dist/components/virtual-command-entry.d.mts.map +1 -1
  26. package/dist/components/virtual-command-entry.mjs +18 -22
  27. package/dist/components/virtual-command-entry.mjs.map +1 -1
  28. package/dist/index.cjs +37 -7
  29. package/dist/index.d.cts.map +1 -1
  30. package/dist/index.d.mts.map +1 -1
  31. package/dist/index.mjs +38 -8
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/plugin-banner/dist/components/banner-builtin.cjs +63 -0
  34. package/dist/plugin-banner/dist/components/banner-builtin.mjs +62 -0
  35. package/dist/plugin-banner/dist/components/banner-builtin.mjs.map +1 -0
  36. package/dist/plugin-banner/dist/components/banner-function-declaration.cjs +135 -0
  37. package/dist/plugin-banner/dist/components/banner-function-declaration.d.cts +45 -0
  38. package/dist/plugin-banner/dist/components/banner-function-declaration.d.cts.map +1 -0
  39. package/dist/plugin-banner/dist/components/banner-function-declaration.d.mts +45 -0
  40. package/dist/plugin-banner/dist/components/banner-function-declaration.d.mts.map +1 -0
  41. package/dist/plugin-banner/dist/components/banner-function-declaration.mjs +133 -0
  42. package/dist/plugin-banner/dist/components/banner-function-declaration.mjs.map +1 -0
  43. package/dist/plugin-help/dist/components/display.cjs +14 -0
  44. package/dist/plugin-help/dist/components/display.mjs +14 -0
  45. package/dist/plugin-help/dist/components/display.mjs.map +1 -1
  46. package/dist/plugin-help/dist/index.cjs +1 -1
  47. package/dist/plugin-help/dist/index.mjs +1 -1
  48. package/package.json +19 -19
  49. package/dist/components/banner-function-declaration.d.cts +0 -11
  50. package/dist/components/banner-function-declaration.d.cts.map +0 -1
  51. package/dist/components/banner-function-declaration.d.mts +0 -11
  52. package/dist/components/banner-function-declaration.d.mts.map +0 -1
  53. package/dist/components/banner-function-declaration.mjs +0 -78
  54. package/dist/components/banner-function-declaration.mjs.map +0 -1
@@ -1,4 +1,3 @@
1
- import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
2
1
  import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
3
2
  import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
4
3
  import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
@@ -63,6 +62,7 @@ function CommandEntry(props) {
63
62
  "createSpinner"
64
63
  ],
65
64
  utils: [
65
+ "sleep",
66
66
  "useApp",
67
67
  "useArgs",
68
68
  "hasFlag",
@@ -79,61 +79,58 @@ function CommandEntry(props) {
79
79
  "select",
80
80
  "confirm",
81
81
  "waitForKeyPress",
82
- "isCancel",
83
- "sleep"
82
+ "isCancel"
84
83
  ],
85
84
  [joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
85
+ [joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"],
86
86
  upgrade: ["executeUpgrade"]
87
87
  });
88
88
  },
89
89
  get children() {
90
- return [
91
- createComponent(BannerFunctionDeclaration, { command }),
92
- createComponent(Spacing, {}),
93
- createComponent(CommandHandlerDeclaration, {
94
- command,
95
- banner: code`await banner();
90
+ return [createComponent(Spacing, {}), createComponent(CommandHandlerDeclaration, {
91
+ command,
92
+ banner: code`await showBanner();
96
93
  await executeUpgrade(); `,
97
- get children() {
98
- return [createComponent(IfStatement, {
99
- condition: code`!isInteractive`,
100
- get children() {
101
- return createComponent(CommandValidationLogic, { command });
102
- }
103
- }), createComponent(Show, {
104
- get when() {
105
- return Object.values(command.options ?? {}).filter((option) => !option.optional).length > 0 || Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0;
106
- },
107
- get children() {
108
- return createComponent(ElseIfClause, {
109
- get condition() {
110
- return code`!isHelp && (${Object.values(command.options ?? {}).filter((option) => !option.optional).map((option) => (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.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.optional).length > 0 && Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0 ? " || " : ""}${Object.values(command.args ?? {}).filter((arg) => !arg.optional).map((arg) => (arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? `(!${camelCase(arg.name)} || ${camelCase(arg.name)}.length === 0)` : `${camelCase(arg.name)} === undefined`).join(" || ")}) `;
111
- },
112
- get children() {
113
- return [
114
- code`writeLine(""); `,
115
- createComponent(Spacing, {}),
116
- createComponent(For, {
117
- get each() {
118
- return Object.values(command.options ?? {});
94
+ get children() {
95
+ return [createComponent(IfStatement, {
96
+ condition: code`!isInteractive`,
97
+ get children() {
98
+ return createComponent(CommandValidationLogic, { command });
99
+ }
100
+ }), createComponent(Show, {
101
+ get when() {
102
+ return Object.values(command.options ?? {}).filter((option) => !option.optional).length > 0 || Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0;
103
+ },
104
+ get children() {
105
+ return createComponent(ElseIfClause, {
106
+ get condition() {
107
+ return code`!isHelp && (${Object.values(command.options ?? {}).filter((option) => !option.optional).map((option) => (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.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.optional).length > 0 && Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0 ? " || " : ""}${Object.values(command.args ?? {}).filter((arg) => !arg.optional).map((arg) => (arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? `(!${camelCase(arg.name)} || ${camelCase(arg.name)}.length === 0)` : `${camelCase(arg.name)} === undefined`).join(" || ")}) `;
108
+ },
109
+ get children() {
110
+ return [
111
+ code`writeLine(""); `,
112
+ createComponent(Spacing, {}),
113
+ createComponent(For, {
114
+ get each() {
115
+ return Object.values(command.options ?? {});
116
+ },
117
+ doubleHardline: true,
118
+ children: (option) => [createComponent(Show, {
119
+ get when() {
120
+ return !option.optional;
119
121
  },
120
- doubleHardline: true,
121
- children: (option) => [createComponent(Show, {
122
- get when() {
123
- return !option.optional;
124
- },
125
- get children() {
126
- return [createComponent(IfStatement, {
127
- get condition() {
128
- return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
129
- },
130
- get children() {
131
- return createComponent(Show, {
132
- get when() {
133
- return option.kind === CommandParameterKinds.boolean || !option.choices || option.choices.length === 0;
134
- },
135
- get fallback() {
136
- return code`const value = await select({
122
+ get children() {
123
+ return [createComponent(IfStatement, {
124
+ get condition() {
125
+ return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
126
+ },
127
+ get children() {
128
+ return createComponent(Show, {
129
+ get when() {
130
+ return option.kind === CommandParameterKinds.boolean || !option.choices || option.choices.length === 0;
131
+ },
132
+ get fallback() {
133
+ return code`const value = await select({
137
134
  message: \`Please select a value for the \${colors.italic("${option.name}")} option\`, ${option.description ? `description: \`${formatDescription(option.description)}\`,
138
135
  ` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${formatShortDescription(option.description)}\`` : ""} }`).join(", ")} ]
139
136
  });
@@ -143,16 +140,16 @@ function CommandEntry(props) {
143
140
 
144
141
  options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
145
142
  `;
146
- },
147
- get children() {
148
- return createComponent(Switch, { get children() {
149
- return [
150
- createComponent(Match, {
151
- get when() {
152
- return option.kind === CommandParameterKinds.string;
153
- },
154
- get children() {
155
- return code`
143
+ },
144
+ get children() {
145
+ return createComponent(Switch, { get children() {
146
+ return [
147
+ createComponent(Match, {
148
+ get when() {
149
+ return option.kind === CommandParameterKinds.string;
150
+ },
151
+ get children() {
152
+ return code`
156
153
  const value = await text({
157
154
  message: \`Please provide a value for the \${colors.italic("${option.name}")} option\`,
158
155
  ${option.description ? `description: \`${formatDescription(option.description)}\`,
@@ -170,14 +167,14 @@ function CommandEntry(props) {
170
167
 
171
168
  options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
172
169
  `;
173
- }
174
- }),
175
- createComponent(Match, {
176
- get when() {
177
- return option.kind === CommandParameterKinds.number;
178
- },
179
- get children() {
180
- return code`
170
+ }
171
+ }),
172
+ createComponent(Match, {
173
+ get when() {
174
+ return option.kind === CommandParameterKinds.number;
175
+ },
176
+ get children() {
177
+ return code`
181
178
  const value = await numeric({
182
179
  message: \`Please provide a numeric value for the \${colors.italic("${option.name}")} option\`,
183
180
  ${option.description ? `description: \`${formatDescription(option.description)}\`,
@@ -189,14 +186,14 @@ function CommandEntry(props) {
189
186
 
190
187
  options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
191
188
  `;
192
- }
193
- }),
194
- createComponent(Match, {
195
- get when() {
196
- return option.kind === CommandParameterKinds.boolean;
197
- },
198
- get children() {
199
- return code`
189
+ }
190
+ }),
191
+ createComponent(Match, {
192
+ get when() {
193
+ return option.kind === CommandParameterKinds.boolean;
194
+ },
195
+ get children() {
196
+ return code`
200
197
  const value = await toggle({
201
198
  message: \`Please select a value for the \${colors.italic("${option.name}")} option\`,
202
199
  ${option.description ? `description: \`${formatDescription(option.description)}\`,
@@ -208,24 +205,24 @@ function CommandEntry(props) {
208
205
 
209
206
  options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
210
207
  `;
211
- }
212
- })
213
- ];
214
- } });
215
- }
216
- });
217
- }
218
- }), createComponent(Show, {
219
- get when() {
220
- return (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic;
221
- },
222
- get children() {
223
- return createComponent(ElseIfClause, {
224
- get condition() {
225
- return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
226
- },
227
- get children() {
228
- return code`
208
+ }
209
+ })
210
+ ];
211
+ } });
212
+ }
213
+ });
214
+ }
215
+ }), createComponent(Show, {
216
+ get when() {
217
+ return (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic;
218
+ },
219
+ get children() {
220
+ return createComponent(ElseIfClause, {
221
+ get condition() {
222
+ return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
223
+ },
224
+ get children() {
225
+ return code`
229
226
  const value = await text({
230
227
  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)\`,
231
228
  ${option.description ? `description: \`${formatDescription(option.description)}\`,
@@ -249,35 +246,35 @@ function CommandEntry(props) {
249
246
 
250
247
  options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.kind === CommandParameterKinds.number ? `.map(Number)` : ""} ;
251
248
  `;
252
- }
253
- });
254
- }
255
- })];
256
- }
257
- })]
258
- }),
259
- createComponent(Spacing, {}),
260
- createComponent(For, {
261
- get each() {
262
- return command.args;
249
+ }
250
+ });
251
+ }
252
+ })];
253
+ }
254
+ })]
255
+ }),
256
+ createComponent(Spacing, {}),
257
+ createComponent(For, {
258
+ get each() {
259
+ return command.args;
260
+ },
261
+ doubleHardline: true,
262
+ children: (arg) => [createComponent(Show, {
263
+ get when() {
264
+ return !arg.optional;
263
265
  },
264
- doubleHardline: true,
265
- children: (arg) => [createComponent(Show, {
266
- get when() {
267
- return !arg.optional;
268
- },
269
- get children() {
270
- return [createComponent(IfStatement, {
271
- get condition() {
272
- return code`!${camelCase(arg.name)}`;
273
- },
274
- get children() {
275
- return createComponent(Show, {
276
- get when() {
277
- return arg.kind === CommandParameterKinds.boolean || !arg.choices || arg.choices.length === 0;
278
- },
279
- get fallback() {
280
- return code`const value = await select({
266
+ get children() {
267
+ return [createComponent(IfStatement, {
268
+ get condition() {
269
+ return code`!${camelCase(arg.name)}`;
270
+ },
271
+ get children() {
272
+ return createComponent(Show, {
273
+ get when() {
274
+ return arg.kind === CommandParameterKinds.boolean || !arg.choices || arg.choices.length === 0;
275
+ },
276
+ get fallback() {
277
+ return code`const value = await select({
281
278
  message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,${arg.description ? `description: \`${formatDescription(arg.description)}\`,
282
279
  ` : ""}
283
280
  options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`` : ""} }`).join(", ")} ]
@@ -288,16 +285,16 @@ function CommandEntry(props) {
288
285
 
289
286
  ${camelCase(arg.name)} = value;
290
287
  `;
291
- },
292
- get children() {
293
- return createComponent(Switch, { get children() {
294
- return [
295
- createComponent(Match, {
296
- get when() {
297
- return arg.kind === CommandParameterKinds.string;
298
- },
299
- get children() {
300
- return code`
288
+ },
289
+ get children() {
290
+ return createComponent(Switch, { get children() {
291
+ return [
292
+ createComponent(Match, {
293
+ get when() {
294
+ return arg.kind === CommandParameterKinds.string;
295
+ },
296
+ get children() {
297
+ return code`
301
298
  const value = await text({
302
299
  message: \`Please provide a value for the \${colors.italic("${arg.name}")} argument\`,
303
300
  ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
@@ -315,14 +312,14 @@ function CommandEntry(props) {
315
312
 
316
313
  ${camelCase(arg.name)} = value;
317
314
  `;
318
- }
319
- }),
320
- createComponent(Match, {
321
- get when() {
322
- return arg.kind === CommandParameterKinds.number;
323
- },
324
- get children() {
325
- return code`
315
+ }
316
+ }),
317
+ createComponent(Match, {
318
+ get when() {
319
+ return arg.kind === CommandParameterKinds.number;
320
+ },
321
+ get children() {
322
+ return code`
326
323
  const value = await numeric({
327
324
  message: \`Please provide a numeric value for the \${colors.italic("${arg.name}")} argument\`,
328
325
  ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
@@ -334,14 +331,14 @@ function CommandEntry(props) {
334
331
 
335
332
  ${camelCase(arg.name)} = value;
336
333
  `;
337
- }
338
- }),
339
- createComponent(Match, {
340
- get when() {
341
- return arg.kind === CommandParameterKinds.boolean;
342
- },
343
- get children() {
344
- return code`
334
+ }
335
+ }),
336
+ createComponent(Match, {
337
+ get when() {
338
+ return arg.kind === CommandParameterKinds.boolean;
339
+ },
340
+ get children() {
341
+ return code`
345
342
  const value = await toggle({
346
343
  message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,
347
344
  ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
@@ -353,24 +350,24 @@ function CommandEntry(props) {
353
350
 
354
351
  ${camelCase(arg.name)} = value;
355
352
  `;
356
- }
357
- })
358
- ];
359
- } });
360
- }
361
- });
362
- }
363
- }), createComponent(Show, {
364
- get when() {
365
- return (arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic;
366
- },
367
- get children() {
368
- return createComponent(ElseIfClause, {
369
- get condition() {
370
- return code`${camelCase(arg.name)}.length === 0`;
371
- },
372
- get children() {
373
- return code`
353
+ }
354
+ })
355
+ ];
356
+ } });
357
+ }
358
+ });
359
+ }
360
+ }), createComponent(Show, {
361
+ get when() {
362
+ return (arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic;
363
+ },
364
+ get children() {
365
+ return createComponent(ElseIfClause, {
366
+ get condition() {
367
+ return code`${camelCase(arg.name)}.length === 0`;
368
+ },
369
+ get children() {
370
+ return code`
374
371
  const value = await text({
375
372
  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)\`,
376
373
  ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
@@ -395,29 +392,28 @@ function CommandEntry(props) {
395
392
 
396
393
  ${camelCase(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.kind === CommandParameterKinds.number ? `.map(Number)` : ""} ;
397
394
  `;
398
- }
399
- });
400
- }
401
- })];
402
- }
403
- })]
404
- }),
405
- code`writeLine(""); `,
406
- createComponent(Spacing, {}),
407
- createComponent(CommandValidationLogic, { command }),
408
- createComponent(IfStatement, {
409
- condition: code`failures.length > 0`,
410
- children: code`error("The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\n\\n" + failures.map(failure => " - " + failure).join("\\n"));
395
+ }
396
+ });
397
+ }
398
+ })];
399
+ }
400
+ })]
401
+ }),
402
+ code`writeLine(""); `,
403
+ createComponent(Spacing, {}),
404
+ createComponent(CommandValidationLogic, { command }),
405
+ createComponent(IfStatement, {
406
+ condition: code`failures.length > 0`,
407
+ children: code`error("The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\n\\n" + failures.map(failure => " - " + failure).join("\\n"));
411
408
  options.help = true; `
412
- })
413
- ];
414
- }
415
- });
416
- }
417
- })];
418
- }
419
- })
420
- ];
409
+ })
410
+ ];
411
+ }
412
+ });
413
+ }
414
+ })];
415
+ }
416
+ })];
421
417
  }
422
418
  })), createComponent(For, {
423
419
  get each() {