@shell-shock/core 0.17.7 → 0.17.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/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/api.cjs +1 -95
- package/dist/api.d.cts +52 -4
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +52 -4
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +1 -92
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +1 -292
- package/dist/components/command-validation-logic.mjs +1 -289
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -265
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +1 -256
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +13 -429
- package/dist/components/exec-builtin.mjs +13 -425
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/helpers.cjs +1 -120
- package/dist/components/helpers.mjs +1 -112
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +1 -58
- package/dist/components/index.mjs +1 -10
- package/dist/components/options-parser-logic.cjs +5 -960
- package/dist/components/options-parser-logic.d.cts +1 -1
- package/dist/components/options-parser-logic.mjs +5 -945
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +8 -629
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts.map +1 -1
- package/dist/components/state-builtin.mjs +8 -622
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/usage.cjs +1 -117
- package/dist/components/usage.mjs +1 -114
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +33 -838
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +33 -828
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +1 -31
- package/dist/config.mjs +1 -29
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +1 -26
- package/dist/contexts/command.mjs +1 -23
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/index.cjs +1 -9
- package/dist/contexts/index.mjs +1 -4
- package/dist/contexts/options.cjs +1 -63
- package/dist/contexts/options.mjs +1 -58
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +1 -71
- package/dist/helpers/automd.mjs +1 -70
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -23
- package/dist/helpers/docs-helpers.mjs +1 -22
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +1 -137
- package/dist/helpers/paths.mjs +1 -133
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +1 -113
- package/dist/helpers/persistence.mjs +1 -110
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +1 -59
- package/dist/helpers/update-package-json.mjs +1 -57
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +1 -95
- package/dist/helpers/utilities.mjs +1 -93
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +1 -71
- package/dist/helpers/validations.mjs +1 -71
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +1 -52
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -7
- package/dist/plugin-utils/compute-bin.cjs +1 -50
- package/dist/plugin-utils/compute-bin.mjs +1 -49
- package/dist/plugin-utils/compute-bin.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +1 -231
- package/dist/plugin-utils/context-helpers.mjs +1 -221
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +1 -71
- package/dist/plugin-utils/deepkit.mjs +1 -69
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +2 -111
- package/dist/plugin-utils/description-helpers.mjs +2 -107
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +1 -117
- package/dist/plugin-utils/get-command-tree.mjs +1 -114
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +1 -39
- package/dist/plugin-utils/index.mjs +1 -10
- package/dist/plugin-utils/reflect.cjs +1 -52
- package/dist/plugin-utils/reflect.mjs +1 -52
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +1 -64
- package/dist/plugin-utils/traverse-command-tree.mjs +1 -62
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +1 -93
- package/dist/plugin-utils/type-checks.mjs +1 -88
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +4 -429
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +4 -423
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +1 -135
- package/dist/resolver/deepkit.mjs +1 -134
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +1 -173
- package/dist/resolver/helpers.mjs +1 -168
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +1 -145
- package/dist/resolver/module.mjs +1 -144
- package/dist/resolver/module.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +1 -222
- package/dist/resolver/resolve.mjs +1 -221
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +1 -441
- package/dist/types/command.mjs +1 -405
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -144
- package/dist/types/config.d.cts +3 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +3 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -138
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -37
- package/dist/types/context.d.cts +3 -2
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -2
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +1 -34
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/env.cjs +1 -52
- package/dist/types/env.mjs +1 -50
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +1 -49
- package/dist/types/index.mjs +1 -6
- package/dist/types/options.cjs +1 -12
- package/dist/types/options.mjs +1 -10
- package/package.json +23 -23
|
@@ -1,292 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_types_command = require('../types/command.cjs');
|
|
4
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
|
-
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
6
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
7
|
-
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
|
-
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
9
|
-
let _stryke_string_format_list = require("@stryke/string-format/list");
|
|
10
|
-
|
|
11
|
-
//#region src/components/command-validation-logic.tsx
|
|
12
|
-
function __assignType(fn, args) {
|
|
13
|
-
fn.__type = args;
|
|
14
|
-
return fn;
|
|
15
|
-
}
|
|
16
|
-
const __ΩCommandValidationLogicProps = [
|
|
17
|
-
"CommandTree",
|
|
18
|
-
"command",
|
|
19
|
-
"CommandValidationLogicProps",
|
|
20
|
-
"P\"w!4\"Mw#y"
|
|
21
|
-
];
|
|
22
|
-
/**
|
|
23
|
-
* A component that generates command validation logic for required options and arguments.
|
|
24
|
-
*/
|
|
25
|
-
function CommandValidationLogic(props) {
|
|
26
|
-
const { command } = props;
|
|
27
|
-
return [
|
|
28
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
29
|
-
name: "failures",
|
|
30
|
-
type: "string[]",
|
|
31
|
-
initializer: _alloy_js_core.code`[];`
|
|
32
|
-
}),
|
|
33
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
34
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
35
|
-
get each() {
|
|
36
|
-
return Object.values(command.options ?? {});
|
|
37
|
-
},
|
|
38
|
-
doubleHardline: true,
|
|
39
|
-
get children() {
|
|
40
|
-
return __assignType((option) => [
|
|
41
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
42
|
-
get when() {
|
|
43
|
-
return !option.optional;
|
|
44
|
-
},
|
|
45
|
-
get children() {
|
|
46
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
47
|
-
get condition() {
|
|
48
|
-
return _alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}`;
|
|
49
|
-
},
|
|
50
|
-
get children() {
|
|
51
|
-
return _alloy_js_core.code`failures.push("Missing required \\"${option.name}\\" option");`;
|
|
52
|
-
}
|
|
53
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
54
|
-
get when() {
|
|
55
|
-
return option.variadic;
|
|
56
|
-
},
|
|
57
|
-
get children() {
|
|
58
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
59
|
-
get condition() {
|
|
60
|
-
return _alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}.length === 0`;
|
|
61
|
-
},
|
|
62
|
-
get children() {
|
|
63
|
-
return _alloy_js_core.code`failures.push("No values were provided to the required \\"${option.name}\\" array option");`;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
})];
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
71
|
-
get when() {
|
|
72
|
-
return option.kind === require_types_command.CommandParameterKinds.number;
|
|
73
|
-
},
|
|
74
|
-
get children() {
|
|
75
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
76
|
-
get when() {
|
|
77
|
-
return option.variadic;
|
|
78
|
-
},
|
|
79
|
-
get fallback() {
|
|
80
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
81
|
-
get condition() {
|
|
82
|
-
return _alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`} && Number.isNaN(options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`})`;
|
|
83
|
-
},
|
|
84
|
-
get children() {
|
|
85
|
-
return _alloy_js_core.code`failures.push("Invalid numeric value provided for the \\"${option.name}\\" option");`;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
get children() {
|
|
90
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
91
|
-
get condition() {
|
|
92
|
-
return _alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}.some(value => Number.isNaN(value))`;
|
|
93
|
-
},
|
|
94
|
-
get children() {
|
|
95
|
-
return _alloy_js_core.code`failures.push("Invalid numeric value provided in the \\"${option.name}\\" array option");`;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
103
|
-
get when() {
|
|
104
|
-
return (option.kind === require_types_command.CommandParameterKinds.string || option.kind === require_types_command.CommandParameterKinds.number) && option.choices && option.choices.length > 0;
|
|
105
|
-
},
|
|
106
|
-
get children() {
|
|
107
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
108
|
-
get when() {
|
|
109
|
-
return !option.variadic;
|
|
110
|
-
},
|
|
111
|
-
get fallback() {
|
|
112
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
113
|
-
get when() {
|
|
114
|
-
return !option.optional;
|
|
115
|
-
},
|
|
116
|
-
get fallback() {
|
|
117
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
118
|
-
get condition() {
|
|
119
|
-
return _alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}.every(value => [${option.choices?.map(__assignType((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
120
|
-
"choice",
|
|
121
|
-
"",
|
|
122
|
-
"P\"2!\"/\""
|
|
123
|
-
])).join(", ")}].includes(value))`;
|
|
124
|
-
},
|
|
125
|
-
get children() {
|
|
126
|
-
return _alloy_js_core.code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${(0, _stryke_string_format_list.list)(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
127
|
-
"choice",
|
|
128
|
-
"",
|
|
129
|
-
"P\"2!\"/\""
|
|
130
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
get children() {
|
|
135
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
136
|
-
get condition() {
|
|
137
|
-
return _alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}.every(value => [${option.choices?.map(__assignType((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
138
|
-
"choice",
|
|
139
|
-
"",
|
|
140
|
-
"P\"2!\"/\""
|
|
141
|
-
])).join(", ")}].includes(value))`;
|
|
142
|
-
},
|
|
143
|
-
get children() {
|
|
144
|
-
return _alloy_js_core.code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${(0, _stryke_string_format_list.list)(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
145
|
-
"choice",
|
|
146
|
-
"",
|
|
147
|
-
"P\"2!\"/\""
|
|
148
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
},
|
|
154
|
-
get children() {
|
|
155
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
156
|
-
get when() {
|
|
157
|
-
return !option.optional;
|
|
158
|
-
},
|
|
159
|
-
get fallback() {
|
|
160
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
161
|
-
get condition() {
|
|
162
|
-
return _alloy_js_core.code`![${option.choices?.map(__assignType((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
163
|
-
"choice",
|
|
164
|
-
"",
|
|
165
|
-
"P\"2!\"/\""
|
|
166
|
-
])).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`})`;
|
|
167
|
-
},
|
|
168
|
-
get children() {
|
|
169
|
-
return _alloy_js_core.code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${(0, _stryke_string_format_list.list)(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
170
|
-
"choice",
|
|
171
|
-
"",
|
|
172
|
-
"P\"2!\"/\""
|
|
173
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
},
|
|
177
|
-
get children() {
|
|
178
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
179
|
-
get condition() {
|
|
180
|
-
return _alloy_js_core.code`![${option.choices?.map(__assignType((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
181
|
-
"choice",
|
|
182
|
-
"",
|
|
183
|
-
"P\"2!\"/\""
|
|
184
|
-
])).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`})`;
|
|
185
|
-
},
|
|
186
|
-
get children() {
|
|
187
|
-
return _alloy_js_core.code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${(0, _stryke_string_format_list.list)(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
188
|
-
"choice",
|
|
189
|
-
"",
|
|
190
|
-
"P\"2!\"/\""
|
|
191
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
], [
|
|
201
|
-
"option",
|
|
202
|
-
"",
|
|
203
|
-
"P\"2!\"/\""
|
|
204
|
-
]);
|
|
205
|
-
}
|
|
206
|
-
}),
|
|
207
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
208
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
209
|
-
get each() {
|
|
210
|
-
return command.args;
|
|
211
|
-
},
|
|
212
|
-
doubleHardline: true,
|
|
213
|
-
get children() {
|
|
214
|
-
return __assignType((argument) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
215
|
-
get when() {
|
|
216
|
-
return !argument.optional;
|
|
217
|
-
},
|
|
218
|
-
get children() {
|
|
219
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
220
|
-
get condition() {
|
|
221
|
-
return _alloy_js_core.code`!${(0, _stryke_string_format_camel_case.camelCase)(argument.name)}`;
|
|
222
|
-
},
|
|
223
|
-
get children() {
|
|
224
|
-
return _alloy_js_core.code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
|
|
225
|
-
}
|
|
226
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
227
|
-
get when() {
|
|
228
|
-
return argument.variadic;
|
|
229
|
-
},
|
|
230
|
-
get children() {
|
|
231
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
232
|
-
get condition() {
|
|
233
|
-
return _alloy_js_core.code`${(0, _stryke_string_format_camel_case.camelCase)(argument.name)}.length === 0`;
|
|
234
|
-
},
|
|
235
|
-
get children() {
|
|
236
|
-
return _alloy_js_core.code`failures.push("No values were provided to the required \\"${argument.name}\\" array positional argument");`;
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
})];
|
|
241
|
-
}
|
|
242
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
243
|
-
get when() {
|
|
244
|
-
return argument.kind === require_types_command.CommandParameterKinds.number;
|
|
245
|
-
},
|
|
246
|
-
get children() {
|
|
247
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
248
|
-
get when() {
|
|
249
|
-
return argument.variadic;
|
|
250
|
-
},
|
|
251
|
-
get fallback() {
|
|
252
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
253
|
-
get condition() {
|
|
254
|
-
return _alloy_js_core.code`${(0, _stryke_string_format_camel_case.camelCase)(argument.name)} && Number.isNaN(${(0, _stryke_string_format_camel_case.camelCase)(argument.name)})`;
|
|
255
|
-
},
|
|
256
|
-
get children() {
|
|
257
|
-
return _alloy_js_core.code`failures.push("Invalid numeric value provided for the \\"${argument.name}\\" positional argument");`;
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
},
|
|
261
|
-
get children() {
|
|
262
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
263
|
-
get condition() {
|
|
264
|
-
return _alloy_js_core.code`${(0, _stryke_string_format_camel_case.camelCase)(argument.name)}.some(value => Number.isNaN(value))`;
|
|
265
|
-
},
|
|
266
|
-
get children() {
|
|
267
|
-
return _alloy_js_core.code`failures.push("Invalid numeric value provided in the \\"${argument.name}\\" array positional argument");`;
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
})], [
|
|
274
|
-
"argument",
|
|
275
|
-
"",
|
|
276
|
-
"P\"2!\"/\""
|
|
277
|
-
]);
|
|
278
|
-
}
|
|
279
|
-
})
|
|
280
|
-
];
|
|
281
|
-
}
|
|
282
|
-
CommandValidationLogic.__type = [
|
|
283
|
-
() => __ΩCommandValidationLogicProps,
|
|
284
|
-
"props",
|
|
285
|
-
"CommandValidationLogic",
|
|
286
|
-
"A component that generates command validation logic for required options and arguments.",
|
|
287
|
-
"Pn!2\"\"/#?$"
|
|
288
|
-
];
|
|
289
|
-
|
|
290
|
-
//#endregion
|
|
291
|
-
exports.CommandValidationLogic = CommandValidationLogic;
|
|
292
|
-
exports.__ΩCommandValidationLogicProps = __ΩCommandValidationLogicProps;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../types/command.cjs`);let t=require(`@alloy-js/core/jsx-runtime`),n=require(`@stryke/string-format/camel-case`),r=require(`@alloy-js/core`),i=require(`@powerlines/plugin-alloy/core/components/spacing`),a=require(`@alloy-js/typescript`),o=require(`@stryke/string-format/list`);function s(e,t){return e.__type=t,e}const c=[`CommandTree`,`command`,`CommandValidationLogicProps`,`P"w!4"Mw#y`];function l(c){let{command:l}=c;return[(0,t.createComponent)(a.VarDeclaration,{name:`failures`,type:`string[]`,initializer:r.code`[];`}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(r.For,{get each(){return Object.values(l.options??{})},doubleHardline:!0,get children(){return s(i=>[(0,t.createComponent)(r.Show,{get when(){return!i.optional},get children(){return[(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`!options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}`},get children(){return r.code`failures.push("Missing required \\"${i.name}\\" option");`}}),(0,t.createComponent)(r.Show,{get when(){return i.variadic},get children(){return(0,t.createComponent)(a.ElseIfClause,{get condition(){return r.code`options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}.length === 0`},get children(){return r.code`failures.push("No values were provided to the required \\"${i.name}\\" array option");`}})}})]}}),(0,t.createComponent)(r.Show,{get when(){return i.kind===e.CommandParameterKinds.number},get children(){return(0,t.createComponent)(r.Show,{get when(){return i.variadic},get fallback(){return(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`} && Number.isNaN(options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`})`},get children(){return r.code`failures.push("Invalid numeric value provided for the \\"${i.name}\\" option");`}})},get children(){return(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}.some(value => Number.isNaN(value))`},get children(){return r.code`failures.push("Invalid numeric value provided in the \\"${i.name}\\" array option");`}})}})}}),(0,t.createComponent)(r.Show,{get when(){return(i.kind===e.CommandParameterKinds.string||i.kind===e.CommandParameterKinds.number)&&i.choices&&i.choices.length>0},get children(){return(0,t.createComponent)(r.Show,{get when(){return!i.variadic},get fallback(){return(0,t.createComponent)(r.Show,{get when(){return!i.optional},get fallback(){return(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`!options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}.every(value => [${i.choices?.map(s(t=>i.kind===e.CommandParameterKinds.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(value))`},get children(){return r.code`failures.push(\`Invalid value provided for the \\"${i.name}\\" option - valid values include: ${(0,o.list)(i?.choices?.map(s(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}}\`);`}})},get children(){return(0,t.createComponent)(a.ElseIfClause,{get condition(){return r.code`!options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}.every(value => [${i.choices?.map(s(t=>i.kind===e.CommandParameterKinds.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(value))`},get children(){return r.code`failures.push(\`Invalid value provided for the \\"${i.name}\\" option - valid values include: ${(0,o.list)(i?.choices?.map(s(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}}\`);`}})}})},get children(){return(0,t.createComponent)(r.Show,{get when(){return!i.optional},get fallback(){return(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`![${i.choices?.map(s(t=>i.kind===e.CommandParameterKinds.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`})`},get children(){return r.code`failures.push(\`Invalid value provided for the \\"${i.name}\\" option - valid values include: ${(0,o.list)(i?.choices?.map(s(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}}\`);`}})},get children(){return(0,t.createComponent)(a.ElseIfClause,{get condition(){return r.code`![${i.choices?.map(s(t=>i.kind===e.CommandParameterKinds.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`})`},get children(){return r.code`failures.push(\`Invalid value provided for the \\"${i.name}\\" option - valid values include: ${(0,o.list)(i?.choices?.map(s(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${i.name.includes(`?`)?`["${i.name}"]`:`.${(0,n.camelCase)(i.name)}`}}\`);`}})}})}})}})],[`option`,``,`P"2!"/"`])}}),(0,t.createComponent)(i.Spacing,{}),(0,t.createComponent)(r.For,{get each(){return l.args},doubleHardline:!0,get children(){return s(i=>[(0,t.createComponent)(r.Show,{get when(){return!i.optional},get children(){return[(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`!${(0,n.camelCase)(i.name)}`},get children(){return r.code`failures.push("Missing required \\"${i.name}\\" positional argument");`}}),(0,t.createComponent)(r.Show,{get when(){return i.variadic},get children(){return(0,t.createComponent)(a.ElseIfClause,{get condition(){return r.code`${(0,n.camelCase)(i.name)}.length === 0`},get children(){return r.code`failures.push("No values were provided to the required \\"${i.name}\\" array positional argument");`}})}})]}}),(0,t.createComponent)(r.Show,{get when(){return i.kind===e.CommandParameterKinds.number},get children(){return(0,t.createComponent)(r.Show,{get when(){return i.variadic},get fallback(){return(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`${(0,n.camelCase)(i.name)} && Number.isNaN(${(0,n.camelCase)(i.name)})`},get children(){return r.code`failures.push("Invalid numeric value provided for the \\"${i.name}\\" positional argument");`}})},get children(){return(0,t.createComponent)(a.IfStatement,{get condition(){return r.code`${(0,n.camelCase)(i.name)}.some(value => Number.isNaN(value))`},get children(){return r.code`failures.push("Invalid numeric value provided in the \\"${i.name}\\" array positional argument");`}})}})}})],[`argument`,``,`P"2!"/"`])}})]}l.__type=[()=>c,`props`,`CommandValidationLogic`,`A component that generates command validation logic for required options and arguments.`,`Pn!2""/#?$`],exports.CommandValidationLogic=l,exports.__ΩCommandValidationLogicProps=c;
|
|
@@ -1,290 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { camelCase } from "@stryke/string-format/camel-case";
|
|
4
|
-
import { For, Show, code } from "@alloy-js/core";
|
|
5
|
-
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
6
|
-
import { ElseIfClause, IfStatement, VarDeclaration } from "@alloy-js/typescript";
|
|
7
|
-
import { list } from "@stryke/string-format/list";
|
|
8
|
-
|
|
9
|
-
//#region src/components/command-validation-logic.tsx
|
|
10
|
-
function __assignType(fn, args) {
|
|
11
|
-
fn.__type = args;
|
|
12
|
-
return fn;
|
|
13
|
-
}
|
|
14
|
-
const __ΩCommandValidationLogicProps = [
|
|
15
|
-
"CommandTree",
|
|
16
|
-
"command",
|
|
17
|
-
"CommandValidationLogicProps",
|
|
18
|
-
"P\"w!4\"Mw#y"
|
|
19
|
-
];
|
|
20
|
-
/**
|
|
21
|
-
* A component that generates command validation logic for required options and arguments.
|
|
22
|
-
*/
|
|
23
|
-
function CommandValidationLogic(props) {
|
|
24
|
-
const { command } = props;
|
|
25
|
-
return [
|
|
26
|
-
createComponent(VarDeclaration, {
|
|
27
|
-
name: "failures",
|
|
28
|
-
type: "string[]",
|
|
29
|
-
initializer: code`[];`
|
|
30
|
-
}),
|
|
31
|
-
createIntrinsic("hbr", {}),
|
|
32
|
-
createComponent(For, {
|
|
33
|
-
get each() {
|
|
34
|
-
return Object.values(command.options ?? {});
|
|
35
|
-
},
|
|
36
|
-
doubleHardline: true,
|
|
37
|
-
get children() {
|
|
38
|
-
return __assignType((option) => [
|
|
39
|
-
createComponent(Show, {
|
|
40
|
-
get when() {
|
|
41
|
-
return !option.optional;
|
|
42
|
-
},
|
|
43
|
-
get children() {
|
|
44
|
-
return [createComponent(IfStatement, {
|
|
45
|
-
get condition() {
|
|
46
|
-
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
|
|
47
|
-
},
|
|
48
|
-
get children() {
|
|
49
|
-
return code`failures.push("Missing required \\"${option.name}\\" option");`;
|
|
50
|
-
}
|
|
51
|
-
}), createComponent(Show, {
|
|
52
|
-
get when() {
|
|
53
|
-
return option.variadic;
|
|
54
|
-
},
|
|
55
|
-
get children() {
|
|
56
|
-
return createComponent(ElseIfClause, {
|
|
57
|
-
get condition() {
|
|
58
|
-
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
|
|
59
|
-
},
|
|
60
|
-
get children() {
|
|
61
|
-
return code`failures.push("No values were provided to the required \\"${option.name}\\" array option");`;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
})];
|
|
66
|
-
}
|
|
67
|
-
}),
|
|
68
|
-
createComponent(Show, {
|
|
69
|
-
get when() {
|
|
70
|
-
return option.kind === CommandParameterKinds.number;
|
|
71
|
-
},
|
|
72
|
-
get children() {
|
|
73
|
-
return createComponent(Show, {
|
|
74
|
-
get when() {
|
|
75
|
-
return option.variadic;
|
|
76
|
-
},
|
|
77
|
-
get fallback() {
|
|
78
|
-
return createComponent(IfStatement, {
|
|
79
|
-
get condition() {
|
|
80
|
-
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} && Number.isNaN(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
81
|
-
},
|
|
82
|
-
get children() {
|
|
83
|
-
return code`failures.push("Invalid numeric value provided for the \\"${option.name}\\" option");`;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
get children() {
|
|
88
|
-
return createComponent(IfStatement, {
|
|
89
|
-
get condition() {
|
|
90
|
-
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.some(value => Number.isNaN(value))`;
|
|
91
|
-
},
|
|
92
|
-
get children() {
|
|
93
|
-
return code`failures.push("Invalid numeric value provided in the \\"${option.name}\\" array option");`;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}),
|
|
100
|
-
createComponent(Show, {
|
|
101
|
-
get when() {
|
|
102
|
-
return (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.choices && option.choices.length > 0;
|
|
103
|
-
},
|
|
104
|
-
get children() {
|
|
105
|
-
return createComponent(Show, {
|
|
106
|
-
get when() {
|
|
107
|
-
return !option.variadic;
|
|
108
|
-
},
|
|
109
|
-
get fallback() {
|
|
110
|
-
return createComponent(Show, {
|
|
111
|
-
get when() {
|
|
112
|
-
return !option.optional;
|
|
113
|
-
},
|
|
114
|
-
get fallback() {
|
|
115
|
-
return createComponent(IfStatement, {
|
|
116
|
-
get condition() {
|
|
117
|
-
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.every(value => [${option.choices?.map(__assignType((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
118
|
-
"choice",
|
|
119
|
-
"",
|
|
120
|
-
"P\"2!\"/\""
|
|
121
|
-
])).join(", ")}].includes(value))`;
|
|
122
|
-
},
|
|
123
|
-
get children() {
|
|
124
|
-
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
125
|
-
"choice",
|
|
126
|
-
"",
|
|
127
|
-
"P\"2!\"/\""
|
|
128
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
get children() {
|
|
133
|
-
return createComponent(ElseIfClause, {
|
|
134
|
-
get condition() {
|
|
135
|
-
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.every(value => [${option.choices?.map(__assignType((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
136
|
-
"choice",
|
|
137
|
-
"",
|
|
138
|
-
"P\"2!\"/\""
|
|
139
|
-
])).join(", ")}].includes(value))`;
|
|
140
|
-
},
|
|
141
|
-
get children() {
|
|
142
|
-
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
143
|
-
"choice",
|
|
144
|
-
"",
|
|
145
|
-
"P\"2!\"/\""
|
|
146
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
get children() {
|
|
153
|
-
return createComponent(Show, {
|
|
154
|
-
get when() {
|
|
155
|
-
return !option.optional;
|
|
156
|
-
},
|
|
157
|
-
get fallback() {
|
|
158
|
-
return createComponent(IfStatement, {
|
|
159
|
-
get condition() {
|
|
160
|
-
return code`![${option.choices?.map(__assignType((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
161
|
-
"choice",
|
|
162
|
-
"",
|
|
163
|
-
"P\"2!\"/\""
|
|
164
|
-
])).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
165
|
-
},
|
|
166
|
-
get children() {
|
|
167
|
-
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
168
|
-
"choice",
|
|
169
|
-
"",
|
|
170
|
-
"P\"2!\"/\""
|
|
171
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
},
|
|
175
|
-
get children() {
|
|
176
|
-
return createComponent(ElseIfClause, {
|
|
177
|
-
get condition() {
|
|
178
|
-
return code`![${option.choices?.map(__assignType((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice, [
|
|
179
|
-
"choice",
|
|
180
|
-
"",
|
|
181
|
-
"P\"2!\"/\""
|
|
182
|
-
])).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
183
|
-
},
|
|
184
|
-
get children() {
|
|
185
|
-
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
186
|
-
"choice",
|
|
187
|
-
"",
|
|
188
|
-
"P\"2!\"/\""
|
|
189
|
-
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
], [
|
|
199
|
-
"option",
|
|
200
|
-
"",
|
|
201
|
-
"P\"2!\"/\""
|
|
202
|
-
]);
|
|
203
|
-
}
|
|
204
|
-
}),
|
|
205
|
-
createComponent(Spacing, {}),
|
|
206
|
-
createComponent(For, {
|
|
207
|
-
get each() {
|
|
208
|
-
return command.args;
|
|
209
|
-
},
|
|
210
|
-
doubleHardline: true,
|
|
211
|
-
get children() {
|
|
212
|
-
return __assignType((argument) => [createComponent(Show, {
|
|
213
|
-
get when() {
|
|
214
|
-
return !argument.optional;
|
|
215
|
-
},
|
|
216
|
-
get children() {
|
|
217
|
-
return [createComponent(IfStatement, {
|
|
218
|
-
get condition() {
|
|
219
|
-
return code`!${camelCase(argument.name)}`;
|
|
220
|
-
},
|
|
221
|
-
get children() {
|
|
222
|
-
return code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
|
|
223
|
-
}
|
|
224
|
-
}), createComponent(Show, {
|
|
225
|
-
get when() {
|
|
226
|
-
return argument.variadic;
|
|
227
|
-
},
|
|
228
|
-
get children() {
|
|
229
|
-
return createComponent(ElseIfClause, {
|
|
230
|
-
get condition() {
|
|
231
|
-
return code`${camelCase(argument.name)}.length === 0`;
|
|
232
|
-
},
|
|
233
|
-
get children() {
|
|
234
|
-
return code`failures.push("No values were provided to the required \\"${argument.name}\\" array positional argument");`;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
})];
|
|
239
|
-
}
|
|
240
|
-
}), createComponent(Show, {
|
|
241
|
-
get when() {
|
|
242
|
-
return argument.kind === CommandParameterKinds.number;
|
|
243
|
-
},
|
|
244
|
-
get children() {
|
|
245
|
-
return createComponent(Show, {
|
|
246
|
-
get when() {
|
|
247
|
-
return argument.variadic;
|
|
248
|
-
},
|
|
249
|
-
get fallback() {
|
|
250
|
-
return createComponent(IfStatement, {
|
|
251
|
-
get condition() {
|
|
252
|
-
return code`${camelCase(argument.name)} && Number.isNaN(${camelCase(argument.name)})`;
|
|
253
|
-
},
|
|
254
|
-
get children() {
|
|
255
|
-
return code`failures.push("Invalid numeric value provided for the \\"${argument.name}\\" positional argument");`;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
},
|
|
259
|
-
get children() {
|
|
260
|
-
return createComponent(IfStatement, {
|
|
261
|
-
get condition() {
|
|
262
|
-
return code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`;
|
|
263
|
-
},
|
|
264
|
-
get children() {
|
|
265
|
-
return code`failures.push("Invalid numeric value provided in the \\"${argument.name}\\" array positional argument");`;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
})], [
|
|
272
|
-
"argument",
|
|
273
|
-
"",
|
|
274
|
-
"P\"2!\"/\""
|
|
275
|
-
]);
|
|
276
|
-
}
|
|
277
|
-
})
|
|
278
|
-
];
|
|
279
|
-
}
|
|
280
|
-
CommandValidationLogic.__type = [
|
|
281
|
-
() => __ΩCommandValidationLogicProps,
|
|
282
|
-
"props",
|
|
283
|
-
"CommandValidationLogic",
|
|
284
|
-
"A component that generates command validation logic for required options and arguments.",
|
|
285
|
-
"Pn!2\"\"/#?$"
|
|
286
|
-
];
|
|
287
|
-
|
|
288
|
-
//#endregion
|
|
289
|
-
export { CommandValidationLogic, __ΩCommandValidationLogicProps };
|
|
1
|
+
import{CommandParameterKinds as e}from"../types/command.mjs";import{createComponent as t,createIntrinsic as n}from"@alloy-js/core/jsx-runtime";import{camelCase as r}from"@stryke/string-format/camel-case";import{For as i,Show as a,code as o}from"@alloy-js/core";import{Spacing as s}from"@powerlines/plugin-alloy/core/components/spacing";import{ElseIfClause as c,IfStatement as l,VarDeclaration as u}from"@alloy-js/typescript";import{list as d}from"@stryke/string-format/list";function f(e,t){return e.__type=t,e}const p=[`CommandTree`,`command`,`CommandValidationLogicProps`,`P"w!4"Mw#y`];function m(p){let{command:m}=p;return[t(u,{name:`failures`,type:`string[]`,initializer:o`[];`}),n(`hbr`,{}),t(i,{get each(){return Object.values(m.options??{})},doubleHardline:!0,get children(){return f(n=>[t(a,{get when(){return!n.optional},get children(){return[t(l,{get condition(){return o`!options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}`},get children(){return o`failures.push("Missing required \\"${n.name}\\" option");`}}),t(a,{get when(){return n.variadic},get children(){return t(c,{get condition(){return o`options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}.length === 0`},get children(){return o`failures.push("No values were provided to the required \\"${n.name}\\" array option");`}})}})]}}),t(a,{get when(){return n.kind===e.number},get children(){return t(a,{get when(){return n.variadic},get fallback(){return t(l,{get condition(){return o`options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`} && Number.isNaN(options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`})`},get children(){return o`failures.push("Invalid numeric value provided for the \\"${n.name}\\" option");`}})},get children(){return t(l,{get condition(){return o`options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}.some(value => Number.isNaN(value))`},get children(){return o`failures.push("Invalid numeric value provided in the \\"${n.name}\\" array option");`}})}})}}),t(a,{get when(){return(n.kind===e.string||n.kind===e.number)&&n.choices&&n.choices.length>0},get children(){return t(a,{get when(){return!n.variadic},get fallback(){return t(a,{get when(){return!n.optional},get fallback(){return t(l,{get condition(){return o`!options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}.every(value => [${n.choices?.map(f(t=>n.kind===e.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(value))`},get children(){return o`failures.push(\`Invalid value provided for the \\"${n.name}\\" option - valid values include: ${d(n?.choices?.map(f(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}}\`);`}})},get children(){return t(c,{get condition(){return o`!options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}.every(value => [${n.choices?.map(f(t=>n.kind===e.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(value))`},get children(){return o`failures.push(\`Invalid value provided for the \\"${n.name}\\" option - valid values include: ${d(n?.choices?.map(f(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}}\`);`}})}})},get children(){return t(a,{get when(){return!n.optional},get fallback(){return t(l,{get condition(){return o`![${n.choices?.map(f(t=>n.kind===e.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`})`},get children(){return o`failures.push(\`Invalid value provided for the \\"${n.name}\\" option - valid values include: ${d(n?.choices?.map(f(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}}\`);`}})},get children(){return t(c,{get condition(){return o`![${n.choices?.map(f(t=>n.kind===e.string?`"${t}"`:t,[`choice`,``,`P"2!"/"`])).join(`, `)}].includes(options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`})`},get children(){return o`failures.push(\`Invalid value provided for the \\"${n.name}\\" option - valid values include: ${d(n?.choices?.map(f(e=>String(e),[`choice`,``,`P"2!"/"`]))??[])}; provided: \${options${n.name.includes(`?`)?`["${n.name}"]`:`.${r(n.name)}`}}\`);`}})}})}})}})],[`option`,``,`P"2!"/"`])}}),t(s,{}),t(i,{get each(){return m.args},doubleHardline:!0,get children(){return f(n=>[t(a,{get when(){return!n.optional},get children(){return[t(l,{get condition(){return o`!${r(n.name)}`},get children(){return o`failures.push("Missing required \\"${n.name}\\" positional argument");`}}),t(a,{get when(){return n.variadic},get children(){return t(c,{get condition(){return o`${r(n.name)}.length === 0`},get children(){return o`failures.push("No values were provided to the required \\"${n.name}\\" array positional argument");`}})}})]}}),t(a,{get when(){return n.kind===e.number},get children(){return t(a,{get when(){return n.variadic},get fallback(){return t(l,{get condition(){return o`${r(n.name)} && Number.isNaN(${r(n.name)})`},get children(){return o`failures.push("Invalid numeric value provided for the \\"${n.name}\\" positional argument");`}})},get children(){return t(l,{get condition(){return o`${r(n.name)}.some(value => Number.isNaN(value))`},get children(){return o`failures.push("Invalid numeric value provided in the \\"${n.name}\\" array positional argument");`}})}})}})],[`argument`,``,`P"2!"/"`])}})]}m.__type=[()=>p,`props`,`CommandValidationLogic`,`A component that generates command validation logic for required options and arguments.`,`Pn!2""/#?$`];export{m as CommandValidationLogic,p as __ΩCommandValidationLogicProps};
|
|
290
2
|
//# sourceMappingURL=command-validation-logic.mjs.map
|