@shell-shock/core 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/api.cjs +3 -2
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +0 -1
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +0 -1
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +1 -1
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +197 -0
- package/dist/components/command-validation-logic.cjs.map +1 -0
- package/dist/components/command-validation-logic.d.cts +14 -0
- package/dist/components/command-validation-logic.d.cts.map +1 -0
- package/dist/components/command-validation-logic.d.mts +14 -0
- package/dist/components/command-validation-logic.d.mts.map +1 -0
- package/dist/components/command-validation-logic.mjs +195 -0
- package/dist/components/command-validation-logic.mjs.map +1 -0
- package/dist/components/docs.cjs +45 -44
- package/dist/components/docs.cjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/helpers.cjs +16 -15
- package/dist/components/helpers.cjs.map +1 -1
- package/dist/components/helpers.d.cts +7 -8
- package/dist/components/helpers.d.cts.map +1 -1
- package/dist/components/helpers.d.mts +7 -8
- package/dist/components/helpers.d.mts.map +1 -1
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +3 -0
- package/dist/components/index.d.cts +2 -1
- package/dist/components/index.d.mts +2 -1
- package/dist/components/index.mjs +2 -1
- package/dist/components/options-parser-logic.cjs +187 -186
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +9 -9
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +9 -9
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.cjs +21 -20
- package/dist/components/usage.cjs.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.d.mts +2 -2
- package/dist/components/usage.d.mts.map +1 -1
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +128 -127
- package/dist/components/utils-builtin.cjs.map +1 -1
- 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 +4 -4
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +1 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +0 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +0 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +5 -4
- package/dist/contexts/command.cjs.map +1 -1
- package/dist/contexts/command.d.cts +0 -1
- package/dist/contexts/command.d.cts.map +1 -1
- package/dist/contexts/command.d.mts +0 -1
- package/dist/contexts/command.d.mts.map +1 -1
- package/dist/contexts/index.cjs +1 -0
- package/dist/contexts/options.cjs +12 -11
- package/dist/contexts/options.cjs.map +1 -1
- package/dist/contexts/options.d.cts +0 -1
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts +0 -1
- package/dist/contexts/options.d.mts.map +1 -1
- package/dist/contexts/options.mjs +3 -3
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +16 -16
- package/dist/helpers/automd.cjs.map +1 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +3 -3
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +26 -26
- package/dist/helpers/paths.cjs.map +1 -1
- package/dist/helpers/paths.mjs +1 -1
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +3 -3
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +16 -16
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +9 -9
- package/dist/helpers/utilities.cjs.map +1 -1
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.mts +0 -1
- package/dist/plugin-utils/context-helpers.cjs +10 -10
- package/dist/plugin-utils/context-helpers.cjs.map +1 -1
- package/dist/plugin-utils/context-helpers.d.cts +0 -3
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/context-helpers.d.mts +0 -3
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +1 -1
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +18 -18
- package/dist/plugin-utils/deepkit.cjs.map +1 -1
- package/dist/plugin-utils/deepkit.d.cts +0 -1
- package/dist/plugin-utils/deepkit.d.cts.map +1 -1
- package/dist/plugin-utils/deepkit.d.mts +0 -1
- package/dist/plugin-utils/deepkit.d.mts.map +1 -1
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs.map +1 -1
- package/dist/plugin-utils/description-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/description-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.d.cts +0 -1
- package/dist/plugin-utils/get-command-tree.d.cts.map +1 -1
- package/dist/plugin-utils/get-command-tree.d.mts +0 -1
- package/dist/plugin-utils/get-command-tree.d.mts.map +1 -1
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +1 -0
- package/dist/plugin-utils/reflect.cjs.map +1 -1
- package/dist/plugin-utils/reflect.d.cts +0 -1
- package/dist/plugin-utils/reflect.d.cts.map +1 -1
- package/dist/plugin-utils/reflect.d.mts +0 -1
- package/dist/plugin-utils/reflect.d.mts.map +1 -1
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.d.cts +0 -1
- package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.d.mts +0 -1
- package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +7 -7
- package/dist/plugin-utils/type-checks.cjs.map +1 -1
- package/dist/plugin-utils/type-checks.d.cts +0 -1
- package/dist/plugin-utils/type-checks.d.cts.map +1 -1
- package/dist/plugin-utils/type-checks.d.mts +0 -1
- package/dist/plugin-utils/type-checks.d.mts.map +1 -1
- package/dist/plugin-utils/type-checks.mjs +1 -1
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +68 -75
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +0 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +0 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +23 -30
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +29 -29
- package/dist/resolver/deepkit.cjs.map +1 -1
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +17 -17
- package/dist/resolver/helpers.cjs.map +1 -1
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +29 -29
- package/dist/resolver/module.cjs.map +1 -1
- package/dist/resolver/module.mjs +1 -1
- package/dist/resolver/module.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +17 -17
- package/dist/resolver/resolve.cjs.map +1 -1
- package/dist/resolver/resolve.mjs +3 -3
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +1 -0
- package/dist/types/command.cjs.map +1 -1
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -0
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -0
- package/dist/types/context.cjs.map +1 -1
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/env.cjs +1 -0
- package/dist/types/env.d.cts.map +1 -1
- package/dist/types/env.d.mts.map +1 -1
- package/dist/types/index.cjs +1 -0
- package/dist/types/options.cjs +1 -0
- package/dist/types/options.d.cts.map +1 -1
- package/dist/types/options.d.mts.map +1 -1
- package/dist/types/runtime.cjs +1 -0
- package/dist/types/runtime.d.cts.map +1 -1
- package/dist/types/runtime.d.mts.map +1 -1
- package/package.json +37 -23
package/dist/api.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_plugin = require('./plugin.cjs');
|
|
3
4
|
let powerlines = require("powerlines");
|
|
4
5
|
|
|
@@ -20,7 +21,7 @@ var ShellShockAPI = class ShellShockAPI {
|
|
|
20
21
|
return new ShellShockAPI(await (0, powerlines.createPowerlines)({
|
|
21
22
|
framework: "shell-shock",
|
|
22
23
|
...config,
|
|
23
|
-
plugins: [require_plugin.
|
|
24
|
+
plugins: [require_plugin.default(), ...config.plugins ?? []]
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
26
27
|
constructor(powerlines$1) {
|
package/dist/api.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.cjs","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 PowerlinesAPI,\n PrepareInlineConfig\n} from \"powerlines\";\nimport { createPowerlines } 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(config: UserConfig = {}): Promise<ShellShockAPI> {\n const powerlines = await createPowerlines({\n framework: \"shell-shock\",\n ...config,\n plugins: [plugin(), ...(config.plugins ?? [])] as PluginConfig<any>[]\n });\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 options.root ??= process.cwd();\n\n return ShellShockAPI.from(options);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.cjs","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 PowerlinesAPI,\n PrepareInlineConfig\n} from \"powerlines\";\nimport { createPowerlines } 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(config: UserConfig = {}): Promise<ShellShockAPI> {\n const powerlines = await createPowerlines({\n framework: \"shell-shock\",\n ...config,\n plugins: [plugin(), ...(config.plugins ?? [])] as PluginConfig<any>[]\n });\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 options.root ??= process.cwd();\n\n return ShellShockAPI.from(options);\n}\n"],"mappings":";;;;;;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;;;;;;AAS/D,IAAa,gBAAb,MAAa,cAAc;CAC1B;CACA,aAAgB,KAAK,SAAK,EAAM,EAAE;2BACR,uCAAsB;;GAE3C,GAAQ;;GAEL,CAAC;;CAGR,YAAA,cAAiB;AACjB,QAAA,aAAiB;;CAEjB,MAAA,MAAA,cAAgB;AAChB,SAAY,MAAA,WAAA,MAAA,aAAA;;CAEZ,MAAA,QAAA,cAAA;AACM,SAAA,MAAW,WAAA,QAAA,aAAA;;CAEnB,MAAS,KAAM,cAAW;AACnB,SAAO,MAAA,WAAkB,KAAG,aAAa;;CAE9C,MAAA,MAAA,cAAA;AACK,SAAM,MAAM,WAAS,MAAA,aAAA;;CAExB,MAAA,KAAA,cAAA;AACI,SAAM,MAAA,WAAiB,KAAG,aAAc;;CAEhD,MAAO,WAAM;AACV,SAAY,MAAA,WAAa,UAAA;;CAE1B,OAAO,SAAO;EAAK;EAAc;EAAe;SAAW,EAAA;QAAe;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;;;;;;;;AAQ5E,eAAE,iBAAA,UAAA,EAAA,EAAA;;AAEA,QAAQ,cAAY,KAAA,QAAY;;AAElC,iBAAE,SAAA;OAAA;CAAA;CAAA;QAAA,EAAA;OAAA;CAAA;CAAA;CAAA"}
|
package/dist/api.d.cts
CHANGED
package/dist/api.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.cts","names":[],"sources":["../src/api.ts"],"
|
|
1
|
+
{"version":3,"file":"api.d.cts","names":[],"sources":["../src/api.ts"],"mappings":";;;;;;AAqCA;;;;cAAa,aAAA;EAAA;SAGS,IAAA,CAAK,MAAA,GAAQ,UAAA,GAAkB,OAAA,CAAQ,aAAA;EAAA,QAUpD,WAAA,CAAA;EAIM,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAoB,OAAA;EAIxC,OAAA,CAAQ,YAAA,EAAc,mBAAA,GAAsB,OAAA;EAI5C,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAmB,OAAA;EAItC,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAoB,OAAA;EAIxC,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAmB,OAAA;EAItC,QAAA,CAAA,GAAY,OAAA;AAAA;;;;;;;iBAWL,gBAAA,CACpB,OAAA,GAAS,OAAA,CAAQ,UAAA,IAChB,OAAA,CAAQ,aAAA"}
|
package/dist/api.d.mts
CHANGED
package/dist/api.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.mts","names":[],"sources":["../src/api.ts"],"
|
|
1
|
+
{"version":3,"file":"api.d.mts","names":[],"sources":["../src/api.ts"],"mappings":";;;;;;AAqCA;;;;cAAa,aAAA;EAAA;SAGS,IAAA,CAAK,MAAA,GAAQ,UAAA,GAAkB,OAAA,CAAQ,aAAA;EAAA,QAUpD,WAAA,CAAA;EAIM,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAoB,OAAA;EAIxC,OAAA,CAAQ,YAAA,EAAc,mBAAA,GAAsB,OAAA;EAI5C,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAmB,OAAA;EAItC,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAoB,OAAA;EAIxC,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAmB,OAAA;EAItC,QAAA,CAAA,GAAY,OAAA;AAAA;;;;;;;iBAWL,gBAAA,CACpB,OAAA,GAAS,OAAA,CAAQ,UAAA,IAChB,OAAA,CAAQ,aAAA"}
|
package/dist/api.mjs
CHANGED
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 PowerlinesAPI,\n PrepareInlineConfig\n} from \"powerlines\";\nimport { createPowerlines } 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(config: UserConfig = {}): Promise<ShellShockAPI> {\n const powerlines = await createPowerlines({\n framework: \"shell-shock\",\n ...config,\n plugins: [plugin(), ...(config.plugins ?? [])] as PluginConfig<any>[]\n });\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 options.root ??= process.cwd();\n\n return ShellShockAPI.from(options);\n}\n"],"mappings":";;;;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;;;;;;AAS/D,IAAa,gBAAb,MAAa,cAAc;
|
|
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 PowerlinesAPI,\n PrepareInlineConfig\n} from \"powerlines\";\nimport { createPowerlines } 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(config: UserConfig = {}): Promise<ShellShockAPI> {\n const powerlines = await createPowerlines({\n framework: \"shell-shock\",\n ...config,\n plugins: [plugin(), ...(config.plugins ?? [])] as PluginConfig<any>[]\n });\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 options.root ??= process.cwd();\n\n return ShellShockAPI.from(options);\n}\n"],"mappings":";;;;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;;;;;;AAS/D,IAAa,gBAAb,MAAa,cAAc;CAC1B;CACA,aAAgB,KAAK,SAAK,EAAM,EAAE;2BACR,MAAM,iBAAgB;;GAE3C,GAAQ;;GAEL,CAAC;;CAGR,YAAA,YAAiB;AACjB,QAAA,aAAiB;;CAEjB,MAAA,MAAA,cAAgB;AAChB,SAAY,MAAA,WAAA,MAAA,aAAA;;CAEZ,MAAA,QAAA,cAAA;AACM,SAAA,MAAW,WAAA,QAAA,aAAA;;CAEnB,MAAS,KAAM,cAAW;AACnB,SAAO,MAAA,WAAkB,KAAG,aAAa;;CAE9C,MAAA,MAAA,cAAA;AACK,SAAM,MAAM,WAAS,MAAA,aAAA;;CAExB,MAAA,KAAA,cAAA;AACI,SAAM,MAAA,WAAiB,KAAG,aAAc;;CAEhD,MAAO,WAAM;AACV,SAAY,MAAA,WAAa,UAAA;;CAE1B,OAAO,SAAO;EAAK;EAAc;EAAe;SAAW,EAAA;QAAe;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;;;;;;;;AAQ5E,eAAE,iBAAA,UAAA,EAAA,EAAA;;AAEA,QAAQ,cAAY,KAAA,QAAY;;AAElC,iBAAE,SAAA;OAAA;CAAA;CAAA;QAAA,EAAA;OAAA;CAAA;CAAA;CAAA"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
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
|
+
/**
|
|
13
|
+
* A component that generates command validation logic for required options and arguments.
|
|
14
|
+
*/
|
|
15
|
+
function CommandValidationLogic(props) {
|
|
16
|
+
const { command } = props;
|
|
17
|
+
return [
|
|
18
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
19
|
+
name: "failures",
|
|
20
|
+
type: "string[]",
|
|
21
|
+
initializer: _alloy_js_core.code`[];`
|
|
22
|
+
}),
|
|
23
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
24
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
25
|
+
get each() {
|
|
26
|
+
return Object.values(command.options ?? {});
|
|
27
|
+
},
|
|
28
|
+
doubleHardline: true,
|
|
29
|
+
children: (option) => [
|
|
30
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
31
|
+
get when() {
|
|
32
|
+
return !option.optional;
|
|
33
|
+
},
|
|
34
|
+
get children() {
|
|
35
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
36
|
+
get condition() {
|
|
37
|
+
return _alloy_js_core.code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}`;
|
|
38
|
+
},
|
|
39
|
+
get children() {
|
|
40
|
+
return _alloy_js_core.code`failures.push("Missing required ${option.name} option");`;
|
|
41
|
+
}
|
|
42
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
43
|
+
get when() {
|
|
44
|
+
return (option.kind === require_types_command.CommandParameterKinds.string || option.kind === require_types_command.CommandParameterKinds.number) && option.variadic;
|
|
45
|
+
},
|
|
46
|
+
get children() {
|
|
47
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
48
|
+
get condition() {
|
|
49
|
+
return _alloy_js_core.code`options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, _stryke_string_format_camel_case.camelCase)(option.name)}`}.length === 0`;
|
|
50
|
+
},
|
|
51
|
+
get children() {
|
|
52
|
+
return _alloy_js_core.code`failures.push("No values were provided to the required ${option.name} array option");`;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
})];
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
60
|
+
get when() {
|
|
61
|
+
return option.kind === require_types_command.CommandParameterKinds.number;
|
|
62
|
+
},
|
|
63
|
+
get children() {
|
|
64
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
65
|
+
get when() {
|
|
66
|
+
return option.variadic;
|
|
67
|
+
},
|
|
68
|
+
get fallback() {
|
|
69
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
70
|
+
get condition() {
|
|
71
|
+
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)}`})`;
|
|
72
|
+
},
|
|
73
|
+
get children() {
|
|
74
|
+
return _alloy_js_core.code`failures.push("Invalid numeric value provided for the ${option.name} option");`;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
get children() {
|
|
79
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
80
|
+
get condition() {
|
|
81
|
+
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))`;
|
|
82
|
+
},
|
|
83
|
+
get children() {
|
|
84
|
+
return _alloy_js_core.code`failures.push("Invalid numeric value provided in the ${option.name} array option");`;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
92
|
+
get when() {
|
|
93
|
+
return (option.kind === require_types_command.CommandParameterKinds.string || option.kind === require_types_command.CommandParameterKinds.number) && option.choices && option.choices.length > 0;
|
|
94
|
+
},
|
|
95
|
+
get children() {
|
|
96
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
97
|
+
get when() {
|
|
98
|
+
return (option.kind === require_types_command.CommandParameterKinds.string || option.kind === require_types_command.CommandParameterKinds.number) && option.variadic;
|
|
99
|
+
},
|
|
100
|
+
get fallback() {
|
|
101
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
102
|
+
get condition() {
|
|
103
|
+
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))`;
|
|
104
|
+
},
|
|
105
|
+
get children() {
|
|
106
|
+
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)}`}}\`);`;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
get children() {
|
|
111
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
112
|
+
get condition() {
|
|
113
|
+
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)}`})`;
|
|
114
|
+
},
|
|
115
|
+
get children() {
|
|
116
|
+
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)}`}}\`);`;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
}),
|
|
125
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
126
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
127
|
+
get each() {
|
|
128
|
+
return command.args;
|
|
129
|
+
},
|
|
130
|
+
doubleHardline: true,
|
|
131
|
+
children: (argument) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
132
|
+
get when() {
|
|
133
|
+
return !argument.optional;
|
|
134
|
+
},
|
|
135
|
+
get children() {
|
|
136
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
137
|
+
get condition() {
|
|
138
|
+
return _alloy_js_core.code`!${(0, _stryke_string_format_camel_case.camelCase)(argument.name)}`;
|
|
139
|
+
},
|
|
140
|
+
get children() {
|
|
141
|
+
return _alloy_js_core.code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
|
|
142
|
+
}
|
|
143
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
144
|
+
get when() {
|
|
145
|
+
return (argument.kind === require_types_command.CommandParameterKinds.string || argument.kind === require_types_command.CommandParameterKinds.number) && argument.variadic;
|
|
146
|
+
},
|
|
147
|
+
get children() {
|
|
148
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
149
|
+
get condition() {
|
|
150
|
+
return _alloy_js_core.code`${(0, _stryke_string_format_camel_case.camelCase)(argument.name)}.length === 0`;
|
|
151
|
+
},
|
|
152
|
+
get children() {
|
|
153
|
+
return _alloy_js_core.code`failures.push("No values were provided to the required ${argument.name} array positional argument");`;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
})];
|
|
158
|
+
}
|
|
159
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
160
|
+
get when() {
|
|
161
|
+
return argument.kind === require_types_command.CommandParameterKinds.number;
|
|
162
|
+
},
|
|
163
|
+
get children() {
|
|
164
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
165
|
+
get when() {
|
|
166
|
+
return argument.variadic;
|
|
167
|
+
},
|
|
168
|
+
get fallback() {
|
|
169
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
170
|
+
get condition() {
|
|
171
|
+
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)})`;
|
|
172
|
+
},
|
|
173
|
+
get children() {
|
|
174
|
+
return _alloy_js_core.code`failures.push("Invalid numeric value provided for the ${argument.name} positional argument");`;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
get children() {
|
|
179
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
180
|
+
get condition() {
|
|
181
|
+
return _alloy_js_core.code`${(0, _stryke_string_format_camel_case.camelCase)(argument.name)}.some(value => Number.isNaN(value))`;
|
|
182
|
+
},
|
|
183
|
+
get children() {
|
|
184
|
+
return _alloy_js_core.code`failures.push("Invalid numeric value provided in the ${argument.name} array positional argument");`;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
})]
|
|
191
|
+
})
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
exports.CommandValidationLogic = CommandValidationLogic;
|
|
197
|
+
//# sourceMappingURL=command-validation-logic.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-validation-logic.cjs","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={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }\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 </Show>\n </>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;CAkCA,MAAO,EACL,YACF;;;GAEE,MAAA;GACE,MAAC;GACH,aAAA,mBAAA;GACF,CAAA;kDAAgB,OAAA,EAAA,CAAA;kDAA8B,oBAAA;GAC5C,IAAM,OAAE;;;GAGN,gBAAC;GACD,WAAG,WAAe;oDAAqB,qBAAC;KACtC,IAAI,OAAE;AACL,aAAQ,CAAC,OAAO;;KAEjB,IAAI,WAAC;AACH,aAAK,iDAAmB,kCAAS;OAC/B,IAAI,YAAC;AACH,eAAI,mBAAA,WAAiB,OAAQ,KAAA,SAAA,IAAA,GAAA,KAAA,OAAA,KAAA,MAAA,oDAAA,OAAA,KAAA;;OAE/B,IAAI,WAAW;AACb,eAAO,mBAAI,mCAA0B,OAAA,KAAA;;OAExC,CAAC,kDAAoB,qBAAM;OAC1B,IAAI,OAAE;AACJ,gBAAG,OAAA,SAAA,4CAAA,UAAA,OAAA,SAAA,4CAAA,WAAA,OAAA;;OAEL,IAAI,WAAW;AACb,+DAAwB,mCAAA;SACtB,IAAI,YAAO;AACT,iBAAC,mBAAA,UAAA,OAAA,KAAA,SAAA,IAAA,GAAA,KAAA,OAAA,KAAA,MAAA,oDAAA,OAAA,KAAA,GAAA;;SAEH,IAAI,WAAW;AACb,iBAAI,mBAAO,0DAAiB,OAAA,KAAA;;SAE/B,CAAC;;OAEL,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AAA,SAAA,4CAAA,WAAA,SAAA;;MAExB,IAAI,WAAW;AACb,8DAAc,mCAAA;QACZ,IAAI,YAAE;AACJ,gBAAK,mBAAM,mDAAO,SAAS,KAAQ,CAAA;;QAErC,IAAI,WAAW;AACb,gBAAO,mBAAI,0DAAwB,SAAA,KAAA;;QAEtC,CAAC;;MAEL,CAAC,CAAC;;IAEN,CAAC,kDAAgB,qBAAU;IAC1B,IAAI,OAAO;AACT,YAAO,SAAO,SAAW,4CAAU;;IAErC,IAAI,WAAW;AACb,4DAAoB,qBAAU;MAC5B,IAAI,OAAO;AACT,cAAM,SAAY;;MAEpB,IAAI,WAAI;AACN,8DAAA,kCAAA;QACH,IAAA,YAAA;AACE,gBAAA,mBAAA,mDAAA,SAAA,KAAA,CAAA,mEAAA,SAAA,KAAA,CAAA;;QAEA,IAAM,WAAY;AACpB,gBAAY,mBAAA,yDAAA,SAAA,KAAA;;QAER,CAAA;;MAEH,IAAI,WAAQ;AACV,8DAAe,kCAAA;QACb,IAAI,YAAG;AACL,gBAAA,mBAAW,mDAAA,SAAA,KAAA,CAAA;;QAEb,IAAE,WAAK;AACL,gBAAG,mBAAQ,wDAAwC,SAAA,KAAA;;QAEtD,CAAC;;MAEL,CAAC;;IAEL,CAAC,CAAC;GACJ,CAAC;EAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommandTree } from "../types/command.cjs";
|
|
2
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
3
|
+
|
|
4
|
+
//#region src/components/command-validation-logic.d.ts
|
|
5
|
+
interface CommandValidationLogicProps {
|
|
6
|
+
command: CommandTree;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A component that generates command validation logic for required options and arguments.
|
|
10
|
+
*/
|
|
11
|
+
declare function CommandValidationLogic(props: CommandValidationLogicProps): _alloy_js_core0.Children;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CommandValidationLogic, CommandValidationLogicProps };
|
|
14
|
+
//# sourceMappingURL=command-validation-logic.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-validation-logic.d.cts","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"mappings":";;;;UAkCiB,2BAAA;EACf,OAAA,EAAS,WAAA;AAAA;;AADX;;iBAOgB,sBAAA,CAAuB,KAAA,EAAO,2BAAA,GAA2B,eAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommandTree } from "../types/command.mjs";
|
|
2
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
3
|
+
|
|
4
|
+
//#region src/components/command-validation-logic.d.ts
|
|
5
|
+
interface CommandValidationLogicProps {
|
|
6
|
+
command: CommandTree;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A component that generates command validation logic for required options and arguments.
|
|
10
|
+
*/
|
|
11
|
+
declare function CommandValidationLogic(props: CommandValidationLogicProps): _alloy_js_core0.Children;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CommandValidationLogic, CommandValidationLogicProps };
|
|
14
|
+
//# sourceMappingURL=command-validation-logic.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-validation-logic.d.mts","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"mappings":";;;;UAkCiB,2BAAA;EACf,OAAA,EAAS,WAAA;AAAA;;AADX;;iBAOgB,sBAAA,CAAuB,KAAA,EAAO,2BAAA,GAA2B,eAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { CommandParameterKinds } from "../types/command.mjs";
|
|
2
|
+
import { createComponent, createIntrinsic, memo } 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
|
+
/**
|
|
11
|
+
* A component that generates command validation logic for required options and arguments.
|
|
12
|
+
*/
|
|
13
|
+
function CommandValidationLogic(props) {
|
|
14
|
+
const { command } = props;
|
|
15
|
+
return [
|
|
16
|
+
createComponent(VarDeclaration, {
|
|
17
|
+
name: "failures",
|
|
18
|
+
type: "string[]",
|
|
19
|
+
initializer: code`[];`
|
|
20
|
+
}),
|
|
21
|
+
createIntrinsic("hbr", {}),
|
|
22
|
+
createComponent(For, {
|
|
23
|
+
get each() {
|
|
24
|
+
return Object.values(command.options ?? {});
|
|
25
|
+
},
|
|
26
|
+
doubleHardline: true,
|
|
27
|
+
children: (option) => [
|
|
28
|
+
createComponent(Show, {
|
|
29
|
+
get when() {
|
|
30
|
+
return !option.optional;
|
|
31
|
+
},
|
|
32
|
+
get children() {
|
|
33
|
+
return [createComponent(IfStatement, {
|
|
34
|
+
get condition() {
|
|
35
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
|
|
36
|
+
},
|
|
37
|
+
get children() {
|
|
38
|
+
return code`failures.push("Missing required ${option.name} option");`;
|
|
39
|
+
}
|
|
40
|
+
}), createComponent(Show, {
|
|
41
|
+
get when() {
|
|
42
|
+
return (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic;
|
|
43
|
+
},
|
|
44
|
+
get children() {
|
|
45
|
+
return createComponent(ElseIfClause, {
|
|
46
|
+
get condition() {
|
|
47
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
|
|
48
|
+
},
|
|
49
|
+
get children() {
|
|
50
|
+
return code`failures.push("No values were provided to the required ${option.name} array option");`;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
})];
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
createComponent(Show, {
|
|
58
|
+
get when() {
|
|
59
|
+
return option.kind === CommandParameterKinds.number;
|
|
60
|
+
},
|
|
61
|
+
get children() {
|
|
62
|
+
return createComponent(Show, {
|
|
63
|
+
get when() {
|
|
64
|
+
return option.variadic;
|
|
65
|
+
},
|
|
66
|
+
get fallback() {
|
|
67
|
+
return createComponent(IfStatement, {
|
|
68
|
+
get condition() {
|
|
69
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} && Number.isNaN(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
return code`failures.push("Invalid numeric value provided for the ${option.name} option");`;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
get children() {
|
|
77
|
+
return createComponent(IfStatement, {
|
|
78
|
+
get condition() {
|
|
79
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.some(value => Number.isNaN(value))`;
|
|
80
|
+
},
|
|
81
|
+
get children() {
|
|
82
|
+
return code`failures.push("Invalid numeric value provided in the ${option.name} array option");`;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
createComponent(Show, {
|
|
90
|
+
get when() {
|
|
91
|
+
return (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.choices && option.choices.length > 0;
|
|
92
|
+
},
|
|
93
|
+
get children() {
|
|
94
|
+
return createComponent(Show, {
|
|
95
|
+
get when() {
|
|
96
|
+
return (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic;
|
|
97
|
+
},
|
|
98
|
+
get fallback() {
|
|
99
|
+
return createComponent(ElseIfClause, {
|
|
100
|
+
get condition() {
|
|
101
|
+
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))`;
|
|
102
|
+
},
|
|
103
|
+
get children() {
|
|
104
|
+
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)}`}}\`);`;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
get children() {
|
|
109
|
+
return createComponent(ElseIfClause, {
|
|
110
|
+
get condition() {
|
|
111
|
+
return code`![${option.choices?.map((choice) => option.kind === CommandParameterKinds.string ? `"${choice}"` : choice).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
112
|
+
},
|
|
113
|
+
get children() {
|
|
114
|
+
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)}`}}\`);`;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
}),
|
|
123
|
+
createComponent(Spacing, {}),
|
|
124
|
+
createComponent(For, {
|
|
125
|
+
get each() {
|
|
126
|
+
return command.args;
|
|
127
|
+
},
|
|
128
|
+
doubleHardline: true,
|
|
129
|
+
children: (argument) => [createComponent(Show, {
|
|
130
|
+
get when() {
|
|
131
|
+
return !argument.optional;
|
|
132
|
+
},
|
|
133
|
+
get children() {
|
|
134
|
+
return [createComponent(IfStatement, {
|
|
135
|
+
get condition() {
|
|
136
|
+
return code`!${camelCase(argument.name)}`;
|
|
137
|
+
},
|
|
138
|
+
get children() {
|
|
139
|
+
return code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
|
|
140
|
+
}
|
|
141
|
+
}), createComponent(Show, {
|
|
142
|
+
get when() {
|
|
143
|
+
return (argument.kind === CommandParameterKinds.string || argument.kind === CommandParameterKinds.number) && argument.variadic;
|
|
144
|
+
},
|
|
145
|
+
get children() {
|
|
146
|
+
return createComponent(ElseIfClause, {
|
|
147
|
+
get condition() {
|
|
148
|
+
return code`${camelCase(argument.name)}.length === 0`;
|
|
149
|
+
},
|
|
150
|
+
get children() {
|
|
151
|
+
return code`failures.push("No values were provided to the required ${argument.name} array positional argument");`;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
})];
|
|
156
|
+
}
|
|
157
|
+
}), createComponent(Show, {
|
|
158
|
+
get when() {
|
|
159
|
+
return argument.kind === CommandParameterKinds.number;
|
|
160
|
+
},
|
|
161
|
+
get children() {
|
|
162
|
+
return createComponent(Show, {
|
|
163
|
+
get when() {
|
|
164
|
+
return argument.variadic;
|
|
165
|
+
},
|
|
166
|
+
get fallback() {
|
|
167
|
+
return createComponent(IfStatement, {
|
|
168
|
+
get condition() {
|
|
169
|
+
return code`${camelCase(argument.name)} && Number.isNaN(${camelCase(argument.name)})`;
|
|
170
|
+
},
|
|
171
|
+
get children() {
|
|
172
|
+
return code`failures.push("Invalid numeric value provided for the ${argument.name} positional argument");`;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
get children() {
|
|
177
|
+
return createComponent(IfStatement, {
|
|
178
|
+
get condition() {
|
|
179
|
+
return code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`;
|
|
180
|
+
},
|
|
181
|
+
get children() {
|
|
182
|
+
return code`failures.push("Invalid numeric value provided in the ${argument.name} array positional argument");`;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
})]
|
|
189
|
+
})
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
//#endregion
|
|
194
|
+
export { CommandValidationLogic };
|
|
195
|
+
//# sourceMappingURL=command-validation-logic.mjs.map
|
|
@@ -0,0 +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={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic\n }\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 </Show>\n </>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;CAkCA,MAAO,EACL,YACF;;;GAEE,MAAA;GACE,MAAC;GACH,aAAA,IAA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