@shell-shock/preset-cli 0.1.5 → 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.1-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_core1 from "@alloy-js/core";
1
+ import * as _alloy_js_core0 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_core1.Children;
8
+ declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps): _alloy_js_core0.Children;
9
9
  //#endregion
10
10
  export { BannerFunctionDeclaration };
11
11
  //# sourceMappingURL=banner-function-declaration.d.mts.map
@@ -3,13 +3,16 @@ const require_components_banner_function_declaration = require('./banner-functio
3
3
  const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
4
4
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
5
  let __alloy_js_core = require("@alloy-js/core");
6
+ let __alloy_js_typescript = require("@alloy-js/typescript");
6
7
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
7
8
  let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
9
+ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
8
10
  let __powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
9
11
  let __shell_shock_preset_script_components_command_entry = require("@shell-shock/preset-script/components/command-entry");
10
12
  let __stryke_path_find = require("@stryke/path/find");
11
13
  let __stryke_path_join = require("@stryke/path/join");
12
14
  let __stryke_path_replace = require("@stryke/path/replace");
15
+ let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
13
16
  let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
14
17
  let defu = require("defu");
15
18
  defu = require_rolldown_runtime.__toESM(defu);
@@ -35,7 +38,10 @@ function CommandEntry(props) {
35
38
  return typeDefinition.value;
36
39
  },
37
40
  get imports() {
38
- 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
+ });
39
45
  },
40
46
  get builtinImports() {
41
47
  return (0, defu.default)(builtinImports ?? {}, {
@@ -53,14 +59,18 @@ function CommandEntry(props) {
53
59
  "colors",
54
60
  "stripAnsi",
55
61
  "writeLine",
56
- "splitText"
62
+ "splitText",
63
+ "text",
64
+ "confirm",
65
+ "isCancel"
57
66
  ],
58
67
  utils: [
59
68
  "getArgs",
60
69
  "hasFlag",
61
70
  "isMinimal",
71
+ "isInteractive",
62
72
  "isUnicodeSupported",
63
- "internal_commandContext"
73
+ "internal_commandContextStore"
64
74
  ]
65
75
  });
66
76
  },
@@ -69,7 +79,226 @@ function CommandEntry(props) {
69
79
  (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_banner_function_declaration.BannerFunctionDeclaration, { command }),
70
80
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
71
81
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
72
- (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_command_entry.CommandHandlerDeclaration, { command })
82
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_command_entry.CommandHandlerDeclaration, {
83
+ command,
84
+ get children() {
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 ?? {});
96
+ },
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;
199
+ },
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
+ } })];
300
+ }
301
+ })
73
302
  ];
74
303
  }
75
304
  })), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UAkCiB,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,4 +1,4 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
1
+ import * as _alloy_js_core1 from "@alloy-js/core";
2
2
  import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
3
3
  import { CommandTree } from "@shell-shock/core/types/command";
4
4
 
@@ -9,7 +9,7 @@ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinitio
9
9
  /**
10
10
  * The command entry point for the Shell Shock project.
11
11
  */
12
- declare function CommandEntry(props: CommandEntryProps): _alloy_js_core0.Children;
12
+ declare function CommandEntry(props: CommandEntryProps): _alloy_js_core1.Children;
13
13
  //#endregion
14
14
  export { CommandEntry, CommandEntryProps };
15
15
  //# sourceMappingURL=command-entry.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UAkCiB,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,14 +1,17 @@
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, computed } from "@alloy-js/core";
4
+ import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
5
+ import { ElseClause, ElseIfClause, IfStatement } from "@alloy-js/typescript";
5
6
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
6
7
  import { isDynamicPathSegment } from "@shell-shock/core/plugin-utils/context-helpers";
8
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
7
9
  import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
8
- import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
10
+ import { CommandHandlerDeclaration, CommandValidationLogic } from "@shell-shock/preset-script/components/command-entry";
9
11
  import { findFilePath, relativePath } from "@stryke/path/find";
10
12
  import { joinPaths } from "@stryke/path/join";
11
13
  import { replaceExtension } from "@stryke/path/replace";
14
+ import { camelCase } from "@stryke/string-format/camel-case";
12
15
  import { pascalCase } from "@stryke/string-format/pascal-case";
13
16
  import defu from "defu";
14
17
 
@@ -33,7 +36,10 @@ function CommandEntry(props) {
33
36
  return typeDefinition.value;
34
37
  },
35
38
  get imports() {
36
- return defu(imports ?? {}, { [commandSourcePath.value]: `handle${pascalCase(command.name)}` });
39
+ return defu(imports ?? {}, {
40
+ [commandSourcePath.value]: `handle${pascalCase(command.name)}`,
41
+ prompts: "prompts"
42
+ });
37
43
  },
38
44
  get builtinImports() {
39
45
  return defu(builtinImports ?? {}, {
@@ -51,14 +57,18 @@ function CommandEntry(props) {
51
57
  "colors",
52
58
  "stripAnsi",
53
59
  "writeLine",
54
- "splitText"
60
+ "splitText",
61
+ "text",
62
+ "confirm",
63
+ "isCancel"
55
64
  ],
56
65
  utils: [
57
66
  "getArgs",
58
67
  "hasFlag",
59
68
  "isMinimal",
69
+ "isInteractive",
60
70
  "isUnicodeSupported",
61
- "internal_commandContext"
71
+ "internal_commandContextStore"
62
72
  ]
63
73
  });
64
74
  },
@@ -67,7 +77,226 @@ function CommandEntry(props) {
67
77
  createComponent(BannerFunctionDeclaration, { command }),
68
78
  createIntrinsic("hbr", {}),
69
79
  createIntrinsic("hbr", {}),
70
- createComponent(CommandHandlerDeclaration, { command })
80
+ createComponent(CommandHandlerDeclaration, {
81
+ command,
82
+ get children() {
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 ?? {});
94
+ },
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;
197
+ },
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
+ } })];
298
+ }
299
+ })
71
300
  ];
72
301
  }
73
302
  })), createComponent(For, {
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.mjs","names":["computed","For","Show","usePowerlines","EntryFile","isDynamicPathSegment","CommandHandlerDeclaration","findFilePath","relativePath","joinPaths","replaceExtension","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","each","Object","values","child","when","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 { computed, For, Show } from \"@alloy-js/core\";\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 { 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 { 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 </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":";;;;;;;;;;;;;;;;;;AA4CA,SAAgBe,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUlB,eAAiC;CACjD,MAAMmB,WAAWtB,eACfS,UACEQ,QAAQM,SACLC,QAAOC,YAAW,CAACpB,qBAAqBoB,QAAQ,CAAC,CACjDC,KAAK,IAAI,EACZ,WAEJ,CAAC;CACD,MAAMC,oBAAoB3B,eACxBU,iBACEF,aACEC,UAAUY,QAAQO,WAAWrB,aAAae,SAASO,MAAM,CAAC,EAC1DZ,QAAQa,MAAMC,OAAOC,QAAQf,QAAQa,MAAME,KAE/C,CACF,CAAC;CACD,MAAMC,iBAAiBjC,gBAAgB;EACrC,GAAGiB,QAAQa;EACXI,QAAQjB,QAAQkB;EACjB,EAAE;AAEH,QAAA,CAAAC,gBAEKhC,WAASiC,WACJjB,MAAI;EAAA,IACRkB,OAAI;AAAA,UAAEhB,SAASO;;EAAK,IACpBI,iBAAc;AAAA,UAAEA,eAAeJ;;EAAK,IACpCX,UAAO;AAAA,UAAEN,KAAKM,WAAW,EAAE,EAAE,GAC1BS,kBAAkBE,QAAQ,SAASlB,WAAWM,QAAQsB,KAAK,IAC7D,CAAC;;EAAA,IACFpB,iBAAc;AAAA,UAAEP,KAAKO,kBAAkB,EAAE,EAAE;IACzCqB,KAAK;KAAC;KAAO;KAAQ;KAAiB;KAAU;IAChDC,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDC,OAAO;KACL;KACA;KACA;KACA;KACA;KAAyB;IAE5B,CAAC;;EAAA,IAAAC,WAAA;AAAA,UAAA;IAAAP,gBACDvB,2BAAyB,EAAUI,SAAO,CAAA;IAAA2B,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAR,gBAG1C9B,2BAAyB,EAAUW,SAAO,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAmB,gBAE5CnC,KAAG;EAAA,IAAC4C,OAAI;AAAA,UAAEC,OAAOC,OAAO9B,QAAQ0B,SAAS;;EAAAA,WACvCK,UAAKZ,gBACHlC,MAAI;GAAA,IACH+C,OAAI;AAAA,WAAED,MAAME;;GAAS,IACrBC,WAAQ;AAAA,WAAAf,gBAAGrB,cAAY,EAACE,SAAS+B,OAAK,CAAA;;GAAA,IAAAL,WAAA;AAAA,WAAAP,gBACrCtB,qBAAmB,EAACG,SAAS+B,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,QAAQO,WAAWtB,aAAagB,SAASO,MAAM,CAAC,EAC1DZ,QAAQa,MAAMC,OAAOC,QAAQf,QAAQa,MAAME,KAE/C,CACF,CAAC;CACD,MAAMC,iBAAiBzC,gBAAgB;EACrC,GAAGyB,QAAQa;EACXI,QAAQjB,QAAQkB;EACjB,EAAE;AAEH,QAAA,CAAAC,gBAEKlC,WAASmC,WACJjB,MAAI;EAAA,IACRkB,OAAI;AAAA,UAAEhB,SAASO;;EAAK,IACpBI,iBAAc;AAAA,UAAEA,eAAeJ;;EAAK,IACpCX,UAAO;AAAA,UAAEN,KAAKM,WAAW,EAAE,EAAE;KAC1BS,kBAAkBE,QAAQ,SAASlB,WAAWM,QAAQsB,KAAK;IAC5DC,SAAS;IACV,CAAC;;EAAA,IACFr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ASF;;YAAQ,IAAAjB,WAAA;AAAA,oBAAAR,gBAElBtC,cAAY;cAAA,IACXgD,YAAS;AAAA,sBAAEvD,IAAI,GAAGmB,UAAUqD,SAASxB,KAAK,CAAA;;cAAe,IAAAK,WAAA;AAAA,sBACxDrD,IAAI;;oFAGGwE,SAASJ,MAAK;;;;;;;;;;;kCAaZI,SAASP,SAASxD,eAAe0D,SAC7B;;;0CAIA,GAAE;;;;;;;;;8BAUVhD,UAAUqD,SAASxB,KAAK,CAAA,gEACxBwB,SAASP,SAASxD,eAAe0D,SAC7B,iBACA,GAAE;;;cAET,CAAA;;YAAA,CAAA,CAAA;;UAAA,CAAA,CAAA;SAKZ,CAAA;QAAA;SAAA,CAAA,CAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAtB,gBAKR3C,KAAG;EAAA,IAACsD,OAAI;AAAA,UAAEC,OAAOC,OAAOhC,QAAQ2B,SAAS;;EAAAA,WACvCoB,UAAK5B,gBACHzC,MAAI;GAAA,IACH0D,OAAI;AAAA,WAAEW,MAAMC;;GAAS,IACrBC,WAAQ;AAAA,WAAA9B,gBAAGrB,cAAY,EAACE,SAAS+C,OAAK,CAAA;;GAAA,IAAApB,WAAA;AAAA,WAAAR,gBACrCtB,qBAAmB,EAACG,SAAS+C,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -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;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AAA;;MAAA,CAAA,EAAAd,gBAGhCxB,MAAI;MAAA,IAACmC,OAAI;AAAA,cAAEC,OAAOO,OAAOhB,OAAKW,SAAS,CAACC,SAAS;;MAAC,IAAAL,WAAA;AAAA,cAAAV,gBAChDzB,KAAG;QAAA,IAAC6C,OAAI;AAAA,gBAAER,OAAOO,OAAOhB,OAAKW,SAAS;;QAAEO,gBAAc;QAAAX,WACpDY,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;;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C,SAAS;;MAAC,IAAAd,WAAA;AAAA,cAAAD,gBAChDzB,KAAG;QAAA,IAAC6C,OAAI;AAAA,gBAAER,OAAOO,OAAOf,OAAKU,SAAS;;QAAEO,gBAAc;QAAApB,WACpDqB,UAAKtB,gBACHxB,MAAI;SAAA,IACHmC,OAAI;AAAA,iBAAEW,MAAMC;;SAAS,IACrBC,WAAQ;AAAA,iBAAAxB,gBAAGd,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.5",
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.0",
160
- "@shell-shock/plugin-theme": "^0.0.17",
161
- "@shell-shock/preset-script": "^0.5.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": "a3710248496a9b6251c18d6ee4af3587a0dc1fa5"
196
+ "gitHead": "29463ac608044d8268c0fcd661e83def6cf7fb07"
197
197
  }