@shell-shock/preset-cli 0.9.20 → 0.9.22

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.
@@ -1 +1 @@
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 { 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 \"italic\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"createSpinner\"\n ],\n utils: [\"sleep\", \"isMinimal\", \"isInteractive\", \"isUnicodeSupported\"],\n state: [\n { name: \"GlobalOptions\", type: true },\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner();\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(\n command.options ?? {}\n )\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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 when={arg.variadic}>\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 \\${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 : arg.kind === CommandParameterKinds.boolean\n ? `.map(Boolean)`\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 \\${italic(\"${\n command.title\n }\")} command 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":"6sCAsCA,SAAS,EAAmB,EAAO,CACnC,GAAQ,CACR,UACA,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,EAAS,CAC3B,UAAW,CAAI,sBACf,IAAI,UAAW,CACb,MAAO,EAAG,8IAAA,EAAA,MAAA;wCAGb,CAAC,CAAC,EAEN,CAAC,MAIT,CAAC,CAAC,EAEN,CAAC,CAAC,CAAE,EAAkB,EAAK,CAC1B,IAAI,MAAO,CACT,OAAO,OAAO,OAAO,EAAG,SAAc,EAExC,SAAU,GAAS,EAAY,EAAA,CAC7B,IAAI,MAAO,CACT,OAAO,EAAM,WAEf,IAAI,UAAW,CACb,OAAO,EAAW,EAAA,CAChB,QAAS,EACV,CAAC,EAEJ,IAAI,UAAK,CACP,OAAO,EAAkB,EAAoB,CAC3C,QAAO,EACR,CAAC,EAEL,CAAC,CACH,CAAC,CAAC"}
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 { 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 \"italic\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"textColors\",\n \"createSpinner\"\n ],\n utils: [\"sleep\", \"isMinimal\", \"isInteractive\", \"isUnicodeSupported\"],\n state: [\n { name: \"GlobalOptions\", type: true },\n \"useGlobal\",\n \"useGlobalOptions\",\n \"withCommand\",\n \"useArgs\",\n \"hasFlag\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner();\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(\n command.options ?? {}\n )\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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 \\${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 when={arg.variadic}>\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 \\${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 : arg.kind === CommandParameterKinds.boolean\n ? `.map(Boolean)`\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 \\${italic(\"${\n command.title\n }\")} command 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":";;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAS,aAAmB,OAAO;CACnC,MAAQ,EACR,SACA,SACA,gBACA,GAAO,SACD;;CAEN,MAAO,WAAU,eAAiB,UAAS,QAAI,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CAC7C,MAAA,oBAAc,eAAA,iBAAA,aAAA,UAAA,QAAA,WAAA,aAAA,SAAA,MAAA,CAAA,EAAA,QAAA,MAAA,OAAA,QAAA,QAAA,MAAA,KAAA,CAAA,CAAA;CACd,MAAM,iBAAI,gBAAc;EACxB,GAAA,QAAA;EACA,QAAS,QAAA;EACX,EAAA;;EAEE,IAAA,OAAA;AACI,UAAC,SAAc;;EAErB,IAAO,iBAAS;AACd,UAAQ,eAAkB;;EAE1B,IAAM,UAAU;AAChB,UAAM,KAAU,WAAW,EAAE,EAAC,GAC5B,kBAAS,MAAA,WAAA,IAAA,GAAA,kBAAA,QAAA,KAAA,kBAAA,UAAA,SAAA,WAAA,QAAA,KAAA,IACP,CAAA;;EAEF,IAAI,iBAAU;AACZ,UAAO,KAAE,kBAAA,EAAA,EAAA;IACX,KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACD,SAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACK,OAAA;KAAA;KAAiB;KAAa;KAAG;KAAA;IACrC,OAAA;KAAA;MACE,MAAA;MACE,MAAA;MACA;KAAA;KAAc;KAA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AC,gBAAA,cAAA;gBACF,IAAO,YAAS;AACf,wBAAW,IAAI,GAAC,UAAA,IAAA,KAAqB,CAAC;;gBAEzC,IAAA,WAAA;AACA,wBAAA,IAAA;;qEAE2B,IAAA,SAAA,sBAAA,SAAA,aAAA,GAAA,6BAAA,IAAA,KAAA;gCACpB,IAAI,cAAc,kBAAC,uBAAA,IAAA,YAAA,CAAA;kCACjB,GAAE;;;;;;;kCAOF,IAAG,SAAA,sBAAA,SAAA;;;0CAGK,GAAC;;;;;;;;;8BASb,UAAU,IAAI,KAAI,CAAA,gEAAe,IAAA,SAAA,sBAAA,SAAA,iBAAA,IAAA,SAAA,sBAAA,UAAA,kBAAA,GAAA;;;gBAGlC,CAAC;;cAEL,CAAC,CAAC;;YAEN,CAAC,CAAC;WACJ,CAAC;UAAE,IAAI;UAAmB,gBAAkB,SAAS,EAAE,CAAC;UAAA,gBAAmB,wBAAyB,EAC1F,SACV,CAAC;UAAE,gBAAgB,aAAS;WAC3B,WAAW,IAAI;WACf,IAAI,WAAW;AACb,mBAAO,IAAG,8IAAA,QAAA,MAAA;;;WAGb,CAAC;UAAC;;QAEN,CAAC;;;;IAIT,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAkB,KAAK;EAC1B,IAAI,OAAO;AACT,UAAO,OAAO,OAAO,QAAG,SAAc;;EAExC,WAAU,UAAS,gBAAY,MAAA;GAC7B,IAAI,OAAO;AACT,WAAO,MAAM;;GAEf,IAAI,WAAW;AACb,WAAO,gBAAW,cAAA,EAChB,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAK;AACP,WAAO,gBAAkB,qBAAoB,EAC3C,SAAO,OACR,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
@@ -1,8 +1,50 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@alloy-js/core`),n=require(`@alloy-js/typescript`),r=require(`@shell-shock/core/plugin-utils`),i=require(`@powerlines/plugin-alloy/core/components/spacing`),a=require(`@powerlines/plugin-alloy/core/contexts/context`),o=require(`@shell-shock/preset-script/components`);function s(n){let{commands:i}=n,o=(0,a.usePowerlines)();return(0,e.createComponent)(t.For,{get each(){return Object.values(i??{})},joiner:`,`,hardline:!0,children:n=>n.isVirtual?(0,e.createComponent)(s,{get commands(){return n.children??{}}}):t.code`{ value: [${n.segments.map(e=>`"${e}"`).join(`, `)}], label: "${n.title}", description: \`(${(0,r.getAppBin)(o)} ${n.segments.join(` `)})\`${n.icon?`, icon: "${n.icon.trim()}"`:``} }`})}function c(r){let{segments:a,commands:c}=r;return[(0,e.createComponent)(o.CommandRouter,(0,e.mergeProps)(r,{segments:a,commands:c})),(0,e.createComponent)(i.Spacing,{}),(0,e.createComponent)(n.IfStatement,{condition:t.code`isInteractive && !isHelp()`,get children(){return[t.code`await showBanner();
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 _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
+ let _shell_shock_preset_script_components = require("@shell-shock/preset-script/components");
10
+
11
+ //#region src/components/command-router.tsx
12
+ function CommandRouterSelectOptions(props) {
13
+ const { commands } = props;
14
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
15
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
16
+ get each() {
17
+ return Object.values(commands ?? {});
18
+ },
19
+ joiner: ",",
20
+ hardline: true,
21
+ children: (command) => command.isVirtual ? (0, _alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { get commands() {
22
+ return command.children ?? {};
23
+ } }) : _alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`(${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} ${command.segments.join(" ")})\`${command.icon ? `, icon: "${command.icon.trim()}"` : ""} }`
24
+ });
25
+ }
26
+ /**
27
+ * 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.
28
+ */
29
+ function CommandRouter(props) {
30
+ const { segments, commands } = props;
31
+ return [
32
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_preset_script_components.CommandRouter, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
33
+ segments,
34
+ commands
35
+ })),
36
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
37
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
38
+ condition: _alloy_js_core.code`isInteractive && !isHelp()`,
39
+ get children() {
40
+ return [
41
+ _alloy_js_core.code`await showBanner();
2
42
 
3
43
  let segments = await select({
4
44
  message: "Which command would you like to execute?",
5
- options: [ `,(0,e.createComponent)(s,{commands:c}),(0,e.memo)(()=>` ],
45
+ options: [ `,
46
+ (0, _alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { commands }),
47
+ (0, _alloy_js_core_jsx_runtime.memo)(() => ` ],
6
48
  });
7
49
  if (isCancel(segments)) {
8
50
  return;
@@ -22,8 +64,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
22
64
  segments = segments.map(segment => dynamics[segment] || segment);
23
65
  const context = useGlobal();
24
66
  if (context) {
25
- context.inputArgs = [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${a.length+2})].filter(Boolean) as string[];
67
+ context.inputArgs = [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${segments.length + 2})].filter(Boolean) as string[];
26
68
  }
27
69
 
28
70
  command = segments[0];
29
- args = context.inputArgs; `),(0,e.createComponent)(o.CommandRouterBody,(0,e.mergeProps)(r,{segments:a,commands:c}))]}}),(0,e.createComponent)(i.Spacing,{})]}exports.CommandRouter=c,exports.CommandRouterSelectOptions=s;
71
+ args = context.inputArgs; `),
72
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_preset_script_components.CommandRouterBody, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
73
+ segments,
74
+ commands
75
+ }))
76
+ ];
77
+ }
78
+ }),
79
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
80
+ ];
81
+ }
82
+
83
+ //#endregion
84
+ exports.CommandRouter = CommandRouter;
85
+ exports.CommandRouterSelectOptions = CommandRouterSelectOptions;
@@ -1,8 +1,48 @@
1
- import{createComponent as e,memo as t,mergeProps as n}from"@alloy-js/core/jsx-runtime";import{For as r,code as i}from"@alloy-js/core";import{IfStatement as a}from"@alloy-js/typescript";import{getAppBin as o}from"@shell-shock/core/plugin-utils";import{Spacing as s}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as c}from"@powerlines/plugin-alloy/core/contexts/context";import{CommandRouter as l,CommandRouterBody as u}from"@shell-shock/preset-script/components";function d(t){let{commands:n}=t,a=c();return e(r,{get each(){return Object.values(n??{})},joiner:`,`,hardline:!0,children:t=>t.isVirtual?e(d,{get commands(){return t.children??{}}}):i`{ value: [${t.segments.map(e=>`"${e}"`).join(`, `)}], label: "${t.title}", description: \`(${o(a)} ${t.segments.join(` `)})\`${t.icon?`, icon: "${t.icon.trim()}"`:``} }`})}function f(r){let{segments:o,commands:c}=r;return[e(l,n(r,{segments:o,commands:c})),e(s,{}),e(a,{condition:i`isInteractive && !isHelp()`,get children(){return[i`await showBanner();
1
+ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { For, code } from "@alloy-js/core";
3
+ import { IfStatement } from "@alloy-js/typescript";
4
+ import { getAppBin } from "@shell-shock/core/plugin-utils";
5
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
+ import { CommandRouter as CommandRouter$1, CommandRouterBody } from "@shell-shock/preset-script/components";
8
+
9
+ //#region src/components/command-router.tsx
10
+ function CommandRouterSelectOptions(props) {
11
+ const { commands } = props;
12
+ const context = usePowerlines();
13
+ return createComponent(For, {
14
+ get each() {
15
+ return Object.values(commands ?? {});
16
+ },
17
+ joiner: ",",
18
+ hardline: true,
19
+ children: (command) => command.isVirtual ? createComponent(CommandRouterSelectOptions, { get commands() {
20
+ return command.children ?? {};
21
+ } }) : code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`(${getAppBin(context)} ${command.segments.join(" ")})\`${command.icon ? `, icon: "${command.icon.trim()}"` : ""} }`
22
+ });
23
+ }
24
+ /**
25
+ * 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.
26
+ */
27
+ function CommandRouter(props) {
28
+ const { segments, commands } = props;
29
+ return [
30
+ createComponent(CommandRouter$1, mergeProps(props, {
31
+ segments,
32
+ commands
33
+ })),
34
+ createComponent(Spacing, {}),
35
+ createComponent(IfStatement, {
36
+ condition: code`isInteractive && !isHelp()`,
37
+ get children() {
38
+ return [
39
+ code`await showBanner();
2
40
 
3
41
  let segments = await select({
4
42
  message: "Which command would you like to execute?",
5
- options: [ `,e(d,{commands:c}),t(()=>` ],
43
+ options: [ `,
44
+ createComponent(CommandRouterSelectOptions, { commands }),
45
+ memo(() => ` ],
6
46
  });
7
47
  if (isCancel(segments)) {
8
48
  return;
@@ -22,9 +62,22 @@ import{createComponent as e,memo as t,mergeProps as n}from"@alloy-js/core/jsx-ru
22
62
  segments = segments.map(segment => dynamics[segment] || segment);
23
63
  const context = useGlobal();
24
64
  if (context) {
25
- context.inputArgs = [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${o.length+2})].filter(Boolean) as string[];
65
+ context.inputArgs = [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${segments.length + 2})].filter(Boolean) as string[];
26
66
  }
27
67
 
28
68
  command = segments[0];
29
- args = context.inputArgs; `),e(u,n(r,{segments:o,commands:c}))]}}),e(s,{})]}export{f as CommandRouter,d as CommandRouterSelectOptions};
69
+ args = context.inputArgs; `),
70
+ createComponent(CommandRouterBody, mergeProps(props, {
71
+ segments,
72
+ commands
73
+ }))
74
+ ];
75
+ }
76
+ }),
77
+ createComponent(Spacing, {})
78
+ ];
79
+ }
80
+
81
+ //#endregion
82
+ export { CommandRouter, CommandRouterSelectOptions };
30
83
  //# sourceMappingURL=command-router.mjs.map
@@ -1 +1 @@
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 { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppBin } 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\";\nimport type { CLIPresetContext } from \"../types\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n const context = usePowerlines<CLIPresetContext>();\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: \\`(${getAppBin(\n context\n )} ${command.segments.join(\" \")})\\`${\n command.icon ? `, icon: \"${command.icon.trim()}\"` : \"\"\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 <Spacing />\n <IfStatement condition={code`isInteractive && !isHelp()`}>\n {code`await showBanner();\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 = useGlobal();\n if (context) {\n context.inputArgs = [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\n command = segments[0];\n args = context.inputArgs; `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <Spacing />\n </>\n );\n}\n"],"mappings":"2eAyBA,SAAO,EAAA,EAAA,CACL,GAAA,CACA,YACI,EACC,EAAO,GAAmB,aAEjC,IAAO,MAAA,CACL,OAAW,OAAO,OAAO,GAAY,EAAC,CAAA,aAGxC,SAAO,GACL,SAAO,GAAA,EAAA,UAAA,EAAA,EAAA,CACP,IAAA,UAAA,CACM,OAAE,EAAa,UAAK,EAAA,EAE1B,CAAA,CAAM,CAAA,aAAU,EAAc,SAAA,IAAA,GAAmB,IAAA,EAAA,GAAA,CAAA,KAAA,KAAA,CAAA,aAAA,EAAA,MAAA,qBAAA,EAAA,EAAA,CAAA,GAAA,EAAA,SAAA,KAAA,IAAA,CAAA,KAAA,EAAA,KAAA,YAAA,EAAA,KAAA,MAAA,CAAA,GAAA,GAAA,MAOnD,SAAY,EAAA,EAAA,CACV,GAAM,CACJ,WACA,YACE,EACJ,MAAO,CAAC,EAAiB,EAAiB,EAAgB,EAAE,CAClD,WACE,WACX,CAAC,CAAC,CAAE,EAAkB,EAAS,EAAE,CAAC,CAAE,EAAkB,EAAQ,CAC7D,UAAS,CAAA,6BACT,IAAI,UAAA,CACF,MAAA,CAAA,CAAA;;;;4BAKJ,WACG,CAAA,CAAA,MAAe;;;;;;;;;;;;;;;;;;;;0IAoBZ,EAAA,OAAA,EAAA;;;;oCAI2B,CAAA,EAAA,EAAA,EAAA,EAAA,CACvB,WACA,WACL,CAAC,CAAC,CAAC,EAEP,CAAC,CAAE,EAAI,EAAA,EAAA,CAAA,CAAA"}
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 { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppBin } 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\";\nimport type { CLIPresetContext } from \"../types\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n const context = usePowerlines<CLIPresetContext>();\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: \\`(${getAppBin(\n context\n )} ${command.segments.join(\" \")})\\`${\n command.icon ? `, icon: \"${command.icon.trim()}\"` : \"\"\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 <Spacing />\n <IfStatement condition={code`isInteractive && !isHelp()`}>\n {code`await showBanner();\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 = useGlobal();\n if (context) {\n context.inputArgs = [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\n command = segments[0];\n args = context.inputArgs; `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAO,2BAAA,OAAA;CACL,MAAA,EACA,aACI;CACN,MAAO,UAAO,eAAmB;;EAEjC,IAAO,OAAA;AACL,UAAW,OAAO,OAAO,YAAY,EAAC,CAAA;;;EAGxC,UAAO;EACL,WAAO,YAAA,QAAA,YAAA,gBAAA,4BAAA,EACP,IAAA,WAAA;AACM,UAAE,QAAa,YAAK,EAAA;KAE1B,CAAA,GAAM,IAAA,aAAU,QAAc,SAAA,KAAA,YAAmB,IAAA,QAAA,GAAA,CAAA,KAAA,KAAA,CAAA,aAAA,QAAA,MAAA,qBAAA,UAAA,QAAA,CAAA,GAAA,QAAA,SAAA,KAAA,IAAA,CAAA,KAAA,QAAA,OAAA,YAAA,QAAA,KAAA,MAAA,CAAA,KAAA,GAAA;;;;;;AAOnD,SAAY,cAAA,OAAA;CACV,MAAM,EACJ,UACA,aACE;AACJ,QAAO;EAAC,gBAAiB,iBAAiB,WAAgB,OAAE;GAClD;GACE;GACX,CAAC,CAAC;EAAE,gBAAkB,SAAS,EAAE,CAAC;EAAE,gBAAkB,aAAQ;GAC7D,WAAS,IAAA;GACT,IAAI,WAAA;AACF,WAAA;KAAA,IAAA;;;;;mDAKJ,UACG,CAAA;KAAA,WAAe;;;;;;;;;;;;;;;;;;;;0IAoBZ,SAAA,SAAA,EAAA;;;;oCAI2B;KAAA,gBAAA,mBAAA,WAAA,OAAA;MACvB;MACA;MACL,CAAC,CAAC;KAAC;;GAEP,CAAC;EAAE,gBAAI,SAAA,EAAA,CAAA;EAAA"}
@@ -1 +1,15 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./banner-builtin.cjs`),t=require(`./command-router.cjs`),n=require(`./virtual-command-entry.cjs`),r=require(`./command-entry.cjs`),i=require(`./upgrade-builtin.cjs`);exports.BannerBuiltin=e.BannerBuiltin,exports.BannerFunctionBodyDeclaration=e.BannerFunctionBodyDeclaration,exports.CommandEntry=r.CommandEntry,exports.CommandRouter=t.CommandRouter,exports.CommandRouterSelectOptions=t.CommandRouterSelectOptions,exports.ExecuteUpgradeFunctionDeclaration=i.ExecuteUpgradeFunctionDeclaration,exports.UpgradeBuiltin=i.UpgradeBuiltin,exports.VirtualCommandEntry=n.VirtualCommandEntry;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_components_banner_builtin = require('./banner-builtin.cjs');
3
+ const require_components_command_router = require('./command-router.cjs');
4
+ const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
5
+ const require_components_command_entry = require('./command-entry.cjs');
6
+ const require_components_upgrade_builtin = require('./upgrade-builtin.cjs');
7
+
8
+ exports.BannerBuiltin = require_components_banner_builtin.BannerBuiltin;
9
+ exports.BannerFunctionBodyDeclaration = require_components_banner_builtin.BannerFunctionBodyDeclaration;
10
+ exports.CommandEntry = require_components_command_entry.CommandEntry;
11
+ exports.CommandRouter = require_components_command_router.CommandRouter;
12
+ exports.CommandRouterSelectOptions = require_components_command_router.CommandRouterSelectOptions;
13
+ exports.ExecuteUpgradeFunctionDeclaration = require_components_upgrade_builtin.ExecuteUpgradeFunctionDeclaration;
14
+ exports.UpgradeBuiltin = require_components_upgrade_builtin.UpgradeBuiltin;
15
+ exports.VirtualCommandEntry = require_components_virtual_command_entry.VirtualCommandEntry;
@@ -1 +1,7 @@
1
- import{BannerBuiltin as e,BannerFunctionBodyDeclaration as t}from"./banner-builtin.mjs";import{CommandRouter as n,CommandRouterSelectOptions as r}from"./command-router.mjs";import{VirtualCommandEntry as i}from"./virtual-command-entry.mjs";import{CommandEntry as a}from"./command-entry.mjs";import{ExecuteUpgradeFunctionDeclaration as o,UpgradeBuiltin as s}from"./upgrade-builtin.mjs";export{e as BannerBuiltin,t as BannerFunctionBodyDeclaration,a as CommandEntry,n as CommandRouter,r as CommandRouterSelectOptions,o as ExecuteUpgradeFunctionDeclaration,s as UpgradeBuiltin,i as VirtualCommandEntry};
1
+ import { BannerBuiltin, BannerFunctionBodyDeclaration } from "./banner-builtin.mjs";
2
+ import { CommandRouter, CommandRouterSelectOptions } from "./command-router.mjs";
3
+ import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
4
+ import { CommandEntry } from "./command-entry.mjs";
5
+ import { ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin } from "./upgrade-builtin.mjs";
6
+
7
+ export { BannerBuiltin, BannerFunctionBodyDeclaration, CommandEntry, CommandRouter, CommandRouterSelectOptions, ExecuteUpgradeFunctionDeclaration, UpgradeBuiltin, VirtualCommandEntry };
@@ -1,15 +1,73 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@alloy-js/core`),n=require(`@alloy-js/typescript`),r=require(`@shell-shock/core/plugin-utils`),i=require(`@powerlines/plugin-alloy/core/components/spacing`),a=require(`@powerlines/plugin-alloy/core/contexts/context`),o=require(`defu`),s=require(`@shell-shock/plugin-upgrade/components/upgrade-builtin`);function c(){let o=(0,a.usePowerlines)();return(0,e.createComponent)(t.Show,{get when(){return o.config.upgradeType!==!1},get children(){return(0,e.createComponent)(n.FunctionDeclaration,{export:!0,async:!0,name:`executeUpgrade`,get doc(){return`Run upgrade processing for the ${(0,r.getAppTitle)(o,!0)} application.`},get children(){return(0,e.createComponent)(n.IfStatement,{condition:t.code`await isCheckForUpdatesRequired()`,get children(){return[(0,e.createComponent)(n.VarDeclaration,{const:!0,name:`spinner`,initializer:t.code`createSpinner({
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 _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
+ let defu = require("defu");
10
+ let _shell_shock_plugin_upgrade_components_upgrade_builtin = require("@shell-shock/plugin-upgrade/components/upgrade-builtin");
11
+
12
+ //#region src/components/upgrade-builtin.tsx
13
+ /**
14
+ * A component to generate the `executeUpgrade` function in the `shell-shock:upgrade` builtin module.
15
+ */
16
+ function ExecuteUpgradeFunctionDeclaration() {
17
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
18
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
19
+ get when() {
20
+ return context.config.upgradeType !== false;
21
+ },
22
+ get children() {
23
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
24
+ "export": true,
25
+ async: true,
26
+ name: "executeUpgrade",
27
+ get doc() {
28
+ return `Run upgrade processing for the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application.`;
29
+ },
30
+ get children() {
31
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
32
+ condition: _alloy_js_core.code`await isCheckForUpdatesRequired()`,
33
+ get children() {
34
+ return [
35
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
36
+ "const": true,
37
+ name: "spinner",
38
+ initializer: _alloy_js_core.code`createSpinner({
2
39
  message: "Checking for updates..."
3
- }).start(); `}),(0,e.createComponent)(n.VarDeclaration,{const:!0,name:`result`,initializer:t.code`await checkForUpdates({ force: true }); `}),(0,e.createComponent)(n.IfStatement,{condition:t.code`(result as CheckForUpdatesErrorResult)?.isError`,get children(){return t.code`spinner.error(\`An error occurred while checking for ${(0,r.getAppTitle)(o,!0)} application updates. Please try again later - if the problem persists, please contact support.\`);
4
- debug((result as CheckForUpdatesErrorResult).error); `}}),(0,e.createComponent)(n.ElseIfClause,{condition:t.code`!(result as CheckForUpdatesSuccessResult)?.isUpToDate`,get children(){return(0,e.createComponent)(t.Show,{get when(){return o.config.upgradeType!==!1&&(o.config.upgradeType===`confirm`||o.config.upgradeType===`manual`)},get fallback(){return[(0,e.memo)(()=>t.code`spinner.stop();
5
- info(\`A new version of ${(0,r.getAppTitle)(o,!0)} is available: \${red(\`v\${(result as CheckForUpdatesSuccessResult).currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${(result as CheckForUpdatesSuccessResult).latestVersion}\`)}\${(result as CheckForUpdatesSuccessResult).package?.date ? textColors.body.tertiary(\` (updated on \${(result as CheckForUpdatesSuccessResult).package?.date})\`) : ""}\`);
40
+ }).start(); `
41
+ }),
42
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
43
+ "const": true,
44
+ name: "result",
45
+ initializer: _alloy_js_core.code`await checkForUpdates({ force: true }); `
46
+ }),
47
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
48
+ condition: _alloy_js_core.code`(result as CheckForUpdatesErrorResult)?.isError`,
49
+ get children() {
50
+ return _alloy_js_core.code`spinner.error(\`An error occurred while checking for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application updates. Please try again later - if the problem persists, please contact support.\`);
51
+ debug((result as CheckForUpdatesErrorResult).error); `;
52
+ }
53
+ }),
54
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
55
+ condition: _alloy_js_core.code`!(result as CheckForUpdatesSuccessResult)?.isUpToDate`,
56
+ get children() {
57
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
58
+ get when() {
59
+ return context.config.upgradeType !== false && (context.config.upgradeType === "confirm" || context.config.upgradeType === "manual");
60
+ },
61
+ get fallback() {
62
+ return [(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`spinner.stop();
63
+ info(\`A new version of ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} is available: \${red(\`v\${(result as CheckForUpdatesSuccessResult).currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${(result as CheckForUpdatesSuccessResult).latestVersion}\`)}\${(result as CheckForUpdatesSuccessResult).package?.date ? textColors.body.tertiary(\` (updated on \${(result as CheckForUpdatesSuccessResult).package?.date})\`) : ""}\`);
6
64
 
7
65
  try {
8
66
  await upgrade();
9
67
  spinner.success("Update successful! Please restart the application to apply the update.");
10
68
 
11
69
  writeLine("");
12
- help(\`You can view the changelog for this release at any time by running the \${inlineCode("${(0,r.getAppBin)(o)} changelog --latest")} command.\`);
70
+ help(\`You can view the changelog for this release at any time by running the \${inlineCode("${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} changelog --latest")} command.\`);
13
71
 
14
72
  writeLine("");
15
73
  writeLine("Press any key to exit the application...");
@@ -17,10 +75,21 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
17
75
  await waitForKeyPress();
18
76
  return;
19
77
  } catch (err) {
20
- spinner.error(\`An error occurred while updating ${(0,r.getAppTitle)(o,!0)} to v\${(result as CheckForUpdatesSuccessResult).latestVersion}. Please try again later - if the problem persists, please contact support.\`);
78
+ spinner.error(\`An error occurred while updating ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} to v\${(result as CheckForUpdatesSuccessResult).latestVersion}. Please try again later - if the problem persists, please contact support.\`);
21
79
  debug(err);
22
- } `),(0,e.createComponent)(i.Spacing,{})]},get children(){return[(0,e.memo)(()=>t.code`spinner.stop();
23
- warn(\`A new version of ${(0,r.getAppTitle)(o,!0)} is available: \${red(\`v\${(result as CheckForUpdatesSuccessResult).currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${(result as CheckForUpdatesSuccessResult).latestVersion}\`)}\${(result as CheckForUpdatesSuccessResult).package.date ? textColors.body.tertiary(\` (updated on \${(result as CheckForUpdatesSuccessResult).package.date})\`) : ""}${o.config.upgradeType!==!1&&o.config.upgradeType===`manual`?` \\nPlease run \`${(0,r.getAppBin)(o)} upgrade\` to upgrade to the latest version.`:``}\`); `),(0,e.createComponent)(i.Spacing,{}),(0,e.createComponent)(t.Show,{get when(){return o.config.upgradeType!==!1&&o.config.upgradeType===`confirm`},get children(){return t.code`const willUpgradeNow = await confirm({
80
+ } `), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})];
81
+ },
82
+ get children() {
83
+ return [
84
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`spinner.stop();
85
+ warn(\`A new version of ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} is available: \${red(\`v\${(result as CheckForUpdatesSuccessResult).currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${(result as CheckForUpdatesSuccessResult).latestVersion}\`)}\${(result as CheckForUpdatesSuccessResult).package.date ? textColors.body.tertiary(\` (updated on \${(result as CheckForUpdatesSuccessResult).package.date})\`) : ""}${context.config.upgradeType !== false && context.config.upgradeType === "manual" ? ` \\nPlease run \`${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} upgrade\` to upgrade to the latest version.` : ""}\`); `),
86
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
87
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
88
+ get when() {
89
+ return context.config.upgradeType !== false && context.config.upgradeType === "confirm";
90
+ },
91
+ get children() {
92
+ return _alloy_js_core.code`const willUpgradeNow = await confirm({
24
93
  message: \`Would you like to update to v\${(result as CheckForUpdatesSuccessResult).latestVersion} now?\`,
25
94
  initialValue: true
26
95
  });
@@ -29,7 +98,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
29
98
  }
30
99
 
31
100
  if (willUpgradeNow) {
32
- spinner.text = \`Updating ${(0,r.getAppTitle)(o,!0)} to v\${(result as CheckForUpdatesSuccessResult).latestVersion}...\`;
101
+ spinner.text = \`Updating ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} to v\${(result as CheckForUpdatesSuccessResult).latestVersion}...\`;
33
102
  spinner.start();
34
103
 
35
104
  try {
@@ -37,7 +106,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
37
106
  spinner.success("Update successful! Please restart the application to apply the update.");
38
107
 
39
108
  writeLine("");
40
- help(\`You can view the changelog for this release at any time by running the \${inlineCode("${(0,r.getAppBin)(o)} changelog --latest")} command.\`);
109
+ help(\`You can view the changelog for this release at any time by running the \${inlineCode("${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} changelog --latest")} command.\`);
41
110
 
42
111
  writeLine("");
43
112
  writeLine("Press any key to exit the application...");
@@ -45,11 +114,63 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
45
114
  await waitForKeyPress();
46
115
  return;
47
116
  } catch (err) {
48
- spinner.error(\`An error occurred while updating ${(0,r.getAppTitle)(o,!0)} to v\${(result as CheckForUpdatesSuccessResult).latestVersion}. Please try again later - if the problem persists, please contact support.\`);
117
+ spinner.error(\`An error occurred while updating ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} to v\${(result as CheckForUpdatesSuccessResult).latestVersion}. Please try again later - if the problem persists, please contact support.\`);
49
118
  return { error: err };
50
119
  }
51
120
  } else {
52
- help("Updates can be performed at any time by running the \`${(0,r.getAppBin)(o)} upgrade\` command. Please remember that keeping your application up to date is important for ensuring you have the latest features, performance improvements, and security patches.");
53
- } `}})]}})}}),(0,e.createComponent)(n.ElseClause,{get children(){return t.code`spinner.success("Currently running the latest version of ${(0,r.getAppTitle)(o,!0)}.");
121
+ help("Updates can be performed at any time by running the \`${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} upgrade\` command. Please remember that keeping your application up to date is important for ensuring you have the latest features, performance improvements, and security patches.");
122
+ } `;
123
+ }
124
+ })
125
+ ];
126
+ }
127
+ });
128
+ }
129
+ }),
130
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
131
+ return _alloy_js_core.code`spinner.success("Currently running the latest version of ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)}.");
54
132
  writeLine("");
55
- `}})]}})}})}})}function l(n){let[{children:r,builtinImports:a},l]=(0,t.splitProps)(n,[`children`,`builtinImports`]);return(0,e.createComponent)(s.UpgradeBuiltin,(0,e.mergeProps)(l,{get builtinImports(){return(0,o.defu)(a??{},{console:[`createSpinner`,`debug`,`info`],prompts:[`waitForKeyPress`]})},get children(){return[(0,e.createComponent)(c,{}),(0,e.createComponent)(i.Spacing,{}),(0,e.createComponent)(t.Show,{get when(){return!!r},children:r})]}}))}exports.ExecuteUpgradeFunctionDeclaration=c,exports.UpgradeBuiltin=l;
133
+ `;
134
+ } })
135
+ ];
136
+ }
137
+ });
138
+ }
139
+ });
140
+ }
141
+ });
142
+ }
143
+ /**
144
+ * A built-in upgrade module for Shell Shock.
145
+ */
146
+ function UpgradeBuiltin(props) {
147
+ const [{ children, builtinImports }, rest] = (0, _alloy_js_core.splitProps)(props, ["children", "builtinImports"]);
148
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_plugin_upgrade_components_upgrade_builtin.UpgradeBuiltin, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
149
+ get builtinImports() {
150
+ return (0, defu.defu)(builtinImports ?? {}, {
151
+ console: [
152
+ "createSpinner",
153
+ "debug",
154
+ "info"
155
+ ],
156
+ prompts: ["waitForKeyPress"]
157
+ });
158
+ },
159
+ get children() {
160
+ return [
161
+ (0, _alloy_js_core_jsx_runtime.createComponent)(ExecuteUpgradeFunctionDeclaration, {}),
162
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
163
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
164
+ get when() {
165
+ return Boolean(children);
166
+ },
167
+ children
168
+ })
169
+ ];
170
+ }
171
+ }));
172
+ }
173
+
174
+ //#endregion
175
+ exports.ExecuteUpgradeFunctionDeclaration = ExecuteUpgradeFunctionDeclaration;
176
+ exports.UpgradeBuiltin = UpgradeBuiltin;