@shell-shock/preset-cli 0.3.0 → 0.3.1

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.6-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.2.0-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_core3 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_core3.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.cts.map
@@ -13,6 +13,7 @@ let __stryke_path_find = require("@stryke/path/find");
13
13
  let __stryke_path_join = require("@stryke/path/join");
14
14
  let __stryke_path_replace = require("@stryke/path/replace");
15
15
  let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
16
+ let __stryke_string_format_lower_case_first = require("@stryke/string-format/lower-case-first");
16
17
  let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
17
18
  let defu = require("defu");
18
19
  defu = require_rolldown_runtime.__toESM(defu);
@@ -124,15 +125,15 @@ function CommandEntry(props) {
124
125
  get children() {
125
126
  return __alloy_js_core.code`
126
127
  const value = await text({
127
- message: 'Please provide a value for the ${option.title} option:',
128
- validate(value) {
129
- if (isCancel(value)) {
128
+ message: 'Please provide a${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? " numeric" : ""} value for the "${option.name}" option${option.description ? ` (${(0, __stryke_string_format_lower_case_first.lowerCaseFirst)(option.description).replace(/\.+$/, "")})` : ""}:',
129
+ validate(val) {
130
+ if (isCancel(val)) {
130
131
  return true;
131
132
  }
132
- if (!value || value.trim() === "") {
133
- return "A value is required for this option";
133
+ if (!val || val.trim() === "") {
134
+ return "A value must be provided for this option";
134
135
  }
135
- ${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
136
+ ${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `if (Number.isNaN(Number(val))) {
136
137
  return "The value provided must be a valid number";
137
138
  }` : ""}
138
139
  return undefined;
@@ -152,7 +153,7 @@ function CommandEntry(props) {
152
153
  get children() {
153
154
  return __alloy_js_core.code`
154
155
  options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = await confirm({
155
- message: 'Please select a value for the ${option.title} option:'
156
+ message: 'Please select a value for the "${option.name}" option${option.description ? ` (${(0, __stryke_string_format_lower_case_first.lowerCaseFirst)(option.description).replace(/\.+$/, "")})` : ""}:'
156
157
  });
157
158
  `;
158
159
  }
@@ -171,18 +172,18 @@ function CommandEntry(props) {
171
172
  get children() {
172
173
  return __alloy_js_core.code`
173
174
  const value = await text({
174
- message: 'Please provide one or more values for the ${option.title} option (values are separated by a "," character):',
175
- validate(value) {
176
- if (isCancel(value)) {
175
+ message: 'Please provide one or more${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? " numeric" : ""} values for the "${option.name}" option${option.description ? ` (${(0, __stryke_string_format_lower_case_first.lowerCaseFirst)(option.description).replace(/\.+$/, "")})` : ""} - values are separated by a "," character:',
176
+ validate(val) {
177
+ if (isCancel(val)) {
177
178
  return true;
178
179
  }
179
- if (!value || value.trim() === "") {
180
- return "A value is required for this option";
180
+ if (!val || val.trim() === "") {
181
+ return "A value must be provided for this option";
181
182
  }
182
- if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
183
- return "At least one value is required for this option";
183
+ if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
184
+ return "At least one value must be provided for this option";
184
185
  }
185
- ${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
186
+ ${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
186
187
  if (invalidIndex !== -1) {
187
188
  return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
188
189
  } ` : ""}
@@ -227,16 +228,16 @@ function CommandEntry(props) {
227
228
  get children() {
228
229
  return __alloy_js_core.code`
229
230
  const value = await text({
230
- message: 'Please provide a value for the ${argument.title} positional argument:',
231
- validate(value) {
232
- if (isCancel(value)) {
231
+ message: 'Please provide a${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? " numeric" : ""} value for the "${argument.name}" argument${argument.description ? ` (${(0, __stryke_string_format_lower_case_first.lowerCaseFirst)(argument.description).replace(/\.+$/, "")})` : ""}:',
232
+ validate(val) {
233
+ if (isCancel(val)) {
233
234
  return true;
234
235
  }
235
- if (!value || value.trim() === "") {
236
- return "A value is required for this positional argument";
236
+ if (!val || val.trim() === "") {
237
+ return "A value must be provided for this argument";
237
238
  }
238
- ${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
239
- return "The value provided must be a valid number";
239
+ ${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `if (Number.isNaN(Number(val))) {
240
+ return "The provided value must be a valid number";
240
241
  }` : ""}
241
242
  return undefined;
242
243
  }
@@ -255,7 +256,7 @@ function CommandEntry(props) {
255
256
  get children() {
256
257
  return __alloy_js_core.code`
257
258
  ${(0, __stryke_string_format_camel_case.camelCase)(argument.name)} = await confirm({
258
- message: 'Please select a value for the ${argument.title} positional argument:'
259
+ message: 'Please select a value for the "${argument.name}" argument${argument.description ? ` (${(0, __stryke_string_format_lower_case_first.lowerCaseFirst)(argument.description).replace(/\.+$/, "")})` : ""}:'
259
260
  });
260
261
  `;
261
262
  }
@@ -274,18 +275,18 @@ function CommandEntry(props) {
274
275
  get children() {
275
276
  return __alloy_js_core.code`
276
277
  const value = await text({
277
- message: 'Please provide one or more values for the ${argument.title} option (values are separated by a "," character):',
278
- validate(value) {
279
- if (isCancel(value)) {
278
+ message: 'Please provide one or more${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? " numeric" : ""} values for the "${argument.name}" argument${argument.description ? ` (${(0, __stryke_string_format_lower_case_first.lowerCaseFirst)(argument.description).replace(/\.+$/, "")})` : ""} - values are separated by a "," character:',
279
+ validate(val) {
280
+ if (isCancel(val)) {
280
281
  return true;
281
282
  }
282
- if (!value || value.trim() === "") {
283
- return "A value is required for this option";
283
+ if (!val || val.trim() === "") {
284
+ return "A value must be provided for this argument";
284
285
  }
285
- if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
286
- return "At least one value is required for this option";
286
+ if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
287
+ return "At least one value must be provided for this argument";
287
288
  }
288
- ${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
289
+ ${argument.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
289
290
  if (invalidIndex !== -1) {
290
291
  return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
291
292
  } ` : ""}
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core2 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_core2.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.cts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UAyCiB,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":";;;;;UAwCiB,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":";;;;;UAyCiB,iBAAA,SAA0B,KACzC;WAGS;;AAJX;;;AAA2C,iBAU3B,YAAA,CAV2B,KAAA,EAUP,iBAVO,CAAA,EAUU,eAAA,CAAA,QAVV"}
@@ -12,6 +12,7 @@ import { findFilePath, relativePath } from "@stryke/path/find";
12
12
  import { joinPaths } from "@stryke/path/join";
13
13
  import { replaceExtension } from "@stryke/path/replace";
14
14
  import { camelCase } from "@stryke/string-format/camel-case";
15
+ import { lowerCaseFirst } from "@stryke/string-format/lower-case-first";
15
16
  import { pascalCase } from "@stryke/string-format/pascal-case";
16
17
  import defu from "defu";
17
18
 
@@ -122,15 +123,15 @@ function CommandEntry(props) {
122
123
  get children() {
123
124
  return code`
124
125
  const value = await text({
125
- message: 'Please provide a value for the ${option.title} option:',
126
- validate(value) {
127
- if (isCancel(value)) {
126
+ message: 'Please provide a${option.kind === ReflectionKind.number ? " numeric" : ""} value for the "${option.name}" option${option.description ? ` (${lowerCaseFirst(option.description).replace(/\.+$/, "")})` : ""}:',
127
+ validate(val) {
128
+ if (isCancel(val)) {
128
129
  return true;
129
130
  }
130
- if (!value || value.trim() === "") {
131
- return "A value is required for this option";
131
+ if (!val || val.trim() === "") {
132
+ return "A value must be provided for this option";
132
133
  }
133
- ${option.kind === ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
134
+ ${option.kind === ReflectionKind.number ? `if (Number.isNaN(Number(val))) {
134
135
  return "The value provided must be a valid number";
135
136
  }` : ""}
136
137
  return undefined;
@@ -150,7 +151,7 @@ function CommandEntry(props) {
150
151
  get children() {
151
152
  return code`
152
153
  options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = await confirm({
153
- message: 'Please select a value for the ${option.title} option:'
154
+ message: 'Please select a value for the "${option.name}" option${option.description ? ` (${lowerCaseFirst(option.description).replace(/\.+$/, "")})` : ""}:'
154
155
  });
155
156
  `;
156
157
  }
@@ -169,18 +170,18 @@ function CommandEntry(props) {
169
170
  get children() {
170
171
  return code`
171
172
  const value = await text({
172
- message: 'Please provide one or more values for the ${option.title} option (values are separated by a "," character):',
173
- validate(value) {
174
- if (isCancel(value)) {
173
+ message: 'Please provide one or more${option.kind === ReflectionKind.number ? " numeric" : ""} values for the "${option.name}" option${option.description ? ` (${lowerCaseFirst(option.description).replace(/\.+$/, "")})` : ""} - values are separated by a "," character:',
174
+ validate(val) {
175
+ if (isCancel(val)) {
175
176
  return true;
176
177
  }
177
- if (!value || value.trim() === "") {
178
- return "A value is required for this option";
178
+ if (!val || val.trim() === "") {
179
+ return "A value must be provided for this option";
179
180
  }
180
- if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
181
- return "At least one value is required for this option";
181
+ if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
182
+ return "At least one value must be provided for this option";
182
183
  }
183
- ${option.kind === ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
184
+ ${option.kind === ReflectionKind.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
184
185
  if (invalidIndex !== -1) {
185
186
  return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
186
187
  } ` : ""}
@@ -225,16 +226,16 @@ function CommandEntry(props) {
225
226
  get children() {
226
227
  return code`
227
228
  const value = await text({
228
- message: 'Please provide a value for the ${argument.title} positional argument:',
229
- validate(value) {
230
- if (isCancel(value)) {
229
+ message: 'Please provide a${argument.kind === ReflectionKind.number ? " numeric" : ""} value for the "${argument.name}" argument${argument.description ? ` (${lowerCaseFirst(argument.description).replace(/\.+$/, "")})` : ""}:',
230
+ validate(val) {
231
+ if (isCancel(val)) {
231
232
  return true;
232
233
  }
233
- if (!value || value.trim() === "") {
234
- return "A value is required for this positional argument";
234
+ if (!val || val.trim() === "") {
235
+ return "A value must be provided for this argument";
235
236
  }
236
- ${argument.kind === ReflectionKind.number ? `if (Number.isNaN(Number(value))) {
237
- return "The value provided must be a valid number";
237
+ ${argument.kind === ReflectionKind.number ? `if (Number.isNaN(Number(val))) {
238
+ return "The provided value must be a valid number";
238
239
  }` : ""}
239
240
  return undefined;
240
241
  }
@@ -253,7 +254,7 @@ function CommandEntry(props) {
253
254
  get children() {
254
255
  return code`
255
256
  ${camelCase(argument.name)} = await confirm({
256
- message: 'Please select a value for the ${argument.title} positional argument:'
257
+ message: 'Please select a value for the "${argument.name}" argument${argument.description ? ` (${lowerCaseFirst(argument.description).replace(/\.+$/, "")})` : ""}:'
257
258
  });
258
259
  `;
259
260
  }
@@ -272,18 +273,18 @@ function CommandEntry(props) {
272
273
  get children() {
273
274
  return code`
274
275
  const value = await text({
275
- message: 'Please provide one or more values for the ${argument.title} option (values are separated by a "," character):',
276
- validate(value) {
277
- if (isCancel(value)) {
276
+ message: 'Please provide one or more${argument.kind === ReflectionKind.number ? " numeric" : ""} values for the "${argument.name}" argument${argument.description ? ` (${lowerCaseFirst(argument.description).replace(/\.+$/, "")})` : ""} - values are separated by a "," character:',
277
+ validate(val) {
278
+ if (isCancel(val)) {
278
279
  return true;
279
280
  }
280
- if (!value || value.trim() === "") {
281
- return "A value is required for this option";
281
+ if (!val || val.trim() === "") {
282
+ return "A value must be provided for this argument";
282
283
  }
283
- if (value.split(",").map(value => value.trim()).filter(Boolean).length === 0) {
284
- return "At least one value is required for this option";
284
+ if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
285
+ return "At least one value must be provided for this argument";
285
286
  }
286
- ${argument.kind === ReflectionKind.number ? `const invalidIndex = value.split(",").map(value => value.trim()).filter(Boolean).findIndex(value => Number.isNaN(Number(value));
287
+ ${argument.kind === ReflectionKind.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
287
288
  if (invalidIndex !== -1) {
288
289
  return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
289
290
  } ` : ""}
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","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","Object","values","options","option","optional","map","kind","string","number","variadic","includes","length","arguments","argument","each","doubleHardline","when","title","boolean","child","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { 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\", \"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 \"intro\",\n \"outro\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\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 <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.arguments ?? {}).filter(\n argument => !argument.optional\n ).length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.arguments ?? {})\n .filter(argument => !argument.optional)\n .map(argument =>\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? `(!${camelCase(\n argument.name\n )} || ${camelCase(argument.name)}.length === 0)`\n : `${camelCase(argument.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\");\n\n intro(\"Select required input parameters\"); `}\n <hbr />\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 ${\n option.title\n } 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 {code`outro(\"Completed providing all required input parameters\");\n\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n </ElseIfClause>\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,SAAgBuB,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUpB,eAAiC;CACjD,MAAMqB,WAAW7B,eACfe,UACES,QAAQM,SACLC,QAAOC,YAAW,CAACtB,qBAAqBsB,QAAQ,CAAC,CACjDC,KAAK,IAAI,EACZ,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;GAAS,IACrBC,WAAQ;AAAA,WAAAhC,gBAAGrB,cAAY,EAACE,SAASiD,OAAK,CAAA;;GAAA,IAAAtB,WAAA;AAAA,WAAAR,gBACrCtB,qBAAmB,EAACG,SAASiD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseIfClause","IfStatement","ReflectionKind","usePowerlines","EntryFile","isDynamicPathSegment","CommandHandlerDeclaration","CommandValidationLogic","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","lowerCaseFirst","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","Object","values","options","option","optional","map","kind","string","number","variadic","includes","length","arguments","argument","each","doubleHardline","when","description","replace","boolean","child","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { 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 { lowerCaseFirst } from \"@stryke/string-format/lower-case-first\";\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\", \"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 \"intro\",\n \"outro\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\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 <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.arguments ?? {}).filter(\n argument => !argument.optional\n ).length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.arguments ?? {})\n .filter(argument => !argument.optional)\n .map(argument =>\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? `(!${camelCase(\n argument.name\n )} || ${camelCase(argument.name)}.length === 0)`\n : `${camelCase(argument.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\");\n\n intro(\"Select required input parameters\"); `}\n <hbr />\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${\n option.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } value for the \"${option.name}\" option${\n option.description\n ? ` (${lowerCaseFirst(\n option.description\n ).replace(/\\.+$/, \"\")})`\n : \"\"\n }:',\n validate(val) {\n if (isCancel(val)) {\n return true;\n }\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n ${\n option.kind === ReflectionKind.number\n ? `if (Number.isNaN(Number(val))) {\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 \"${\n option.name\n }\" option${\n option.description\n ? ` (${lowerCaseFirst(\n option.description\n ).replace(/\\.+$/, \"\")})`\n : \"\"\n }:'\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${\n option.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } values for the \"${option.name}\" option${\n option.description\n ? ` (${lowerCaseFirst(\n option.description\n ).replace(/\\.+$/, \"\")})`\n : \"\"\n } - values are separated by a \",\" character:',\n validate(val) {\n if (isCancel(val)) {\n return true;\n }\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === ReflectionKind.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === 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${\n argument.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } value for the \"${argument.name}\" argument${\n argument.description\n ? ` (${lowerCaseFirst(argument.description).replace(/\\.+$/, \"\")})`\n : \"\"\n }:',\n validate(val) {\n if (isCancel(val)) {\n return true;\n }\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n ${\n argument.kind === ReflectionKind.number\n ? `if (Number.isNaN(Number(val))) {\n return \"The provided value 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.name}\" argument${\n argument.description\n ? ` (${lowerCaseFirst(argument.description).replace(/\\.+$/, \"\")})`\n : \"\"\n }:'\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${\n argument.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } values for the \"${argument.name}\" argument${\n argument.description\n ? ` (${lowerCaseFirst(argument.description).replace(/\\.+$/, \"\")})`\n : \"\"\n } - values are separated by a \",\" character:',\n validate(val) {\n if (isCancel(val)) {\n return true;\n }\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n argument.kind === ReflectionKind.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(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 {code`outro(\"Completed providing all required input parameters\");\n\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n </ElseIfClause>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgBwB,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC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AASP,SAAStD,eAAewD,WACnCK,SAASJ;;aAAQ,IAAAZ,WAAA;AAAA,qBAAAR,gBAElBvC,cAAY;eAAA,IACXiD,YAAS;AAAA,uBAAEvD,IAAI,GAAGkB,UAAUmD,SAASrB,KAAK,CAAA;;eAAe,IAAAK,WAAA;AAAA,uBACxDrD,IAAI;;oEAGGqE,SAASP,SAAStD,eAAewD,SAC7B,aACA,GAAE,mBACYK,SAASrB,KAAI,YAC/BqB,SAASI,cACL,KAAKtD,eAAekD,SAASI,YAAY,CAACC,QAAQ,QAAQ,GAAG,CAAA,KAC7D,GAAE;;;;;;;;;;;kCAaJL,SAASP,SAAStD,eAAewD,SAC7B;;;0CAIA,GAAE;;;;;;;;;8BAUV9C,UAAUmD,SAASrB,KAAK,CAAA,gEACxBqB,SAASP,SAAStD,eAAewD,SAC7B,iBACA,GAAE;;;eAET,CAAA;;aAAA,CAAA,CAAA;;WAAA,CAAA,CAAA;UAKZ,CAAA;SAEFhE,IAAI;;;SAEWsD,gBAAA,OAAA,EAAA,CAAA;SAAAA,gBAAA,OAAA,EAAA,CAAA;SAAA;;OAAA,CAAA,CAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAT,gBAMrB3C,KAAG;EAAA,IAACoE,OAAI;AAAA,UAAEd,OAAOC,OAAO/B,QAAQ2B,SAAS;;EAAAA,WACvCuB,UAAK/B,gBACHzC,MAAI;GAAA,IACHoE,OAAI;AAAA,WAAEI,MAAMC;;GAAS,IACrBC,WAAQ;AAAA,WAAAjC,gBAAGrB,cAAY,EAACE,SAASkD,OAAK,CAAA;;GAAA,IAAAvB,WAAA;AAAA,WAAAR,gBACrCtB,qBAAmB,EAACG,SAASkD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -36,40 +36,38 @@ function CommandRouter(props) {
36
36
  return [
37
37
  __alloy_js_core.code`
38
38
  banner();
39
- writeLine("");
40
39
 
41
- intro("Command selection");
40
+ intro("Command selection");
42
41
 
43
- let segments = await select({
44
- message: "Please select a command to execute:",
45
- options: [ `,
42
+ let segments = await select({
43
+ message: "Please select a command to execute:",
44
+ options: [ `,
46
45
  (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { commands }),
47
46
  (0, __alloy_js_core_jsx_runtime.memo)(() => ` ],
48
- });
49
- if (isCancel(segments)) {
50
- return;
51
- }
52
-
53
- let dynamics = {} as Record<string, string>;
54
- for (const dynamic of segments.filter(segment => segment.startsWith("[") && segment.endsWith("]"))) {
55
- const value = await text({
56
- message: \`Please provide a value for \${dynamic.replace(/^\[+/, "").replace(/\]+$/, "")}:\`,
57
47
  });
58
- if (isCancel(value)) {
48
+ if (isCancel(segments)) {
59
49
  return;
60
50
  }
61
- dynamics[dynamic] = value;
62
- }
63
51
 
64
- segments = segments.map(segment => dynamics[segment] || segment);
65
- const context = useApp();
66
- context.set("args", [args[0], ...segments, ...args.slice(${segments.length + 2})]);
52
+ let dynamics = {} as Record<string, string>;
53
+ for (const dynamic of segments.filter(segment => segment.startsWith("[") && segment.endsWith("]"))) {
54
+ const value = await text({
55
+ message: \`Please provide a value for \${dynamic.replace(/^\[+/, "").replace(/\]+$/, "")}:\`,
56
+ });
57
+ if (isCancel(value)) {
58
+ return;
59
+ }
60
+ dynamics[dynamic] = value;
61
+ }
62
+
63
+ segments = segments.map(segment => dynamics[segment] || segment);
64
+ const context = useApp();
65
+ context.set("args", [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${segments.length + 2})].filter(Boolean) as string[]);
67
66
 
68
- outro(\`Executing \${segments.join(" ")} command\`);
67
+ outro(\`Executing \${segments.join(" ")} command\`);
69
68
 
70
- command = segments[0];
71
- args = context.get("args");
72
- `),
69
+ command = segments[0];
70
+ args = context.get("args"); `),
73
71
  (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components_command_router.CommandRouterBody, (0, __alloy_js_core_jsx_runtime.mergeProps)(props, {
74
72
  segments,
75
73
  commands
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
1
+ import * as _alloy_js_core2 from "@alloy-js/core";
2
2
  import { CommandTree } from "@shell-shock/core/types/command";
3
3
  import { CommandRouterProps } from "@shell-shock/preset-script/components/command-router";
4
4
 
@@ -6,11 +6,11 @@ import { CommandRouterProps } from "@shell-shock/preset-script/components/comman
6
6
  interface CommandRouterSelectOptionsProps {
7
7
  commands?: Record<string, CommandTree>;
8
8
  }
9
- declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps): _alloy_js_core0.Children;
9
+ declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps): _alloy_js_core2.Children;
10
10
  /**
11
11
  * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.
12
12
  */
13
- declare function CommandRouter(props: CommandRouterProps): _alloy_js_core0.Children;
13
+ declare function CommandRouter(props: CommandRouterProps): _alloy_js_core2.Children;
14
14
  //#endregion
15
15
  export { CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps };
16
16
  //# sourceMappingURL=command-router.d.cts.map
@@ -35,40 +35,38 @@ function CommandRouter(props) {
35
35
  return [
36
36
  code`
37
37
  banner();
38
- writeLine("");
39
38
 
40
- intro("Command selection");
39
+ intro("Command selection");
41
40
 
42
- let segments = await select({
43
- message: "Please select a command to execute:",
44
- options: [ `,
41
+ let segments = await select({
42
+ message: "Please select a command to execute:",
43
+ options: [ `,
45
44
  createComponent(CommandRouterSelectOptions, { commands }),
46
45
  memo(() => ` ],
47
- });
48
- if (isCancel(segments)) {
49
- return;
50
- }
51
-
52
- let dynamics = {} as Record<string, string>;
53
- for (const dynamic of segments.filter(segment => segment.startsWith("[") && segment.endsWith("]"))) {
54
- const value = await text({
55
- message: \`Please provide a value for \${dynamic.replace(/^\[+/, "").replace(/\]+$/, "")}:\`,
56
46
  });
57
- if (isCancel(value)) {
47
+ if (isCancel(segments)) {
58
48
  return;
59
49
  }
60
- dynamics[dynamic] = value;
61
- }
62
50
 
63
- segments = segments.map(segment => dynamics[segment] || segment);
64
- const context = useApp();
65
- context.set("args", [args[0], ...segments, ...args.slice(${segments.length + 2})]);
51
+ let dynamics = {} as Record<string, string>;
52
+ for (const dynamic of segments.filter(segment => segment.startsWith("[") && segment.endsWith("]"))) {
53
+ const value = await text({
54
+ message: \`Please provide a value for \${dynamic.replace(/^\[+/, "").replace(/\]+$/, "")}:\`,
55
+ });
56
+ if (isCancel(value)) {
57
+ return;
58
+ }
59
+ dynamics[dynamic] = value;
60
+ }
61
+
62
+ segments = segments.map(segment => dynamics[segment] || segment);
63
+ const context = useApp();
64
+ context.set("args", [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${segments.length + 2})].filter(Boolean) as string[]);
66
65
 
67
- outro(\`Executing \${segments.join(" ")} command\`);
66
+ outro(\`Executing \${segments.join(" ")} command\`);
68
67
 
69
- command = segments[0];
70
- args = context.get("args");
71
- `),
68
+ command = segments[0];
69
+ args = context.get("args"); `),
72
70
  createComponent(CommandRouterBody, mergeProps(props, {
73
71
  segments,
74
72
  commands
@@ -1 +1 @@
1
- {"version":3,"file":"command-router.mjs","names":["code","For","IfStatement","CommandRouter","BaseCommandRouter","CommandRouterBody","CommandRouterSelectOptions","props","commands","_$createComponent","each","Object","values","joiner","hardline","children","command","isVirtual","segments","map","segment","join","icon","title","description","_$mergeProps","_$createIntrinsic","condition","_$memo","length"],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport type { CommandRouterProps } from \"@shell-shock/preset-script/components/command-router\";\nimport {\n CommandRouter as BaseCommandRouter,\n CommandRouterBody\n} from \"@shell-shock/preset-script/components/command-router\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n return (\n <For each={Object.values(commands ?? {})} joiner=\",\" hardline>\n {command =>\n command.isVirtual ? (\n <CommandRouterSelectOptions commands={command.children ?? {}} />\n ) : (\n code`{ value: [${command.segments\n .map(segment => `\"${segment}\"`)\n .join(\n \", \"\n )}], label: \"${command.icon ? `${command.icon} ` : \"\"}${command.title}\", hint: \"${\n command.description\n }\" }`\n )\n }\n </For>\n );\n}\n\n/**\n * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands } = props;\n\n return (\n <>\n <BaseCommandRouter {...props} segments={segments} commands={commands} />\n <hbr />\n <hbr />\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`\n banner();\n writeLine(\"\");\n\n intro(\"Command selection\");\n\n let segments = await select({\n message: \"Please select a command to execute:\",\n options: [ `}\n <CommandRouterSelectOptions commands={commands} />\n {` ],\n });\n if (isCancel(segments)) {\n return;\n }\n\n let dynamics = {} as Record<string, string>;\n for (const dynamic of segments.filter(segment => segment.startsWith(\"[\") && segment.endsWith(\"]\"))) {\n const value = await text({\n message: \\`Please provide a value for \\${dynamic.replace(/^\\[+/, \"\").replace(/\\]+$/, \"\")}:\\`,\n });\n if (isCancel(value)) {\n return;\n }\n dynamics[dynamic] = value;\n }\n\n segments = segments.map(segment => dynamics[segment] || segment);\n const context = useApp();\n context.set(\"args\", [args[0], ...segments, ...args.slice(${segments.length + 2})]);\n\n outro(\\`Executing \\${segments.join(\" \")} command\\`);\n\n command = segments[0];\n args = context.get(\"args\");\n `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <hbr />\n <hbr />\n </>\n );\n}\n"],"mappings":";;;;;;AA+BA,SAAgBM,2BACdC,OACA;CACA,MAAM,EAAEC,aAAaD;AAErB,QAAAE,gBACGR,KAAG;EAAA,IAACS,OAAI;AAAA,UAAEC,OAAOC,OAAOJ,YAAY,EAAE,CAAC;;EAAEK,QAAM;EAAKC,UAAQ;EAAAC,WAC1DC,YACCA,QAAQC,YAASR,gBACdH,4BAA0B,EAAA,IAACE,WAAQ;AAAA,UAAEQ,QAAQD,YAAY,EAAE;KAAA,CAAA,GAE5Df,IAAI,aAAagB,QAAQE,SACtBC,KAAIC,YAAW,IAAIA,QAAO,GAAI,CAC9BC,KACC,KACD,CAAA,aAAcL,QAAQM,OAAO,GAAGN,QAAQM,KAAI,MAAO,KAAKN,QAAQO,MAAK,YACtEP,QAAQQ,YAAW;EAEtB,CAAA;;;;;AAST,SAAgBrB,cAAcI,OAA2B;CACvD,MAAM,EAAEW,UAAUV,aAAaD;AAE/B,QAAA;EAAAE,gBAEKL,iBAAiBqB,WAAKlB,OAAK;GAAYW;GAAoBV;GAAQ,CAAA,CAAA;EAAAkB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAAjB,gBAGnEP,aAAW;GAACyB,WAAW3B,IAAI;GAA0B,IAAAe,WAAA;AAAA,WAAA;KACnDf,IAAI;;;;;;;;;KAQOS,gBACXH,4BAA0B,EAAWE,UAAQ,CAAA;KAAAoB,WAC7C;;;;;;;;;;;;;;;;;;;iEAmBwDV,SAASW,SAAS,EAAC;;;;;;QAM7E;KAAApB,gBACEJ,mBAAiBoB,WAAKlB,OAAK;MAAYW;MAAoBV;MAAQ,CAAA,CAAA;KAAA;;GAAA,CAAA;EAAAkB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAA"}
1
+ {"version":3,"file":"command-router.mjs","names":["code","For","IfStatement","CommandRouter","BaseCommandRouter","CommandRouterBody","CommandRouterSelectOptions","props","commands","_$createComponent","each","Object","values","joiner","hardline","children","command","isVirtual","segments","map","segment","join","icon","title","description","_$mergeProps","_$createIntrinsic","condition","_$memo","length"],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport type { CommandRouterProps } from \"@shell-shock/preset-script/components/command-router\";\nimport {\n CommandRouter as BaseCommandRouter,\n CommandRouterBody\n} from \"@shell-shock/preset-script/components/command-router\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n return (\n <For each={Object.values(commands ?? {})} joiner=\",\" hardline>\n {command =>\n command.isVirtual ? (\n <CommandRouterSelectOptions commands={command.children ?? {}} />\n ) : (\n code`{ value: [${command.segments\n .map(segment => `\"${segment}\"`)\n .join(\n \", \"\n )}], label: \"${command.icon ? `${command.icon} ` : \"\"}${command.title}\", hint: \"${\n command.description\n }\" }`\n )\n }\n </For>\n );\n}\n\n/**\n * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands } = props;\n\n return (\n <>\n <BaseCommandRouter {...props} segments={segments} commands={commands} />\n <hbr />\n <hbr />\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`\n banner();\n\n intro(\"Command selection\");\n\n let segments = await select({\n message: \"Please select a command to execute:\",\n options: [ `}\n <CommandRouterSelectOptions commands={commands} />\n {` ],\n });\n if (isCancel(segments)) {\n return;\n }\n\n let dynamics = {} as Record<string, string>;\n for (const dynamic of segments.filter(segment => segment.startsWith(\"[\") && segment.endsWith(\"]\"))) {\n const value = await text({\n message: \\`Please provide a value for \\${dynamic.replace(/^\\[+/, \"\").replace(/\\]+$/, \"\")}:\\`,\n });\n if (isCancel(value)) {\n return;\n }\n dynamics[dynamic] = value;\n }\n\n segments = segments.map(segment => dynamics[segment] || segment);\n const context = useApp();\n context.set(\"args\", [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${\n segments.length + 2\n })].filter(Boolean) as string[]);\n\n outro(\\`Executing \\${segments.join(\" \")} command\\`);\n\n command = segments[0];\n args = context.get(\"args\"); `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <hbr />\n <hbr />\n </>\n );\n}\n"],"mappings":";;;;;;AA+BA,SAAgBM,2BACdC,OACA;CACA,MAAM,EAAEC,aAAaD;AAErB,QAAAE,gBACGR,KAAG;EAAA,IAACS,OAAI;AAAA,UAAEC,OAAOC,OAAOJ,YAAY,EAAE,CAAC;;EAAEK,QAAM;EAAKC,UAAQ;EAAAC,WAC1DC,YACCA,QAAQC,YAASR,gBACdH,4BAA0B,EAAA,IAACE,WAAQ;AAAA,UAAEQ,QAAQD,YAAY,EAAE;KAAA,CAAA,GAE5Df,IAAI,aAAagB,QAAQE,SACtBC,KAAIC,YAAW,IAAIA,QAAO,GAAI,CAC9BC,KACC,KACD,CAAA,aAAcL,QAAQM,OAAO,GAAGN,QAAQM,KAAI,MAAO,KAAKN,QAAQO,MAAK,YACtEP,QAAQQ,YAAW;EAEtB,CAAA;;;;;AAST,SAAgBrB,cAAcI,OAA2B;CACvD,MAAM,EAAEW,UAAUV,aAAaD;AAE/B,QAAA;EAAAE,gBAEKL,iBAAiBqB,WAAKlB,OAAK;GAAYW;GAAoBV;GAAQ,CAAA,CAAA;EAAAkB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAAjB,gBAGnEP,aAAW;GAACyB,WAAW3B,IAAI;GAA0B,IAAAe,WAAA;AAAA,WAAA;KACnDf,IAAI;;;;;;;;KAOSS,gBACbH,4BAA0B,EAAWE,UAAQ,CAAA;KAAAoB,WAC7C;;;;;;;;;;;;;;;;;;;wIAoBCV,SAASW,SAAS,EAAC;;;;;sCAMQ;KAAApB,gBAC5BJ,mBAAiBoB,WAAKlB,OAAK;MAAYW;MAAoBV;MAAQ,CAAA,CAAA;KAAA;;GAAA,CAAA;EAAAkB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/preset-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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": {
@@ -170,18 +170,18 @@
170
170
  "@powerlines/deepkit": "^0.6.51",
171
171
  "@powerlines/plugin-alloy": "^0.20.15",
172
172
  "@powerlines/plugin-plugin": "^0.12.222",
173
- "@shell-shock/core": "^0.8.3",
174
- "@shell-shock/plugin-theme": "^0.0.20",
175
- "@shell-shock/preset-script": "^0.6.2",
176
- "@stryke/path": "^0.26.6",
177
- "@stryke/string-format": "^0.13.7",
173
+ "@shell-shock/core": "^0.8.4",
174
+ "@shell-shock/plugin-theme": "^0.0.21",
175
+ "@shell-shock/preset-script": "^0.6.3",
176
+ "@stryke/path": "0.26.6",
177
+ "@stryke/string-format": "^0.14.2",
178
178
  "cfonts": "^3.3.1",
179
179
  "defu": "^6.1.4",
180
180
  "powerlines": "^0.38.38"
181
181
  },
182
182
  "devDependencies": {
183
183
  "@babel/core": "^7.29.0",
184
- "@types/node": "^22.19.10",
184
+ "@types/node": "^22.19.11",
185
185
  "@types/react": "^19.2.13"
186
186
  },
187
187
  "publishConfig": {
@@ -207,5 +207,5 @@
207
207
  "./package.json": "./package.json"
208
208
  }
209
209
  },
210
- "gitHead": "109668970cbd9b415822d1e030858a154ef01834"
210
+ "gitHead": "b748bcb948ef2c11eca8e4259c76afb65ce963f0"
211
211
  }