@shell-shock/core 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/command-validation-logic.cjs +1 -1
- package/dist/components/command-validation-logic.cjs.map +1 -1
- package/dist/components/command-validation-logic.mjs +1 -1
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +38 -39
- package/dist/components/exec-builtin.cjs.map +1 -1
- package/dist/components/exec-builtin.mjs +38 -39
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/options-parser-logic.cjs +14 -6
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +2 -5
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +2 -5
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +14 -6
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +43 -8
- package/dist/components/state-builtin.cjs.map +1 -1
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts.map +1 -1
- package/dist/components/state-builtin.mjs +44 -9
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +10 -3
- 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 +10 -3
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +1 -1
- package/dist/resolver/resolve.cjs.map +1 -1
- package/dist/resolver/resolve.mjs +1 -1
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +1 -1
- package/dist/types/config.d.mts +1 -1
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/env.cjs +1 -1
- package/dist/types/env.cjs.map +1 -1
- package/dist/types/env.d.cts +7 -1
- package/dist/types/env.d.cts.map +1 -1
- package/dist/types/env.d.mts +7 -1
- package/dist/types/env.d.mts.map +1 -1
- package/dist/types/env.mjs +1 -1
- package/dist/types/env.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommandOption, CommandTree } from "../types/command.cjs";
|
|
2
|
+
import { PartialKeys } from "@stryke/types/base";
|
|
2
3
|
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
3
4
|
|
|
4
5
|
//#region src/components/options-parser-logic.d.ts
|
|
@@ -76,11 +77,7 @@ declare function OptionsMemberParserCondition(props: OptionsMemberParserConditio
|
|
|
76
77
|
declare function OptionsInterfaceDeclaration(props: {
|
|
77
78
|
command: CommandTree;
|
|
78
79
|
}): _$_alloy_js_core0.Children;
|
|
79
|
-
interface OptionsParserLogicProps {
|
|
80
|
-
/**
|
|
81
|
-
* The command to generate the options parser logic for.
|
|
82
|
-
*/
|
|
83
|
-
command: CommandTree;
|
|
80
|
+
interface OptionsParserLogicProps extends PartialKeys<Pick<CommandTree, "segments" | "options" | "name">, "segments" | "name"> {
|
|
84
81
|
/**
|
|
85
82
|
* The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).
|
|
86
83
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-parser-logic.d.cts","names":[],"sources":["../../src/components/options-parser-logic.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"options-parser-logic.d.cts","names":[],"sources":["../../src/components/options-parser-logic.tsx"],"mappings":";;;;;UAgDiB,+BAAA;;;AAAjB;EAIE,OAAA,EAAS,WAAA;;;;EAKT,eAAA;AAAA;AAAA,iBAGc,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,iBAAA,CAAA,QAAA;AAAA,UA4BvB,yBAAA;EA7BD;;;EAiCd,OAAA,EAA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
|
|
4
5
|
//#region src/components/options-parser-logic.d.ts
|
|
5
6
|
interface DynamicSegmentsParserLogicProps {
|
|
@@ -76,11 +77,7 @@ declare function OptionsMemberParserCondition(props: OptionsMemberParserConditio
|
|
|
76
77
|
declare function OptionsInterfaceDeclaration(props: {
|
|
77
78
|
command: CommandTree;
|
|
78
79
|
}): _$_alloy_js_core0.Children;
|
|
79
|
-
interface OptionsParserLogicProps {
|
|
80
|
-
/**
|
|
81
|
-
* The command to generate the options parser logic for.
|
|
82
|
-
*/
|
|
83
|
-
command: CommandTree;
|
|
80
|
+
interface OptionsParserLogicProps extends PartialKeys<Pick<CommandTree, "segments" | "options" | "name">, "segments" | "name"> {
|
|
84
81
|
/**
|
|
85
82
|
* The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).
|
|
86
83
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-parser-logic.d.mts","names":[],"sources":["../../src/components/options-parser-logic.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"options-parser-logic.d.mts","names":[],"sources":["../../src/components/options-parser-logic.tsx"],"mappings":";;;;;UAgDiB,+BAAA;;;AAAjB;EAIE,OAAA,EAAS,WAAA;;;;EAKT,eAAA;AAAA;AAAA,iBAGc,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,iBAAA,CAAA,QAAA;AAAA,UA4BvB,yBAAA;EA7BD;;;EAiCd,OAAA,EAAS,WAAA;EAhCF;;;EAqCP,oBAAA;EArCsC;AA4BxC;;EAcE,eAAA;AAAA;AAAA,iBAGc,oBAAA,CAAqB,KAAA,EAAO,yBAAA,GAAyB,iBAAA,CAAA,QAAA;;;;iBA4KrD,aAAA,CAAA;EAAgB;AAAA;EAAY,MAAA,EAAQ,aAAA;AAAA,IAAa,iBAAA,CAAE,QAAA;AAAA,UAmClD,6BAAA;;;;EAIf,IAAA;EAnNmE;;;EAwNnE,MAAA,EAAQ,aAAA;EA5CmB;;;;;EAmD3B,eAAA;AAAA;;;;iBAMc,wBAAA,CAAyB,KAAA,EAAO,6BAAA,GAA6B,iBAAA,CAAA,QAAA;AAAA,UAsO5D,iCAAA;EA/RgD;;AAmCjE;EAgQE,IAAA;;;;EAKA,KAAA;EA5PQ;;;;AAaV;EAsPE,eAAA;AAAA;AAAA,iBAGc,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,iBAAA,CAAA,QAAA;AAAA,iBAkE1B,2BAAA,CAA4B,KAAA;EAAS,OAAA,EAAS,WAAA;AAAA,IAAW,iBAAA,CAAE,QAAA;AAAA,UAwB1D,uBAAA,SAAgC,WAAA,CAC/C,IAAA,CAAK,WAAA;EArVsE;AAsO7E;;EAqHE,oBAAA;EArHgD;;;;;EA4HhD,eAAA;AAAA;;;;iBAMc,kBAAA,CAAmB,KAAA,EAAO,uBAAA,GAAuB,iBAAA,CAAA,QAAA;AAAA,UAuJhD,uBAAA;EArQyB;;;EAyQxC,OAAA,EAAS,WAAA;EAvMgC;;;EA4MzC,oBAAA;EA5M4D;;;;;EAmN5D,eAAA;AAAA;;;;iBAMc,kBAAA,CAAmB,KAAA,EAAO,uBAAA,GAAuB,iBAAA,CAAA,QAAA"}
|
|
@@ -590,8 +590,8 @@ function OptionsInterfaceDeclaration(props) {
|
|
|
590
590
|
* The command options parser logic.
|
|
591
591
|
*/
|
|
592
592
|
function OptionsParserLogic(props) {
|
|
593
|
-
const {
|
|
594
|
-
const options = computed(() => computedOptions(Object.entries(
|
|
593
|
+
const { segments = [], options: _options, name: _name, appSpecificEnvPrefix, isCaseSensitive = false } = props;
|
|
594
|
+
const options = computed(() => computedOptions(Object.entries(_options).map(([name, option]) => ({
|
|
595
595
|
...option,
|
|
596
596
|
name
|
|
597
597
|
}))));
|
|
@@ -601,17 +601,17 @@ function OptionsParserLogic(props) {
|
|
|
601
601
|
name: "options",
|
|
602
602
|
get initializer() {
|
|
603
603
|
return code` {
|
|
604
|
-
${Object.entries(options.value).filter(([, option]) => option.env || option.default !== void 0 || (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic).map(([name, option]) => {
|
|
604
|
+
${segments.length > 0 ? "...useGlobalOptions(), " : ""}${Object.entries(options.value).filter(([, option]) => option.env || option.default !== void 0 || (option.kind === CommandParameterKinds.string || option.kind === CommandParameterKinds.number) && option.variadic).map(([name, option]) => {
|
|
605
605
|
if (option.kind === CommandParameterKinds.string) return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default !== void 0 ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}"${option.default}"` : ""}, `;
|
|
606
606
|
else if (option.kind === CommandParameterKinds.number) return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default && Array.isArray(option.default) ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}${option.default}` : ""}, `;
|
|
607
607
|
else if (option.kind === CommandParameterKinds.boolean) return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env} ?? ` : ""}${option.default ? "true" : "false"},`;
|
|
608
608
|
return "";
|
|
609
609
|
}).join("")}
|
|
610
|
-
} as unknown as ${pascalCase(
|
|
610
|
+
} as unknown as ${segments.length > 0 ? pascalCase(_name) : "Global"}Options;`;
|
|
611
611
|
}
|
|
612
612
|
}),
|
|
613
613
|
createComponent(Spacing, {}),
|
|
614
|
-
memo(() => code`for (let i = 0; i < args.slice(${
|
|
614
|
+
memo(() => code`for (let i = 0; i < args.slice(${segments.filter((segment) => isDynamicPathSegment(segment)).length}).length; i++) { `),
|
|
615
615
|
createIntrinsic("hbr", {}),
|
|
616
616
|
createComponent(VarDeclaration, {
|
|
617
617
|
"const": true,
|
|
@@ -690,7 +690,15 @@ function CommandParserLogic(props) {
|
|
|
690
690
|
}),
|
|
691
691
|
createComponent(Spacing, {}),
|
|
692
692
|
createComponent(OptionsParserLogic, {
|
|
693
|
-
|
|
693
|
+
get name() {
|
|
694
|
+
return command.name;
|
|
695
|
+
},
|
|
696
|
+
get options() {
|
|
697
|
+
return command.options;
|
|
698
|
+
},
|
|
699
|
+
get segments() {
|
|
700
|
+
return command.segments;
|
|
701
|
+
},
|
|
694
702
|
appSpecificEnvPrefix,
|
|
695
703
|
isCaseSensitive
|
|
696
704
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-parser-logic.mjs","names":[],"sources":["../../src/components/options-parser-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, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\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 { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { computedOptions } from \"../contexts/options\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { BooleanInputParserLogic, CommandParameterType } from \"./helpers\";\n\nexport interface DynamicSegmentsParserLogicProps {\n /**\n * The command to generate the dynamic path segments parser logic for. This is used to access the command options and parameters when generating the parser logic for dynamic path segments.\n */\n command: CommandTree;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function DynamicSegmentsParserLogic(\n props: DynamicSegmentsParserLogicProps\n) {\n const { command } = props;\n\n return (\n <For each={command.segments ?? []}>\n {(segment, index) => (\n <Show when={isDynamicPathSegment(segment)}>\n <VarDeclaration\n let\n name={camelCase(getDynamicPathSegmentName(segment))}\n type=\"string | undefined\"\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${2 + index} && args[${2 + index}]`}>\n {code`${camelCase(\n getDynamicPathSegmentName(segment)\n )} = args[${2 + index}];`}\n </IfStatement>\n <hbr />\n <hbr />\n </Show>\n )}\n </For>\n );\n}\n\nexport interface ArgumentsParserLogicProps {\n /**\n * The command to generate the positional parameters parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function ArgumentsParserLogic(props: ArgumentsParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive } = props;\n\n return (\n <Show when={command.args && command.args.length > 0}>\n <VarDeclaration\n let\n name=\"optionsIndex\"\n type=\"number\"\n initializer={code`Math.max(0, args.slice(${\n command.segments.length + 1\n }).findIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1};`}\n />\n <Spacing />\n <VarDeclaration\n let\n name=\"argsIndex\"\n type=\"number\"\n initializer={code`optionsIndex > ${\n command.segments.length + 1\n } ? ${command.segments.length + 1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1});`}\n />\n <Spacing />\n <For each={command.args ?? []} hardline>\n {(arg, index) => (\n <>\n <Show\n when={\n isSetString(arg.env) ||\n arg.default !== undefined ||\n ((arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic)\n }\n fallback={\n <>\n {code`let ${camelCase(arg.name)}!: `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }>\n <VarDeclaration\n let\n name={camelCase(arg.name)}\n type={<CommandParameterType parameter={arg} />}\n initializer={\n <>\n {code` ( `}\n <Show when={isSetString(arg.env)}>\n {code`env.${appSpecificEnvPrefix}_${constantCase(String(arg.env))} ?? `}\n </Show>\n <Show\n when={arg.default !== undefined}\n fallback={arg.variadic ? code`[]` : code`undefined`}>\n {arg.kind === CommandParameterKinds.string\n ? code`\"${arg.default}\"`\n : code`${arg.default}`}\n </Show>\n {code`) as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }\n />\n </Show>\n <Spacing />\n <IfStatement\n condition={code`argsIndex + ${index} < args.length && argsIndex + ${index} !== optionsIndex`}>\n {code`${camelCase(arg.name)} = `}\n <Show\n when={\n arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number\n }\n fallback={\n <BooleanInputParserLogic\n name={`args[argsIndex + ${index}] `}\n />\n }>\n <Show\n when={arg.variadic}\n fallback={\n <Show\n when={arg.kind === CommandParameterKinds.number}\n fallback={code`args[argsIndex + ${index}] `}>\n {code`Number(args[argsIndex + ${index}]) `}\n </Show>\n }>\n {code`args.slice(argsIndex + ${\n index\n }, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${\n command.args.length - index\n }).join(\" \").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean)`}\n </Show>\n </Show>\n {code` as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </IfStatement>\n <Spacing />\n </>\n )}\n </For>\n </Show>\n );\n}\n\n/**\n * The command option interface property.\n */\nexport function OptionsMember({ option }: { option: CommandOption }) {\n const doc = option.description || `The ${option.title} command option.`;\n\n return (\n <>\n <Show when={Boolean(option.name)}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserLogicProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * The command option to generate the parser logic for.\n */\n option: CommandOption;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\n/**\n * The command option property parser logic.\n */\nexport function OptionsMemberParserLogic(props: OptionsMemberParserLogicProps) {\n const { name, option, isCaseSensitive } = props;\n\n const equalsRegex = `/^--?(${\n isCaseSensitive || name.length === 1\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")})=/`;\n\n return (\n <>\n <Show\n when={\n option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number\n }>\n <Show\n when={\n (option as StringCommandParameter | NumberCommandParameter).variadic\n }>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} ??= []; `}>\n {code`options[\"${name}\"] ??= []; `}\n </Show>\n <hbr />\n <IfStatement\n condition={`${equalsRegex}.test(${\n isCaseSensitive\n ? \"arg\"\n : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n })`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\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 {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\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 {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </ElseIfClause>\n </Show>\n <Show\n when={\n !(option as StringCommandParameter | NumberCommandParameter)\n .variadic\n }>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices\n ?.map(choice => `\"${choice}\"`)\n .join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices?.map(choice => `\"${choice}\"`).join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </ElseIfClause>\n <hbr />\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\").toLowerCase(); `}\n />\n <hbr />\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = `}>\n {code`options[\"${name}\"] = `}\n </Show>\n <BooleanInputParserLogic name=\"value\" />\n </IfStatement>\n <ElseClause>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = true; `}>\n {code`options[\"${name}\"] = true; `}\n </Show>\n </ElseClause>\n <Show when={Boolean((option as BooleanCommandOption).isNegativeOf)}>\n <hbr />\n <Show\n when={\n (option as BooleanCommandOption).isNegativeOf!.includes(\"?\") ||\n (option as BooleanCommandOption).isNegativeOf!.includes(\"-\")\n }\n fallback={code`options.${(option as BooleanCommandOption).isNegativeOf} = false; `}>\n {code`options[\"${(option as BooleanCommandOption).isNegativeOf}\"] = false; `}\n </Show>\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserConditionProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * Aliases for the option, which will also be parsed in the generated code. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n alias?: string[];\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\nexport function OptionsMemberParserCondition(\n props: OptionsMemberParserConditionProps\n) {\n const { name, alias: aliasProp, isCaseSensitive } = props;\n\n return (\n <>\n {code`${\n isCaseSensitive\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`}\n <Show when={aliasProp && aliasProp.length > 0}>\n <For each={aliasProp ?? []}>\n {alias =>\n code` || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`\n }\n </For>\n </Show>\n </>\n );\n}\n\nexport function OptionsInterfaceDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(command.options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <InterfaceDeclaration\n export\n name={`${pascalCase(command.name)}Options`}\n extends=\"GlobalOptions\">\n <For each={Object.values(options.value)} hardline>\n {option => <OptionsMember option={option} />}\n </For>\n </InterfaceDeclaration>\n );\n}\n\nexport interface OptionsParserLogicProps {\n /**\n * The command to generate the options parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command options parser logic.\n */\nexport function OptionsParserLogic(props: OptionsParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(command.options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <>\n <VarDeclaration\n const\n name=\"options\"\n initializer={code` {\n ${Object.entries(options.value)\n .filter(\n ([, option]) =>\n option.env ||\n option.default !== undefined ||\n ((option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic)\n )\n .map(([name, option]) => {\n if (option.kind === CommandParameterKinds.string) {\n return ` ${\n name.includes(\"?\") || name.includes(\"-\")\n ? `\"${name}\"`\n : `${name}`\n }: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default !== undefined\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}\"${option.default}\"`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.number) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default && Array.isArray(option.default)\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}${option.default}`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.boolean) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env\n ? `env.${appSpecificEnvPrefix}_${option.env} ?? `\n : \"\"\n }${option.default ? \"true\" : \"false\"},`;\n }\n\n return \"\";\n })\n .join(\"\")}\n } as unknown as ${pascalCase(command.name)}Options;`}\n />\n <Spacing />\n {code`for (let i = 0; i < args.slice(${\n command.segments.filter(segment => isDynamicPathSegment(segment)).length\n }).length; i++) { `}\n <hbr />\n <VarDeclaration\n const\n name=\"arg\"\n type=\"string\"\n initializer={code` args[i].length > 3 && args[i].startsWith(\"--\")\n ? \\`--\\${args[i].slice(2).replaceAll(\"-\", \"\")${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }}\\`\n : args[i].length > 2 && args[i].startsWith(\"-\")\n ? \\`-\\${args[i].slice(1).replaceAll(\"-\", \"\")}\\`\n : args[i]; `}\n />\n <hbr />\n\n <For each={Object.entries(options.value)} hardline>\n {([name, option], i) => (\n <Show\n when={i === 0}\n fallback={\n <ElseIfClause\n condition={\n <>\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n </>\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </ElseIfClause>\n }>\n <IfStatement\n condition={\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </IfStatement>\n </Show>\n )}\n </For>\n\n <hbr />\n {code` } `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandParserLogicProps {\n /**\n * The command to generate the parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.\n */\nexport function CommandParserLogic(props: CommandParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;\n\n return (\n <>\n <DynamicSegmentsParserLogic\n command={command}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <OptionsParserLogic\n command={command}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <ArgumentsParserLogic\n command={command}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,SAAE,2BAAA,OAAA;CACA,MAAM,EACR,YACM;;EAEN,IAAO,OAAA;AACH,UAAA,QAAA,YAAA,EAAA;;EAEA,WAAA,SAAA,UAAA,gBAAA,MAAA;GACF,IAAQ,OAAC;;;GAGN,IAAA,WAAY;AACb,WAAA;KAAA,gBAAA,gBAAA;MACF,OAAe;MACjB,IAAA,OAAA;;;MAGS,MAAA;MACP,CAAA;KAAA,gBAAA,OAAA,EAAA,CAAA;KAAA,gBAAA,aAAA;MACQ,WAAW,IAAC,iBAAK,IAAA,MAAA,WAAA,IAAA,MAAA;;AAElB,cAAA,IAAA,GAAA,UAAA,0BAAA,QAAA,CAAA,CAAA,UAAA,IAAA,MAAA;;MAED,CAAA;KAAA,gBAAmB,OAAA,EAAA,CAAA;KAAA,gBAAA,OAAA,EAAA,CAAA;KAAA;;GAEtB,CAAC;EACH,CAAC;;;CAmBJ,MAAO,EACH,SACA,sBACA,oBACF;;EAEE,IAA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E,gBAAkB,OAAO,EAAE,CAAC;EAAA,IAAA;EAAA,gBAA8B,OAAA,EAAA,CAAA;EAAA;;;;;AAwBhE,SAAgB,mBAAS,OAAA;CACvB,MAAM,EACJ,SACA,sBACA,kBAAkB,UAChB;AACJ,QAAO;EAAC,gBAAkB,4BAAK;GACpB;GACQ;GAClB,CAAC;EAAE,gBAAkB,SAAS,EAAC,CAAA;EAAI,gBAAgB,oBAAe;GACxD;GACO;GACC;GAClB,CAAC;EAAE,gBAAkB,SAAQ,EAAA,CAAA;EAAA,gBAAsB,sBAAwB;GACjE;GACa;GACL;GAClB,CAAC;EAAE,gBAAa,SAAc,EAAE,CAAC;EAAC"}
|
|
1
|
+
{"version":3,"file":"options-parser-logic.mjs","names":[],"sources":["../../src/components/options-parser-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, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\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 { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { PartialKeys } from \"@stryke/types/base\";\nimport { computedOptions } from \"../contexts/options\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { BooleanInputParserLogic, CommandParameterType } from \"./helpers\";\n\nexport interface DynamicSegmentsParserLogicProps {\n /**\n * The command to generate the dynamic path segments parser logic for. This is used to access the command options and parameters when generating the parser logic for dynamic path segments.\n */\n command: CommandTree;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function DynamicSegmentsParserLogic(\n props: DynamicSegmentsParserLogicProps\n) {\n const { command } = props;\n\n return (\n <For each={command.segments ?? []}>\n {(segment, index) => (\n <Show when={isDynamicPathSegment(segment)}>\n <VarDeclaration\n let\n name={camelCase(getDynamicPathSegmentName(segment))}\n type=\"string | undefined\"\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${2 + index} && args[${2 + index}]`}>\n {code`${camelCase(\n getDynamicPathSegmentName(segment)\n )} = args[${2 + index}];`}\n </IfStatement>\n <hbr />\n <hbr />\n </Show>\n )}\n </For>\n );\n}\n\nexport interface ArgumentsParserLogicProps {\n /**\n * The command to generate the positional parameters parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n isCaseSensitive: boolean;\n}\n\nexport function ArgumentsParserLogic(props: ArgumentsParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive } = props;\n\n return (\n <Show when={command.args && command.args.length > 0}>\n <VarDeclaration\n let\n name=\"optionsIndex\"\n type=\"number\"\n initializer={code`Math.max(0, args.slice(${\n command.segments.length + 1\n }).findIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1};`}\n />\n <Spacing />\n <VarDeclaration\n let\n name=\"argsIndex\"\n type=\"number\"\n initializer={code`optionsIndex > ${\n command.segments.length + 1\n } ? ${command.segments.length + 1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith(\"-\") && /^(${Object.values(\n command.options ?? {}\n )\n .map(\n option =>\n `${\n isCaseSensitive || option.name.length === 1\n ? option.name\n : option.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || option.name.length === 1\n ? a\n : a\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || option.name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")}`\n )\n .join(\"|\")})=?.*$/.test(arg${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }))) + ${command.segments.length + 1});`}\n />\n <Spacing />\n <For each={command.args ?? []} hardline>\n {(arg, index) => (\n <>\n <Show\n when={\n isSetString(arg.env) ||\n arg.default !== undefined ||\n ((arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic)\n }\n fallback={\n <>\n {code`let ${camelCase(arg.name)}!: `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }>\n <VarDeclaration\n let\n name={camelCase(arg.name)}\n type={<CommandParameterType parameter={arg} />}\n initializer={\n <>\n {code` ( `}\n <Show when={isSetString(arg.env)}>\n {code`env.${appSpecificEnvPrefix}_${constantCase(String(arg.env))} ?? `}\n </Show>\n <Show\n when={arg.default !== undefined}\n fallback={arg.variadic ? code`[]` : code`undefined`}>\n {arg.kind === CommandParameterKinds.string\n ? code`\"${arg.default}\"`\n : code`${arg.default}`}\n </Show>\n {code`) as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </>\n }\n />\n </Show>\n <Spacing />\n <IfStatement\n condition={code`argsIndex + ${index} < args.length && argsIndex + ${index} !== optionsIndex`}>\n {code`${camelCase(arg.name)} = `}\n <Show\n when={\n arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number\n }\n fallback={\n <BooleanInputParserLogic\n name={`args[argsIndex + ${index}] `}\n />\n }>\n <Show\n when={arg.variadic}\n fallback={\n <Show\n when={arg.kind === CommandParameterKinds.number}\n fallback={code`args[argsIndex + ${index}] `}>\n {code`Number(args[argsIndex + ${index}]) `}\n </Show>\n }>\n {code`args.slice(argsIndex + ${\n index\n }, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${\n command.args.length - index\n }).join(\" \").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean)`}\n </Show>\n </Show>\n {code` as `}\n <CommandParameterType parameter={arg} />\n {code`; `}\n </IfStatement>\n <Spacing />\n </>\n )}\n </For>\n </Show>\n );\n}\n\n/**\n * The command option interface property.\n */\nexport function OptionsMember({ option }: { option: CommandOption }) {\n const doc = option.description || `The ${option.title} command option.`;\n\n return (\n <>\n <Show when={Boolean(option.name)}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={<CommandParameterType parameter={option} />}\n optional={option.optional}\n />\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserLogicProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * The command option to generate the parser logic for.\n */\n option: CommandOption;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\n/**\n * The command option property parser logic.\n */\nexport function OptionsMemberParserLogic(props: OptionsMemberParserLogicProps) {\n const { name, option, isCaseSensitive } = props;\n\n const equalsRegex = `/^--?(${\n isCaseSensitive || name.length === 1\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive || name.length === 1\n ? a\n : a.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n )\n .join(\"|\")})=/`;\n\n return (\n <>\n <Show\n when={\n option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number\n }>\n <Show\n when={\n (option as StringCommandParameter | NumberCommandParameter).variadic\n }>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} ??= []; `}>\n {code`options[\"${name}\"] ??= []; `}\n </Show>\n <hbr />\n <IfStatement\n condition={`${equalsRegex}.test(${\n isCaseSensitive\n ? \"arg\"\n : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n })`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\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 {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}.push(`}>\n {code`options[\"${name}\"].push(`}\n </Show>\n <Show when={option.kind === CommandParameterKinds.string}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\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 {code` as ${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice => (isSetString(choice) ? `\"${choice}\"` : choice))\n .join(\" | \")} `}\n </Show>\n {code`); `}\n </ElseIfClause>\n </Show>\n <Show\n when={\n !(option as StringCommandParameter | NumberCommandParameter)\n .variadic\n }>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices\n ?.map(choice => `\"${choice}\"`)\n .join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show when={option.kind === CommandParameterKinds.string}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")`}\n <Show\n when={\n (option as StringCommandParameter).choices &&\n (option as StringCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as StringCommandParameter).choices?.map(choice => `\"${choice}\"`).join(\" | \")}`}\n </Show>\n {code`; `}\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` Number(args[++i].trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")); `}\n />\n <hbr />\n <IfStatement condition={`!Number.isNaN(value)`}>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name}`}>\n {code`options[\"${name}\"]`}\n </Show>\n {code` = value`}\n <Show\n when={\n (option as NumberCommandParameter).choices &&\n (option as NumberCommandParameter).choices!.length > 0\n }>\n {code` as ${(option as NumberCommandParameter).choices?.join(\" | \")}`}\n </Show>\n {code`; `}\n </IfStatement>\n </Show>\n </ElseIfClause>\n <hbr />\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.boolean}>\n <IfStatement\n condition={`${equalsRegex}.test(${isCaseSensitive ? \"arg\" : '\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'})`}>\n <VarDeclaration\n const\n name=\"value\"\n initializer={code` arg.replace(${equalsRegex}, \"\").trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\").toLowerCase(); `}\n />\n <hbr />\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = `}>\n {code`options[\"${name}\"] = `}\n </Show>\n <BooleanInputParserLogic name=\"value\" />\n </IfStatement>\n <ElseClause>\n <Show\n when={name.includes(\"?\") || name.includes(\"-\")}\n fallback={code`options.${name} = true; `}>\n {code`options[\"${name}\"] = true; `}\n </Show>\n </ElseClause>\n <Show when={Boolean((option as BooleanCommandOption).isNegativeOf)}>\n <hbr />\n <Show\n when={\n (option as BooleanCommandOption).isNegativeOf!.includes(\"?\") ||\n (option as BooleanCommandOption).isNegativeOf!.includes(\"-\")\n }\n fallback={code`options.${(option as BooleanCommandOption).isNegativeOf} = false; `}>\n {code`options[\"${(option as BooleanCommandOption).isNegativeOf}\"] = false; `}\n </Show>\n </Show>\n </Show>\n </>\n );\n}\n\nexport interface OptionsMemberParserConditionProps {\n /**\n * The option name to generate the parser logic for.\n */\n name: string;\n\n /**\n * Aliases for the option, which will also be parsed in the generated code. This will affect how the generated code compares command-line arguments to option names and aliases.\n */\n alias?: string[];\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive: boolean;\n}\n\nexport function OptionsMemberParserCondition(\n props: OptionsMemberParserConditionProps\n) {\n const { name, alias: aliasProp, isCaseSensitive } = props;\n\n return (\n <>\n {code`${\n isCaseSensitive\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive ? name : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive\n ? name\n : name.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`}\n <Show when={aliasProp && aliasProp.length > 0}>\n <For each={aliasProp ?? []}>\n {alias =>\n code` || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"--'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\" || ${\n isCaseSensitive || alias.length === 1\n ? 'arg.startsWith(\"-'\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\"'\n }${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")}=\") || ${\n isCaseSensitive || alias.length === 1\n ? \"arg\"\n : 'arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n isCaseSensitive || alias.length === 1\n ? alias\n : alias.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")\n }\"`\n }\n </For>\n </Show>\n </>\n );\n}\n\nexport function OptionsInterfaceDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(command.options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <InterfaceDeclaration\n export\n name={`${pascalCase(command.name)}Options`}\n extends=\"GlobalOptions\">\n <For each={Object.values(options.value)} hardline>\n {option => <OptionsMember option={option} />}\n </For>\n </InterfaceDeclaration>\n );\n}\n\nexport interface OptionsParserLogicProps extends PartialKeys<\n Pick<CommandTree, \"segments\" | \"options\" | \"name\">,\n \"segments\" | \"name\"\n> {\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command options parser logic.\n */\nexport function OptionsParserLogic(props: OptionsParserLogicProps) {\n const {\n segments = [],\n options: _options,\n name: _name,\n appSpecificEnvPrefix,\n isCaseSensitive = false\n } = props;\n\n const options = computed(() =>\n computedOptions(\n Object.entries(_options).map(([name, option]) => ({\n ...option,\n name\n }))\n )\n );\n\n return (\n <>\n <VarDeclaration\n const\n name=\"options\"\n initializer={code` {\n ${\n segments.length > 0 ? \"...useGlobalOptions(), \" : \"\"\n }${Object.entries(options.value)\n .filter(\n ([, option]) =>\n option.env ||\n option.default !== undefined ||\n ((option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.variadic)\n )\n .map(([name, option]) => {\n if (option.kind === CommandParameterKinds.string) {\n return ` ${\n name.includes(\"?\") || name.includes(\"-\")\n ? `\"${name}\"`\n : `${name}`\n }: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default !== undefined\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}\"${option.default}\"`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.number) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : \"\"\n }${\n option.variadic\n ? option.default && Array.isArray(option.default)\n ? `${\n option.env ? \" ?? \" : \"\"\n }${JSON.stringify(option.default)}`\n : option.env\n ? \" ?? []\"\n : \"[]\"\n : option.default !== undefined\n ? `${option.env ? \" ?? \" : \"\"}${option.default}`\n : \"\"\n }, `;\n } else if (option.kind === CommandParameterKinds.boolean) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env\n ? `env.${appSpecificEnvPrefix}_${option.env} ?? `\n : \"\"\n }${option.default ? \"true\" : \"false\"},`;\n }\n\n return \"\";\n })\n .join(\"\")}\n } as unknown as ${segments.length > 0 ? pascalCase(_name) : \"Global\"}Options;`}\n />\n <Spacing />\n {code`for (let i = 0; i < args.slice(${\n segments.filter(segment => isDynamicPathSegment(segment)).length\n }).length; i++) { `}\n <hbr />\n <VarDeclaration\n const\n name=\"arg\"\n type=\"string\"\n initializer={code` args[i].length > 3 && args[i].startsWith(\"--\")\n ? \\`--\\${args[i].slice(2).replaceAll(\"-\", \"\")${\n isCaseSensitive\n ? \"\"\n : '.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n }}\\`\n : args[i].length > 2 && args[i].startsWith(\"-\")\n ? \\`-\\${args[i].slice(1).replaceAll(\"-\", \"\")}\\`\n : args[i]; `}\n />\n <hbr />\n <For each={Object.entries(options.value)} hardline>\n {([name, option], i) => (\n <Show\n when={i === 0}\n fallback={\n <ElseIfClause\n condition={\n <>\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n </>\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </ElseIfClause>\n }>\n <IfStatement\n condition={\n <OptionsMemberParserCondition\n name={name}\n alias={option.alias}\n isCaseSensitive={isCaseSensitive}\n />\n }>\n <OptionsMemberParserLogic\n name={name}\n option={option}\n isCaseSensitive={isCaseSensitive}\n />\n </IfStatement>\n </Show>\n )}\n </For>\n <hbr />\n {code` } `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandParserLogicProps {\n /**\n * The command to generate the parser logic for.\n */\n command: CommandTree;\n\n /**\n * The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).\n */\n appSpecificEnvPrefix: string;\n\n /**\n * Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.\n *\n * @defaultValue false\n */\n isCaseSensitive?: boolean;\n}\n\n/**\n * The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.\n */\nexport function CommandParserLogic(props: CommandParserLogicProps) {\n const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;\n\n return (\n <>\n <DynamicSegmentsParserLogic\n command={command}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <OptionsParserLogic\n name={command.name}\n options={command.options}\n segments={command.segments}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n <ArgumentsParserLogic\n command={command}\n appSpecificEnvPrefix={appSpecificEnvPrefix}\n isCaseSensitive={isCaseSensitive}\n />\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA2CA,SAAE,2BAAA,OAAA;CACA,MAAM,EACR,YACM;;EAEN,IAAO,OAAA;AACH,UAAA,QAAA,YAAA,EAAA;;EAEA,WAAA,SAAA,UAAA,gBAAA,MAAA;GACF,IAAQ,OAAC;;;GAGN,IAAA,WAAY;AACb,WAAA;KAAA,gBAAA,gBAAA;MACF,OAAe;MACjB,IAAA,OAAA;;;MAGS,MAAA;MACP,CAAA;KAAA,gBAAA,OAAA,EAAA,CAAA;KAAA,gBAAA,aAAA;MACQ,WAAW,IAAC,iBAAK,IAAA,MAAA,WAAA,IAAA,MAAA;;AAElB,cAAA,IAAA,GAAA,UAAA,0BAAA,QAAA,CAAA,CAAA,UAAA,IAAA,MAAA;;MAED,CAAA;KAAA,gBAAmB,OAAA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;;;AAGK,cAAA,gBAAA,0BAAA;QACJ;QACE;QACC;QACK,CAAC;;MAEL,CAAC;;IAEL,CAAC;GACH,CAAC;EAAE,gBAAa,OAAA,EAAA,CAAA;EAAA,IAAA;EAAA,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AAwBnB,SAAgB,mBAAa,OAAA;CAC3B,MAAM,EACJ,SACA,sBACA,kBAAgB,UACd;AACJ,QAAO;EAAC,gBAAiB,4BAA2B;GACzC;GACK;GACf,CAAC;EAAE,gBAAkB,SAAC,EAAA,CAAA;EAAA,gBAAA,oBAAA;GACrB,IAAI,OAAO;AACT,WAAO,QAAQ;;GAEjB,IAAI,UAAU;AACZ,WAAO,QAAQ;;GAEjB,IAAI,WAAW;AACb,WAAO,QAAQ;;GAEI;GACL;GACjB,CAAC;EAAE,gBAAkB,SAAQ,EAAA,CAAI;EAAE,gBAAG,sBAA+B;GAC3D;GACY;GACJ;GAClB,CAAC;EAAE,gBAAiB,SAAA,EAAA,CAAA;EAAA"}
|
|
@@ -166,6 +166,7 @@ function ArgsUtilities() {
|
|
|
166
166
|
}
|
|
167
167
|
function ContextUtilities() {
|
|
168
168
|
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
169
|
+
const options = (0, _alloy_js_core.computed)(() => Object.fromEntries(context.options.map((option) => [option.name, option])));
|
|
169
170
|
return [
|
|
170
171
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
171
172
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
@@ -188,12 +189,9 @@ function ContextUtilities() {
|
|
|
188
189
|
return `Get the ${require_context_helpers.getAppTitle(context)} application context for the current application.`;
|
|
189
190
|
},
|
|
190
191
|
get children() {
|
|
191
|
-
return
|
|
192
|
-
name: "options",
|
|
193
|
-
children: `The options to use when getting the context. This can include parameters for how to handle missing contexts, such as whether to throw an error or return undefined. By default, if the context is not available, this function will return undefined.`
|
|
194
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { get children() {
|
|
192
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { get children() {
|
|
195
193
|
return `The ${require_context_helpers.getAppTitle(context)} application context for the current application or undefined if the context is not available.`;
|
|
196
|
-
} })
|
|
194
|
+
} });
|
|
197
195
|
}
|
|
198
196
|
}),
|
|
199
197
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -218,6 +216,21 @@ function ContextUtilities() {
|
|
|
218
216
|
children: _alloy_js_core.code`return useGlobal()?.inputArgs ?? getInputArgs();`
|
|
219
217
|
}),
|
|
220
218
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
219
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
220
|
+
get heading() {
|
|
221
|
+
return `A utility hook function to get the command-line global options from the ${require_context_helpers.getAppTitle(context)} application context.`;
|
|
222
|
+
},
|
|
223
|
+
get children() {
|
|
224
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: "An object containing the global options from the application context." });
|
|
225
|
+
}
|
|
226
|
+
}),
|
|
227
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
228
|
+
"export": true,
|
|
229
|
+
name: "useGlobalOptions",
|
|
230
|
+
returnType: "GlobalOptions",
|
|
231
|
+
children: _alloy_js_core.code`return useGlobal()?.options ?? {};`
|
|
232
|
+
}),
|
|
233
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
221
234
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
222
235
|
get heading() {
|
|
223
236
|
return `A utility hook function to get the state of the ${require_context_helpers.getAppTitle(context)} application context.`;
|
|
@@ -457,8 +470,30 @@ return result;`;
|
|
|
457
470
|
type: "() => any"
|
|
458
471
|
}],
|
|
459
472
|
returnType: "Promise<void>",
|
|
460
|
-
children
|
|
461
|
-
|
|
473
|
+
get children() {
|
|
474
|
+
return [
|
|
475
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
476
|
+
"const": true,
|
|
477
|
+
name: "args",
|
|
478
|
+
initializer: _alloy_js_core.code`getInputArgs(); `
|
|
479
|
+
}),
|
|
480
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
481
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_options_parser_logic.OptionsParserLogic, {
|
|
482
|
+
get options() {
|
|
483
|
+
return options.value;
|
|
484
|
+
},
|
|
485
|
+
get appSpecificEnvPrefix() {
|
|
486
|
+
return context.config.appSpecificEnvPrefix;
|
|
487
|
+
},
|
|
488
|
+
get isCaseSensitive() {
|
|
489
|
+
return context.config.isCaseSensitive;
|
|
490
|
+
}
|
|
491
|
+
}),
|
|
492
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
493
|
+
_alloy_js_core.code`
|
|
494
|
+
return unstable_globalStore.run({ options, inputArgs: args, state: { executionId: randomUUID(), status: "initializing", isError: false, meta: new Map() } as GlobalContextState }, handler);`
|
|
495
|
+
];
|
|
496
|
+
}
|
|
462
497
|
}),
|
|
463
498
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
464
499
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
@@ -530,7 +565,7 @@ function StateBuiltin(props) {
|
|
|
530
565
|
});
|
|
531
566
|
},
|
|
532
567
|
get builtinImports() {
|
|
533
|
-
return (0, defu.default)(rest.builtinImports ?? {}, { env: ["isCI"] });
|
|
568
|
+
return (0, defu.default)(rest.builtinImports ?? {}, { env: ["isCI", "env"] });
|
|
534
569
|
},
|
|
535
570
|
get children() {
|
|
536
571
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-builtin.cjs","names":[],"sources":["../../src/components/state-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n TypeDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocInternal,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\nimport { computedOptions } from \"../contexts/options\";\nimport { getAppBin } from \"../plugin-utils\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type { Context } from \"../types\";\nimport { OptionsMember } from \"./options-parser-logic\";\n\nexport function GlobalTypeDefinitions() {\n const context = usePowerlines<Context>();\n\n const options = computed(() => computedOptions(context.options));\n\n return (\n <>\n <TSDoc\n heading={`An object representing the global options available for every command in the ${getAppTitle(\n context,\n true\n )} command-line application.`}\n />\n <InterfaceDeclaration export name=\"GlobalOptions\">\n <For each={Object.values(options.value)} hardline>\n {option => <OptionsMember option={option} />}\n </For>\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"The context object for the current command execution, containing the command path and segments.\" />\n <InterfaceDeclaration\n export\n name=\"CommandContext\"\n typeParameters={[\n {\n name: \"THandler\",\n extends: \"(...params: any[]) => any\",\n default: \"any\"\n }\n ]}>\n <TSDoc\n heading={`The full command path as a string. For example, if the user runs \\`${getAppBin(\n context\n )} foo bar\\`, this would be \\`foo bar\\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`}\n />\n <InterfaceMember name=\"path\" type=\"string\" />\n <Spacing />\n <TSDoc\n heading={`An array of command path segments. For example, if the user runs \\`${getAppBin(\n context\n )} foo bar\\`, this would be \\`[\"foo\", \"bar\"]\\`. This is useful for commands that need to know their individual path segments, such as for dynamic routing or for commands that have behavior based on specific segments in the command hierarchy.`}\n />\n <InterfaceMember name=\"segments\" type=\"string[]\" />\n <Spacing />\n <TSDoc\n heading={`The parameters for the current command's handler function.`}\n />\n <InterfaceMember name=\"params\" type=\"Parameters<THandler>\" />\n </InterfaceDeclaration>\n <Spacing />\n <TypeDeclaration export name=\"GlobalContextStatus\">\n {code`\"initializing\" | \"preparing\" | \"executing\" | \"completed\"`}\n </TypeDeclaration>\n <Spacing />\n <TSDoc\n heading={`The state object for the ${getAppTitle(context)} application context.`}\n />\n <InterfaceDeclaration export name=\"GlobalContextState\">\n <TSDoc heading=\"The unique identifier for the current execution context.\" />\n <InterfaceMember name=\"executionId\" type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The status of the current execution context.\" />\n <InterfaceMember name=\"status\" type=\"GlobalContextStatus\" />\n <Spacing />\n <TSDoc heading=\"Indicates whether the current execution context has encountered an error.\" />\n <InterfaceMember name=\"isError\" type=\"boolean\" />\n <Spacing />\n <TSDoc heading=\"A map containing arbitrary data associated with the current execution context.\" />\n <InterfaceMember name=\"meta\" type=\"Map<string, unknown>\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc\n heading={`The context object for the ${getAppTitle(context)} application.`}\n />\n <InterfaceDeclaration export name=\"GlobalContext\">\n <TSDoc heading=\"The global options shared across all commands in the application.\" />\n <InterfaceMember name=\"options\" type=\"GlobalOptions\" />\n <Spacing />\n <TSDoc heading=\"The raw command-line arguments passed to the application.\" />\n <InterfaceMember name=\"inputArgs\" type=\"string[]\" />\n <Spacing />\n <TSDoc heading=\"The state of the current execution context.\" />\n <InterfaceMember name=\"state\" type=\"GlobalContextState\" />\n </InterfaceDeclaration>\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ArgsUtilities() {\n return (\n <>\n <TSDoc heading=\"Retrieves the command-line arguments from Deno or Node.js environments.\">\n <TSDocRemarks>\n {`This function is only intended for internal use. Please use \\`useArgs()\\` instead.`}\n </TSDocRemarks>\n <Spacing />\n <TSDocInternal />\n <Spacing />\n <TSDocReturns>\n {`An array of command-line arguments from Deno or Node.js environments.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration name=\"getInputArgs\" returnType=\"string[]\">\n {code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport function ContextUtilities() {\n const context = usePowerlines<Context>();\n\n return (\n <>\n <Spacing />\n\n <TSDoc\n heading={`The global ${getAppTitle(context)} application context store instance.`}>\n <TSDocInternal />\n </TSDoc>\n <VarDeclaration export const name=\"unstable_globalStore\">\n {code` new AsyncLocalStorage<GlobalContext>({ name: \"globalStore\" }); `}\n </VarDeclaration>\n <Spacing />\n <TSDoc\n heading={`Get the ${getAppTitle(\n context\n )} application context for the current application.`}>\n <TSDocParam name=\"options\">\n {`The options to use when getting the context. This can include parameters for how to handle missing contexts, such as whether to throw an error or return undefined. By default, if the context is not available, this function will return undefined.`}\n </TSDocParam>\n <TSDocReturns>\n {`The ${getAppTitle(\n context\n )} application context for the current application or undefined if the context is not available.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useGlobal\" returnType=\"GlobalContext\">\n {code`return unstable_globalStore.getStore() as GlobalContext;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the command-line arguments from the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>\n {\"An array of command-line arguments from the application context.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useArgs\" returnType=\"string[]\">\n {code`return useGlobal()?.inputArgs ?? getInputArgs();`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the state of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>{\"The state of the application context.\"}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"useState\"\n returnType=\"GlobalContextState\">\n {code`return useGlobal()?.state;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility function to update the state of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocRemarks>\n {`This function will throw an error if the global context is not available, so it should only be used within a valid context scope, such as within a command handler or within the \\`withGlobal()\\` function.`}\n </TSDocRemarks>\n <Spacing />\n <TSDocParam name=\"update\">\n {`The new state or a function that receives the previous state and returns the new state. This allows for both direct state updates and functional updates based on the previous state.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"setState\"\n parameters={[\n {\n name: \"update\",\n type: \"Partial<GlobalContextState> | ((prev: GlobalContextState) => GlobalContextState)\"\n }\n ]}>\n {code`const prev = useGlobal()?.state;\n if (!prev) {\n throw new Error(\n \\`The ${getAppTitle(\n context\n )} application context is not available. Make sure to call setState() within a valid context scope.\\`\n );\n }\n\n useGlobal().state = typeof update === \"function\" ? update(prev) : { ...prev, ...update }; `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the execution ID of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>\n {\"The execution ID of the application context.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useExecutionId\" returnType=\"string\">\n {code`return useState().executionId;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the metadata of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>\n {\"The metadata of the application context.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"useMeta\"\n returnType=\"Map<string, unknown>\">\n {code`return useState().meta;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the current status of the ${getAppTitle(\n context\n )} application.`}>\n <TSDocReturns>{\"The current status of the application.\"}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"useStatus\"\n returnType=\"GlobalContextStatus\">\n {code`return useState().status;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`The global ${getAppTitle(context)} - command context store instance.`}>\n <TSDocInternal />\n </TSDoc>\n <VarDeclaration export name=\"unstable_commandStore\">\n {code`new AsyncLocalStorage<CommandContext>({ name: \"commandStore\" });`}\n </VarDeclaration>\n <Spacing />\n <TSDoc\n heading={`Get the ${getAppTitle(context)} - command context for the current application.`}>\n <TSDocReturns>\n {`The ${getAppTitle(context)} - command context for the current application.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useCommand\" returnType=\"CommandContext\">\n {code`const result = unstable_commandStore.getStore();\nif (!result) {\n throw new Error(\n \\`The ${getAppTitle(context)} - command context is not available. Make sure to call useCommand() within a valid context scope.\\`\n );\n}\nreturn result;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A utility hook function to get the individual segments of the current command path.\">\n <TSDocReturns>{\"An array of command path segments.\"}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useSegments\" returnType=\"string[]\">\n {code`return useCommand().segments;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A utility hook function to get the full command path as a string.\">\n <TSDocReturns>\n {`The full command path as a string. For example, if the user runs \\`${getAppBin(\n context\n )} foo bar\\`, this would return \\`\"foo bar\"\\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"usePath\" returnType=\"string\">\n {code`return useCommand().path;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Checks if a specific flag is present in the command-line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {\n 'The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\".'\n }\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command-line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"hasFlag\"\n parameters={[\n { name: \"flag\", type: \"string | string[]\" },\n {\n name: \"argv\",\n type: \"string[]\",\n default: \"useArgs()\"\n }\n ]}>\n <VarDeclaration\n const\n name=\"position\"\n type=\"number\"\n initializer={code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {\n const pos = argv.findIndex(arg => (f.startsWith(\"-\") ? \"\" : (f.length === 1 ? \"-\" : \"--\") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? \"-\" : \"--\") + f + \"=\"));\n return pos !== -1 ? pos : ret;\n }, -1);`}\n />\n <hbr />\n {code`return position !== -1 && argv.indexOf(\"--\") === -1 || position < argv.indexOf(\"--\");`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A utility function to determine if the help flag is present or if the command is in an error state during preparation.\">\n <TSDocReturns>\n {`True if the help flag is present or if the command is in an error state during preparation, false otherwise. This can be used to conditionally display help text or to alter command behavior when the user is likely seeking help.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"isHelp\" returnType=\"boolean\">\n {code`return !isCI && (hasFlag([\"help\", \"h\", \"?\"]) || (useStatus() === \"preparing\" && useState().isError)); `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility function to wrap the ${getAppTitle(\n context\n )} application within the global context scope.`}>\n <TSDocParam name=\"handler\">\n {`The callback function to run within the global context scope. This function will receive the global context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`}\n </TSDocParam>\n <TSDocReturns>\n {`The result of the callback function, which can be a value or a promise that resolves to a value.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"withGlobal\"\n parameters={[{ name: \"handler\", type: \"() => any\" }]}\n returnType=\"Promise<void>\">\n {code`\n return unstable_globalStore.run({ options: {} as unknown as GlobalOptions, inputArgs: getInputArgs(), state: { executionId: randomUUID(), status: \"initializing\", isError: false, meta: new Map() } as GlobalContextState }, handler);`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility function to wrap a ${getAppTitle(\n context\n )} application command handler within the command context scope.`}>\n <TSDocParam name=\"handler\">\n {`The callback function to run within the command context scope. This function will receive the command context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`}\n </TSDocParam>\n <TSDocReturns>\n {`The result of the callback function, which can be a value or a promise that resolves to a value.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"withCommand\"\n typeParameters={[\n {\n name: \"THandler\",\n extends: \"(this: CommandContext, ...params: any[]) => any\",\n default: \"(this: CommandContext, ...params: any[]) => any\"\n }\n ]}\n parameters={[\n { name: \"path\", type: \"string\" },\n { name: \"segments\", type: \"string[]\" },\n { name: \"params\", type: \"Parameters<THandler>\" },\n { name: \"handler\", type: \"THandler\" }\n ]}\n returnType=\"Promise<{ error: string | Error | null }>\">\n {code`setState({ status: \"preparing\", isError: false });\n\n const ctx = { path, segments, params } as CommandContext<THandler>;\n const result = await Promise.resolve(unstable_commandStore.run(ctx, Reflect.apply(handler, ctx, params)));\n if (result instanceof Error || (typeof result === \"object\" && ((result as { error: unknown }).error instanceof Error || typeof (result as { error: unknown }).error === \"string\"))) {\n setState({ status: \"completed\", isError: true });\n return { error: result instanceof Error ? result : (result as { error: Error | string }).error };\n }\n\n setState({ status: \"completed\", isError: false });\n return { error: null }; `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface StateBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * A built-in module for handling application state utilities in Shell Shock.\n */\nexport function StateBuiltin(props: StateBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"state\"\n description=\"A module that provides context hooks and utilities for accessing the application state.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:async_hooks\": [\"AsyncLocalStorage\"],\n \"node:crypto\": [\"randomUUID\"]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n env: [\"isCI\"]\n })}>\n <GlobalTypeDefinitions />\n <Spacing />\n <ArgsUtilities />\n <Spacing />\n <ContextUtilities />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAe,wBAAA;CACb,MAAA,6EAAS;CACT,MAAA,6CAAU,yCAAA,QAAA,QAAA,CAAA;AACV,QAAA;kDAAY,4DAAA,EACZ,IAAA,UAAA;AACI,UAAG,gF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MACF,aAAK,mBAAA;;;;MAIN,CAAC;qDAAgB,OAAA,EAAA,CAAA;KAAA,mBAAA;KAAA;;GAErB,CAAC;kDAAgB,0DAAa,EAAC,CAAA;kDAAA,4DAAA;GAC9B,SAAS;GACT,IAAI,WAAO;AACT,2DAAqB,mEAAA,EACpB,UAAS,uOACT,CAAA;;GAEJ,CAAC;kDAAM,0CAAA;GACN,UAAO;GACP,MAAK;GACL,YAAY;GACZ,UAAM,mBAAA;GACP,CAAC;kDAAiB,0DAAA,EAAA,CAAA;kDAAA,4DAAA;GACjB,IAAI,UAAQ;AACV,WAAI,kCAAY,oCAAA,QAAA,CAAA;;GAElB,IAAG,WAAA;AACD,WAAE,iDAAA,iEAAA;KACA,MAAA;KACA,UAAM;KACP,CAAC,kDAAgB,mEAAA,EAChB,UAAE,oGACH,CAAC,CAAC;;GAEN,CAAC;kDAAmB,0CAAsB;GACzC,UAAM;GACN,OAAK;GACL,MAAI;GACJ,YAAY,CAAC;IACX,MAAM;IACN,MAAM;IACP,CAAC;GACF,YAAK;GACL,UAAI,mBAAU;;;;;GAGd,IAAI,UAAU;AACZ,WAAO,gCAAgC,oCAAA,QAAA,CAAqB;;GAE9D,IAAI,WAAW;AACb,WAAI,iDAAsB,iEAAY;KACpC,MAAA;;KAED,CAAC,kDAAoB,mEAAY,EAChC,UAAS,oGACV,CAAC,CAAA;;GAEL,CAAA;kDAAA,0CAAA;GACH,UAAA;;GAEA,MAAO;GACL,gBAAgB,CAAA;IACZ,MAAI;IACP,SAAA;;IAED,CAAA;GACE,YAAU;IAAA;KACZ,MAAA;KACI,MAAC;KACL;IAAK;;KAEL,MAAO;KACJ;IAAA;KACC,MAAI;KACJ,MAAA;KACD;IAAE;KACD,MAAA;KACA,MAAG;KACJ;IAAC;GACF,YAAI;GACJ,UAAE,mBAAA;;;;;;;;;;;GAWH,CAAA;EAAA"}
|
|
1
|
+
{"version":3,"file":"state-builtin.cjs","names":[],"sources":["../../src/components/state-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n TypeDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocInternal,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\nimport { computedOptions } from \"../contexts/options\";\nimport { getAppBin } from \"../plugin-utils\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type { Context } from \"../types\";\nimport { OptionsMember, OptionsParserLogic } from \"./options-parser-logic\";\n\nexport function GlobalTypeDefinitions() {\n const context = usePowerlines<Context>();\n\n const options = computed(() => computedOptions(context.options));\n\n return (\n <>\n <TSDoc\n heading={`An object representing the global options available for every command in the ${getAppTitle(\n context,\n true\n )} command-line application.`}\n />\n <InterfaceDeclaration export name=\"GlobalOptions\">\n <For each={Object.values(options.value)} hardline>\n {option => <OptionsMember option={option} />}\n </For>\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"The context object for the current command execution, containing the command path and segments.\" />\n <InterfaceDeclaration\n export\n name=\"CommandContext\"\n typeParameters={[\n {\n name: \"THandler\",\n extends: \"(...params: any[]) => any\",\n default: \"any\"\n }\n ]}>\n <TSDoc\n heading={`The full command path as a string. For example, if the user runs \\`${getAppBin(\n context\n )} foo bar\\`, this would be \\`foo bar\\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`}\n />\n <InterfaceMember name=\"path\" type=\"string\" />\n <Spacing />\n <TSDoc\n heading={`An array of command path segments. For example, if the user runs \\`${getAppBin(\n context\n )} foo bar\\`, this would be \\`[\"foo\", \"bar\"]\\`. This is useful for commands that need to know their individual path segments, such as for dynamic routing or for commands that have behavior based on specific segments in the command hierarchy.`}\n />\n <InterfaceMember name=\"segments\" type=\"string[]\" />\n <Spacing />\n <TSDoc\n heading={`The parameters for the current command's handler function.`}\n />\n <InterfaceMember name=\"params\" type=\"Parameters<THandler>\" />\n </InterfaceDeclaration>\n <Spacing />\n <TypeDeclaration export name=\"GlobalContextStatus\">\n {code`\"initializing\" | \"preparing\" | \"executing\" | \"completed\"`}\n </TypeDeclaration>\n <Spacing />\n <TSDoc\n heading={`The state object for the ${getAppTitle(context)} application context.`}\n />\n <InterfaceDeclaration export name=\"GlobalContextState\">\n <TSDoc heading=\"The unique identifier for the current execution context.\" />\n <InterfaceMember name=\"executionId\" type=\"string\" />\n <Spacing />\n <TSDoc heading=\"The status of the current execution context.\" />\n <InterfaceMember name=\"status\" type=\"GlobalContextStatus\" />\n <Spacing />\n <TSDoc heading=\"Indicates whether the current execution context has encountered an error.\" />\n <InterfaceMember name=\"isError\" type=\"boolean\" />\n <Spacing />\n <TSDoc heading=\"A map containing arbitrary data associated with the current execution context.\" />\n <InterfaceMember name=\"meta\" type=\"Map<string, unknown>\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc\n heading={`The context object for the ${getAppTitle(context)} application.`}\n />\n <InterfaceDeclaration export name=\"GlobalContext\">\n <TSDoc heading=\"The global options shared across all commands in the application.\" />\n <InterfaceMember name=\"options\" type=\"GlobalOptions\" />\n <Spacing />\n <TSDoc heading=\"The raw command-line arguments passed to the application.\" />\n <InterfaceMember name=\"inputArgs\" type=\"string[]\" />\n <Spacing />\n <TSDoc heading=\"The state of the current execution context.\" />\n <InterfaceMember name=\"state\" type=\"GlobalContextState\" />\n </InterfaceDeclaration>\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ArgsUtilities() {\n return (\n <>\n <TSDoc heading=\"Retrieves the command-line arguments from Deno or Node.js environments.\">\n <TSDocRemarks>\n {`This function is only intended for internal use. Please use \\`useArgs()\\` instead.`}\n </TSDocRemarks>\n <Spacing />\n <TSDocInternal />\n <Spacing />\n <TSDocReturns>\n {`An array of command-line arguments from Deno or Node.js environments.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration name=\"getInputArgs\" returnType=\"string[]\">\n {code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport function ContextUtilities() {\n const context = usePowerlines<Context>();\n\n const options = computed(() =>\n Object.fromEntries(context.options.map(option => [option.name, option]))\n );\n\n return (\n <>\n <Spacing />\n\n <TSDoc\n heading={`The global ${getAppTitle(context)} application context store instance.`}>\n <TSDocInternal />\n </TSDoc>\n <VarDeclaration export const name=\"unstable_globalStore\">\n {code` new AsyncLocalStorage<GlobalContext>({ name: \"globalStore\" }); `}\n </VarDeclaration>\n <Spacing />\n <TSDoc\n heading={`Get the ${getAppTitle(\n context\n )} application context for the current application.`}>\n <TSDocReturns>\n {`The ${getAppTitle(\n context\n )} application context for the current application or undefined if the context is not available.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useGlobal\" returnType=\"GlobalContext\">\n {code`return unstable_globalStore.getStore() as GlobalContext;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the command-line arguments from the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>\n {\"An array of command-line arguments from the application context.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useArgs\" returnType=\"string[]\">\n {code`return useGlobal()?.inputArgs ?? getInputArgs();`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the command-line global options from the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>\n {\n \"An object containing the global options from the application context.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"useGlobalOptions\"\n returnType=\"GlobalOptions\">\n {code`return useGlobal()?.options ?? {};`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the state of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>{\"The state of the application context.\"}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"useState\"\n returnType=\"GlobalContextState\">\n {code`return useGlobal()?.state;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility function to update the state of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocRemarks>\n {`This function will throw an error if the global context is not available, so it should only be used within a valid context scope, such as within a command handler or within the \\`withGlobal()\\` function.`}\n </TSDocRemarks>\n <Spacing />\n <TSDocParam name=\"update\">\n {`The new state or a function that receives the previous state and returns the new state. This allows for both direct state updates and functional updates based on the previous state.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"setState\"\n parameters={[\n {\n name: \"update\",\n type: \"Partial<GlobalContextState> | ((prev: GlobalContextState) => GlobalContextState)\"\n }\n ]}>\n {code`const prev = useGlobal()?.state;\n if (!prev) {\n throw new Error(\n \\`The ${getAppTitle(\n context\n )} application context is not available. Make sure to call setState() within a valid context scope.\\`\n );\n }\n\n useGlobal().state = typeof update === \"function\" ? update(prev) : { ...prev, ...update }; `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the execution ID of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>\n {\"The execution ID of the application context.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useExecutionId\" returnType=\"string\">\n {code`return useState().executionId;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the metadata of the ${getAppTitle(\n context\n )} application context.`}>\n <TSDocReturns>\n {\"The metadata of the application context.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"useMeta\"\n returnType=\"Map<string, unknown>\">\n {code`return useState().meta;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility hook function to get the current status of the ${getAppTitle(\n context\n )} application.`}>\n <TSDocReturns>{\"The current status of the application.\"}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"useStatus\"\n returnType=\"GlobalContextStatus\">\n {code`return useState().status;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`The global ${getAppTitle(context)} - command context store instance.`}>\n <TSDocInternal />\n </TSDoc>\n <VarDeclaration export name=\"unstable_commandStore\">\n {code`new AsyncLocalStorage<CommandContext>({ name: \"commandStore\" });`}\n </VarDeclaration>\n <Spacing />\n <TSDoc\n heading={`Get the ${getAppTitle(context)} - command context for the current application.`}>\n <TSDocReturns>\n {`The ${getAppTitle(context)} - command context for the current application.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useCommand\" returnType=\"CommandContext\">\n {code`const result = unstable_commandStore.getStore();\nif (!result) {\n throw new Error(\n \\`The ${getAppTitle(context)} - command context is not available. Make sure to call useCommand() within a valid context scope.\\`\n );\n}\nreturn result;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A utility hook function to get the individual segments of the current command path.\">\n <TSDocReturns>{\"An array of command path segments.\"}</TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"useSegments\" returnType=\"string[]\">\n {code`return useCommand().segments;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A utility hook function to get the full command path as a string.\">\n <TSDocReturns>\n {`The full command path as a string. For example, if the user runs \\`${getAppBin(\n context\n )} foo bar\\`, this would return \\`\"foo bar\"\\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"usePath\" returnType=\"string\">\n {code`return useCommand().path;`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Checks if a specific flag is present in the command-line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {\n 'The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\".'\n }\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command-line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"hasFlag\"\n parameters={[\n { name: \"flag\", type: \"string | string[]\" },\n {\n name: \"argv\",\n type: \"string[]\",\n default: \"useArgs()\"\n }\n ]}>\n <VarDeclaration\n const\n name=\"position\"\n type=\"number\"\n initializer={code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {\n const pos = argv.findIndex(arg => (f.startsWith(\"-\") ? \"\" : (f.length === 1 ? \"-\" : \"--\") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? \"-\" : \"--\") + f + \"=\"));\n return pos !== -1 ? pos : ret;\n }, -1);`}\n />\n <hbr />\n {code`return position !== -1 && argv.indexOf(\"--\") === -1 || position < argv.indexOf(\"--\");`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"A utility function to determine if the help flag is present or if the command is in an error state during preparation.\">\n <TSDocReturns>\n {`True if the help flag is present or if the command is in an error state during preparation, false otherwise. This can be used to conditionally display help text or to alter command behavior when the user is likely seeking help.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"isHelp\" returnType=\"boolean\">\n {code`return !isCI && (hasFlag([\"help\", \"h\", \"?\"]) || (useStatus() === \"preparing\" && useState().isError)); `}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility function to wrap the ${getAppTitle(\n context\n )} application within the global context scope.`}>\n <TSDocParam name=\"handler\">\n {`The callback function to run within the global context scope. This function will receive the global context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`}\n </TSDocParam>\n <TSDocReturns>\n {`The result of the callback function, which can be a value or a promise that resolves to a value.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"withGlobal\"\n parameters={[{ name: \"handler\", type: \"() => any\" }]}\n returnType=\"Promise<void>\">\n <VarDeclaration\n const\n name=\"args\"\n initializer={code`getInputArgs(); `}\n />\n <Spacing />\n <OptionsParserLogic\n options={options.value}\n appSpecificEnvPrefix={context.config.appSpecificEnvPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <Spacing />\n {code`\n return unstable_globalStore.run({ options, inputArgs: args, state: { executionId: randomUUID(), status: \"initializing\", isError: false, meta: new Map() } as GlobalContextState }, handler);`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc\n heading={`A utility function to wrap a ${getAppTitle(\n context\n )} application command handler within the command context scope.`}>\n <TSDocParam name=\"handler\">\n {`The callback function to run within the command context scope. This function will receive the command context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`}\n </TSDocParam>\n <TSDocReturns>\n {`The result of the callback function, which can be a value or a promise that resolves to a value.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"withCommand\"\n typeParameters={[\n {\n name: \"THandler\",\n extends: \"(this: CommandContext, ...params: any[]) => any\",\n default: \"(this: CommandContext, ...params: any[]) => any\"\n }\n ]}\n parameters={[\n { name: \"path\", type: \"string\" },\n { name: \"segments\", type: \"string[]\" },\n { name: \"params\", type: \"Parameters<THandler>\" },\n { name: \"handler\", type: \"THandler\" }\n ]}\n returnType=\"Promise<{ error: string | Error | null }>\">\n {code`setState({ status: \"preparing\", isError: false });\n\n const ctx = { path, segments, params } as CommandContext<THandler>;\n const result = await Promise.resolve(unstable_commandStore.run(ctx, Reflect.apply(handler, ctx, params)));\n if (result instanceof Error || (typeof result === \"object\" && ((result as { error: unknown }).error instanceof Error || typeof (result as { error: unknown }).error === \"string\"))) {\n setState({ status: \"completed\", isError: true });\n return { error: result instanceof Error ? result : (result as { error: Error | string }).error };\n }\n\n setState({ status: \"completed\", isError: false });\n return { error: null }; `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface StateBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * A built-in module for handling application state utilities in Shell Shock.\n */\nexport function StateBuiltin(props: StateBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"state\"\n description=\"A module that provides context hooks and utilities for accessing the application state.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:async_hooks\": [\"AsyncLocalStorage\"],\n \"node:crypto\": [\"randomUUID\"]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n env: [\"isCI\", \"env\"]\n })}>\n <GlobalTypeDefinitions />\n <Spacing />\n <ArgsUtilities />\n <Spacing />\n <ContextUtilities />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAe,wBAAA;CACb,MAAA,6EAAS;CACT,MAAA,6CAAU,yCAAA,QAAA,QAAA,CAAA;AACV,QAAA;kDAAY,4DAAA,EACZ,IAAA,UAAA;AACI,UAAG,gFAAoD,oCAAA,SAAA,KAAA,CAAA;KAE7D,CAAA;kDAAwB,2CAAqB;G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;;;GAGV,IAAI,WAAM;AACR,WAAM,iDAAkB,iEAAU;KAChC,MAAE;KACF,UAAU;KACX,CAAC,kDAAA,mEAAA,gHAED,CAAC,CAAA;;GAEL,CAAC;kDAAI,0CAAmB;GACvB,UAAE;GACH,OAAA;GACH,MAAA;;IAEM,MAAC;IACL,SAAA;IACI,SAAI;IACP,CAAA;;;KAED,MAAA;KACG,MAAM;KACT;IAAA;KACI,MAAC;KACL,MAAS;;;KAET,MAAO;KACJ,MAAA;KACA;IAAC;KACA,MAAA;KACA,MAAI;KACL;IAAC;GACF,YAAU;GACV,UAAU,mBAAA;;;;;;;;;;;GAWX,CAAC;EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-builtin.d.cts","names":[],"sources":["../../src/components/state-builtin.tsx"],"mappings":";;;;iBA6CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA;;;AAArC;iBA2FgB,aAAA,CAAA,GAAa,iBAAA,CAAA,QAAA;AAAA,iBAqBb,gBAAA,CAAA,GAAgB,iBAAA,CAAA,QAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"state-builtin.d.cts","names":[],"sources":["../../src/components/state-builtin.tsx"],"mappings":";;;;iBA6CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA;;;AAArC;iBA2FgB,aAAA,CAAA,GAAa,iBAAA,CAAA,QAAA;AAAA,iBAqBb,gBAAA,CAAA,GAAgB,iBAAA,CAAA,QAAA;AAAA,UA+Tf,iBAAA,SAA0B,IAAA,CACzC,gBAAA;AArVF;;;AAAA,iBA4VgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,iBAAA,CAAA,QAAA"}
|