@shell-shock/preset-cli 0.7.13 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/components/banner-function-declaration.cjs +48 -164
- package/dist/components/banner-function-declaration.d.cts +2 -2
- package/dist/components/banner-function-declaration.d.cts.map +1 -1
- package/dist/components/banner-function-declaration.d.mts +2 -2
- package/dist/components/banner-function-declaration.d.mts.map +1 -1
- package/dist/components/banner-function-declaration.mjs +29 -146
- package/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/components/command-entry.cjs +185 -144
- package/dist/components/command-entry.d.cts +2 -2
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +3 -3
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +124 -84
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +20 -18
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts.map +1 -1
- package/dist/components/command-router.mjs +2 -1
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/index.cjs +4 -0
- package/dist/components/index.d.cts +2 -1
- package/dist/components/index.d.mts +2 -1
- package/dist/components/index.mjs +2 -1
- package/dist/components/upgrade-builtin.cjs +171 -0
- package/dist/components/upgrade-builtin.d.cts +15 -0
- package/dist/components/upgrade-builtin.d.cts.map +1 -0
- package/dist/components/upgrade-builtin.d.mts +15 -0
- package/dist/components/upgrade-builtin.d.mts.map +1 -0
- package/dist/components/upgrade-builtin.mjs +169 -0
- package/dist/components/upgrade-builtin.mjs.map +1 -0
- package/dist/components/virtual-command-entry.cjs +26 -24
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +1 -1
- package/dist/components/virtual-command-entry.d.mts.map +1 -1
- package/dist/components/virtual-command-entry.mjs +7 -6
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/get-default-options.cjs +6 -6
- package/dist/helpers/get-default-options.mjs.map +1 -1
- package/dist/index.cjs +49 -62
- package/dist/index.d.cts +0 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +23 -36
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-help/dist/components/display.cjs +259 -0
- package/dist/plugin-help/dist/components/display.mjs +254 -0
- package/dist/plugin-help/dist/components/display.mjs.map +1 -0
- package/dist/plugin-help/dist/components/help-builtin.cjs +85 -0
- package/dist/plugin-help/dist/components/help-builtin.mjs +84 -0
- package/dist/plugin-help/dist/components/help-builtin.mjs.map +1 -0
- package/dist/plugin-help/dist/components/help-command.cjs +96 -0
- package/dist/plugin-help/dist/components/help-command.mjs +96 -0
- package/dist/plugin-help/dist/components/help-command.mjs.map +1 -0
- package/dist/plugin-help/dist/components/index.cjs +3 -0
- package/dist/plugin-help/dist/components/index.mjs +5 -0
- package/dist/plugin-help/dist/index.cjs +103 -0
- package/dist/plugin-help/dist/index.d.cts +2 -0
- package/dist/plugin-help/dist/index.d.mts +2 -0
- package/dist/plugin-help/dist/index.mjs +100 -0
- package/dist/plugin-help/dist/index.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.cjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.cjs +38 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs +38 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.cjs +33 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs +34 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.cjs +40 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs +41 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.cjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.cjs +20 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs +21 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.cjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.cjs +20 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs +21 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.cjs +19 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs +20 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.cjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.cjs +8 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs +8 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs.map +1 -0
- package/dist/plugin-help/dist/types/plugin.d.cts +62 -0
- package/dist/plugin-help/dist/types/plugin.d.cts.map +1 -0
- package/dist/plugin-help/dist/types/plugin.d.mts +62 -0
- package/dist/plugin-help/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/plugin.d.cts +20 -34
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +20 -34
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +30 -16
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
|
|
2
2
|
import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
|
|
3
|
-
import { createComponent,
|
|
3
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
4
4
|
import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
|
|
5
5
|
import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
|
|
6
|
+
import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
6
7
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
8
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
-
import { isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
9
|
-
import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
10
9
|
import { CommandParameterKinds } from "@shell-shock/core";
|
|
11
|
-
import
|
|
12
|
-
import { findFilePath, relativePath } from "@stryke/path/find";
|
|
10
|
+
import defu from "defu";
|
|
13
11
|
import { joinPaths } from "@stryke/path/join";
|
|
12
|
+
import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
13
|
+
import { CommandValidationLogic } from "@shell-shock/core/components/command-validation-logic";
|
|
14
|
+
import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
|
|
15
|
+
import { findFilePath, relativePath } from "@stryke/path/find";
|
|
14
16
|
import { replaceExtension } from "@stryke/path/replace";
|
|
15
17
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
16
18
|
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
17
|
-
import defu from "defu";
|
|
18
19
|
|
|
19
20
|
//#region src/components/command-entry.tsx
|
|
20
21
|
/**
|
|
@@ -24,7 +25,7 @@ function CommandEntry(props) {
|
|
|
24
25
|
const { command, imports, builtinImports, ...rest } = props;
|
|
25
26
|
const context = usePowerlines();
|
|
26
27
|
const filePath = computed(() => joinPaths(command.segments.filter((segment) => !isDynamicPathSegment(segment)).join("/"), "index.ts"));
|
|
27
|
-
const commandSourcePath = computed(() =>
|
|
28
|
+
const commandSourcePath = computed(() => replaceExtension(relativePath(joinPaths(context.entryPath, findFilePath(filePath.value)), command.entry.input?.file || command.entry.file)));
|
|
28
29
|
const typeDefinition = computed(() => ({
|
|
29
30
|
...command.entry,
|
|
30
31
|
output: command.id
|
|
@@ -37,10 +38,7 @@ function CommandEntry(props) {
|
|
|
37
38
|
return typeDefinition.value;
|
|
38
39
|
},
|
|
39
40
|
get imports() {
|
|
40
|
-
return defu(imports ?? {}, {
|
|
41
|
-
[commandSourcePath.value]: `handle${pascalCase(command.name)}`,
|
|
42
|
-
prompts: "prompts"
|
|
43
|
-
});
|
|
41
|
+
return defu(imports ?? {}, { [commandSourcePath.value.startsWith(".") ? commandSourcePath.value : `./${commandSourcePath.value}`]: `handle${pascalCase(command.name)}` });
|
|
44
42
|
},
|
|
45
43
|
get builtinImports() {
|
|
46
44
|
return defu(builtinImports ?? {}, {
|
|
@@ -84,21 +82,18 @@ function CommandEntry(props) {
|
|
|
84
82
|
"isCancel",
|
|
85
83
|
"sleep"
|
|
86
84
|
],
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"isCheckForUpdatesRequired",
|
|
90
|
-
"upgrade"
|
|
91
|
-
]
|
|
85
|
+
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
|
|
86
|
+
upgrade: ["executeUpgrade"]
|
|
92
87
|
});
|
|
93
88
|
},
|
|
94
89
|
get children() {
|
|
95
90
|
return [
|
|
96
91
|
createComponent(BannerFunctionDeclaration, { command }),
|
|
97
|
-
|
|
98
|
-
createIntrinsic("hbr", {}),
|
|
92
|
+
createComponent(Spacing, {}),
|
|
99
93
|
createComponent(CommandHandlerDeclaration, {
|
|
100
94
|
command,
|
|
101
|
-
banner: code`await banner();
|
|
95
|
+
banner: code`await banner();
|
|
96
|
+
await executeUpgrade(); `,
|
|
102
97
|
get children() {
|
|
103
98
|
return [createComponent(IfStatement, {
|
|
104
99
|
condition: code`!isInteractive`,
|
|
@@ -133,17 +128,34 @@ function CommandEntry(props) {
|
|
|
133
128
|
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
|
|
134
129
|
},
|
|
135
130
|
get children() {
|
|
136
|
-
return createComponent(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
131
|
+
return createComponent(Show, {
|
|
132
|
+
get when() {
|
|
133
|
+
return option.kind === CommandParameterKinds.boolean || !option.choices || option.choices.length === 0;
|
|
134
|
+
},
|
|
135
|
+
get fallback() {
|
|
136
|
+
return code`const value = await select({
|
|
137
|
+
message: \`Please select a value for the \${colors.italic("${option.name}")} option\`, ${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
138
|
+
` : ""}options: [ ${option.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${option.description ? `description: \`${formatShortDescription(option.description)}\`` : ""} }`).join(", ")} ]
|
|
139
|
+
});
|
|
140
|
+
if (isCancel(value)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
145
|
+
`;
|
|
146
|
+
},
|
|
147
|
+
get children() {
|
|
148
|
+
return createComponent(Switch, { get children() {
|
|
149
|
+
return [
|
|
150
|
+
createComponent(Match, {
|
|
151
|
+
get when() {
|
|
152
|
+
return option.kind === CommandParameterKinds.string;
|
|
153
|
+
},
|
|
154
|
+
get children() {
|
|
155
|
+
return code`
|
|
144
156
|
const value = await text({
|
|
145
157
|
message: \`Please provide a value for the \${colors.italic("${option.name}")} option\`,
|
|
146
|
-
${option.description ? `description:
|
|
158
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
147
159
|
` : ""}validate(val) {
|
|
148
160
|
if (!val || val.trim() === "") {
|
|
149
161
|
return "A value must be provided for this option";
|
|
@@ -158,17 +170,17 @@ function CommandEntry(props) {
|
|
|
158
170
|
|
|
159
171
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
160
172
|
`;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
}
|
|
174
|
+
}),
|
|
175
|
+
createComponent(Match, {
|
|
176
|
+
get when() {
|
|
177
|
+
return option.kind === CommandParameterKinds.number;
|
|
178
|
+
},
|
|
179
|
+
get children() {
|
|
180
|
+
return code`
|
|
169
181
|
const value = await numeric({
|
|
170
182
|
message: \`Please provide a numeric value for the \${colors.italic("${option.name}")} option\`,
|
|
171
|
-
${option.description ? `description:
|
|
183
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
172
184
|
` : ""}
|
|
173
185
|
});
|
|
174
186
|
if (isCancel(value)) {
|
|
@@ -177,17 +189,17 @@ function CommandEntry(props) {
|
|
|
177
189
|
|
|
178
190
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
179
191
|
`;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
}
|
|
193
|
+
}),
|
|
194
|
+
createComponent(Match, {
|
|
195
|
+
get when() {
|
|
196
|
+
return option.kind === CommandParameterKinds.boolean;
|
|
197
|
+
},
|
|
198
|
+
get children() {
|
|
199
|
+
return code`
|
|
188
200
|
const value = await toggle({
|
|
189
201
|
message: \`Please select a value for the \${colors.italic("${option.name}")} option\`,
|
|
190
|
-
${option.description ? `description:
|
|
202
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
191
203
|
` : ""}
|
|
192
204
|
});
|
|
193
205
|
if (isCancel(value)) {
|
|
@@ -196,10 +208,12 @@ function CommandEntry(props) {
|
|
|
196
208
|
|
|
197
209
|
options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} = value;
|
|
198
210
|
`;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
];
|
|
214
|
+
} });
|
|
215
|
+
}
|
|
216
|
+
});
|
|
203
217
|
}
|
|
204
218
|
}), createComponent(Show, {
|
|
205
219
|
get when() {
|
|
@@ -214,7 +228,7 @@ function CommandEntry(props) {
|
|
|
214
228
|
return code`
|
|
215
229
|
const value = await text({
|
|
216
230
|
message: \`Please provide one or more${option.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
217
|
-
${option.description ? `description:
|
|
231
|
+
${option.description ? `description: \`${formatDescription(option.description)}\`,
|
|
218
232
|
` : ""}validate(val) {
|
|
219
233
|
if (!val || val.trim() === "") {
|
|
220
234
|
return "A value must be provided for this option";
|
|
@@ -258,17 +272,35 @@ function CommandEntry(props) {
|
|
|
258
272
|
return code`!${camelCase(arg.name)}`;
|
|
259
273
|
},
|
|
260
274
|
get children() {
|
|
261
|
-
return createComponent(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
275
|
+
return createComponent(Show, {
|
|
276
|
+
get when() {
|
|
277
|
+
return arg.kind === CommandParameterKinds.boolean || !arg.choices || arg.choices.length === 0;
|
|
278
|
+
},
|
|
279
|
+
get fallback() {
|
|
280
|
+
return code`const value = await select({
|
|
281
|
+
message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,${arg.description ? `description: \`${formatDescription(arg.description)}\`,
|
|
282
|
+
` : ""}
|
|
283
|
+
options: [ ${arg.choices?.map((choice) => `{ value: ${JSON.stringify(choice)}, label: "${choice}", ${arg.description ? `description: \`${formatShortDescription(arg.description)}\`` : ""} }`).join(", ")} ]
|
|
284
|
+
});
|
|
285
|
+
if (isCancel(value)) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
${camelCase(arg.name)} = value;
|
|
290
|
+
`;
|
|
291
|
+
},
|
|
292
|
+
get children() {
|
|
293
|
+
return createComponent(Switch, { get children() {
|
|
294
|
+
return [
|
|
295
|
+
createComponent(Match, {
|
|
296
|
+
get when() {
|
|
297
|
+
return arg.kind === CommandParameterKinds.string;
|
|
298
|
+
},
|
|
299
|
+
get children() {
|
|
300
|
+
return code`
|
|
269
301
|
const value = await text({
|
|
270
302
|
message: \`Please provide a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
271
|
-
${arg.description ? `description:
|
|
303
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
272
304
|
` : ""}validate(val) {
|
|
273
305
|
if (!val || val.trim() === "") {
|
|
274
306
|
return "A value must be provided for this argument";
|
|
@@ -283,17 +315,17 @@ function CommandEntry(props) {
|
|
|
283
315
|
|
|
284
316
|
${camelCase(arg.name)} = value;
|
|
285
317
|
`;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
318
|
+
}
|
|
319
|
+
}),
|
|
320
|
+
createComponent(Match, {
|
|
321
|
+
get when() {
|
|
322
|
+
return arg.kind === CommandParameterKinds.number;
|
|
323
|
+
},
|
|
324
|
+
get children() {
|
|
325
|
+
return code`
|
|
294
326
|
const value = await numeric({
|
|
295
327
|
message: \`Please provide a numeric value for the \${colors.italic("${arg.name}")} argument\`,
|
|
296
|
-
${arg.description ? `description:
|
|
328
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
297
329
|
` : ""}
|
|
298
330
|
});
|
|
299
331
|
if (isCancel(value)) {
|
|
@@ -302,17 +334,17 @@ function CommandEntry(props) {
|
|
|
302
334
|
|
|
303
335
|
${camelCase(arg.name)} = value;
|
|
304
336
|
`;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
337
|
+
}
|
|
338
|
+
}),
|
|
339
|
+
createComponent(Match, {
|
|
340
|
+
get when() {
|
|
341
|
+
return arg.kind === CommandParameterKinds.boolean;
|
|
342
|
+
},
|
|
343
|
+
get children() {
|
|
344
|
+
return code`
|
|
313
345
|
const value = await toggle({
|
|
314
346
|
message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
315
|
-
${arg.description ? `description:
|
|
347
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
316
348
|
` : ""}
|
|
317
349
|
});
|
|
318
350
|
if (isCancel(value)) {
|
|
@@ -321,10 +353,12 @@ function CommandEntry(props) {
|
|
|
321
353
|
|
|
322
354
|
${camelCase(arg.name)} = value;
|
|
323
355
|
`;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
];
|
|
359
|
+
} });
|
|
360
|
+
}
|
|
361
|
+
});
|
|
328
362
|
}
|
|
329
363
|
}), createComponent(Show, {
|
|
330
364
|
get when() {
|
|
@@ -339,7 +373,7 @@ function CommandEntry(props) {
|
|
|
339
373
|
return code`
|
|
340
374
|
const value = await text({
|
|
341
375
|
message: \`Please provide one or more${arg.kind === CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
342
|
-
${arg.description ? `description:
|
|
376
|
+
${arg.description ? `description: \`${formatShortDescription(arg.description)}\`,
|
|
343
377
|
` : ""}validate(val) {
|
|
344
378
|
if (!val || val.trim() === "") {
|
|
345
379
|
return "A value must be provided for this argument";
|
|
@@ -369,7 +403,13 @@ function CommandEntry(props) {
|
|
|
369
403
|
})]
|
|
370
404
|
}),
|
|
371
405
|
code`writeLine(""); `,
|
|
372
|
-
createComponent(Spacing, {})
|
|
406
|
+
createComponent(Spacing, {}),
|
|
407
|
+
createComponent(CommandValidationLogic, { command }),
|
|
408
|
+
createComponent(IfStatement, {
|
|
409
|
+
condition: code`failures.length > 0`,
|
|
410
|
+
children: code`error("The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\n\\n" + failures.map(failure => " - " + failure).join("\\n"));
|
|
411
|
+
options.help = true; `
|
|
412
|
+
})
|
|
373
413
|
];
|
|
374
414
|
}
|
|
375
415
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseIfClause","IfStatement","Spacing","usePowerlines","EntryFile","CommandParameterKinds","isDynamicPathSegment","CommandHandlerDeclaration","CommandValidationLogic","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","pascalCase","defu","BannerFunctionDeclaration","VirtualCommandEntry","CommandEntry","props","command","imports","builtinImports","rest","context","filePath","segments","filter","segment","join","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$createComponent","_$mergeProps","path","name","prompts","env","console","utils","upgrade","children","_$createIntrinsic","banner","condition","when","Object","values","options","option","optional","length","args","arg","map","kind","string","number","variadic","includes","each","doubleHardline","description","boolean","child","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { 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 { CommandTree } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils\";\nimport {\n CommandHandlerDeclaration,\n CommandValidationLogic\n} from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )}`\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`,\n prompts: \"prompts\"\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n upgrade: [\"checkForUpdates\", \"isCheckForUpdatesRequired\", \"upgrade\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <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(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \"${option.description}\",\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: \"${option.description}\",\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: \"${option.description}\",\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 </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(\"${option.name}\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \"${option.description}\",\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 <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: \"${arg.description}\",\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: \"${arg.description}\",\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: \"${arg.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\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: \"${arg.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgBwB,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUrB,eAAiC;CACjD,MAAMsB,WAAW9B,eACfgB,UACES,QAAQM,SACLC,QAAOC,YAAW,CAACtB,qBAAqBsB,QAAQ,CAAC,CACjDC,KAAK,IAAI,EACZ,WAEJ,CAAC;CACD,MAAMC,oBAAoBnC,eAEtB,KAAKiB,iBACHF,aACEC,UAAUa,QAAQO,WAAWtB,aAAagB,SAASO,MAAM,CAAC,EAC1DZ,QAAQa,MAAMC,OAAOC,QAAQf,QAAQa,MAAME,KAE/C,CAAC,G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+
{"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport {\n formatDescription,\n formatShortDescription,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { CommandHandlerDeclaration } from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"cursor\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n upgrade: [\"executeUpgrade\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner();\n await executeUpgrade(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.args ?? {}).filter(arg => !arg.optional)\n .length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.args ?? {})\n .filter(arg => !arg.optional)\n .map(arg =>\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? `(!${camelCase(\n arg.name\n )} || ${camelCase(arg.name)}.length === 0)`\n : `${camelCase(arg.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Show\n when={\n option.kind === CommandParameterKinds.boolean ||\n !option.choices ||\n option.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`, ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }options: [ ${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n option.description\n ? `description: \\`${formatShortDescription(\n option.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}>\n <Switch>\n <Match\n when={\n option.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${\n option.name\n }\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={\n option.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${option.name}\")} option\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n option.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${\n option.name\n }\")} option (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n option.description\n ? `description: \\`${formatDescription(\n option.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {arg => (\n <>\n <Show when={!arg.optional}>\n <IfStatement condition={code`!${camelCase(arg.name)}`}>\n <Show\n when={\n arg.kind === CommandParameterKinds.boolean ||\n !arg.choices ||\n arg.choices.length === 0\n }\n fallback={code`const value = await select({\n message: \\`Please select a value for the \\${colors.italic(\"${\n arg.name\n }\")} argument\\`,${\n arg.description\n ? `description: \\`${formatDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n options: [ ${(\n arg as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(\n choice =>\n `{ value: ${JSON.stringify(\n choice\n )}, label: \"${choice}\", ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\``\n : \"\"\n } }`\n )\n .join(\", \")} ]\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}>\n <Switch>\n <Match\n when={\n arg.kind === CommandParameterKinds.string\n }>{code`\n const value = await text({\n message: \\`Please provide a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.number\n }>{code`\n const value = await numeric({\n message: \\`Please provide a numeric value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n <Match\n when={\n arg.kind === CommandParameterKinds.boolean\n }>{code`\n const value = await toggle({\n message: \\`Please select a value for the \\${colors.italic(\"${arg.name}\")} argument\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value;\n `}</Match>\n </Switch>\n </Show>\n </IfStatement>\n <Show\n when={\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(arg.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \\`Please provide one or more${\n arg.kind === CommandParameterKinds.number\n ? \" numeric\"\n : \"\"\n } values for the \\${colors.italic(\"${arg.name}\")} argument (values are separated by a \\\\\",\\\\\" character)\\`,\n ${\n arg.description\n ? `description: \\`${formatShortDescription(\n arg.description\n )}\\`,\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n arg.kind === CommandParameterKinds.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(arg.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n arg.kind === CommandParameterKinds.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\"The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\\\n\\\\n\" + failures.map(failure => \" - \" + failure).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CA+CA,MAAO,EACL,SACC,SACD,gBACA,GAAA,SACF;;CAEE,MAAA,WAAA,eAAA,UAAA,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,KAAA,IAAA,EAAA,WAAA,CAAA;CACA,MAAK,oBAAoB,eAAc,iBAAa,aAAA,UAAA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;;YAEf,CAAC;WAAC;;SAEN,CAAC;;OAEL,CAAC,CAAC;;KAEN,CAAC;IAAC;;EAEN,CAAC,CAAC,EAAE,gBAAe,KAAI;EACtB,IAAI,OAAO;AACT,UAAO,OAAI,OAAA,QAAA,SAAA;;EAEb,WAAU,UAAS,gBAAC,MAAA;GAClB,IAAI,OAAK;AACP,WAAO,MAAM;;GAEf,IAAI,WAAW;AACb,WAAO,gBAAQ,cAAuB,EACpC,SAAS,OACV,CAAC;;GAEJ,IAAI,WAAW;AACb,WAAO,gBAAiB,qBAAmB,EACzC,SAAS,OACV,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
let
|
|
5
|
-
let
|
|
6
|
-
let
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
7
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
|
+
let _shell_shock_preset_script_components = require("@shell-shock/preset-script/components");
|
|
7
9
|
|
|
8
10
|
//#region src/components/command-router.tsx
|
|
9
11
|
function CommandRouterSelectOptions(props) {
|
|
10
12
|
const { commands } = props;
|
|
11
|
-
return (0,
|
|
13
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
12
14
|
get each() {
|
|
13
15
|
return Object.values(commands ?? {});
|
|
14
16
|
},
|
|
15
17
|
joiner: ",",
|
|
16
18
|
hardline: true,
|
|
17
|
-
children: (command) => command.isVirtual ? (0,
|
|
19
|
+
children: (command) => command.isVirtual ? (0, _alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { get commands() {
|
|
18
20
|
return command.children ?? {};
|
|
19
|
-
} }) :
|
|
21
|
+
} }) : _alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`${(0, _shell_shock_core_plugin_utils.formatShortDescription)(command.description)}\`${command.icon ? `, icon: "${command.icon}"` : ""} }`
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
@@ -25,22 +27,22 @@ function CommandRouterSelectOptions(props) {
|
|
|
25
27
|
function CommandRouter(props) {
|
|
26
28
|
const { segments, commands } = props;
|
|
27
29
|
return [
|
|
28
|
-
(0,
|
|
30
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_preset_script_components.CommandRouter, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
|
|
29
31
|
segments,
|
|
30
32
|
commands
|
|
31
33
|
})),
|
|
32
|
-
(0,
|
|
33
|
-
(0,
|
|
34
|
-
condition:
|
|
34
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
35
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
36
|
+
condition: _alloy_js_core.code`isInteractive && !isHelp`,
|
|
35
37
|
get children() {
|
|
36
38
|
return [
|
|
37
|
-
|
|
39
|
+
_alloy_js_core.code`await banner();
|
|
38
40
|
|
|
39
41
|
let segments = await select({
|
|
40
42
|
message: "Which command would you like to execute?",
|
|
41
43
|
options: [ `,
|
|
42
|
-
(0,
|
|
43
|
-
(0,
|
|
44
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { commands }),
|
|
45
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => ` ],
|
|
44
46
|
});
|
|
45
47
|
if (isCancel(segments)) {
|
|
46
48
|
return;
|
|
@@ -63,14 +65,14 @@ function CommandRouter(props) {
|
|
|
63
65
|
|
|
64
66
|
command = segments[0];
|
|
65
67
|
args = context.get("args"); `),
|
|
66
|
-
(0,
|
|
68
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_preset_script_components.CommandRouterBody, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
|
|
67
69
|
segments,
|
|
68
70
|
commands
|
|
69
71
|
}))
|
|
70
72
|
];
|
|
71
73
|
}
|
|
72
74
|
}),
|
|
73
|
-
(0,
|
|
75
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
74
76
|
];
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"
|
|
1
|
+
{"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;UA6BiB,+BAAA;EACf,QAAA,GAAW,MAAA,SAAe,WAAA;AAAA;AAAA,iBAGZ,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,eAAA,CAAA,QAAA;;;;iBA0BxB,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,eAAA,CAAA,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"
|
|
1
|
+
{"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;UA6BiB,+BAAA;EACf,QAAA,GAAW,MAAA,SAAe,WAAA;AAAA;AAAA,iBAGZ,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,eAAA,CAAA,QAAA;;;;iBA0BxB,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,eAAA,CAAA,QAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { For, code } from "@alloy-js/core";
|
|
3
3
|
import { IfStatement } from "@alloy-js/typescript";
|
|
4
|
+
import { formatShortDescription } from "@shell-shock/core/plugin-utils";
|
|
4
5
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
6
|
import { CommandRouter as CommandRouter$1, CommandRouterBody } from "@shell-shock/preset-script/components";
|
|
6
7
|
|
|
@@ -15,7 +16,7 @@ function CommandRouterSelectOptions(props) {
|
|
|
15
16
|
hardline: true,
|
|
16
17
|
children: (command) => command.isVirtual ? createComponent(CommandRouterSelectOptions, { get commands() {
|
|
17
18
|
return command.children ?? {};
|
|
18
|
-
} }) : code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description:
|
|
19
|
+
} }) : code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`${formatShortDescription(command.description)}\`${command.icon ? `, icon: "${command.icon}"` : ""} }`
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
/**
|