@shell-shock/preset-cli 0.8.0 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
  2. package/dist/_virtual/_rolldown/runtime.mjs +3 -0
  3. package/dist/components/banner-function-declaration.cjs +48 -164
  4. package/dist/components/banner-function-declaration.d.cts +2 -2
  5. package/dist/components/banner-function-declaration.d.cts.map +1 -1
  6. package/dist/components/banner-function-declaration.d.mts +2 -2
  7. package/dist/components/banner-function-declaration.d.mts.map +1 -1
  8. package/dist/components/banner-function-declaration.mjs +29 -146
  9. package/dist/components/banner-function-declaration.mjs.map +1 -1
  10. package/dist/components/command-entry.cjs +122 -120
  11. package/dist/components/command-entry.d.cts.map +1 -1
  12. package/dist/components/command-entry.d.mts +3 -3
  13. package/dist/components/command-entry.d.mts.map +1 -1
  14. package/dist/components/command-entry.mjs +21 -20
  15. package/dist/components/command-entry.mjs.map +1 -1
  16. package/dist/components/command-router.cjs +20 -19
  17. package/dist/components/command-router.d.cts +3 -3
  18. package/dist/components/command-router.d.cts.map +1 -1
  19. package/dist/components/command-router.d.mts.map +1 -1
  20. package/dist/components/command-router.mjs +1 -1
  21. package/dist/components/command-router.mjs.map +1 -1
  22. package/dist/components/index.cjs +4 -0
  23. package/dist/components/index.d.cts +2 -1
  24. package/dist/components/index.d.mts +2 -1
  25. package/dist/components/index.mjs +2 -1
  26. package/dist/components/upgrade-builtin.cjs +171 -0
  27. package/dist/components/upgrade-builtin.d.cts +15 -0
  28. package/dist/components/upgrade-builtin.d.cts.map +1 -0
  29. package/dist/components/upgrade-builtin.d.mts +15 -0
  30. package/dist/components/upgrade-builtin.d.mts.map +1 -0
  31. package/dist/components/upgrade-builtin.mjs +169 -0
  32. package/dist/components/upgrade-builtin.mjs.map +1 -0
  33. package/dist/components/virtual-command-entry.cjs +26 -24
  34. package/dist/components/virtual-command-entry.d.cts.map +1 -1
  35. package/dist/components/virtual-command-entry.d.mts +3 -3
  36. package/dist/components/virtual-command-entry.d.mts.map +1 -1
  37. package/dist/components/virtual-command-entry.mjs +7 -6
  38. package/dist/components/virtual-command-entry.mjs.map +1 -1
  39. package/dist/helpers/get-default-options.cjs +6 -6
  40. package/dist/helpers/get-default-options.mjs.map +1 -1
  41. package/dist/index.cjs +49 -62
  42. package/dist/index.d.cts +0 -1
  43. package/dist/index.d.cts.map +1 -1
  44. package/dist/index.d.mts +0 -1
  45. package/dist/index.d.mts.map +1 -1
  46. package/dist/index.mjs +23 -36
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/plugin-help/dist/components/display.cjs +259 -0
  49. package/dist/plugin-help/dist/components/display.mjs +254 -0
  50. package/dist/plugin-help/dist/components/display.mjs.map +1 -0
  51. package/dist/plugin-help/dist/components/help-builtin.cjs +85 -0
  52. package/dist/plugin-help/dist/components/help-builtin.mjs +84 -0
  53. package/dist/plugin-help/dist/components/help-builtin.mjs.map +1 -0
  54. package/dist/plugin-help/dist/components/help-command.cjs +96 -0
  55. package/dist/plugin-help/dist/components/help-command.mjs +96 -0
  56. package/dist/plugin-help/dist/components/help-command.mjs.map +1 -0
  57. package/dist/plugin-help/dist/components/index.cjs +3 -0
  58. package/dist/plugin-help/dist/components/index.mjs +5 -0
  59. package/dist/plugin-help/dist/index.cjs +103 -0
  60. package/dist/plugin-help/dist/index.d.cts +2 -0
  61. package/dist/plugin-help/dist/index.d.mts +2 -0
  62. package/dist/plugin-help/dist/index.mjs +100 -0
  63. package/dist/plugin-help/dist/index.mjs.map +1 -0
  64. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.cjs +17 -0
  65. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs +17 -0
  66. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs.map +1 -0
  67. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.cjs +38 -0
  68. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs +38 -0
  69. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs.map +1 -0
  70. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.cjs +33 -0
  71. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs +34 -0
  72. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +1 -0
  73. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.cjs +40 -0
  74. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs +41 -0
  75. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs.map +1 -0
  76. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.cjs +17 -0
  77. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs +17 -0
  78. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs.map +1 -0
  79. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.cjs +20 -0
  80. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs +21 -0
  81. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs.map +1 -0
  82. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.cjs +12 -0
  83. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs +12 -0
  84. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs.map +1 -0
  85. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.cjs +20 -0
  86. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs +21 -0
  87. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs.map +1 -0
  88. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.cjs +19 -0
  89. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs +20 -0
  90. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs.map +1 -0
  91. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.cjs +12 -0
  92. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs +12 -0
  93. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs.map +1 -0
  94. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.cjs +8 -0
  95. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs +8 -0
  96. package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs.map +1 -0
  97. package/dist/plugin-help/dist/types/plugin.d.cts +62 -0
  98. package/dist/plugin-help/dist/types/plugin.d.cts.map +1 -0
  99. package/dist/plugin-help/dist/types/plugin.d.mts +62 -0
  100. package/dist/plugin-help/dist/types/plugin.d.mts.map +1 -0
  101. package/dist/types/index.d.cts +2 -2
  102. package/dist/types/index.d.mts +2 -2
  103. package/dist/types/plugin.d.cts +20 -34
  104. package/dist/types/plugin.d.cts.map +1 -1
  105. package/dist/types/plugin.d.mts +20 -34
  106. package/dist/types/plugin.d.mts.map +1 -1
  107. package/package.json +30 -16
@@ -1,20 +1,21 @@
1
1
  import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
2
2
  import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
3
- import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
3
+ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
4
4
  import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
5
5
  import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
6
+ import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
6
7
  import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
7
8
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
- import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
9
- import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
10
9
  import { CommandParameterKinds } from "@shell-shock/core";
11
- import { CommandHandlerDeclaration, CommandValidationLogic } from "@shell-shock/preset-script/components/command-entry";
12
- import { findFilePath, relativePath } from "@stryke/path/find";
10
+ import defu from "defu";
13
11
  import { joinPaths } from "@stryke/path/join";
12
+ import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
13
+ import { CommandValidationLogic } from "@shell-shock/core/components/command-validation-logic";
14
+ import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
15
+ import { findFilePath, relativePath } from "@stryke/path/find";
14
16
  import { replaceExtension } from "@stryke/path/replace";
15
17
  import { camelCase } from "@stryke/string-format/camel-case";
16
18
  import { pascalCase } from "@stryke/string-format/pascal-case";
17
- import defu from "defu";
18
19
 
19
20
  //#region src/components/command-entry.tsx
20
21
  /**
@@ -24,7 +25,7 @@ function CommandEntry(props) {
24
25
  const { command, imports, builtinImports, ...rest } = props;
25
26
  const context = usePowerlines();
26
27
  const filePath = computed(() => joinPaths(command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
27
- const commandSourcePath = computed(() => `./${replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file))}`);
28
+ const commandSourcePath = computed(() => replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file)));
28
29
  const typeDefinition = computed(() => ({
29
30
  ...command.entry,
30
31
  output: command.id
@@ -37,10 +38,7 @@ function CommandEntry(props) {
37
38
  return typeDefinition.value;
38
39
  },
39
40
  get imports() {
40
- return defu(imports ?? {}, {
41
- [commandSourcePath.value]: `handle${pascalCase(command.name)}`,
42
- prompts: "prompts"
43
- });
41
+ return defu(imports ?? {}, { [commandSourcePath.value.startsWith(".") ? commandSourcePath.value : `./${commandSourcePath.value}`]: `handle${pascalCase(command.name)}` });
44
42
  },
45
43
  get builtinImports() {
46
44
  return defu(builtinImports ?? {}, {
@@ -84,21 +82,18 @@ function CommandEntry(props) {
84
82
  "isCancel",
85
83
  "sleep"
86
84
  ],
87
- upgrade: [
88
- "checkForUpdates",
89
- "isCheckForUpdatesRequired",
90
- "upgrade"
91
- ]
85
+ [joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
86
+ upgrade: ["executeUpgrade"]
92
87
  });
93
88
  },
94
89
  get children() {
95
90
  return [
96
91
  createComponent(BannerFunctionDeclaration, { command }),
97
- createIntrinsic("hbr", {}),
98
- createIntrinsic("hbr", {}),
92
+ createComponent(Spacing, {}),
99
93
  createComponent(CommandHandlerDeclaration, {
100
94
  command,
101
- banner: code`await banner(); `,
95
+ banner: code`await banner();
96
+ await executeUpgrade(); `,
102
97
  get children() {
103
98
  return [createComponent(IfStatement, {
104
99
  condition: code`!isInteractive`,
@@ -408,7 +403,13 @@ function CommandEntry(props) {
408
403
  })]
409
404
  }),
410
405
  code`writeLine(""); `,
411
- createComponent(Spacing, {})
406
+ createComponent(Spacing, {}),
407
+ createComponent(CommandValidationLogic, { command }),
408
+ createComponent(IfStatement, {
409
+ condition: code`failures.length > 0`,
410
+ children: code`error("The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\n\\n" + failures.map(failure => " - " + failure).join("\\n"));
411
+ options.help = true; `
412
+ })
412
413
  ];
413
414
  }
414
415
  });
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseIfClause","IfStatement","Spacing","usePowerlines","EntryFile","CommandParameterKinds","formatDescription","formatShortDescription","isDynamicPathSegment","CommandHandlerDeclaration","CommandValidationLogic","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","pascalCase","defu","BannerFunctionDeclaration","VirtualCommandEntry","CommandEntry","props","command","imports","builtinImports","rest","context","filePath","segments","filter","segment","join","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$createComponent","_$mergeProps","path","name","prompts","env","console","utils","upgrade","children","_$createIntrinsic","banner","condition","when","Object","values","options","option","optional","length","args","arg","map","kind","string","number","variadic","includes","each","doubleHardline","boolean","choices","fallback","description","choice","JSON","stringify","child","isVirtual"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport {\n CommandHandlerDeclaration,\n CommandValidationLogic\n} from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )}`\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`,\n prompts: \"prompts\"\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n upgrade: [\"checkForUpdates\", \"isCheckForUpdatesRequired\", \"upgrade\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2DA,SAAgB0B,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUvB,eAAiC;CACjD,MAAMwB,WAAWhC,eACfkB,UACES,QAAQM,SACLC,QAAOC,YAAW,CAACtB,qBAAqBsB,QAAQ,CAAC,CACjDC,KAAK,IAAI,EACZ,WAEJ,CAAC;CACD,MAAMC,oBAAoBrC,eAEtB,KAAKmB,iBACHF,aACEC,UAAUa,QAAQO,WAAWtB,aAAagB,SAASO,MAAM,CAAC,EAC1DZ,QAAQa,MAAMC,OAAOC,QAAQf,QAAQa,MAAME,KAE/C,CAAC,GACJ;CACD,M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;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { CommandHandlerDeclaration } from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner();\n await executeUpgrade(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\"The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\\\n\\\\n\" + failures.map(failure => \" - \" + failure).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CA+CA,MAAO,EACL,SACC,SACD,gBACA,GAAA,SACF;;CAEE,MAAA,WAAA,eAAA,UAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CACA,M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AA;YAChB,WAAU,IAAA;YACV,UAAU,IAAI;;YAEf,CAAC;WAAC;;SAEN,CAAC;;OAEL,CAAC,CAAC;;KAEN,CAAC;IAAC;;EAEN,CAAC,CAAC,EAAE,gBAAe,KAAI;EACtB,IAAI,OAAO;AACT,UAAO,OAAI,OAAA,QAAA,SAAA;;EAEb,WAAU,UAAS,gBAAC,MAAA;GAClB,IAAI,OAAK;AACP,WAAO,MAAM;;GAEf,IAAI,WAAW;AACb,WAAO,gBAAQ,cAAuB,EACpC,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAW;AACb,WAAO,gBAAiB,qBAAmB,EACzC,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
@@ -1,23 +1,24 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
- let __alloy_js_core = require("@alloy-js/core");
4
- let __alloy_js_typescript = require("@alloy-js/typescript");
5
- let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
6
- let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
7
- let __shell_shock_preset_script_components = require("@shell-shock/preset-script/components");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
+ let _alloy_js_core = require("@alloy-js/core");
5
+ let _alloy_js_typescript = require("@alloy-js/typescript");
6
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
7
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
8
+ let _shell_shock_preset_script_components = require("@shell-shock/preset-script/components");
8
9
 
9
10
  //#region src/components/command-router.tsx
10
11
  function CommandRouterSelectOptions(props) {
11
12
  const { commands } = props;
12
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
13
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
13
14
  get each() {
14
15
  return Object.values(commands ?? {});
15
16
  },
16
17
  joiner: ",",
17
18
  hardline: true,
18
- children: (command) => command.isVirtual ? (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { get commands() {
19
+ children: (command) => command.isVirtual ? (0, _alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { get commands() {
19
20
  return command.children ?? {};
20
- } }) : __alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`${(0, __shell_shock_core_plugin_utils.formatShortDescription)(command.description)}\`${command.icon ? `, icon: "${command.icon}"` : ""} }`
21
+ } }) : _alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(command.description)}\`${command.icon ? `, icon: "${command.icon}"` : ""} }`
21
22
  });
22
23
  }
23
24
  /**
@@ -26,22 +27,22 @@ function CommandRouterSelectOptions(props) {
26
27
  function CommandRouter(props) {
27
28
  const { segments, commands } = props;
28
29
  return [
29
- (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components.CommandRouter, (0, __alloy_js_core_jsx_runtime.mergeProps)(props, {
30
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_preset_script_components.CommandRouter, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
30
31
  segments,
31
32
  commands
32
33
  })),
33
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
34
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
35
- condition: __alloy_js_core.code`isInteractive && !isHelp`,
34
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
35
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
36
+ condition: _alloy_js_core.code`isInteractive && !isHelp`,
36
37
  get children() {
37
38
  return [
38
- __alloy_js_core.code`await banner();
39
+ _alloy_js_core.code`await banner();
39
40
 
40
41
  let segments = await select({
41
42
  message: "Which command would you like to execute?",
42
43
  options: [ `,
43
- (0, __alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { commands }),
44
- (0, __alloy_js_core_jsx_runtime.memo)(() => ` ],
44
+ (0, _alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { commands }),
45
+ (0, _alloy_js_core_jsx_runtime.memo)(() => ` ],
45
46
  });
46
47
  if (isCancel(segments)) {
47
48
  return;
@@ -64,14 +65,14 @@ function CommandRouter(props) {
64
65
 
65
66
  command = segments[0];
66
67
  args = context.get("args"); `),
67
- (0, __alloy_js_core_jsx_runtime.createComponent)(__shell_shock_preset_script_components.CommandRouterBody, (0, __alloy_js_core_jsx_runtime.mergeProps)(props, {
68
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_preset_script_components.CommandRouterBody, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
68
69
  segments,
69
70
  commands
70
71
  }))
71
72
  ];
72
73
  }
73
74
  }),
74
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {})
75
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
75
76
  ];
76
77
  }
77
78
 
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core2 from "@alloy-js/core";
1
+ import * as _alloy_js_core0 from "@alloy-js/core";
2
2
  import { CommandTree } from "@shell-shock/core";
3
3
  import { CommandRouterProps } from "@shell-shock/preset-script/components";
4
4
 
@@ -6,11 +6,11 @@ import { CommandRouterProps } from "@shell-shock/preset-script/components";
6
6
  interface CommandRouterSelectOptionsProps {
7
7
  commands?: Record<string, CommandTree>;
8
8
  }
9
- declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps): _alloy_js_core2.Children;
9
+ declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps): _alloy_js_core0.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_core2.Children;
13
+ declare function CommandRouter(props: CommandRouterProps): _alloy_js_core0.Children;
14
14
  //#endregion
15
15
  export { CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps };
16
16
  //# sourceMappingURL=command-router.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":[],"mappings":";;;;;UA6BiB,+BAAA;aACJ,eAAe;;AADX,iBAID,0BAAA,CAHY,KAAA,EAInB,+BAJU,CAAA,EAIqB,eAAA,CAAA,QAJrB;AAGnB;AA2BA;;iBAAgB,aAAA,QAAqB,qBAAkB,eAAA,CAAA"}
1
+ {"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;UA6BiB,+BAAA;EACf,QAAA,GAAW,MAAA,SAAe,WAAA;AAAA;AAAA,iBAGZ,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,eAAA,CAAA,QAAA;;;;iBA0BxB,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,eAAA,CAAA,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":[],"mappings":";;;;;UA6BiB,+BAAA;aACJ,eAAe;;AADX,iBAID,0BAAA,CAHY,KAAA,EAInB,+BAJU,CAAA,EAIqB,eAAA,CAAA,QAJrB;AAGnB;AA2BA;;iBAAgB,aAAA,QAAqB,qBAAkB,eAAA,CAAA"}
1
+ {"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;UA6BiB,+BAAA;EACf,QAAA,GAAW,MAAA,SAAe,WAAA;AAAA;AAAA,iBAGZ,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,eAAA,CAAA,QAAA;;;;iBA0BxB,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,eAAA,CAAA,QAAA"}
@@ -1,8 +1,8 @@
1
1
  import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
2
2
  import { For, code } from "@alloy-js/core";
3
3
  import { IfStatement } from "@alloy-js/typescript";
4
- import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
5
4
  import { formatShortDescription } from "@shell-shock/core/plugin-utils";
5
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
6
  import { CommandRouter as CommandRouter$1, CommandRouterBody } from "@shell-shock/preset-script/components";
7
7
 
8
8
  //#region src/components/command-router.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"command-router.mjs","names":["code","For","IfStatement","Spacing","formatShortDescription","CommandRouter","BaseCommandRouter","CommandRouterBody","CommandRouterSelectOptions","props","commands","_$createComponent","each","Object","values","joiner","hardline","children","command","isVirtual","segments","map","segment","join","title","description","icon","_$mergeProps","condition","_$memo","length"],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { formatShortDescription } from \"@shell-shock/core/plugin-utils\";\nimport type { CommandRouterProps } from \"@shell-shock/preset-script/components\";\nimport {\n CommandRouter as BaseCommandRouter,\n CommandRouterBody\n} from \"@shell-shock/preset-script/components\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n return (\n <For each={Object.values(commands ?? {})} joiner=\",\" hardline>\n {command =>\n command.isVirtual ? (\n <CommandRouterSelectOptions commands={command.children ?? {}} />\n ) : (\n code`{ value: [${command.segments\n .map(segment => `\"${segment}\"`)\n .join(\n \", \"\n )}], label: \"${command.title}\", description: \\`${formatShortDescription(\n command.description\n )}\\`${command.icon ? `, icon: \"${command.icon}\"` : \"\"} }`\n )\n }\n </For>\n );\n}\n\n/**\n * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands } = props;\n\n return (\n <>\n <BaseCommandRouter {...props} segments={segments} commands={commands} />\n <Spacing />\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`await banner();\n\n let segments = await select({\n message: \"Which command would you like to execute?\",\n options: [ `}\n <CommandRouterSelectOptions commands={commands} />\n {` ],\n });\n if (isCancel(segments)) {\n return;\n }\n\n let dynamics = {} as Record<string, string>;\n for (const dynamic of segments.filter(segment => segment.startsWith(\"[\") && segment.endsWith(\"]\"))) {\n const value = await text({\n message: \\`Please provide a value for \\${dynamic.replace(/^\\[+/, \"\").replace(/\\]+$/, \"\")}:\\`,\n });\n if (isCancel(value)) {\n return;\n }\n dynamics[dynamic] = value;\n }\n\n segments = segments.map(segment => dynamics[segment] || segment);\n const context = useApp();\n context.set(\"args\", [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${\n segments.length + 2\n })].filter(Boolean) as string[]);\n\n command = segments[0];\n args = context.get(\"args\"); `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;AAiCA,SAAgBQ,2BACdC,OACA;CACA,MAAM,EAAEC,aAAaD;AAErB,QAAAE,gBACGV,KAAG;EAAA,IAACW,OAAI;AAAA,UAAEC,OAAOC,OAAOJ,YAAY,EAAE,CAAC;;EAAEK,QAAM;EAAKC,UAAQ;EAAAC,WAC1DC,YACCA,QAAQC,YAASR,gBACdH,4BAA0B,EAAA,IAACE,WAAQ;AAAA,UAAEQ,QAAQD,YAAY,EAAE;KAAA,CAAA,GAE5DjB,IAAI,aAAakB,QAAQE,SACtBC,KAAIC,YAAW,IAAIA,QAAO,GAAI,CAC9BC,KACC,KACD,CAAA,aAAcL,QAAQM,MAAK,oBAAqBpB,uBACjDc,QAAQO,YACT,CAAA,IAAKP,QAAQQ,OAAO,YAAYR,QAAQQ,KAAI,KAAM,GAAE;EACtD,CAAA;;;;;AAST,SAAgBrB,cAAcI,OAA2B;CACvD,MAAM,EAAEW,UAAUV,aAAaD;AAE/B,QAAA;EAAAE,gBAEKL,iBAAiBqB,WAAKlB,OAAK;GAAYW;GAAoBV;GAAQ,CAAA,CAAA;EAAAC,gBACnER,SAAO,EAAA,CAAA;EAAAQ,gBACPT,aAAW;GAAC0B,WAAW5B,IAAI;GAA0B,IAAAiB,WAAA;AAAA,WAAA;KACnDjB,IAAI;;;;;KAISW,gBACbH,4BAA0B,EAAWE,UAAQ,CAAA;KAAAmB,WAC7C;;;;;;;;;;;;;;;;;;;wIAoBCT,SAASU,SAAS,EAAC;;;sCAIQ;KAAAnB,gBAC5BJ,mBAAiBoB,WAAKlB,OAAK;MAAYW;MAAoBV;MAAQ,CAAA,CAAA;KAAA;;GAAA,CAAA;EAAAC,gBAErER,SAAO,EAAA,CAAA;EAAA"}
1
+ {"version":3,"file":"command-router.mjs","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { formatShortDescription } from \"@shell-shock/core/plugin-utils\";\nimport type { CommandRouterProps } from \"@shell-shock/preset-script/components\";\nimport {\n CommandRouter as BaseCommandRouter,\n CommandRouterBody\n} from \"@shell-shock/preset-script/components\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n return (\n <For each={Object.values(commands ?? {})} joiner=\",\" hardline>\n {command =>\n command.isVirtual ? (\n <CommandRouterSelectOptions commands={command.children ?? {}} />\n ) : (\n code`{ value: [${command.segments\n .map(segment => `\"${segment}\"`)\n .join(\n \", \"\n )}], label: \"${command.title}\", description: \\`${formatShortDescription(\n command.description\n )}\\`${command.icon ? `, icon: \"${command.icon}\"` : \"\"} }`\n )\n }\n </For>\n );\n}\n\n/**\n * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands } = props;\n\n return (\n <>\n <BaseCommandRouter {...props} segments={segments} commands={commands} />\n <Spacing />\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`await banner();\n\n let segments = await select({\n message: \"Which command would you like to execute?\",\n options: [ `}\n <CommandRouterSelectOptions commands={commands} />\n {` ],\n });\n if (isCancel(segments)) {\n return;\n }\n\n let dynamics = {} as Record<string, string>;\n for (const dynamic of segments.filter(segment => segment.startsWith(\"[\") && segment.endsWith(\"]\"))) {\n const value = await text({\n message: \\`Please provide a value for \\${dynamic.replace(/^\\[+/, \"\").replace(/\\]+$/, \"\")}:\\`,\n });\n if (isCancel(value)) {\n return;\n }\n dynamics[dynamic] = value;\n }\n\n segments = segments.map(segment => dynamics[segment] || segment);\n const context = useApp();\n context.set(\"args\", [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${\n segments.length + 2\n })].filter(Boolean) as string[]);\n\n command = segments[0];\n args = context.get(\"args\"); `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;AA6BA,SAAgB,2BAAC,OAAgC;CAC/C,MAAA,EACF;AAEA,QAAO,gBAAS,KAAA;EACd,IAAM,OAAC;AACP,UAAA,OAAA,OAAA,YAAA,EAAA,CAAA;;;EAGA,UAAO;EACL,WAAU,YAAQ,QAAO,YAAgB,gBAAY,4BAAQ,EAC3D,IAAC,WAAS;AACR,UAAO,QAAC,YAAY,EAAA;KAEvB,CAAC,GAAG,IAAG,aAAA,QAAA,SAAA,KAAA,YAAA,IAAA,QAAA,GAAA,CAAA,KAAA,KAAA,CAAA,aAAA,QAAA,MAAA,oBAAA,uBAAA,QAAA,YAAA,CAAA,IAAA,QAAA,OAAA,YAAA,QAAA,KAAA,KAAA,GAAA;EACT,CAAC;;;;;AAMJ,SAAgB,cAAc,OAA2B;CACvD,MAAM,EACJ,UACA,aACD;AACH,QAAA;EAAA,gBAAA,iBAAA,WAAA,OAAA;;GAEE;GACC,CAAC,CAAC;EAAA,gBAAe,SAAU,EAAA,CAAO;EAAC,gBAAkB,aAAc;GACpE,WAAA,IAAA;GACF,IAAO,WAAS;AACd,WAAQ;KAAA,IAAQ;;;;;KAIM,gBAAY,4BAA8B,EAClD,UACT,CAAA;KAAA,WAAY;;;;;;;;;;;;;;;;;;;wIAmBD,SAAA,SAAA,EAAA;;;sCAGV;KAAA,gBAAA,mBAAA,WAAA,OAAA;;MAEU;MACX,CAAC,CAAA;KAAA;;GAEL,CAAC;EAAE,gBAAa,SAAS,EAAA,CAAA;EAAA"}
@@ -1,10 +1,14 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
2
3
  const require_components_command_router = require('./command-router.cjs');
3
4
  const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
4
5
  const require_components_command_entry = require('./command-entry.cjs');
6
+ const require_components_upgrade_builtin = require('./upgrade-builtin.cjs');
5
7
 
6
8
  exports.BannerFunctionDeclaration = require_components_banner_function_declaration.BannerFunctionDeclaration;
7
9
  exports.CommandEntry = require_components_command_entry.CommandEntry;
8
10
  exports.CommandRouter = require_components_command_router.CommandRouter;
9
11
  exports.CommandRouterSelectOptions = require_components_command_router.CommandRouterSelectOptions;
12
+ exports.ExecuteUpgradeFunctionDeclaration = require_components_upgrade_builtin.ExecuteUpgradeFunctionDeclaration;
13
+ exports.UpgradeBuiltin = require_components_upgrade_builtin.UpgradeBuiltin;
10
14
  exports.VirtualCommandEntry = require_components_virtual_command_entry.VirtualCommandEntry;
@@ -1,5 +1,6 @@
1
1
  import { BannerFunctionDeclaration } from "./banner-function-declaration.cjs";
2
2
  import { CommandEntry, CommandEntryProps } from "./command-entry.cjs";
3
3
  import { CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps } from "./command-router.cjs";
4
+ import { ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin } from "./upgrade-builtin.cjs";
4
5
  import { VirtualCommandEntry, VirtualCommandEntryProps } from "./virtual-command-entry.cjs";
5
- export { BannerFunctionDeclaration, CommandEntry, CommandEntryProps, CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps, VirtualCommandEntry, VirtualCommandEntryProps };
6
+ export { BannerFunctionDeclaration, CommandEntry, CommandEntryProps, CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps, ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin, VirtualCommandEntry, VirtualCommandEntryProps };
@@ -1,5 +1,6 @@
1
1
  import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
2
2
  import { CommandEntry, CommandEntryProps } from "./command-entry.mjs";
3
3
  import { CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps } from "./command-router.mjs";
4
+ import { ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin } from "./upgrade-builtin.mjs";
4
5
  import { VirtualCommandEntry, VirtualCommandEntryProps } from "./virtual-command-entry.mjs";
5
- export { BannerFunctionDeclaration, CommandEntry, CommandEntryProps, CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps, VirtualCommandEntry, VirtualCommandEntryProps };
6
+ export { BannerFunctionDeclaration, CommandEntry, CommandEntryProps, CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps, ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin, VirtualCommandEntry, VirtualCommandEntryProps };
@@ -2,5 +2,6 @@ import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
2
2
  import { CommandRouter, CommandRouterSelectOptions } from "./command-router.mjs";
3
3
  import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
4
4
  import { CommandEntry } from "./command-entry.mjs";
5
+ import { ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin } from "./upgrade-builtin.mjs";
5
6
 
6
- export { BannerFunctionDeclaration, CommandEntry, CommandRouter, CommandRouterSelectOptions, VirtualCommandEntry };
7
+ export { BannerFunctionDeclaration, CommandEntry, CommandRouter, CommandRouterSelectOptions, ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin, VirtualCommandEntry };