@shell-shock/preset-cli 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/command-entry.cjs +11 -11
- package/dist/components/command-entry.mjs +11 -11
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/upgrade-builtin.cjs +2 -3
- package/dist/components/upgrade-builtin.mjs +2 -3
- package/dist/components/upgrade-builtin.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +0 -1
- package/dist/components/virtual-command-entry.mjs +0 -1
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/package.json +12 -12
|
@@ -57,7 +57,7 @@ function CommandEntry(props) {
|
|
|
57
57
|
"warn",
|
|
58
58
|
"error",
|
|
59
59
|
"table",
|
|
60
|
-
"
|
|
60
|
+
"italic",
|
|
61
61
|
"cursor",
|
|
62
62
|
"stripAnsi",
|
|
63
63
|
"writeLine",
|
|
@@ -134,7 +134,7 @@ function CommandEntry(props) {
|
|
|
134
134
|
},
|
|
135
135
|
get fallback() {
|
|
136
136
|
return _alloy_js_core.code`const value = await select({
|
|
137
|
-
message: \`Please select a value for the \${
|
|
137
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`, ${option.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
138
138
|
` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(option.description)}\`` : ""} }`).join(", ")} ]
|
|
139
139
|
});
|
|
140
140
|
if (isCancel(value)) {
|
|
@@ -154,7 +154,7 @@ function CommandEntry(props) {
|
|
|
154
154
|
get children() {
|
|
155
155
|
return _alloy_js_core.code`
|
|
156
156
|
const value = await text({
|
|
157
|
-
message: \`Please provide a value for the \${
|
|
157
|
+
message: \`Please provide a value for the \${italic("${option.name}")} option\`,
|
|
158
158
|
${option.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
159
159
|
` : ""}validate(val) {
|
|
160
160
|
if (!val || val.trim() === "") {
|
|
@@ -179,7 +179,7 @@ function CommandEntry(props) {
|
|
|
179
179
|
get children() {
|
|
180
180
|
return _alloy_js_core.code`
|
|
181
181
|
const value = await numeric({
|
|
182
|
-
message: \`Please provide a numeric value for the \${
|
|
182
|
+
message: \`Please provide a numeric value for the \${italic("${option.name}")} option\`,
|
|
183
183
|
${option.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
184
184
|
` : ""}
|
|
185
185
|
});
|
|
@@ -198,7 +198,7 @@ function CommandEntry(props) {
|
|
|
198
198
|
get children() {
|
|
199
199
|
return _alloy_js_core.code`
|
|
200
200
|
const value = await toggle({
|
|
201
|
-
message: \`Please select a value for the \${
|
|
201
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`,
|
|
202
202
|
${option.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
203
203
|
` : ""}
|
|
204
204
|
});
|
|
@@ -227,7 +227,7 @@ function CommandEntry(props) {
|
|
|
227
227
|
get children() {
|
|
228
228
|
return _alloy_js_core.code`
|
|
229
229
|
const value = await text({
|
|
230
|
-
message: \`Please provide one or more${option.kind === _shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${
|
|
230
|
+
message: \`Please provide one or more${option.kind === _shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
231
231
|
${option.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatDescription)(option.description)}\`,
|
|
232
232
|
` : ""}validate(val) {
|
|
233
233
|
if (!val || val.trim() === "") {
|
|
@@ -278,7 +278,7 @@ function CommandEntry(props) {
|
|
|
278
278
|
},
|
|
279
279
|
get fallback() {
|
|
280
280
|
return _alloy_js_core.code`const value = await select({
|
|
281
|
-
message: \`Please select a value for the \${
|
|
281
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,${arg.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatDescription)(arg.description)}\`,
|
|
282
282
|
` : ""}
|
|
283
283
|
options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`` : ""} }`).join(", ")} ]
|
|
284
284
|
});
|
|
@@ -299,7 +299,7 @@ function CommandEntry(props) {
|
|
|
299
299
|
get children() {
|
|
300
300
|
return _alloy_js_core.code`
|
|
301
301
|
const value = await text({
|
|
302
|
-
message: \`Please provide a value for the \${
|
|
302
|
+
message: \`Please provide a value for the \${italic("${arg.name}")} argument\`,
|
|
303
303
|
${arg.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
304
304
|
` : ""}validate(val) {
|
|
305
305
|
if (!val || val.trim() === "") {
|
|
@@ -324,7 +324,7 @@ function CommandEntry(props) {
|
|
|
324
324
|
get children() {
|
|
325
325
|
return _alloy_js_core.code`
|
|
326
326
|
const value = await numeric({
|
|
327
|
-
message: \`Please provide a numeric value for the \${
|
|
327
|
+
message: \`Please provide a numeric value for the \${italic("${arg.name}")} argument\`,
|
|
328
328
|
${arg.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
329
329
|
` : ""}
|
|
330
330
|
});
|
|
@@ -343,7 +343,7 @@ function CommandEntry(props) {
|
|
|
343
343
|
get children() {
|
|
344
344
|
return _alloy_js_core.code`
|
|
345
345
|
const value = await toggle({
|
|
346
|
-
message: \`Please select a value for the \${
|
|
346
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,
|
|
347
347
|
${arg.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
348
348
|
` : ""}
|
|
349
349
|
});
|
|
@@ -372,7 +372,7 @@ function CommandEntry(props) {
|
|
|
372
372
|
get children() {
|
|
373
373
|
return _alloy_js_core.code`
|
|
374
374
|
const value = await text({
|
|
375
|
-
message: \`Please provide one or more${arg.kind === _shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${
|
|
375
|
+
message: \`Please provide one or more${arg.kind === _shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
376
376
|
${arg.description ? `description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(arg.description)}\`,
|
|
377
377
|
` : ""}validate(val) {
|
|
378
378
|
if (!val || val.trim() === "") {
|
|
@@ -54,7 +54,7 @@ function CommandEntry(props) {
|
|
|
54
54
|
"warn",
|
|
55
55
|
"error",
|
|
56
56
|
"table",
|
|
57
|
-
"
|
|
57
|
+
"italic",
|
|
58
58
|
"cursor",
|
|
59
59
|
"stripAnsi",
|
|
60
60
|
"writeLine",
|
|
@@ -131,7 +131,7 @@ function CommandEntry(props) {
|
|
|
131
131
|
},
|
|
132
132
|
get fallback() {
|
|
133
133
|
return code`const value = await select({
|
|
134
|
-
message: \`Please select a value for the \${
|
|
134
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`, ${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
135
135
|
` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${formatShortDescription(option.description)}\`` : ""} }`).join(", ")} ]
|
|
136
136
|
});
|
|
137
137
|
if (isCancel(value)) {
|
|
@@ -151,7 +151,7 @@ function CommandEntry(props) {
|
|
|
151
151
|
get children() {
|
|
152
152
|
return code`
|
|
153
153
|
const value = await text({
|
|
154
|
-
message: \`Please provide a value for the \${
|
|
154
|
+
message: \`Please provide a value for the \${italic("${option.name}")} option\`,
|
|
155
155
|
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
156
156
|
` : ""}validate(val) {
|
|
157
157
|
if (!val || val.trim() === "") {
|
|
@@ -176,7 +176,7 @@ function CommandEntry(props) {
|
|
|
176
176
|
get children() {
|
|
177
177
|
return code`
|
|
178
178
|
const value = await numeric({
|
|
179
|
-
message: \`Please provide a numeric value for the \${
|
|
179
|
+
message: \`Please provide a numeric value for the \${italic("${option.name}")} option\`,
|
|
180
180
|
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
181
181
|
` : ""}
|
|
182
182
|
});
|
|
@@ -195,7 +195,7 @@ function CommandEntry(props) {
|
|
|
195
195
|
get children() {
|
|
196
196
|
return code`
|
|
197
197
|
const value = await toggle({
|
|
198
|
-
message: \`Please select a value for the \${
|
|
198
|
+
message: \`Please select a value for the \${italic("${option.name}")} option\`,
|
|
199
199
|
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
200
200
|
` : ""}
|
|
201
201
|
});
|
|
@@ -224,7 +224,7 @@ function CommandEntry(props) {
|
|
|
224
224
|
get children() {
|
|
225
225
|
return code`
|
|
226
226
|
const value = await text({
|
|
227
|
-
message: \`Please provide one or more${option.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${
|
|
227
|
+
message: \`Please provide one or more${option.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
228
228
|
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
229
229
|
` : ""}validate(val) {
|
|
230
230
|
if (!val || val.trim() === "") {
|
|
@@ -275,7 +275,7 @@ function CommandEntry(props) {
|
|
|
275
275
|
},
|
|
276
276
|
get fallback() {
|
|
277
277
|
return code`const value = await select({
|
|
278
|
-
message: \`Please select a value for the \${
|
|
278
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,${arg.description ? `description: \`${formatDescription(arg.description)}\`,
|
|
279
279
|
` : ""}
|
|
280
280
|
options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`` : ""} }`).join(", ")} ]
|
|
281
281
|
});
|
|
@@ -296,7 +296,7 @@ function CommandEntry(props) {
|
|
|
296
296
|
get children() {
|
|
297
297
|
return code`
|
|
298
298
|
const value = await text({
|
|
299
|
-
message: \`Please provide a value for the \${
|
|
299
|
+
message: \`Please provide a value for the \${italic("${arg.name}")} argument\`,
|
|
300
300
|
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
301
301
|
` : ""}validate(val) {
|
|
302
302
|
if (!val || val.trim() === "") {
|
|
@@ -321,7 +321,7 @@ function CommandEntry(props) {
|
|
|
321
321
|
get children() {
|
|
322
322
|
return code`
|
|
323
323
|
const value = await numeric({
|
|
324
|
-
message: \`Please provide a numeric value for the \${
|
|
324
|
+
message: \`Please provide a numeric value for the \${italic("${arg.name}")} argument\`,
|
|
325
325
|
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
326
326
|
` : ""}
|
|
327
327
|
});
|
|
@@ -340,7 +340,7 @@ function CommandEntry(props) {
|
|
|
340
340
|
get children() {
|
|
341
341
|
return code`
|
|
342
342
|
const value = await toggle({
|
|
343
|
-
message: \`Please select a value for the \${
|
|
343
|
+
message: \`Please select a value for the \${italic("${arg.name}")} argument\`,
|
|
344
344
|
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
345
345
|
` : ""}
|
|
346
346
|
});
|
|
@@ -369,7 +369,7 @@ function CommandEntry(props) {
|
|
|
369
369
|
get children() {
|
|
370
370
|
return code`
|
|
371
371
|
const value = await text({
|
|
372
|
-
message: \`Please provide one or more${arg.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${
|
|
372
|
+
message: \`Please provide one or more${arg.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
373
373
|
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
374
374
|
` : ""}validate(val) {
|
|
375
375
|
if (!val || val.trim() === "") {
|
|
@@ -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 \"colors\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"sleep\",\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 ],\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(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":";;;;;;;;;;;;;;;;;;;;;;;CA8CA,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,MAAK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AC;WACJ,CAAC;UAAE,IAAI;UAAM,gBAAA,SAAA,EAAA,CAAA;UAAA,gBAAA,wBAAA,EACH,SACV,CAAC;UAAE,gBAAQ,aAAA;WACV,WAAU,IAAA;WACV,UAAU,IAAE;;WAEb,CAAC;UAAC;;QAEN,CAAC;;MAEL,CAAC,CAAC;;IAEN,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAkB,KAAK;EAC1B,IAAI,OAAO;AACT,UAAO,OAAO,OAAO,QAAG,SAAA;;EAE1B,WAAU,UAAS,gBAAe,MAAA;GAChC,IAAI,OAAO;AACT,WAAO,MAAM;;GAEf,IAAI,WAAO;AACT,WAAO,gBAAI,cAAA,EACT,SAAK,OACN,CAAC;;GAEJ,IAAI,WAAS;AACX,WAAO,gBAAkB,qBAAa,EACpC,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,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 \"createSpinner\"\n ],\n utils: [\n \"sleep\",\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 ],\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(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 \\${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\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 \\${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":";;;;;;;;;;;;;;;;;;;;;;;CA8CA,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,MAAK,oBAAoB,eAAc,iBAAa,aAAA,UAAA,QAAA,WAAA,aAAA,SAAA,MAAA,CAAA,EAAA,QAAA,MAAA,OAAA,QAAA,QAAA,MAAA,KAAA,CAAA,CAAA;CACpD,MAAA,iBAAA,gBAAA;EACF,GAAO,QAAQ;EACb,QAAQ,QAAS;;AAEjB,QAAM,CAAA,gBAAU,WAAc,WAAmB,MAAA;EACjD,IAAM,OAAA;AACJ,UAAS,SAAA;;EAET,IAAI,iBAAiB;AACnB,UAAO,eAAK;;EAEd,IAAA,UAAA;AACD,UAAA,KAAA,WAAA,EAAA,EAAA,GACK,kBAAmB,MAAC,WAAa,IAAA,GAAA,kBAAA,QAAA,KAAA,kBAAA,UAAA,SAAA,WAAA,QAAA,KAAA,IACrC,CAAA;;EAEA,IAAI,iBAAiB;AACnB,UAAE,KAAQ,kBAAoB,EAAC,EAAA;IAC/B,KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACF,SAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACD,OAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;K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,IAAA,SAAA,sBAAA,WAAA,IAAA;;cAElD,IAAA,WAAA;AACA,sBAAA,gBAAA,cAAA;gBACC,IAAA,YAAgB;AACd,wBAAW,IAAC,GAAA,UAAY,IAAA,KAAA,CAAA;;gBAEtB,IAAI,WAAW;AACjB,wBAAW,IAAG;;qEAEW,IAAA,SAAA,sBAAA,SAAA,aAAA,GAAA,6BAAA,IAAA,KAAA;gCACvB,IAAA,cAAkB,kBAAoB,uBAAA,IAAA,YAAA,CAAA;kCACpC,GAAA;;;;;;;kCAOA,IAAM,SAAC,sBAAA,SAAA;;;0CAGC,GAAA;;;;;;;;;8BASV,UAAE,IAAA,KAAA,CAAA,gEAAA,IAAA,SAAA,sBAAA,SAAA,iBAAA,GAAA;;;gBAGH,CAAC;;cAEL,CAAC,CAAC;;YAEN,CAAC,CAAC;WACJ,CAAC;UAAE,IAAI;UAAM,gBAAA,SAAA,EAAA,CAAA;UAAA,gBAAA,wBAAA,EACH,SACV,CAAC;UAAE,gBAAQ,aAAA;WACV,WAAU,IAAA;WACV,UAAU,IAAE;;WAEb,CAAC;UAAC;;QAEN,CAAC;;MAEL,CAAC,CAAC;;IAEN,CAAC,CAAC;;EAEN,CAAC,CAAC,EAAE,gBAAkB,KAAK;EAC1B,IAAI,OAAO;AACT,UAAO,OAAO,OAAO,QAAG,SAAA;;EAE1B,WAAU,UAAS,gBAAe,MAAA;GAChC,IAAI,OAAO;AACT,WAAO,MAAM;;GAEf,IAAI,WAAO;AACT,WAAO,gBAAI,cAAA,EACT,SAAK,OACN,CAAC;;GAEJ,IAAI,WAAS;AACX,WAAO,gBAAkB,qBAAa,EACpC,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -60,7 +60,7 @@ function ExecuteUpgradeFunctionDeclaration() {
|
|
|
60
60
|
},
|
|
61
61
|
get fallback() {
|
|
62
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: \${
|
|
63
|
+
info(\`A new version of ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} is available: \${red(\`v\${result.currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${result.latestVersion}\`)}\${result.package.date ? textColors.body.tertiary(\` (updated on \${result.package.date})\`) : ""}\`);
|
|
64
64
|
|
|
65
65
|
try {
|
|
66
66
|
await upgrade();
|
|
@@ -79,7 +79,7 @@ function ExecuteUpgradeFunctionDeclaration() {
|
|
|
79
79
|
get children() {
|
|
80
80
|
return [
|
|
81
81
|
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`spinner.stop();
|
|
82
|
-
warn(\`A new version of ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} is available: \${
|
|
82
|
+
warn(\`A new version of ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} is available: \${red(\`v\${result.currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${result.latestVersion}\`)}\${result.package.date ? textColors.body.tertiary(\` (updated on \${result.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.` : ""}\`); `),
|
|
83
83
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
84
84
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
85
85
|
get when() {
|
|
@@ -143,7 +143,6 @@ function UpgradeBuiltin(props) {
|
|
|
143
143
|
get builtinImports() {
|
|
144
144
|
return (0, defu.defu)(builtinImports ?? {}, {
|
|
145
145
|
console: [
|
|
146
|
-
"colors",
|
|
147
146
|
"createSpinner",
|
|
148
147
|
"debug",
|
|
149
148
|
"info"
|
|
@@ -58,7 +58,7 @@ function ExecuteUpgradeFunctionDeclaration() {
|
|
|
58
58
|
},
|
|
59
59
|
get fallback() {
|
|
60
60
|
return [memo(() => code`spinner.stop();
|
|
61
|
-
info(\`A new version of ${getAppTitle(context, true)} is available: \${
|
|
61
|
+
info(\`A new version of ${getAppTitle(context, true)} is available: \${red(\`v\${result.currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${result.latestVersion}\`)}\${result.package.date ? textColors.body.tertiary(\` (updated on \${result.package.date})\`) : ""}\`);
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
64
|
await upgrade();
|
|
@@ -77,7 +77,7 @@ function ExecuteUpgradeFunctionDeclaration() {
|
|
|
77
77
|
get children() {
|
|
78
78
|
return [
|
|
79
79
|
memo(() => code`spinner.stop();
|
|
80
|
-
warn(\`A new version of ${getAppTitle(context, true)} is available: \${
|
|
80
|
+
warn(\`A new version of ${getAppTitle(context, true)} is available: \${red(\`v\${result.currentVersion}\`)} \${textColors.body.tertiary("➜")} \${green(\`v\${result.latestVersion}\`)}\${result.package.date ? textColors.body.tertiary(\` (updated on \${result.package.date})\`) : ""}${context.config.upgradeType !== false && context.config.upgradeType === "manual" ? ` \\nPlease run \`${getAppBin(context)} upgrade\` to upgrade to the latest version.` : ""}\`); `),
|
|
81
81
|
createComponent(Spacing, {}),
|
|
82
82
|
createComponent(Show, {
|
|
83
83
|
get when() {
|
|
@@ -141,7 +141,6 @@ function UpgradeBuiltin(props) {
|
|
|
141
141
|
get builtinImports() {
|
|
142
142
|
return defu$1(builtinImports ?? {}, {
|
|
143
143
|
console: [
|
|
144
|
-
"colors",
|
|
145
144
|
"createSpinner",
|
|
146
145
|
"debug",
|
|
147
146
|
"info"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-builtin.mjs","names":[],"sources":["../../src/components/upgrade-builtin.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, Show, splitProps } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport type { UpgradeBuiltinProps } from \"@shell-shock/plugin-upgrade/components/upgrade-builtin\";\nimport { UpgradeBuiltin as BaseUpgradeBuiltin } from \"@shell-shock/plugin-upgrade/components/upgrade-builtin\";\nimport { defu } from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `executeUpgrade` function in the `shell-shock:upgrade` builtin module.\n */\nexport function ExecuteUpgradeFunctionDeclaration() {\n const context = usePowerlines<CLIPresetContext>();\n\n return (\n <Show when={context.config.upgradeType !== false}>\n <FunctionDeclaration\n export\n async\n name=\"executeUpgrade\"\n doc={`Run upgrade processing for the ${getAppTitle(\n context,\n true\n )} application.`}>\n <IfStatement condition={code`await isCheckForUpdatesRequired()`}>\n <VarDeclaration\n const\n name=\"spinner\"\n initializer={code`createSpinner({\n message: \"Checking for updates...\"\n }).start(); `}\n />\n <VarDeclaration\n const\n name=\"result\"\n initializer={code`await checkForUpdates({ force: true }); `}\n />\n <IfStatement\n condition={code`(result as CheckForUpdatesErrorResult)?.isError`}>\n {code`spinner.error(\\`An error occurred while checking for ${getAppTitle(\n context,\n true\n )} application updates. Please try again later - if the problem persists, please contact support.\\`);\n debug(result.error); `}\n </IfStatement>\n <ElseIfClause\n condition={code`!(result as CheckForUpdatesSuccessResult)?.isUpToDate`}>\n <Show\n when={\n context.config.upgradeType !== false &&\n (context.config.upgradeType === \"confirm\" ||\n context.config.upgradeType === \"manual\")\n }\n fallback={\n <>\n {code`spinner.stop();\n info(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}\\`);\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit the application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n debug(err);\n } `}\n <Spacing />\n </>\n }>\n {code`spinner.stop();\n warn(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}${\n context.config.upgradeType !== false &&\n context.config.upgradeType === \"manual\"\n ? ` \\\\nPlease run \\`${getAppBin(\n context\n )} upgrade\\` to upgrade to the latest version.`\n : \"\"\n }\\`); `}\n <Spacing />\n <Show\n when={\n context.config.upgradeType !== false &&\n context.config.upgradeType === \"confirm\"\n }>\n {code`const willUpgradeNow = await confirm({\n message: \\`Would you like to update to v\\${result.latestVersion} now?\\`,\n initialValue: true\n });\n if (isCancel(willUpgradeNow)) {\n return;\n }\n\n if (willUpgradeNow) {\n spinner.text = \\`Updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}...\\`;\n spinner.start();\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit the application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n return { error: err };\n }\n } else {\n help(\"Updates can be performed at any time by running the \\`${getAppBin(\n context\n )} 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.\");\n } `}\n </Show>\n </Show>\n </ElseIfClause>\n <ElseClause>{code`spinner.success(\"Currently running the latest version of ${getAppTitle(\n context,\n true\n )}.\");\n writeLine(\"\");\n `}</ElseClause>\n </IfStatement>\n </FunctionDeclaration>\n </Show>\n );\n}\n\n/**\n * A built-in upgrade module for Shell Shock.\n */\nexport function UpgradeBuiltin(props: UpgradeBuiltinProps) {\n const [{ children, builtinImports }, rest] = splitProps(props, [\n \"children\",\n \"builtinImports\"\n ]);\n\n return (\n <BaseUpgradeBuiltin\n {...rest}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\"colors\", \"createSpinner\", \"debug\", \"info\"],\n prompts: [\"waitForKeyPress\"]\n })}>\n <ExecuteUpgradeFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BaseUpgradeBuiltin>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAAc,oCAAkC;;AAE9C,QAAA,gBAAA,MAAA;EACE,IAAC,OAAU;AACb,UAAA,QAAA,OAAA,gBAAA;;EAEA,IAAM,WAAU;;IAEV,UAAC;IACJ,OAAU;IACR,MAAA;IACC,IAAA,MAAA;AACA,YAAA,kCAAA,YAAA,SAAA,KAAA,CAAA;;IAEA,IAAI,WAAM;AACR,YAAO,gBAAA,aAAA;MACP,WAAA,IAAA;MACC,IAAA,WAAc;AAChB,cAAY;QAAA,gBAAgB,gBAAM;SAChC,SAAA;SACC,MAAA;SACI,aAAS,IAAA;;;SAGV,CAAC;QA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;KAAA;KAAA;IACZ,SAAS,CAAC,kBAAa;IACxB,CAAC;;EAEJ,IAAI,WAAU;AACZ,UAAM;IAAA,gBAAY,mCAAA,EAAA,CAAA;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KAChB,IAAG,OAAA;AACD,aAAE,QAAO,SAAA;;KAEJ;KACR,CAAC;IAAC;;EAEN,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"upgrade-builtin.mjs","names":[],"sources":["../../src/components/upgrade-builtin.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, Show, splitProps } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport type { UpgradeBuiltinProps } from \"@shell-shock/plugin-upgrade/components/upgrade-builtin\";\nimport { UpgradeBuiltin as BaseUpgradeBuiltin } from \"@shell-shock/plugin-upgrade/components/upgrade-builtin\";\nimport { defu } from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `executeUpgrade` function in the `shell-shock:upgrade` builtin module.\n */\nexport function ExecuteUpgradeFunctionDeclaration() {\n const context = usePowerlines<CLIPresetContext>();\n\n return (\n <Show when={context.config.upgradeType !== false}>\n <FunctionDeclaration\n export\n async\n name=\"executeUpgrade\"\n doc={`Run upgrade processing for the ${getAppTitle(\n context,\n true\n )} application.`}>\n <IfStatement condition={code`await isCheckForUpdatesRequired()`}>\n <VarDeclaration\n const\n name=\"spinner\"\n initializer={code`createSpinner({\n message: \"Checking for updates...\"\n }).start(); `}\n />\n <VarDeclaration\n const\n name=\"result\"\n initializer={code`await checkForUpdates({ force: true }); `}\n />\n <IfStatement\n condition={code`(result as CheckForUpdatesErrorResult)?.isError`}>\n {code`spinner.error(\\`An error occurred while checking for ${getAppTitle(\n context,\n true\n )} application updates. Please try again later - if the problem persists, please contact support.\\`);\n debug(result.error); `}\n </IfStatement>\n <ElseIfClause\n condition={code`!(result as CheckForUpdatesSuccessResult)?.isUpToDate`}>\n <Show\n when={\n context.config.upgradeType !== false &&\n (context.config.upgradeType === \"confirm\" ||\n context.config.upgradeType === \"manual\")\n }\n fallback={\n <>\n {code`spinner.stop();\n info(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${red(\\`v\\${result.currentVersion}\\`)} \\${textColors.body.tertiary(\"➜\")} \\${green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? textColors.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}\\`);\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit the application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n debug(err);\n } `}\n <Spacing />\n </>\n }>\n {code`spinner.stop();\n warn(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${red(\\`v\\${result.currentVersion}\\`)} \\${textColors.body.tertiary(\"➜\")} \\${green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? textColors.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}${\n context.config.upgradeType !== false &&\n context.config.upgradeType === \"manual\"\n ? ` \\\\nPlease run \\`${getAppBin(\n context\n )} upgrade\\` to upgrade to the latest version.`\n : \"\"\n }\\`); `}\n <Spacing />\n <Show\n when={\n context.config.upgradeType !== false &&\n context.config.upgradeType === \"confirm\"\n }>\n {code`const willUpgradeNow = await confirm({\n message: \\`Would you like to update to v\\${result.latestVersion} now?\\`,\n initialValue: true\n });\n if (isCancel(willUpgradeNow)) {\n return;\n }\n\n if (willUpgradeNow) {\n spinner.text = \\`Updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}...\\`;\n spinner.start();\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit the application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n return { error: err };\n }\n } else {\n help(\"Updates can be performed at any time by running the \\`${getAppBin(\n context\n )} 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.\");\n } `}\n </Show>\n </Show>\n </ElseIfClause>\n <ElseClause>{code`spinner.success(\"Currently running the latest version of ${getAppTitle(\n context,\n true\n )}.\");\n writeLine(\"\");\n `}</ElseClause>\n </IfStatement>\n </FunctionDeclaration>\n </Show>\n );\n}\n\n/**\n * A built-in upgrade module for Shell Shock.\n */\nexport function UpgradeBuiltin(props: UpgradeBuiltinProps) {\n const [{ children, builtinImports }, rest] = splitProps(props, [\n \"children\",\n \"builtinImports\"\n ]);\n\n return (\n <BaseUpgradeBuiltin\n {...rest}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\"createSpinner\", \"debug\", \"info\"],\n prompts: [\"waitForKeyPress\"]\n })}>\n <ExecuteUpgradeFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BaseUpgradeBuiltin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A,CAAA;;;cAGzC,CAAA;aAAA;;WAEA,CAAA;;;sCAGF,IAAI,WAAA;AACF,gBAAO,IAAC,4DAA+B,YAAA,SAAA,KAAA,CAAA;;;WAI1C,CAAC;QAAC;;MAEN,CAAC;;IAEL,CAAC;;EAEL,CAAC;;;;;AAMJ,SAAgB,eAAY,OAA+B;CACzD,MAAM,CAAC,EACL,UACA,kBACC,QAAQ,WAAO,OAAS,CAAA,YAAY,iBAAA,CAAA;AACvC,QAAO,gBAAS,kBAAA,WAAA,MAAA;EACd,IAAI,iBAAe;AACjB,UAAO,OAAK,kBAAkB,EAAE,EAAC;IAC/B,SAAS;KAAC;KAAE;KAAA;KAAA;IACZ,SAAS,CAAC,kBAAa;IACxB,CAAC;;EAEJ,IAAI,WAAU;AACZ,UAAM;IAAA,gBAAY,mCAAA,EAAA,CAAA;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KAChB,IAAG,OAAA;AACD,aAAE,QAAO,SAAA;;KAEJ;KACR,CAAC;IAAC;;EAEN,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, For, Show } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport { VirtualCommandHandlerDeclaration } from \"@shell-shock/preset-script/components/virtual-command-entry\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\n \"warn\",\n \"error\",\n \"info\",\n \"help\",\n \"table\",\n \"
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.mjs","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, For, Show } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport { VirtualCommandHandlerDeclaration } from \"@shell-shock/preset-script/components/virtual-command-entry\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\n \"warn\",\n \"error\",\n \"info\",\n \"help\",\n \"table\",\n \"writeLine\",\n \"splitText\",\n \"stripAnsi\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"isInteractive\",\n \"isHelp\",\n \"findSuggestions\",\n \"sleep\"\n ],\n prompts: [\"text\", \"numeric\", \"toggle\", \"select\", \"isCancel\"],\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 })}>\n <Spacing />\n <VirtualCommandHandlerDeclaration command={command}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\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":";;;;;;;;;;;;;;;;;AAyCA,SAAE,oBAAA,OAAA;CACA,MAAK,EACL,SACF,SACE,4BAEA;CACA,MAAM,UAAU,eAAc;CAC9B,MAAE,WAAS,eAAA,UAAA,QAAA,WAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;AACX,QAAI,CAAA,gBAAiB,gBAAA,WAAA,MAAA;EACnB,IAAE,OAAQ;AACR,UAAG,SAAO;;EAEZ,IAAG,UAAQ;AACX,UAAA,KAAA,WAAA,EAAA,EAAA,OAAA,QAAA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AC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shell-shock/preset-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Shell Shock plugin to generate source code given a list design tokens.",
|
|
6
6
|
"keywords": [
|
|
@@ -184,15 +184,15 @@
|
|
|
184
184
|
"@powerlines/deepkit": "^0.6.165",
|
|
185
185
|
"@powerlines/plugin-alloy": "^0.26.2",
|
|
186
186
|
"@powerlines/plugin-plugin": "^0.12.337",
|
|
187
|
-
"@shell-shock/core": "^0.15.
|
|
188
|
-
"@shell-shock/plugin-banner": "^0.1.
|
|
189
|
-
"@shell-shock/plugin-completions": "^0.4.
|
|
190
|
-
"@shell-shock/plugin-console": "^0.
|
|
191
|
-
"@shell-shock/plugin-help": "^0.2.
|
|
192
|
-
"@shell-shock/plugin-prompts": "^0.3.
|
|
193
|
-
"@shell-shock/plugin-theme": "^0.4.
|
|
194
|
-
"@shell-shock/plugin-upgrade": "^0.1.
|
|
195
|
-
"@shell-shock/preset-script": "^0.6.
|
|
187
|
+
"@shell-shock/core": "^0.15.2",
|
|
188
|
+
"@shell-shock/plugin-banner": "^0.1.23",
|
|
189
|
+
"@shell-shock/plugin-completions": "^0.4.4",
|
|
190
|
+
"@shell-shock/plugin-console": "^0.2.0",
|
|
191
|
+
"@shell-shock/plugin-help": "^0.2.14",
|
|
192
|
+
"@shell-shock/plugin-prompts": "^0.3.37",
|
|
193
|
+
"@shell-shock/plugin-theme": "^0.4.9",
|
|
194
|
+
"@shell-shock/plugin-upgrade": "^0.1.41",
|
|
195
|
+
"@shell-shock/preset-script": "^0.6.51",
|
|
196
196
|
"@stryke/path": "^0.27.3",
|
|
197
197
|
"@stryke/string-format": "^0.17.7",
|
|
198
198
|
"@stryke/type-checks": "^0.6.0",
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
},
|
|
203
203
|
"devDependencies": {
|
|
204
204
|
"@babel/core": "^7.29.0",
|
|
205
|
-
"@types/node": "^25.5.
|
|
205
|
+
"@types/node": "^25.5.1",
|
|
206
206
|
"@types/react": "^19.2.14"
|
|
207
207
|
},
|
|
208
208
|
"publishConfig": {
|
|
@@ -228,5 +228,5 @@
|
|
|
228
228
|
"./package.json": "./package.json"
|
|
229
229
|
}
|
|
230
230
|
},
|
|
231
|
-
"gitHead": "
|
|
231
|
+
"gitHead": "ba74aaa8aaa2c911ce54df1fae944951af53a3ad"
|
|
232
232
|
}
|