@shell-shock/preset-cli 0.1.6 → 0.2.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/README.md CHANGED
@@ -27,7 +27,7 @@ This package is part of the ⚡<b>Shell Shock</b> monorepo. The Shell Shock pack
27
27
 
28
28
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
29
 
30
- [![Version](https://img.shields.io/badge/version-0.1.4-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
30
+ [![Version](https://img.shields.io/badge/version-0.1.5-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
31
 
32
32
  <!-- prettier-ignore-start -->
33
33
  <!-- markdownlint-disable -->
@@ -1,11 +1,11 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
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): _alloy_js_core0.Children;
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
@@ -38,7 +38,10 @@ function CommandEntry(props) {
38
38
  return typeDefinition.value;
39
39
  },
40
40
  get imports() {
41
- return (0, defu.default)(imports ?? {}, { [commandSourcePath.value]: `handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}` });
41
+ return (0, defu.default)(imports ?? {}, {
42
+ [commandSourcePath.value]: `handle${(0, __stryke_string_format_pascal_case.pascalCase)(command.name)}`,
43
+ prompts: "prompts"
44
+ });
42
45
  },
43
46
  get builtinImports() {
44
47
  return (0, defu.default)(builtinImports ?? {}, {
@@ -56,14 +59,18 @@ function CommandEntry(props) {
56
59
  "colors",
57
60
  "stripAnsi",
58
61
  "writeLine",
59
- "splitText"
62
+ "splitText",
63
+ "text",
64
+ "confirm",
65
+ "isCancel"
60
66
  ],
61
67
  utils: [
62
68
  "getArgs",
63
69
  "hasFlag",
64
70
  "isMinimal",
71
+ "isInteractive",
65
72
  "isUnicodeSupported",
66
- "internal_commandContext"
73
+ "internal_commandContextStore"
67
74
  ]
68
75
  });
69
76
  },
@@ -75,153 +82,221 @@ function CommandEntry(props) {
75
82
  (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_command_entry.CommandHandlerDeclaration, {
76
83
  command,
77
84
  get children() {
78
- return [
79
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
80
- name: "failures",
81
- type: "string[]",
82
- initializer: __alloy_js_core.code`[];`
83
- }),
84
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
85
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
86
- get each() {
87
- return Object.values(command.options ?? {});
88
- },
89
- doubleHardline: true,
90
- children: (option) => [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
91
- get when() {
92
- return !option.optional;
93
- },
94
- get children() {
95
- return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
96
- get condition() {
97
- return __alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}`;
98
- },
99
- get children() {
100
- return __alloy_js_core.code`failures.push("Missing required \\"${option.name}\\" option");`;
101
- }
102
- }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
103
- get when() {
104
- return (option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) && option.variadic;
105
- },
106
- get children() {
107
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
108
- get condition() {
109
- return __alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}.length === 0`;
110
- },
111
- get children() {
112
- return __alloy_js_core.code`failures.push("No values were provided to the required \\"${option.name}\\" array option");`;
113
- }
114
- });
115
- }
116
- })];
117
- }
118
- }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
119
- get when() {
120
- return option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number;
85
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
86
+ condition: __alloy_js_core.code`!isInteractive`,
87
+ get children() {
88
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_command_entry.CommandValidationLogic, { command });
89
+ }
90
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { get children() {
91
+ return [
92
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
93
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
94
+ get each() {
95
+ return Object.values(command.options ?? {});
121
96
  },
122
- get children() {
123
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
124
- get when() {
125
- return option.variadic;
126
- },
127
- get fallback() {
128
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
129
- get condition() {
130
- return __alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} && Number.isNaN(options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`})`;
131
- },
132
- get children() {
133
- return __alloy_js_core.code`failures.push("Invalid numeric value provided for the \\"${option.name}\\" option");`;
134
- }
135
- });
136
- },
137
- get children() {
138
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
139
- get condition() {
140
- return __alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}.some(value => Number.isNaN(value))`;
141
- },
142
- get children() {
143
- return __alloy_js_core.code`failures.push("Invalid numeric value provided in the \\"${option.name}\\" array option");`;
144
- }
145
- });
146
- }
147
- });
148
- }
149
- })]
150
- }),
151
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
152
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
153
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
154
- get each() {
155
- return command.arguments;
156
- },
157
- doubleHardline: true,
158
- children: (argument) => [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
159
- get when() {
160
- return !argument.optional;
161
- },
162
- get children() {
163
- return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
164
- get condition() {
165
- return __alloy_js_core.code`!${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}`;
166
- },
167
- get children() {
168
- return __alloy_js_core.code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
169
- }
170
- }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
171
- get when() {
172
- return (argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) && argument.variadic;
173
- },
174
- get children() {
175
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
176
- get condition() {
177
- return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}.length === 0`;
178
- },
179
- get children() {
180
- return __alloy_js_core.code`failures.push("No values were provided to the required \\"${argument.name}\\" array positional argument");`;
181
- }
182
- });
183
- }
184
- })];
185
- }
186
- }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
187
- get when() {
188
- return argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number;
97
+ doubleHardline: true,
98
+ children: (option) => [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
99
+ get when() {
100
+ return !option.optional;
101
+ },
102
+ get children() {
103
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
104
+ get condition() {
105
+ return __alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}`;
106
+ },
107
+ get children() {
108
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Switch, { get children() {
109
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
110
+ get when() {
111
+ return option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number;
112
+ },
113
+ get children() {
114
+ return __alloy_js_core.code`
115
+ const value = await text({
116
+ message: 'Please provide a value for the ${option.title} option:',
117
+ validate(value) {
118
+ if (isCancel(value)) {
119
+ return true;
120
+ }
121
+ if (!value || value.trim() === "") {
122
+ return "A value is required for this option";
123
+ }
124
+ ${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
125
+ return "The value provided must be a valid number";
126
+ }` : ""}
127
+ return undefined;
128
+ }
129
+ });
130
+ if (isCancel(value)) {
131
+ return;
132
+ }
133
+
134
+ options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = ${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `Number(value)` : "value"};
135
+ `;
136
+ }
137
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
138
+ get when() {
139
+ return option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean;
140
+ },
141
+ get children() {
142
+ return __alloy_js_core.code`
143
+ options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = await confirm({
144
+ message: 'Please select a value for the ${option.title} option:'
145
+ });
146
+ `;
147
+ }
148
+ })];
149
+ } });
150
+ }
151
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
152
+ get when() {
153
+ return (option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) && option.variadic;
154
+ },
155
+ get children() {
156
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
157
+ get condition() {
158
+ return __alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}.length === 0`;
159
+ },
160
+ get children() {
161
+ return __alloy_js_core.code`
162
+ const value = await text({
163
+ message: 'Please provide one or more values for the ${option.title} option (values are separated by a "," character):',
164
+ validate(value) {
165
+ if (isCancel(value)) {
166
+ return true;
167
+ }
168
+ if (!value || value.trim() === "") {
169
+ return "A value is required for this option";
170
+ }
171
+ if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
172
+ return "At least one value is required for this option";
173
+ }
174
+ ${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
175
+ if (invalidIndex !== -1) {
176
+ return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
177
+ } ` : ""}
178
+ return undefined;
179
+ }
180
+ });
181
+ if (isCancel(value)) {
182
+ return;
183
+ }
184
+
185
+ options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `.map(Number)` : ""} ;
186
+ `;
187
+ }
188
+ });
189
+ }
190
+ })];
191
+ }
192
+ })]
193
+ }),
194
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
195
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
196
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
197
+ get each() {
198
+ return command.arguments;
189
199
  },
190
- get children() {
191
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
192
- get when() {
193
- return argument.variadic;
194
- },
195
- get fallback() {
196
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
197
- get condition() {
198
- return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(argument.name)} && Number.isNaN(${(0, __stryke_string_format_camel_case.camelCase)(argument.name)})`;
199
- },
200
- get children() {
201
- return __alloy_js_core.code`failures.push("Invalid numeric value provided for the \\"${argument.name}\\" positional argument");`;
202
- }
203
- });
204
- },
205
- get children() {
206
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
207
- get condition() {
208
- return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}.some(value => Number.isNaN(value))`;
209
- },
210
- get children() {
211
- return __alloy_js_core.code`failures.push("Invalid numeric value provided in the \\"${argument.name}\\" array positional argument");`;
212
- }
213
- });
214
- }
215
- });
216
- }
217
- })]
218
- }),
219
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
220
- condition: __alloy_js_core.code`failures.length > 0`,
221
- children: __alloy_js_core.code`error(colors.text.message.description.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 => colors.text.body.secondary(" - " + failure)).join("\\n"));
222
- options.help = true; `
223
- })
224
- ];
200
+ doubleHardline: true,
201
+ children: (argument) => [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
202
+ get when() {
203
+ return !argument.optional;
204
+ },
205
+ get children() {
206
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
207
+ get condition() {
208
+ return __alloy_js_core.code`!${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}`;
209
+ },
210
+ get children() {
211
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Switch, { get children() {
212
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
213
+ get when() {
214
+ return argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number;
215
+ },
216
+ get children() {
217
+ return __alloy_js_core.code`
218
+ const value = await text({
219
+ message: 'Please provide a value for the ${argument.title} positional argument:',
220
+ validate(value) {
221
+ if (isCancel(value)) {
222
+ return true;
223
+ }
224
+ if (!value || value.trim() === "") {
225
+ return "A value is required for this positional argument";
226
+ }
227
+ ${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
228
+ return "The value provided must be a valid number";
229
+ }` : ""}
230
+ return undefined;
231
+ }
232
+ });
233
+ if (isCancel(value)) {
234
+ return;
235
+ }
236
+
237
+ ${(0, __stryke_string_format_camel_case.camelCase)(argument.name)} = ${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `Number(value)` : "value"};
238
+ `;
239
+ }
240
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
241
+ get when() {
242
+ return argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean;
243
+ },
244
+ get children() {
245
+ return __alloy_js_core.code`
246
+ ${(0, __stryke_string_format_camel_case.camelCase)(argument.name)} = await confirm({
247
+ message: 'Please select a value for the ${argument.title} positional argument:'
248
+ });
249
+ `;
250
+ }
251
+ })];
252
+ } });
253
+ }
254
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
255
+ get when() {
256
+ return (argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) && argument.variadic;
257
+ },
258
+ get children() {
259
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
260
+ get condition() {
261
+ return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(argument.name)}.length === 0`;
262
+ },
263
+ get children() {
264
+ return __alloy_js_core.code`
265
+ const value = await text({
266
+ message: 'Please provide one or more values for the ${argument.title} option (values are separated by a "," character):',
267
+ validate(value) {
268
+ if (isCancel(value)) {
269
+ return true;
270
+ }
271
+ if (!value || value.trim() === "") {
272
+ return "A value is required for this option";
273
+ }
274
+ if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
275
+ return "At least one value is required for this option";
276
+ }
277
+ ${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
278
+ if (invalidIndex !== -1) {
279
+ return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
280
+ } ` : ""}
281
+
282
+ return undefined;
283
+ }
284
+ });
285
+ if (isCancel(value)) {
286
+ return;
287
+ }
288
+
289
+ ${(0, __stryke_string_format_camel_case.camelCase)(argument.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `.map(Number)` : ""} ;
290
+ `;
291
+ }
292
+ });
293
+ }
294
+ })];
295
+ }
296
+ })]
297
+ })
298
+ ];
299
+ } })];
225
300
  }
226
301
  })
227
302
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA6CiB,iBAAA,SAA0B,KACzC;WAGS;;AAJX;;;AAA2C,iBAU3B,YAAA,CAV2B,KAAA,EAUP,iBAVO,CAAA,EAUU,eAAA,CAAA,QAVV"}
1
+ {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UAwCiB,iBAAA,SAA0B,KACzC;WAGS;;AAJX;;;AAA2C,iBAU3B,YAAA,CAV2B,KAAA,EAUP,iBAVO,CAAA,EAUU,eAAA,CAAA,QAVV"}
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA6CiB,iBAAA,SAA0B,KACzC;WAGS;;AAJX;;;AAA2C,iBAU3B,YAAA,CAV2B,KAAA,EAUP,iBAVO,CAAA,EAUU,eAAA,CAAA,QAVV"}
1
+ {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UAwCiB,iBAAA,SAA0B,KACzC;WAGS;;AAJX;;;AAA2C,iBAU3B,YAAA,CAV2B,KAAA,EAUP,iBAVO,CAAA,EAUU,eAAA,CAAA,QAVV"}
@@ -1,13 +1,13 @@
1
1
  import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
2
2
  import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
3
3
  import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
4
- import { For, Show, code, computed } from "@alloy-js/core";
5
- import { ElseIfClause, IfStatement, VarDeclaration } from "@alloy-js/typescript";
4
+ import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
5
+ import { ElseClause, ElseIfClause, IfStatement } from "@alloy-js/typescript";
6
6
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
7
  import { isDynamicPathSegment } from "@shell-shock/core/plugin-utils/context-helpers";
8
8
  import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
9
9
  import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
10
- import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
10
+ import { CommandHandlerDeclaration, CommandValidationLogic } from "@shell-shock/preset-script/components/command-entry";
11
11
  import { findFilePath, relativePath } from "@stryke/path/find";
12
12
  import { joinPaths } from "@stryke/path/join";
13
13
  import { replaceExtension } from "@stryke/path/replace";
@@ -36,7 +36,10 @@ function CommandEntry(props) {
36
36
  return typeDefinition.value;
37
37
  },
38
38
  get imports() {
39
- return defu(imports ?? {}, { [commandSourcePath.value]: `handle${pascalCase(command.name)}` });
39
+ return defu(imports ?? {}, {
40
+ [commandSourcePath.value]: `handle${pascalCase(command.name)}`,
41
+ prompts: "prompts"
42
+ });
40
43
  },
41
44
  get builtinImports() {
42
45
  return defu(builtinImports ?? {}, {
@@ -54,14 +57,18 @@ function CommandEntry(props) {
54
57
  "colors",
55
58
  "stripAnsi",
56
59
  "writeLine",
57
- "splitText"
60
+ "splitText",
61
+ "text",
62
+ "confirm",
63
+ "isCancel"
58
64
  ],
59
65
  utils: [
60
66
  "getArgs",
61
67
  "hasFlag",
62
68
  "isMinimal",
69
+ "isInteractive",
63
70
  "isUnicodeSupported",
64
- "internal_commandContext"
71
+ "internal_commandContextStore"
65
72
  ]
66
73
  });
67
74
  },
@@ -73,153 +80,221 @@ function CommandEntry(props) {
73
80
  createComponent(CommandHandlerDeclaration, {
74
81
  command,
75
82
  get children() {
76
- return [
77
- createComponent(VarDeclaration, {
78
- name: "failures",
79
- type: "string[]",
80
- initializer: code`[];`
81
- }),
82
- createIntrinsic("hbr", {}),
83
- createComponent(For, {
84
- get each() {
85
- return Object.values(command.options ?? {});
86
- },
87
- doubleHardline: true,
88
- children: (option) => [createComponent(Show, {
89
- get when() {
90
- return !option.optional;
91
- },
92
- get children() {
93
- return [createComponent(IfStatement, {
94
- get condition() {
95
- return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
96
- },
97
- get children() {
98
- return code`failures.push("Missing required \\"${option.name}\\" option");`;
99
- }
100
- }), createComponent(Show, {
101
- get when() {
102
- return (option.kind === ReflectionKind.string || option.kind === ReflectionKind.number) && option.variadic;
103
- },
104
- get children() {
105
- return createComponent(ElseIfClause, {
106
- get condition() {
107
- return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
108
- },
109
- get children() {
110
- return code`failures.push("No values were provided to the required \\"${option.name}\\" array option");`;
111
- }
112
- });
113
- }
114
- })];
115
- }
116
- }), createComponent(Show, {
117
- get when() {
118
- return option.kind === ReflectionKind.number;
83
+ return [createComponent(IfStatement, {
84
+ condition: code`!isInteractive`,
85
+ get children() {
86
+ return createComponent(CommandValidationLogic, { command });
87
+ }
88
+ }), createComponent(ElseClause, { get children() {
89
+ return [
90
+ createIntrinsic("hbr", {}),
91
+ createComponent(For, {
92
+ get each() {
93
+ return Object.values(command.options ?? {});
119
94
  },
120
- get children() {
121
- return createComponent(Show, {
122
- get when() {
123
- return option.variadic;
124
- },
125
- get fallback() {
126
- return createComponent(IfStatement, {
127
- get condition() {
128
- return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} && Number.isNaN(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
129
- },
130
- get children() {
131
- return code`failures.push("Invalid numeric value provided for the \\"${option.name}\\" option");`;
132
- }
133
- });
134
- },
135
- get children() {
136
- return createComponent(IfStatement, {
137
- get condition() {
138
- return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.some(value => Number.isNaN(value))`;
139
- },
140
- get children() {
141
- return code`failures.push("Invalid numeric value provided in the \\"${option.name}\\" array option");`;
142
- }
143
- });
144
- }
145
- });
146
- }
147
- })]
148
- }),
149
- createIntrinsic("hbr", {}),
150
- createIntrinsic("hbr", {}),
151
- createComponent(For, {
152
- get each() {
153
- return command.arguments;
154
- },
155
- doubleHardline: true,
156
- children: (argument) => [createComponent(Show, {
157
- get when() {
158
- return !argument.optional;
159
- },
160
- get children() {
161
- return [createComponent(IfStatement, {
162
- get condition() {
163
- return code`!${camelCase(argument.name)}`;
164
- },
165
- get children() {
166
- return code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
167
- }
168
- }), createComponent(Show, {
169
- get when() {
170
- return (argument.kind === ReflectionKind.string || argument.kind === ReflectionKind.number) && argument.variadic;
171
- },
172
- get children() {
173
- return createComponent(ElseIfClause, {
174
- get condition() {
175
- return code`${camelCase(argument.name)}.length === 0`;
176
- },
177
- get children() {
178
- return code`failures.push("No values were provided to the required \\"${argument.name}\\" array positional argument");`;
179
- }
180
- });
181
- }
182
- })];
183
- }
184
- }), createComponent(Show, {
185
- get when() {
186
- return argument.kind === ReflectionKind.number;
95
+ doubleHardline: true,
96
+ children: (option) => [createComponent(Show, {
97
+ get when() {
98
+ return !option.optional;
99
+ },
100
+ get children() {
101
+ return [createComponent(IfStatement, {
102
+ get condition() {
103
+ return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
104
+ },
105
+ get children() {
106
+ return createComponent(Switch, { get children() {
107
+ return [createComponent(Match, {
108
+ get when() {
109
+ return option.kind === ReflectionKind.string || option.kind === ReflectionKind.number;
110
+ },
111
+ get children() {
112
+ return code`
113
+ const value = await text({
114
+ message: 'Please provide a value for the ${option.title} option:',
115
+ validate(value) {
116
+ if (isCancel(value)) {
117
+ return true;
118
+ }
119
+ if (!value || value.trim() === "") {
120
+ return "A value is required for this option";
121
+ }
122
+ ${option.kind === ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
123
+ return "The value provided must be a valid number";
124
+ }` : ""}
125
+ return undefined;
126
+ }
127
+ });
128
+ if (isCancel(value)) {
129
+ return;
130
+ }
131
+
132
+ options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = ${option.kind === ReflectionKind.number ? `Number(value)` : "value"};
133
+ `;
134
+ }
135
+ }), createComponent(Match, {
136
+ get when() {
137
+ return option.kind === ReflectionKind.boolean;
138
+ },
139
+ get children() {
140
+ return code`
141
+ options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = await confirm({
142
+ message: 'Please select a value for the ${option.title} option:'
143
+ });
144
+ `;
145
+ }
146
+ })];
147
+ } });
148
+ }
149
+ }), createComponent(Show, {
150
+ get when() {
151
+ return (option.kind === ReflectionKind.string || option.kind === ReflectionKind.number) && option.variadic;
152
+ },
153
+ get children() {
154
+ return createComponent(ElseIfClause, {
155
+ get condition() {
156
+ return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
157
+ },
158
+ get children() {
159
+ return code`
160
+ const value = await text({
161
+ message: 'Please provide one or more values for the ${option.title} option (values are separated by a "," character):',
162
+ validate(value) {
163
+ if (isCancel(value)) {
164
+ return true;
165
+ }
166
+ if (!value || value.trim() === "") {
167
+ return "A value is required for this option";
168
+ }
169
+ if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
170
+ return "At least one value is required for this option";
171
+ }
172
+ ${option.kind === ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
173
+ if (invalidIndex !== -1) {
174
+ return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
175
+ } ` : ""}
176
+ return undefined;
177
+ }
178
+ });
179
+ if (isCancel(value)) {
180
+ return;
181
+ }
182
+
183
+ options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.kind === ReflectionKind.number ? `.map(Number)` : ""} ;
184
+ `;
185
+ }
186
+ });
187
+ }
188
+ })];
189
+ }
190
+ })]
191
+ }),
192
+ createIntrinsic("hbr", {}),
193
+ createIntrinsic("hbr", {}),
194
+ createComponent(For, {
195
+ get each() {
196
+ return command.arguments;
187
197
  },
188
- get children() {
189
- return createComponent(Show, {
190
- get when() {
191
- return argument.variadic;
192
- },
193
- get fallback() {
194
- return createComponent(IfStatement, {
195
- get condition() {
196
- return code`${camelCase(argument.name)} && Number.isNaN(${camelCase(argument.name)})`;
197
- },
198
- get children() {
199
- return code`failures.push("Invalid numeric value provided for the \\"${argument.name}\\" positional argument");`;
200
- }
201
- });
202
- },
203
- get children() {
204
- return createComponent(IfStatement, {
205
- get condition() {
206
- return code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`;
207
- },
208
- get children() {
209
- return code`failures.push("Invalid numeric value provided in the \\"${argument.name}\\" array positional argument");`;
210
- }
211
- });
212
- }
213
- });
214
- }
215
- })]
216
- }),
217
- createComponent(IfStatement, {
218
- condition: code`failures.length > 0`,
219
- children: code`error(colors.text.message.description.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 => colors.text.body.secondary(" - " + failure)).join("\\n"));
220
- options.help = true; `
221
- })
222
- ];
198
+ doubleHardline: true,
199
+ children: (argument) => [createComponent(Show, {
200
+ get when() {
201
+ return !argument.optional;
202
+ },
203
+ get children() {
204
+ return [createComponent(IfStatement, {
205
+ get condition() {
206
+ return code`!${camelCase(argument.name)}`;
207
+ },
208
+ get children() {
209
+ return createComponent(Switch, { get children() {
210
+ return [createComponent(Match, {
211
+ get when() {
212
+ return argument.kind === ReflectionKind.string || argument.kind === ReflectionKind.number;
213
+ },
214
+ get children() {
215
+ return code`
216
+ const value = await text({
217
+ message: 'Please provide a value for the ${argument.title} positional argument:',
218
+ validate(value) {
219
+ if (isCancel(value)) {
220
+ return true;
221
+ }
222
+ if (!value || value.trim() === "") {
223
+ return "A value is required for this positional argument";
224
+ }
225
+ ${argument.kind === ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
226
+ return "The value provided must be a valid number";
227
+ }` : ""}
228
+ return undefined;
229
+ }
230
+ });
231
+ if (isCancel(value)) {
232
+ return;
233
+ }
234
+
235
+ ${camelCase(argument.name)} = ${argument.kind === ReflectionKind.number ? `Number(value)` : "value"};
236
+ `;
237
+ }
238
+ }), createComponent(Match, {
239
+ get when() {
240
+ return argument.kind === ReflectionKind.boolean;
241
+ },
242
+ get children() {
243
+ return code`
244
+ ${camelCase(argument.name)} = await confirm({
245
+ message: 'Please select a value for the ${argument.title} positional argument:'
246
+ });
247
+ `;
248
+ }
249
+ })];
250
+ } });
251
+ }
252
+ }), createComponent(Show, {
253
+ get when() {
254
+ return (argument.kind === ReflectionKind.string || argument.kind === ReflectionKind.number) && argument.variadic;
255
+ },
256
+ get children() {
257
+ return createComponent(ElseIfClause, {
258
+ get condition() {
259
+ return code`${camelCase(argument.name)}.length === 0`;
260
+ },
261
+ get children() {
262
+ return code`
263
+ const value = await text({
264
+ message: 'Please provide one or more values for the ${argument.title} option (values are separated by a "," character):',
265
+ validate(value) {
266
+ if (isCancel(value)) {
267
+ return true;
268
+ }
269
+ if (!value || value.trim() === "") {
270
+ return "A value is required for this option";
271
+ }
272
+ if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
273
+ return "At least one value is required for this option";
274
+ }
275
+ ${argument.kind === ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
276
+ if (invalidIndex !== -1) {
277
+ return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
278
+ } ` : ""}
279
+
280
+ return undefined;
281
+ }
282
+ });
283
+ if (isCancel(value)) {
284
+ return;
285
+ }
286
+
287
+ ${camelCase(argument.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${argument.kind === ReflectionKind.number ? `.map(Number)` : ""} ;
288
+ `;
289
+ }
290
+ });
291
+ }
292
+ })];
293
+ }
294
+ })]
295
+ })
296
+ ];
297
+ } })];
223
298
  }
224
299
  })
225
300
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","ReflectionKind","usePowerlines","EntryFile","isDynamicPathSegment","CommandHandlerDeclaration","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","env","console","utils","children","_$createIntrinsic","type","initializer","each","Object","values","options","doubleHardline","option","when","optional","condition","includes","kind","string","number","variadic","fallback","arguments","argument","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, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\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 { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type {\n CommandTree,\n NumberCommandArgument,\n NumberCommandOption\n} from \"@shell-shock/core/types/command\";\nimport { CommandHandlerDeclaration } 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 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 })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isCI\", \"isDevelopment\", \"isDebug\"],\n console: [\n \"debug\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\n \"getArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command}>\n <VarDeclaration\n name=\"failures\"\n type=\"string[]\"\n initializer={code`[];`}\n />\n <hbr />\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 {code`failures.push(\"Missing required \\\\\"${option.name}\\\\\" option\");`}\n </IfStatement>\n <Show\n when={\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.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`failures.push(\"No values were provided to the required \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={option.kind === ReflectionKind.number}>\n <Show\n when={(option as NumberCommandOption).variadic}\n fallback={\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } && Number.isNaN(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n option.name\n }\\\\\" option\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n <hbr />\n <hbr />\n <For each={command.arguments} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n {code`failures.push(\"Missing required \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n <Show\n when={\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={argument.kind === ReflectionKind.number}>\n <Show\n when={(argument as NumberCommandArgument).variadic}\n fallback={\n <IfStatement\n condition={code`${camelCase(\n argument.name\n )} && Number.isNaN(${camelCase(argument.name)})`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(colors.text.message.description.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 => colors.text.body.secondary(\" - \" + failure)).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={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HwD,OAAI;AAAA,WAAEW,MAAMC;;GAAS,IACrBJ,WAAQ;AAAA,WAAAzB,gBAAGrB,cAAY,EAACE,SAAS+C,OAAK,CAAA;;GAAA,IAAArB,WAAA;AAAA,WAAAP,gBACrCtB,qBAAmB,EAACG,SAAS+C,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseClause","ElseIfClause","IfStatement","ReflectionKind","usePowerlines","EntryFile","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","children","_$createIntrinsic","condition","each","Object","values","options","doubleHardline","option","when","optional","includes","kind","string","number","title","boolean","variadic","arguments","argument","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 { ElseClause, ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\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 { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\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 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\", \"isCI\", \"isDevelopment\", \"isDebug\"],\n console: [\n \"debug\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"text\",\n \"confirm\",\n \"isCancel\"\n ],\n utils: [\n \"getArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isUnicodeSupported\",\n \"internal_commandContextStore\"\n ]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration command={command}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <ElseClause>\n <hbr />\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 === ReflectionKind.string ||\n option.kind === ReflectionKind.number\n }>{code`\n const value = await text({\n message: 'Please provide a value for the ${option.title} option:',\n validate(value) {\n if (isCancel(value)) {\n return true;\n }\n if (!value || value.trim() === \"\") {\n return \"A value is required for this option\";\n }\n ${\n option.kind === ReflectionKind.number\n ? `if (Number.isNaN(Number(value))) {\n return \"The value provided 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 } = ${\n option.kind === ReflectionKind.number\n ? `Number(value)`\n : \"value\"\n };\n `}</Match>\n <Match\n when={option.kind === ReflectionKind.boolean}>{code`\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = await confirm({\n message: 'Please select a value for the ${option.title} option:'\n });\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.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 values for the ${\n option.title\n } option (values are separated by a \",\" character):',\n validate(value) {\n if (isCancel(value)) {\n return true;\n }\n if (!value || value.trim() === \"\") {\n return \"A value is required for this option\";\n }\n if (value.split(\",\").map(value => value.trim()).filter(Boolean).length === 0) {\n return \"At least one value is required for this option\";\n }\n ${\n option.kind === ReflectionKind.number\n ? `const invalidIndex = value.split(\",\").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));\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 === ReflectionKind.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <hbr />\n <hbr />\n <For each={command.arguments} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n <Switch>\n <Match\n when={\n argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number\n }>{code`\n const value = await text({\n message: 'Please provide a value for the ${argument.title} positional argument:',\n validate(value) {\n if (isCancel(value)) {\n return true;\n }\n if (!value || value.trim() === \"\") {\n return \"A value is required for this positional argument\";\n }\n ${\n argument.kind === ReflectionKind.number\n ? `if (Number.isNaN(Number(value))) {\n return \"The value provided must be a valid number\";\n }`\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = ${\n argument.kind === ReflectionKind.number\n ? `Number(value)`\n : \"value\"\n };\n `}</Match>\n <Match\n when={argument.kind === ReflectionKind.boolean}>{code`\n ${camelCase(argument.name)} = await confirm({\n message: 'Please select a value for the ${argument.title} positional argument:'\n });\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`\n const value = await text({\n message: 'Please provide one or more values for the ${\n argument.title\n } option (values are separated by a \",\" character):',\n validate(value) {\n if (isCancel(value)) {\n return true;\n }\n if (!value || value.trim() === \"\") {\n return \"A value is required for this option\";\n }\n if (value.split(\",\").map(value => value.trim()).filter(Boolean).length === 0) {\n return \"At least one value is required for this option\";\n }\n ${\n argument.kind === ReflectionKind.number\n ? `const invalidIndex = value.split(\",\").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));\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(argument.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n argument.kind === ReflectionKind.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n </ElseClause>\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":";;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgBwB,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUpB,eAAiC;CACjD,MAAMqB,WAAW9B,eACfgB,UACES,QAAQM,SACLC,QAAOC,YAAW,CAACtB,qBAAqBsB,QAAQ,CAAC,CACjDC,KAAK,IAAI,EACZ,WAEJ,CAAC;CACD,MAAMC,oBAAoBnC,eACxBiB,iBACEF,aACEC,UAAUa,QA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A;AAAA,WAAAR,gBACrCtB,qBAAmB,EAACG,SAAS+C,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core1 from "@alloy-js/core";
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/types/command";
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): _alloy_js_core1.Children;
12
+ declare function VirtualCommandEntry(props: VirtualCommandEntryProps): _alloy_js_core0.Children;
13
13
  //#endregion
14
14
  export { VirtualCommandEntry, VirtualCommandEntryProps };
15
15
  //# sourceMappingURL=virtual-command-entry.d.cts.map
@@ -26,7 +26,7 @@ function getDefaultOptions(context, _) {
26
26
  name: "no-interactive",
27
27
  title: "Non-Interactive",
28
28
  description: "Disable interactive mode - will be set to true if running in a CI pipeline.",
29
- alias: ["no-interact"],
29
+ alias: ["non-interactive", "no-interact"],
30
30
  kind: __powerlines_deepkit_vendor_type.ReflectionKind.boolean,
31
31
  optional: true,
32
32
  default: false,
@@ -25,7 +25,7 @@ function getDefaultOptions$1(context, _) {
25
25
  name: "no-interactive",
26
26
  title: "Non-Interactive",
27
27
  description: "Disable interactive mode - will be set to true if running in a CI pipeline.",
28
- alias: ["no-interact"],
28
+ alias: ["non-interactive", "no-interact"],
29
29
  kind: ReflectionKind.boolean,
30
30
  optional: true,
31
31
  default: false,
@@ -1 +1 @@
1
- {"version":3,"file":"get-default-options.mjs","names":["ReflectionKind","getDefaultOptions","getDefaultOptionsBase","context","_","config","interactive","name","title","description","alias","kind","boolean","optional","default","isNegativeOf","filter","Boolean"],"sources":["../../src/helpers/get-default-options.ts"],"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 { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport type { CommandBase, CommandOption } from \"@shell-shock/core\";\nimport { getDefaultOptions as getDefaultOptionsBase } from \"@shell-shock/preset-script/helpers/get-default-options\";\nimport type { CLIPresetContext } from \"../types\";\n\n/**\n * Get the default command options.\n *\n * @param context - The build context.\n * @param _ - The command input.\n * @returns The default command options.\n */\nexport function getDefaultOptions(\n context: CLIPresetContext,\n _: CommandBase\n): CommandOption[] {\n return [\n ...getDefaultOptionsBase(),\n context.config.interactive !== \"never\" &&\n context.config.interactive !== true && {\n name: \"interactive\",\n title: \"Interactive\",\n description:\n \"Enable interactive mode - will be set to false if running in a CI pipeline.\",\n alias: [\"i\", \"interact\"],\n kind: ReflectionKind.boolean,\n optional: true,\n default: context.config.interactive !== false\n },\n context.config.interactive !== \"never\" &&\n context.config.interactive !== false && {\n name: \"no-interactive\",\n title: \"Non-Interactive\",\n description:\n \"Disable interactive mode - will be set to true if running in a CI pipeline.\",\n alias: [\"no-interact\"],\n kind: ReflectionKind.boolean,\n optional: true,\n default: false,\n isNegativeOf: \"interactive\"\n }\n ].filter(Boolean) as CommandOption[];\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgBC,oBACdE,SACAC,GACiB;AACjB,QAAO;EACL,GAAGF,mBAAuB;EAC1BC,QAAQE,OAAOC,gBAAgB,WAC7BH,QAAQE,OAAOC,gBAAgB,QAAQ;GACrCC,MAAM;GACNC,OAAO;GACPC,aACE;GACFC,OAAO,CAAC,KAAK,WAAW;GACxBC,MAAMX,eAAeY;GACrBC,UAAU;GACVC,SAASX,QAAQE,OAAOC,gBAAgB;GACzC;EACHH,QAAQE,OAAOC,gBAAgB,WAC7BH,QAAQE,OAAOC,gBAAgB,SAAS;GACtCC,MAAM;GACNC,OAAO;GACPC,aACE;GACFC,OAAO,CAAC,cAAc;GACtBC,MAAMX,eAAeY;GACrBC,UAAU;GACVC,SAAS;GACTC,cAAc;GACf;EACJ,CAACC,OAAOC,QAAQ"}
1
+ {"version":3,"file":"get-default-options.mjs","names":["ReflectionKind","getDefaultOptions","getDefaultOptionsBase","context","_","config","interactive","name","title","description","alias","kind","boolean","optional","default","isNegativeOf","filter","Boolean"],"sources":["../../src/helpers/get-default-options.ts"],"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 { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport type { CommandBase, CommandOption } from \"@shell-shock/core\";\nimport { getDefaultOptions as getDefaultOptionsBase } from \"@shell-shock/preset-script/helpers/get-default-options\";\nimport type { CLIPresetContext } from \"../types\";\n\n/**\n * Get the default command options.\n *\n * @param context - The build context.\n * @param _ - The command input.\n * @returns The default command options.\n */\nexport function getDefaultOptions(\n context: CLIPresetContext,\n _: CommandBase\n): CommandOption[] {\n return [\n ...getDefaultOptionsBase(),\n context.config.interactive !== \"never\" &&\n context.config.interactive !== true && {\n name: \"interactive\",\n title: \"Interactive\",\n description:\n \"Enable interactive mode - will be set to false if running in a CI pipeline.\",\n alias: [\"i\", \"interact\"],\n kind: ReflectionKind.boolean,\n optional: true,\n default: context.config.interactive !== false\n },\n context.config.interactive !== \"never\" &&\n context.config.interactive !== false && {\n name: \"no-interactive\",\n title: \"Non-Interactive\",\n description:\n \"Disable interactive mode - will be set to true if running in a CI pipeline.\",\n alias: [\"non-interactive\", \"no-interact\"],\n kind: ReflectionKind.boolean,\n optional: true,\n default: false,\n isNegativeOf: \"interactive\"\n }\n ].filter(Boolean) as CommandOption[];\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgBC,oBACdE,SACAC,GACiB;AACjB,QAAO;EACL,GAAGF,mBAAuB;EAC1BC,QAAQE,OAAOC,gBAAgB,WAC7BH,QAAQE,OAAOC,gBAAgB,QAAQ;GACrCC,MAAM;GACNC,OAAO;GACPC,aACE;GACFC,OAAO,CAAC,KAAK,WAAW;GACxBC,MAAMX,eAAeY;GACrBC,UAAU;GACVC,SAASX,QAAQE,OAAOC,gBAAgB;GACzC;EACHH,QAAQE,OAAOC,gBAAgB,WAC7BH,QAAQE,OAAOC,gBAAgB,SAAS;GACtCC,MAAM;GACNC,OAAO;GACPC,aACE;GACFC,OAAO,CAAC,mBAAmB,cAAc;GACzCC,MAAMX,eAAeY;GACrBC,UAAU;GACVC,SAAS;GACTC,cAAc;GACf;EACJ,CAACC,OAAOC,QAAQ"}
package/dist/index.cjs CHANGED
@@ -35,10 +35,25 @@ const plugin = (options = {}) => {
35
35
  },
36
36
  configResolved() {
37
37
  this.dependencies.didyoumean2 = "^7.0.4";
38
+ this.dependencies["@clack/prompts"] = "^1.0.0";
38
39
  },
39
40
  async prepare() {
40
41
  this.debug("Rendering built-in modules for the Shell Shock `cli` preset.");
41
- return (0, __powerlines_plugin_alloy_render.render)(this, [(0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_utils_builtin.UtilsBuiltin, {}), (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_console_builtin.ConsoleBuiltin, {})]);
42
+ return (0, __powerlines_plugin_alloy_render.render)(this, [(0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_utils_builtin.UtilsBuiltin, {}), (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_console_builtin.ConsoleBuiltin, { children: __alloy_js_core.code`
43
+
44
+ // Re-export prompt functions from @clack/prompts
45
+ export {
46
+ isCancel,
47
+ confirm,
48
+ select,
49
+ text,
50
+ multiselect,
51
+ password,
52
+ progress,
53
+ spinner
54
+ } from "@clack/prompts";
55
+
56
+ ` })]);
42
57
  }
43
58
  },
44
59
  {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,gBAAA,GAAmB,gBAAnB,CAAA,CAAA,OAAA,CAAA,EAC7B,gBAD6B,EAAA,GA0GjC,MA1GiC,CA0G1B,QA1G0B,CAAA,EAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,gBAAA,GAAmB,gBAAnB,CAAA,CAAA,OAAA,CAAA,EAC7B,gBAD6B,EAAA,GA2HjC,MA3HiC,CA2H1B,QA3H0B,CAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,gBAAA,GAAmB,gBAAnB,CAAA,CAAA,OAAA,CAAA,EAC7B,gBAD6B,EAAA,GA0GjC,MA1GiC,CA0G1B,QA1G0B,CAAA,EAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,gBAAA,GAAmB,gBAAnB,CAAA,CAAA,OAAA,CAAA,EAC7B,gBAD6B,EAAA,GA2HjC,MA3HiC,CA2H1B,QA3H0B,CAAA,EAAA"}
package/dist/index.mjs CHANGED
@@ -32,10 +32,25 @@ const plugin = (options = {}) => {
32
32
  },
33
33
  configResolved() {
34
34
  this.dependencies.didyoumean2 = "^7.0.4";
35
+ this.dependencies["@clack/prompts"] = "^1.0.0";
35
36
  },
36
37
  async prepare() {
37
38
  this.debug("Rendering built-in modules for the Shell Shock `cli` preset.");
38
- return render(this, [createComponent(UtilsBuiltin, {}), createComponent(ConsoleBuiltin, {})]);
39
+ return render(this, [createComponent(UtilsBuiltin, {}), createComponent(ConsoleBuiltin, { children: code`
40
+
41
+ // Re-export prompt functions from @clack/prompts
42
+ export {
43
+ isCancel,
44
+ confirm,
45
+ select,
46
+ text,
47
+ multiselect,
48
+ password,
49
+ progress,
50
+ spinner
51
+ } from "@clack/prompts";
52
+
53
+ ` })]);
39
54
  }
40
55
  },
41
56
  {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["code","For","Show","VarDeclaration","render","theme","BinEntry","CommandRouter","ConsoleBuiltin","VirtualHelp","UtilsBuiltin","BannerFunctionDeclaration","CommandEntry","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","_$createComponent","order","handler","_self$","builtinImports","console","utils","env","prefix","_$createIntrinsic","children","when","Object","keys","commands","length","type","initializer","segments","values","each","doubleHardline","child","isVirtual","fallback","command"],"sources":["../src/index.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, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport { BinEntry } from \"@shell-shock/preset-script/components/bin-entry\";\nimport { CommandRouter } from \"@shell-shock/preset-script/components/command-router\";\nimport { ConsoleBuiltin } from \"@shell-shock/preset-script/components/console-builtin\";\nimport { VirtualHelp } from \"@shell-shock/preset-script/components/help\";\nimport { UtilsBuiltin } from \"@shell-shock/preset-script/components/utils-builtin\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BannerFunctionDeclaration } from \"./components/banner-function-declaration\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { CLIPresetContext, CLIPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <TContext extends CLIPresetContext = CLIPresetContext>(\n options: CLIPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:cli-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `cli` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:cli-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"colors\",\n \"help\"\n ],\n utils: [\"getArgs\", \"isMinimal\"],\n env: [\"isCI\"]\n }}\n prefix={\n <>\n <BannerFunctionDeclaration />\n <hbr />\n <hbr />\n </>\n }>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n <VirtualHelp\n options={this.options}\n commands={this.commands ?? {}}\n />\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAae,UACXC,UAA4B,EAAE,KAC3B;AACH,QAAO;EACLX,MAAM,EACJA,OAAOW,QAAQX,OAChB,CAAC;EACF;GACEY,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,oEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;;GAElC,MAAMC,UAAU;AACd,SAAKN,MACH,+DACD;AAED,WAAOf,OACL,MAAI,CAAAsB,gBAEDhB,cAAY,EAAA,CAAA,EAAAgB,gBACZlB,gBAAc,EAAA,CAAA,CAEnB,CAAC;;GAEJ;EACD;GACES,MAAM;GACNQ,SAAS;IACPE,OAAO;IACP,MAAMC,UAAU;KAAA,MAAAC,SAAA;AACd,UAAKV,MACH,iEACD;AAED,YAAOf,OACL,MAAI,CAAAsB,gBAEDp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,UAAKtB,gBACHxB,MAAI;SAAA,IACHmC,OAAI;AAAA,iBAAEW,MAAMC;;SAAS,IACrBC,WAAQ;AAAA,iBAAAxB,gBAAGd,cAAY,EAACuC,SAASH,OAAK,CAAA;;SAAA,IAAAZ,WAAA;AAAA,iBAAAV,gBACrCb,qBAAmB,EAACsC,SAASH,OAAK,CAAA;;SAAA,CAAA;QAEtC,CAAA;;MAAA,CAAA,CAIT,CAAC;;IAEL;GACD;EACF;;AAGH,kBAAejC"}
1
+ {"version":3,"file":"index.mjs","names":["code","For","Show","VarDeclaration","render","theme","BinEntry","CommandRouter","ConsoleBuiltin","VirtualHelp","UtilsBuiltin","BannerFunctionDeclaration","CommandEntry","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","_$createComponent","children","order","handler","_self$","builtinImports","console","utils","env","prefix","_$createIntrinsic","when","Object","keys","commands","length","type","initializer","segments","values","each","doubleHardline","child","isVirtual","fallback","command"],"sources":["../src/index.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, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport { BinEntry } from \"@shell-shock/preset-script/components/bin-entry\";\nimport { CommandRouter } from \"@shell-shock/preset-script/components/command-router\";\nimport { ConsoleBuiltin } from \"@shell-shock/preset-script/components/console-builtin\";\nimport { VirtualHelp } from \"@shell-shock/preset-script/components/help\";\nimport { UtilsBuiltin } from \"@shell-shock/preset-script/components/utils-builtin\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BannerFunctionDeclaration } from \"./components/banner-function-declaration\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { CLIPresetContext, CLIPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <TContext extends CLIPresetContext = CLIPresetContext>(\n options: CLIPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:cli-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `cli` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n this.dependencies[\"@clack/prompts\"] = \"^1.0.0\";\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin>\n {code`\n\n// Re-export prompt functions from @clack/prompts\nexport {\n isCancel,\n confirm,\n select,\n text,\n multiselect,\n password,\n progress,\n spinner\n} from \"@clack/prompts\";\n\n `}\n </ConsoleBuiltin>\n </>\n );\n }\n },\n {\n name: \"shell-shock:cli-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"colors\",\n \"help\"\n ],\n utils: [\"getArgs\", \"isMinimal\"],\n env: [\"isCI\"]\n }}\n prefix={\n <>\n <BannerFunctionDeclaration />\n <hbr />\n <hbr />\n </>\n }>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n <VirtualHelp\n options={this.options}\n commands={this.commands ?? {}}\n />\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAae,UACXC,UAA4B,EAAE,KAC3B;AACH,QAAO;EACLX,MAAM,EACJA,OAAOW,QAAQX,OAChB,CAAC;EACF;GACEY,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,oEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;AAChC,SAAKD,aAAa,oBAAoB;;GAExC,MAAME,UAAU;AACd,SAAKN,MACH,+DACD;AAED,WAAOf,OACL,MAAI,CAAAsB,gBAEDhB,cAAY,EAAA,CAAA,EAAAgB,gBACZlB,gBAAc,EAAAmB,UACZ3B,IAAI;;;;;;;;;;;;;;eAcN,CAAA,CAGL,CAAC;;GAEJ;EACD;GACEiB,MAAM;GACNQ,SAAS;IACPG,OAAO;IACP,MAAMC,UAAU;KAAA,MAAAC,SAAA;AACd,UAAKX,MACH,iEACD;AAED,YAAOf,OACL,MAAI,CAAAsB,gBAEDpB,UAAQ;MACPyB,gBAAgB;OACdC,SAAS;QACP;QACA;QACA;QACA;QACA;QACA;QACD;OACDC,OAAO,CAAC,WAAW,YAAY;OAC/B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Gd,cAAY,EAACuC,SAASH,OAAK,CAAA;;SAAA,IAAArB,WAAA;AAAA,iBAAAD,gBACrCb,qBAAmB,EAACsC,SAASH,OAAK,CAAA;;SAAA,CAAA;QAEtC,CAAA;;MAAA,CAAA,CAIT,CAAC;;IAEL;GACD;EACF;;AAGH,kBAAejC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/preset-cli",
3
- "version": "0.1.6",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "A package containing a Shell Shock plugin to generate source code given a list design tokens.",
6
6
  "repository": {
@@ -156,13 +156,13 @@
156
156
  "@powerlines/deepkit": "^0.6.51",
157
157
  "@powerlines/plugin-alloy": "^0.20.15",
158
158
  "@powerlines/plugin-plugin": "^0.12.222",
159
- "@shell-shock/core": "^0.8.1",
160
- "@shell-shock/plugin-theme": "^0.0.18",
161
- "@shell-shock/preset-script": "^0.6.0",
162
- "@stryke/path": "0.26.4",
163
- "@stryke/string-format": "0.13.7",
159
+ "@shell-shock/core": "^0.8.2",
160
+ "@shell-shock/plugin-theme": "^0.0.19",
161
+ "@shell-shock/preset-script": "^0.6.1",
162
+ "@stryke/path": "^0.26.6",
163
+ "@stryke/string-format": "^0.13.7",
164
164
  "cfonts": "^3.3.1",
165
- "defu": "6.1.4",
165
+ "defu": "^6.1.4",
166
166
  "powerlines": "^0.38.38"
167
167
  },
168
168
  "devDependencies": {
@@ -193,5 +193,5 @@
193
193
  "./package.json": "./package.json"
194
194
  }
195
195
  },
196
- "gitHead": "2d179aff07a4c04d5ff4a96ceed082077a51a7e6"
196
+ "gitHead": "29463ac608044d8268c0fcd661e83def6cf7fb07"
197
197
  }