@shell-shock/core 0.17.2 → 0.17.4
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/api.cjs +5 -4
- package/dist/api.mjs +4 -2
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +44 -11
- package/dist/components/command-validation-logic.mjs +44 -10
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -2
- package/dist/components/exec-builtin.cjs +91 -99
- package/dist/components/exec-builtin.mjs +90 -97
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/helpers.cjs +1 -2
- package/dist/components/options-parser-logic.cjs +1 -2
- package/dist/components/state-builtin.cjs +2 -3
- package/dist/components/state-builtin.mjs +2 -2
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/usage.cjs +1 -2
- package/dist/components/utils-builtin.cjs +2 -17
- package/dist/components/utils-builtin.mjs +1 -15
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +3 -3
- package/dist/config.mjs +2 -1
- package/dist/contexts/command.cjs +6 -3
- package/dist/contexts/command.mjs +5 -1
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/options.cjs +7 -4
- package/dist/contexts/options.mjs +5 -1
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +1 -2
- package/dist/helpers/docs-helpers.cjs +3 -3
- package/dist/helpers/docs-helpers.mjs +2 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +3 -3
- package/dist/helpers/paths.mjs +2 -1
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +7 -5
- package/dist/helpers/persistence.mjs +6 -3
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +1 -2
- package/dist/helpers/utilities.cjs +3 -3
- package/dist/helpers/utilities.mjs +2 -1
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +1 -2
- package/dist/plugin-utils/context-helpers.cjs +21 -12
- package/dist/plugin-utils/context-helpers.mjs +20 -10
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +5 -6
- package/dist/plugin-utils/deepkit.mjs +5 -5
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +14 -8
- package/dist/plugin-utils/description-helpers.mjs +13 -6
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +5 -4
- package/dist/plugin-utils/get-command-tree.mjs +4 -2
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/reflect.cjs +3 -3
- package/dist/plugin-utils/reflect.mjs +2 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +5 -4
- package/dist/plugin-utils/traverse-command-tree.mjs +4 -2
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +11 -7
- package/dist/plugin-utils/type-checks.mjs +10 -5
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +8 -5
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +7 -4
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +4 -9
- package/dist/resolver/deepkit.mjs +4 -8
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +5 -4
- package/dist/resolver/helpers.mjs +4 -2
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +1 -2
- package/dist/resolver/resolve.cjs +8 -5
- package/dist/resolver/resolve.mjs +7 -3
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +65 -12
- package/dist/types/command.d.cts +9 -1
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +9 -1
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +64 -10
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +20 -7
- 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 +19 -5
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +6 -3
- package/dist/types/context.mjs +5 -1
- package/dist/types/env.cjs +38 -3
- package/dist/types/env.d.cts +3 -1
- package/dist/types/env.d.cts.map +1 -1
- package/dist/types/env.d.mts +3 -1
- package/dist/types/env.d.mts.map +1 -1
- package/dist/types/env.mjs +37 -1
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/options.cjs +1 -2
- package/package.json +11 -11
- package/dist/api.cjs.map +0 -1
- package/dist/components/command-validation-logic.cjs.map +0 -1
- package/dist/components/docs.cjs.map +0 -1
- package/dist/components/exec-builtin.cjs.map +0 -1
- package/dist/components/helpers.cjs.map +0 -1
- package/dist/components/options-parser-logic.cjs.map +0 -1
- package/dist/components/state-builtin.cjs.map +0 -1
- package/dist/components/usage.cjs.map +0 -1
- package/dist/components/utils-builtin.cjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/contexts/command.cjs.map +0 -1
- package/dist/contexts/options.cjs.map +0 -1
- package/dist/helpers/automd.cjs.map +0 -1
- package/dist/helpers/docs-helpers.cjs.map +0 -1
- package/dist/helpers/paths.cjs.map +0 -1
- package/dist/helpers/persistence.cjs.map +0 -1
- package/dist/helpers/update-package-json.cjs.map +0 -1
- package/dist/helpers/utilities.cjs.map +0 -1
- package/dist/helpers/validations.cjs.map +0 -1
- package/dist/plugin-utils/context-helpers.cjs.map +0 -1
- package/dist/plugin-utils/deepkit.cjs.map +0 -1
- package/dist/plugin-utils/description-helpers.cjs.map +0 -1
- package/dist/plugin-utils/get-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/reflect.cjs.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/type-checks.cjs.map +0 -1
- package/dist/plugin.cjs.map +0 -1
- package/dist/resolver/deepkit.cjs.map +0 -1
- package/dist/resolver/helpers.cjs.map +0 -1
- package/dist/resolver/module.cjs.map +0 -1
- package/dist/resolver/resolve.cjs.map +0 -1
- package/dist/types/command.cjs.map +0 -1
- package/dist/types/config.cjs.map +0 -1
- package/dist/types/context.cjs.map +0 -1
- package/dist/types/env.cjs.map +0 -1
- package/dist/types/options.cjs.map +0 -1
package/dist/api.cjs
CHANGED
|
@@ -63,7 +63,8 @@ var ShellShockAPI = class ShellShockAPI {
|
|
|
63
63
|
"docs",
|
|
64
64
|
"finalize",
|
|
65
65
|
"ShellShockAPI",
|
|
66
|
-
"
|
|
66
|
+
"The Shell Shock API class.",
|
|
67
|
+
"!3!P\"w\"2#&2$8P7%`0&sP!2'\"0(P!2)$`0*P!2)$`0+P!2)$`0,P!2)$`0-P!2)$`0.P$`0/5w0?1"
|
|
67
68
|
];
|
|
68
69
|
};
|
|
69
70
|
/**
|
|
@@ -85,10 +86,10 @@ createShellShock.__type = [
|
|
|
85
86
|
() => ({}),
|
|
86
87
|
() => ShellShockAPI,
|
|
87
88
|
"createShellShock",
|
|
88
|
-
"
|
|
89
|
+
"Creates a new {@link ShellShockAPI} instance.",
|
|
90
|
+
"P\"w\"o!\"2#>$P7%`/&?'"
|
|
89
91
|
];
|
|
90
92
|
|
|
91
93
|
//#endregion
|
|
92
94
|
exports.ShellShockAPI = ShellShockAPI;
|
|
93
|
-
exports.createShellShock = createShellShock;
|
|
94
|
-
//# sourceMappingURL=api.cjs.map
|
|
95
|
+
exports.createShellShock = createShellShock;
|
package/dist/api.mjs
CHANGED
|
@@ -61,7 +61,8 @@ var ShellShockAPI = class ShellShockAPI {
|
|
|
61
61
|
"docs",
|
|
62
62
|
"finalize",
|
|
63
63
|
"ShellShockAPI",
|
|
64
|
-
"
|
|
64
|
+
"The Shell Shock API class.",
|
|
65
|
+
"!3!P\"w\"2#&2$8P7%`0&sP!2'\"0(P!2)$`0*P!2)$`0+P!2)$`0,P!2)$`0-P!2)$`0.P$`0/5w0?1"
|
|
65
66
|
];
|
|
66
67
|
};
|
|
67
68
|
/**
|
|
@@ -83,7 +84,8 @@ createShellShock.__type = [
|
|
|
83
84
|
() => ({}),
|
|
84
85
|
() => ShellShockAPI,
|
|
85
86
|
"createShellShock",
|
|
86
|
-
"
|
|
87
|
+
"Creates a new {@link ShellShockAPI} instance.",
|
|
88
|
+
"P\"w\"o!\"2#>$P7%`/&?'"
|
|
87
89
|
];
|
|
88
90
|
|
|
89
91
|
//#endregion
|
package/dist/api.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":[],"sources":["../src/api.ts"],"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 type {\n BuildInlineConfig,\n CleanInlineConfig,\n DocsInlineConfig,\n LintInlineConfig,\n PluginConfig,\n PrepareInlineConfig\n} from \"powerlines\";\nimport { createPowerlines, PowerlinesAPI } from \"powerlines\";\nimport { plugin } from \"./plugin\";\nimport type { UserConfig } from \"./types/config\";\n\n/**\n * The Shell Shock API class.\n *\n * @remarks\n * This class provides methods to interact with the Shell Shock build system, including cleaning, preparing, linting, building, generating documentation, and finalizing projects.\n */\nexport class ShellShockAPI {\n #powerlines: PowerlinesAPI;\n\n public static async from(\n config: UserConfig,\n workspaceRoot?: string\n ): Promise<ShellShockAPI> {\n const userConfig = {\n framework: \"shell-shock\",\n ...config,\n plugins: [plugin(), ...(config.plugins ?? [])] as PluginConfig<any>[]\n };\n\n const powerlines = await (workspaceRoot\n ? PowerlinesAPI.from(workspaceRoot, userConfig)\n : createPowerlines(userConfig));\n\n return new ShellShockAPI(powerlines);\n }\n\n private constructor(powerlines: PowerlinesAPI) {\n this.#powerlines = powerlines;\n }\n\n public async clean(inlineConfig: CleanInlineConfig): Promise<void> {\n return this.#powerlines.clean(inlineConfig);\n }\n\n public async prepare(inlineConfig: PrepareInlineConfig): Promise<void> {\n return this.#powerlines.prepare(inlineConfig);\n }\n\n public async lint(inlineConfig: LintInlineConfig): Promise<void> {\n return this.#powerlines.lint(inlineConfig);\n }\n\n public async build(inlineConfig: BuildInlineConfig): Promise<void> {\n return this.#powerlines.build(inlineConfig);\n }\n\n public async docs(inlineConfig: DocsInlineConfig): Promise<void> {\n return this.#powerlines.docs(inlineConfig);\n }\n\n public async finalize(): Promise<void> {\n return this.#powerlines.finalize();\n }\n}\n\n/**\n * Creates a new {@link ShellShockAPI} instance.\n *\n * @param options - The user configuration options.\n * @returns A promise that resolves to a {@link ShellShockAPI} instance.\n */\nexport async function createShellShock(\n options: Partial<UserConfig> = {}\n): Promise<ShellShockAPI> {\n return ShellShockAPI.from({ root: process.cwd(), ...options });\n}\n"],"mappings":";;;;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;;;;;;AAS/D,IAAa,gBAAb,MAAa,cAAc;CAC1B;CACA,aAAgB,KAAK,QAAK,eAAa;EAChC,MAAM,aAAa;;GAErB,GAAQ;;GAEL;AAIP,SAAA,IAAiB,qCAFP,cAAA,KAAA,eAAA,WAAA,GACV,iBAAiB,WAAA,EACA;;CAEjB,YAAA,YAAgB;AAChB,QAAA,aAAY;;CAEZ,MAAM,MAAA,cAAW;AACX,SAAC,MAAA,WAAkB,MAAA,aAAsB;;CAEjD,MAAO,QAAO,cAAkB;;;CAG7B,MAAI,KAAM,cAAe;AAC3B,SAAA,MAAA,WAAA,KAAA,aAAA;;CAEE,MAAK,MAAM,cAAgB;AAC5B,SAAA,MAAA,WAAA,MAAA,aAAA;;CAEC,MAAA,KAAY,cAAa;;;CAGxB,MAAM,WAAE;AACR,SAAA,MAAgB,WAAA,UAAA;;CAEhB,OAAM,SAAU;EAAC;EAAE;EAAA;EAAA;QAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;;;;;;;;AAQvB,eAAQ,iBAA6B,UAAA,EAAA,EAAA;;;;;;AAGrC,iBAAE,SAAA;OAAA;CAAA;CAAA;QAAA,EAAA;OAAA;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"api.mjs","names":[],"sources":["../src/api.ts"],"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 type {\n BuildInlineConfig,\n CleanInlineConfig,\n DocsInlineConfig,\n LintInlineConfig,\n PluginConfig,\n PrepareInlineConfig\n} from \"powerlines\";\nimport { createPowerlines, PowerlinesAPI } from \"powerlines\";\nimport { plugin } from \"./plugin\";\nimport type { UserConfig } from \"./types/config\";\n\n/**\n * The Shell Shock API class.\n *\n * @remarks\n * This class provides methods to interact with the Shell Shock build system, including cleaning, preparing, linting, building, generating documentation, and finalizing projects.\n */\nexport class ShellShockAPI {\n #powerlines: PowerlinesAPI;\n\n public static async from(\n config: UserConfig,\n workspaceRoot?: string\n ): Promise<ShellShockAPI> {\n const userConfig = {\n framework: \"shell-shock\",\n ...config,\n plugins: [plugin(), ...(config.plugins ?? [])] as PluginConfig<any>[]\n };\n\n const powerlines = await (workspaceRoot\n ? PowerlinesAPI.from(workspaceRoot, userConfig)\n : createPowerlines(userConfig));\n\n return new ShellShockAPI(powerlines);\n }\n\n private constructor(powerlines: PowerlinesAPI) {\n this.#powerlines = powerlines;\n }\n\n public async clean(inlineConfig: CleanInlineConfig): Promise<void> {\n return this.#powerlines.clean(inlineConfig);\n }\n\n public async prepare(inlineConfig: PrepareInlineConfig): Promise<void> {\n return this.#powerlines.prepare(inlineConfig);\n }\n\n public async lint(inlineConfig: LintInlineConfig): Promise<void> {\n return this.#powerlines.lint(inlineConfig);\n }\n\n public async build(inlineConfig: BuildInlineConfig): Promise<void> {\n return this.#powerlines.build(inlineConfig);\n }\n\n public async docs(inlineConfig: DocsInlineConfig): Promise<void> {\n return this.#powerlines.docs(inlineConfig);\n }\n\n public async finalize(): Promise<void> {\n return this.#powerlines.finalize();\n }\n}\n\n/**\n * Creates a new {@link ShellShockAPI} instance.\n *\n * @param options - The user configuration options.\n * @returns A promise that resolves to a {@link ShellShockAPI} instance.\n */\nexport async function createShellShock(\n options: Partial<UserConfig> = {}\n): Promise<ShellShockAPI> {\n return ShellShockAPI.from({ root: process.cwd(), ...options });\n}\n"],"mappings":";;;;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;;;;;;AAS/D,IAAa,gBAAb,MAAa,cAAc;CAC1B;CACA,aAAgB,KAAK,QAAK,eAAa;EAChC,MAAM,aAAa;;GAErB,GAAQ;;GAEL;AAIP,SAAA,IAAiB,qCAFP,cAAA,KAAA,eAAA,WAAA,GACV,iBAAiB,WAAA,EACA;;CAEjB,YAAA,YAAgB;AAChB,QAAA,aAAY;;CAEZ,MAAM,MAAA,cAAW;AACX,SAAC,MAAA,WAAkB,MAAA,aAAsB;;CAEjD,MAAO,QAAO,cAAkB;;;CAG7B,MAAI,KAAM,cAAe;AAC3B,SAAA,MAAA,WAAA,KAAA,aAAA;;CAEE,MAAK,MAAM,cAAgB;AAC5B,SAAA,MAAA,WAAA,MAAA,aAAA;;CAEC,MAAA,KAAY,cAAa;;;CAGxB,MAAM,WAAE;AACR,SAAA,MAAgB,WAAA,UAAA;;CAEhB,OAAM,SAAU;EAAC;EAAE;EAAA;EAAA;QAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;;;;;;;;AAQvB,eAAQ,iBAA6B,UAAA,EAAA,EAAA;;;;;;AAGrC,iBAAE,SAAA;OAAA;CAAA;CAAA;QAAA,EAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
@@ -41,7 +41,7 @@ function CommandValidationLogic(props) {
|
|
|
41
41
|
}
|
|
42
42
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
43
43
|
get when() {
|
|
44
|
-
return
|
|
44
|
+
return option.variadic;
|
|
45
45
|
},
|
|
46
46
|
get children() {
|
|
47
47
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
@@ -98,22 +98,56 @@ function CommandValidationLogic(props) {
|
|
|
98
98
|
return !option.variadic;
|
|
99
99
|
},
|
|
100
100
|
get fallback() {
|
|
101
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
102
|
-
get
|
|
103
|
-
return
|
|
101
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
102
|
+
get when() {
|
|
103
|
+
return !option.optional;
|
|
104
|
+
},
|
|
105
|
+
get fallback() {
|
|
106
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
107
|
+
get condition() {
|
|
108
|
+
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((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(value))`;
|
|
109
|
+
},
|
|
110
|
+
get children() {
|
|
111
|
+
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((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
104
114
|
},
|
|
105
115
|
get children() {
|
|
106
|
-
return
|
|
116
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
117
|
+
get condition() {
|
|
118
|
+
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((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(value))`;
|
|
119
|
+
},
|
|
120
|
+
get children() {
|
|
121
|
+
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((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
107
124
|
}
|
|
108
125
|
});
|
|
109
126
|
},
|
|
110
127
|
get children() {
|
|
111
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
112
|
-
get
|
|
113
|
-
return
|
|
128
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
129
|
+
get when() {
|
|
130
|
+
return !option.optional;
|
|
131
|
+
},
|
|
132
|
+
get fallback() {
|
|
133
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
134
|
+
get condition() {
|
|
135
|
+
return _alloy_js_core.code`![${option.choices?.map((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`})`;
|
|
136
|
+
},
|
|
137
|
+
get children() {
|
|
138
|
+
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((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
114
141
|
},
|
|
115
142
|
get children() {
|
|
116
|
-
return
|
|
143
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
144
|
+
get condition() {
|
|
145
|
+
return _alloy_js_core.code`![${option.choices?.map((choice) => option.kind === require_types_command.CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`})`;
|
|
146
|
+
},
|
|
147
|
+
get children() {
|
|
148
|
+
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((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}}\`);`;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
117
151
|
}
|
|
118
152
|
});
|
|
119
153
|
}
|
|
@@ -193,5 +227,4 @@ function CommandValidationLogic(props) {
|
|
|
193
227
|
}
|
|
194
228
|
|
|
195
229
|
//#endregion
|
|
196
|
-
exports.CommandValidationLogic = CommandValidationLogic;
|
|
197
|
-
//# sourceMappingURL=command-validation-logic.cjs.map
|
|
230
|
+
exports.CommandValidationLogic = CommandValidationLogic;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommandParameterKinds } from "../types/command.mjs";
|
|
2
|
-
import { createComponent, createIntrinsic
|
|
2
|
+
import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
3
3
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
4
4
|
import { For, Show, code } from "@alloy-js/core";
|
|
5
5
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
@@ -39,7 +39,7 @@ function CommandValidationLogic(props) {
|
|
|
39
39
|
}
|
|
40
40
|
}), createComponent(Show, {
|
|
41
41
|
get when() {
|
|
42
|
-
return
|
|
42
|
+
return option.variadic;
|
|
43
43
|
},
|
|
44
44
|
get children() {
|
|
45
45
|
return createComponent(ElseIfClause, {
|
|
@@ -96,22 +96,56 @@ function CommandValidationLogic(props) {
|
|
|
96
96
|
return !option.variadic;
|
|
97
97
|
},
|
|
98
98
|
get fallback() {
|
|
99
|
-
return createComponent(
|
|
100
|
-
get
|
|
101
|
-
return
|
|
99
|
+
return createComponent(Show, {
|
|
100
|
+
get when() {
|
|
101
|
+
return !option.optional;
|
|
102
|
+
},
|
|
103
|
+
get fallback() {
|
|
104
|
+
return createComponent(IfStatement, {
|
|
105
|
+
get condition() {
|
|
106
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.every(value => [${option.choices?.map((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(value))`;
|
|
107
|
+
},
|
|
108
|
+
get children() {
|
|
109
|
+
return code`failures.push(\`Invalid value provided for the ${option.name} option - valid values include: ${list(option?.choices?.map((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
102
112
|
},
|
|
103
113
|
get children() {
|
|
104
|
-
return
|
|
114
|
+
return createComponent(ElseIfClause, {
|
|
115
|
+
get condition() {
|
|
116
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.every(value => [${option.choices?.map((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(value))`;
|
|
117
|
+
},
|
|
118
|
+
get children() {
|
|
119
|
+
return code`failures.push(\`Invalid value provided for the ${option.name} option - valid values include: ${list(option?.choices?.map((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
105
122
|
}
|
|
106
123
|
});
|
|
107
124
|
},
|
|
108
125
|
get children() {
|
|
109
|
-
return createComponent(
|
|
110
|
-
get
|
|
111
|
-
return
|
|
126
|
+
return createComponent(Show, {
|
|
127
|
+
get when() {
|
|
128
|
+
return !option.optional;
|
|
129
|
+
},
|
|
130
|
+
get fallback() {
|
|
131
|
+
return createComponent(IfStatement, {
|
|
132
|
+
get condition() {
|
|
133
|
+
return code`![${option.choices?.map((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
134
|
+
},
|
|
135
|
+
get children() {
|
|
136
|
+
return code`failures.push(\`Invalid value provided for the ${option.name} option - valid values include: ${list(option?.choices?.map((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
112
139
|
},
|
|
113
140
|
get children() {
|
|
114
|
-
return
|
|
141
|
+
return createComponent(ElseIfClause, {
|
|
142
|
+
get condition() {
|
|
143
|
+
return code`![${option.choices?.map((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
144
|
+
},
|
|
145
|
+
get children() {
|
|
146
|
+
return code`failures.push(\`Invalid value provided for the ${option.name} option - valid values include: ${list(option?.choices?.map((choice) => String(choice)) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
115
149
|
}
|
|
116
150
|
});
|
|
117
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-validation-logic.mjs","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { list } from \"@stryke/string-format/list\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\n\nexport interface CommandValidationLogicProps {\n command: CommandTree;\n}\n\n/**\n * A component that generates command validation logic for required options and arguments.\n */\nexport function CommandValidationLogic(props: CommandValidationLogicProps) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration name=\"failures\" type=\"string[]\" initializer={code`[];`} />\n <hbr />\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 {code`failures.push(\"Missing required ${option.name} option\");`}\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`failures.push(\"No values were provided to the required ${\n option.name\n } array option\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <Show\n when={(option as NumberCommandParameter).variadic}\n fallback={\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } && Number.isNaN(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\"Invalid numeric value provided for the ${\n option.name\n } option\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the ${\n option.name\n } array option\");`}\n </IfStatement>\n </Show>\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n <Show\n when={!option.variadic}\n fallback={\n <ElseIfClause\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the ${\n option.name\n } option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n }>\n <ElseIfClause\n condition={code`![${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the ${\n option.name\n } option - valid values include: ${list(\n (\n option as StringCommandParameter | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n {code`failures.push(\"Missing required \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n <Show\n when={\n (argument.kind === CommandParameterKinds.string ||\n argument.kind === CommandParameterKinds.number) &&\n argument.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`failures.push(\"No values were provided to the required ${\n argument.name\n } array positional argument\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={argument.kind === CommandParameterKinds.number}>\n <Show\n when={(argument as NumberCommandParameter).variadic}\n fallback={\n <IfStatement\n condition={code`${camelCase(\n argument.name\n )} && Number.isNaN(${camelCase(argument.name)})`}>\n {code`failures.push(\"Invalid numeric value provided for the ${\n argument.name\n } positional argument\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the ${\n argument.name\n } array positional argument\");`}\n </IfStatement>\n </Show>\n </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,IAAI,OAAO;AACT,YAAO,SAAS,SAAC,sBAAA;;IAEnB,IAAI,WAAU;AACZ,YAAM,gBAAI,MAAA;MACR,IAAE,OAAA;AACH,cAAA,SAAA;;MAEF,IAAO,WAAE;AACL,cAAM,gBAAc,aAAc;QACpC,IAAS,YAAG;AACV,gBAAA,IAAA,GAAA,UAAA,SAAA,KAAA,CAAA,mBAAA,UAAA,SAAA,KAAA,CAAA;;QAEG,IAAC,WAAY;AACX,gBAAM,IAAA,yDAAoC,SAAA,KAAA;;QAE7C,CAAC;;MAEJ,IAAI,WAAC;AACH,cAAI,gBAAK,aAAA;QACP,IAAI,YAAU;AACZ,gBAAI,IAAA,GAAS,UAAS,SAAA,KAAA,CAAA;;QAExB,IAAG,WAAA;AACD,gBAAC,IAAA,wDAAA,SAAA,KAAA;;QAEJ,CAAC;;MAEL,CAAC;;IAEL,CAAC,CAAC;GACJ,CAAC;EAAC"}
|
|
1
|
+
{"version":3,"file":"command-validation-logic.mjs","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { list } from \"@stryke/string-format/list\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\n\nexport interface CommandValidationLogicProps {\n command: CommandTree;\n}\n\n/**\n * A component that generates command validation logic for required options and arguments.\n */\nexport function CommandValidationLogic(props: CommandValidationLogicProps) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration name=\"failures\" type=\"string[]\" initializer={code`[];`} />\n <hbr />\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 {code`failures.push(\"Missing required ${option.name} option\");`}\n </IfStatement>\n <Show when={option.variadic}>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`failures.push(\"No values were provided to the required ${\n option.name\n } array option\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <Show\n when={option.variadic}\n fallback={\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } && Number.isNaN(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\"Invalid numeric value provided for the ${\n option.name\n } option\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the ${\n option.name\n } array option\");`}\n </IfStatement>\n </Show>\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n <Show\n when={!option.variadic}\n fallback={\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the ${\n option.name\n } option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the ${\n option.name\n } option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n }>\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`![${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the ${\n option.name\n } option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`![${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the ${\n option.name\n } option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n {code`failures.push(\"Missing required \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n <Show\n when={\n (argument.kind === CommandParameterKinds.string ||\n argument.kind === CommandParameterKinds.number) &&\n argument.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`failures.push(\"No values were provided to the required ${\n argument.name\n } array positional argument\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={argument.kind === CommandParameterKinds.number}>\n <Show\n when={(argument as NumberCommandParameter).variadic}\n fallback={\n <IfStatement\n condition={code`${camelCase(\n argument.name\n )} && Number.isNaN(${camelCase(argument.name)})`}>\n {code`failures.push(\"Invalid numeric value provided for the ${\n argument.name\n } positional argument\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the ${\n argument.name\n } array positional argument\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n </>\n );\n}\n"],"mapp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AkB,MAAM;MAC7B,IAAI,OAAO;AACT,cAAQ,SAAS;;MAEnB,IAAI,WAAK;AACP,cAAO,gBAAA,aAAA;QACL,IAAI,YAAY;AACd,gBAAM,IAAA,GAAO,UAAG,SAAA,KAAsB,CAAC,mBAAE,UAAA,SAAA,KAAA,CAAA;;QAE3C,IAAI,WAAU;AACZ,gBAAO,IAAC,yDAAsC,SAAA,KAAA;;QAEjD,CAAC;;MAEJ,IAAI,WAAS;AACX,cAAO,gBAAe,aAAY;QAChC,IAAI,YAAY;AACd,gBAAO,IAAI,GAAG,UAAU,SAAO,KAAM,CAAA;;QAEvC,IAAI,WAAQ;AACV,gBAAM,IAAA,wDAAO,SAAA,KAAA;;QAEhB,CAAC;;MAEL,CAAC;;IAEL,CAAC,CAAC;GACJ,CAAC;EAAC"}
|
package/dist/components/docs.cjs
CHANGED
|
@@ -158,5 +158,4 @@ function CommandDocsFile(props) {
|
|
|
158
158
|
exports.CommandDocs = CommandDocs;
|
|
159
159
|
exports.CommandDocsFile = CommandDocsFile;
|
|
160
160
|
exports.CommandDocsUsageExample = CommandDocsUsageExample;
|
|
161
|
-
exports.CommandOptionsDocs = CommandOptionsDocs;
|
|
162
|
-
//# sourceMappingURL=docs.cjs.map
|
|
161
|
+
exports.CommandOptionsDocs = CommandOptionsDocs;
|
|
@@ -41,14 +41,7 @@ function ExecBuiltin(props) {
|
|
|
41
41
|
});
|
|
42
42
|
},
|
|
43
43
|
get builtinImports() {
|
|
44
|
-
return (0, defu.default)(rest.builtinImports ?? {}, { env: [
|
|
45
|
-
"isWindows",
|
|
46
|
-
"env",
|
|
47
|
-
{
|
|
48
|
-
name: "Env",
|
|
49
|
-
type: true
|
|
50
|
-
}
|
|
51
|
-
] });
|
|
44
|
+
return (0, defu.default)(rest.builtinImports ?? {}, { env: ["isWindows", "env"] });
|
|
52
45
|
},
|
|
53
46
|
get children() {
|
|
54
47
|
return [
|
|
@@ -60,32 +53,32 @@ function ExecBuiltin(props) {
|
|
|
60
53
|
}],
|
|
61
54
|
returnType: "NodeJS.ProcessEnv",
|
|
62
55
|
children: _alloy_js_core.code`const argv = params.argv;
|
|
63
|
-
const shouldSuppressNpmFund = (() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
const shouldSuppressNpmFund = (() => {
|
|
57
|
+
const cmd = basename(argv[0] ?? "");
|
|
58
|
+
if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (cmd === "node" || cmd === "node.exe") {
|
|
62
|
+
const script = argv[1] ?? "";
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})();
|
|
64
|
+
return script.includes("npm-cli.js");
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
})();
|
|
75
68
|
|
|
76
|
-
const result = Object.fromEntries(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
if (shouldSuppressNpmFund) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
return result; `
|
|
69
|
+
const result = Object.fromEntries(
|
|
70
|
+
Object.entries({
|
|
71
|
+
...env,
|
|
72
|
+
...(params.env ?? {})
|
|
73
|
+
})
|
|
74
|
+
.filter(([, value]) => value !== undefined)
|
|
75
|
+
.map(([key, value]) => [key, String(value)])
|
|
76
|
+
);
|
|
77
|
+
if (shouldSuppressNpmFund) {
|
|
78
|
+
result.NPM_CONFIG_FUND ??= "false";
|
|
79
|
+
result.npm_config_fund ??= "false";
|
|
80
|
+
}
|
|
81
|
+
return result; `
|
|
89
82
|
}),
|
|
90
83
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
91
84
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -96,11 +89,11 @@ return result; `
|
|
|
96
89
|
}],
|
|
97
90
|
returnType: "boolean",
|
|
98
91
|
children: _alloy_js_core.code`if (!isWindows) {
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
const ext = extname(resolvedCommand).toLowerCase();
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const ext = extname(resolvedCommand).toLowerCase();
|
|
102
95
|
|
|
103
|
-
return ext === ".cmd" || ext === ".bat"
|
|
96
|
+
return ext === ".cmd" || ext === ".bat"; `
|
|
104
97
|
}),
|
|
105
98
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
106
99
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -111,15 +104,15 @@ return ext === ".cmd" || ext === ".bat";`
|
|
|
111
104
|
}],
|
|
112
105
|
returnType: "string",
|
|
113
106
|
children: _alloy_js_core.code`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
return \`"\${arg.replace(/"/g, '""')}"
|
|
107
|
+
throw new Error(
|
|
108
|
+
\`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
|
|
109
|
+
"Pass an explicit shell-wrapper argv at the call site instead."
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
113
|
+
return arg;
|
|
114
|
+
}
|
|
115
|
+
return \`"\${arg.replace(/"/g, '""')}"\`; `
|
|
123
116
|
}),
|
|
124
117
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
125
118
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -133,8 +126,8 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
|
|
|
133
126
|
}],
|
|
134
127
|
returnType: "string",
|
|
135
128
|
children: _alloy_js_core.code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
|
|
136
|
-
|
|
137
|
-
)
|
|
129
|
+
" "
|
|
130
|
+
); `
|
|
138
131
|
}),
|
|
139
132
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
140
133
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -146,26 +139,26 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
|
|
|
146
139
|
}],
|
|
147
140
|
returnType: "string[] | null",
|
|
148
141
|
children: _alloy_js_core.code`if (!isWindows || argv.length === 0) {
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
const base = basename(argv[0] ?? "")
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const cliName =
|
|
155
|
-
|
|
156
|
-
if (!cliName) {
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
const nodeDir = dirname(process.execPath);
|
|
160
|
-
const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
|
|
161
|
-
if (!existsSync(cliPath)) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const base = basename(argv[0] ?? "")
|
|
145
|
+
.toLowerCase()
|
|
146
|
+
.replace(/\.(?:cmd|exe|bat)$/, "");
|
|
147
|
+
const cliName =
|
|
148
|
+
base === "npx" ? "npx-cli.js" : base === "npm" ? "npm-cli.js" : null;
|
|
149
|
+
if (!cliName) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const nodeDir = dirname(process.execPath);
|
|
153
|
+
const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
|
|
154
|
+
if (!existsSync(cliPath)) {
|
|
155
|
+
const command = argv[0] ?? "";
|
|
156
|
+
const ext = extname(command).toLowerCase();
|
|
157
|
+
const shimmedCommand = ext ? command : \`\${command}.cmd\`;
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
return [process.execPath, cliPath, ...argv.slice(1)]
|
|
159
|
+
return [shimmedCommand, ...argv.slice(1)];
|
|
160
|
+
}
|
|
161
|
+
return [process.execPath, cliPath, ...argv.slice(1)]; `
|
|
169
162
|
}),
|
|
170
163
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
171
164
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -177,16 +170,16 @@ return [process.execPath, cliPath, ...argv.slice(1)];`
|
|
|
177
170
|
}],
|
|
178
171
|
returnType: "string",
|
|
179
172
|
children: _alloy_js_core.code`if (!isWindows) {
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
const base = basename(command).toLowerCase();
|
|
183
|
-
if (extname(base)) {
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
if (["pnpm", "yarn"].includes(base)) {
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
return command
|
|
173
|
+
return command;
|
|
174
|
+
}
|
|
175
|
+
const base = basename(command).toLowerCase();
|
|
176
|
+
if (extname(base)) {
|
|
177
|
+
return command;
|
|
178
|
+
}
|
|
179
|
+
if (["pnpm", "yarn"].includes(base)) {
|
|
180
|
+
return \`\${command}.cmd\`;
|
|
181
|
+
}
|
|
182
|
+
return command; `
|
|
190
183
|
}),
|
|
191
184
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
192
185
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -197,12 +190,12 @@ return command;`
|
|
|
197
190
|
}],
|
|
198
191
|
returnType: "[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]",
|
|
199
192
|
children: _alloy_js_core.code`const stdin = params.hasInput
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
193
|
+
? "pipe"
|
|
194
|
+
: params.preferInherit
|
|
195
|
+
? "inherit"
|
|
196
|
+
: "pipe";
|
|
204
197
|
|
|
205
|
-
return [stdin, "pipe", "pipe"]
|
|
198
|
+
return [stdin, "pipe", "pipe"]; `
|
|
206
199
|
}),
|
|
207
200
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
208
201
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -213,16 +206,16 @@ return [stdin, "pipe", "pipe"];`
|
|
|
213
206
|
}],
|
|
214
207
|
returnType: "number | null",
|
|
215
208
|
children: _alloy_js_core.code`return (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
)
|
|
209
|
+
params.explicitCode ??
|
|
210
|
+
params.childExitCode ??
|
|
211
|
+
(params.usesWindowsExitCodeShim &&
|
|
212
|
+
params.resolvedSignal == null &&
|
|
213
|
+
!params.timedOut &&
|
|
214
|
+
!params.noOutputTimedOut &&
|
|
215
|
+
!params.killIssuedByTimeout
|
|
216
|
+
? 0
|
|
217
|
+
: null)
|
|
218
|
+
); `
|
|
226
219
|
}),
|
|
227
220
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
228
221
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -233,12 +226,12 @@ return [stdin, "pipe", "pipe"];`
|
|
|
233
226
|
}],
|
|
234
227
|
returnType: "boolean",
|
|
235
228
|
children: _alloy_js_core.code`// SECURITY: never enable \`shell\` for argv-based execution.
|
|
236
|
-
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
237
|
-
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
238
|
-
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
239
|
-
// and validate/escape at the call site.
|
|
240
|
-
void params;
|
|
241
|
-
return false
|
|
229
|
+
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
230
|
+
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
231
|
+
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
232
|
+
// and validate/escape at the call site.
|
|
233
|
+
void params;
|
|
234
|
+
return false; `
|
|
242
235
|
}),
|
|
243
236
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
244
237
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The result of a spawn operation." }),
|
|
@@ -717,5 +710,4 @@ return new Promise((resolve, reject) => {
|
|
|
717
710
|
}
|
|
718
711
|
|
|
719
712
|
//#endregion
|
|
720
|
-
exports.ExecBuiltin = ExecBuiltin;
|
|
721
|
-
//# sourceMappingURL=exec-builtin.cjs.map
|
|
713
|
+
exports.ExecBuiltin = ExecBuiltin;
|