@shell-shock/core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/components/docs.d.cts +5 -5
  3. package/dist/components/index.cjs +1 -1
  4. package/dist/components/index.d.cts +2 -2
  5. package/dist/components/index.d.mts +2 -2
  6. package/dist/components/index.mjs +2 -2
  7. package/dist/components/options-parser-logic.cjs +17 -22
  8. package/dist/components/options-parser-logic.cjs.map +1 -1
  9. package/dist/components/options-parser-logic.d.cts +4 -8
  10. package/dist/components/options-parser-logic.d.cts.map +1 -1
  11. package/dist/components/options-parser-logic.d.mts +4 -8
  12. package/dist/components/options-parser-logic.d.mts.map +1 -1
  13. package/dist/components/options-parser-logic.mjs +18 -23
  14. package/dist/components/options-parser-logic.mjs.map +1 -1
  15. package/dist/components/usage.cjs +1 -1
  16. package/dist/components/usage.cjs.map +1 -1
  17. package/dist/components/usage.d.cts +2 -2
  18. package/dist/components/usage.d.mts +2 -2
  19. package/dist/components/usage.mjs +2 -2
  20. package/dist/components/usage.mjs.map +1 -1
  21. package/dist/helpers/resolve-command.cjs +20 -31
  22. package/dist/helpers/resolve-command.cjs.map +1 -1
  23. package/dist/helpers/resolve-command.mjs +21 -32
  24. package/dist/helpers/resolve-command.mjs.map +1 -1
  25. package/dist/helpers/validations.cjs +20 -20
  26. package/dist/helpers/validations.cjs.map +1 -1
  27. package/dist/helpers/validations.mjs +21 -21
  28. package/dist/helpers/validations.mjs.map +1 -1
  29. package/dist/index.d.cts +2 -2
  30. package/dist/index.d.mts +2 -2
  31. package/dist/plugin-utils/context-helpers.cjs +106 -5
  32. package/dist/plugin-utils/context-helpers.cjs.map +1 -1
  33. package/dist/plugin-utils/context-helpers.d.cts +89 -3
  34. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  35. package/dist/plugin-utils/context-helpers.d.mts +89 -3
  36. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  37. package/dist/plugin-utils/context-helpers.mjs +100 -4
  38. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  39. package/dist/plugin-utils/get-command-tree.cjs +1 -1
  40. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  41. package/dist/plugin-utils/get-command-tree.mjs +2 -2
  42. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  43. package/dist/plugin-utils/index.cjs +7 -2
  44. package/dist/plugin-utils/index.d.cts +2 -2
  45. package/dist/plugin-utils/index.d.mts +2 -2
  46. package/dist/plugin-utils/index.mjs +2 -2
  47. package/dist/plugin.cjs +1 -1
  48. package/dist/plugin.cjs.map +1 -1
  49. package/dist/plugin.d.cts.map +1 -1
  50. package/dist/plugin.d.mts.map +1 -1
  51. package/dist/plugin.mjs +2 -2
  52. package/dist/plugin.mjs.map +1 -1
  53. package/dist/types/command.d.cts +20 -3
  54. package/dist/types/command.d.cts.map +1 -1
  55. package/dist/types/command.d.mts +20 -3
  56. package/dist/types/command.d.mts.map +1 -1
  57. package/dist/types/index.d.cts +2 -2
  58. package/dist/types/index.d.mts +2 -2
  59. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"options-parser-logic.mjs","names":["code","computed","For","Show","ElseClause","ElseIfClause","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","ReflectionKind","camelCase","constantCase","pascalCase","isSetString","computedOptions","getPositionalCommandOptionName","isPositionalCommandOption","PositionalOptionsParserLogic","props","path","envPrefix","_$createComponent","each","segments","children","segment","index","when","name","type","_$memo","positional","kind","number","variadic","initializer","default","_$createIntrinsic","condition","OptionsMember","option","doc","description","title","Boolean","string","optional","boolean","OptionsMemberParserLogic","isCaseSensitive","equalsRegex","length","toLowerCase","alias","map","a","join","includes","fallback","isNegativeOf","OptionsMemberParserCondition","OptionsInterfaceDeclaration","command","options","Object","values","value","hardline","OptionsParserLogic","entries","env","undefined","JSON","stringify","filter","i"],"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 { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\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 getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"../plugin-utils/context-helpers\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree,\n CommandTreePath,\n NumberCommandOption,\n StringCommandOption\n} from \"../types/command\";\n\nexport interface PositionalOptionsParserLogicProps {\n /**\n * The command path to generate the positional options parser logic for.\n */\n path: CommandTreePath;\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.${envPrefix}_OPTION_NAME`).\n */\n envPrefix: string;\n}\n\nexport function PositionalOptionsParserLogic(\n props: PositionalOptionsParserLogicProps\n) {\n const { path, envPrefix } = props;\n\n return (\n <For each={path.segments ?? []}>\n {(segment, index) => (\n <Show when={isPositionalCommandOption(segment)}>\n <VarDeclaration\n let\n name={camelCase(getPositionalCommandOptionName(segment))}\n type={\n path.positional[getPositionalCommandOptionName(segment)]?.kind ===\n ReflectionKind.number\n ? path.positional[getPositionalCommandOptionName(segment)]\n ?.variadic\n ? \"number[]\"\n : \"number | undefined\"\n : path.positional[getPositionalCommandOptionName(segment)]\n ?.variadic\n ? \"string[]\"\n : \"string | undefined\"\n }\n initializer={\n path.positional[getPositionalCommandOptionName(segment)]\n ?.variadic ? (\n code`[]`\n ) : (\n <>\n {code`env.${\n envPrefix\n }_${constantCase(path.positional[getPositionalCommandOptionName(segment)]?.name)} ?? `}\n <Show\n when={isSetString(\n path.positional[getPositionalCommandOptionName(segment)]\n ?.default\n )}>\n {code`\"${\n path.positional[getPositionalCommandOptionName(segment)]\n ?.default\n }\"`}\n </Show>\n {code`undefined;`}\n </>\n )\n }\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${2 + index} && args[${2 + index}]`}>\n {code`${camelCase(getPositionalCommandOptionName(segment))} = args[${2 + index}];`}\n </IfStatement>\n <hbr />\n <hbr />\n </Show>\n )}\n </For>\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 === ReflectionKind.string}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={\n (option as StringCommandOption).variadic ? \"string[]\" : \"string\"\n }\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === ReflectionKind.number}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={\n (option as NumberCommandOption).variadic ? \"number[]\" : \"number\"\n }\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === ReflectionKind.boolean}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type=\"boolean\"\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 ? name : name.toLowerCase()\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive && name.length > 1 ? a : a.toLowerCase()) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive && name.length > 1\n ? a\n : a.toLowerCase()\n )\n .join(\"|\")})=/`;\n\n return (\n <>\n <Show\n when={\n option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number\n }>\n <Show\n when={(option as StringCommandOption | NumberCommandOption).variadic}>\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(arg${isCaseSensitive ? \"\" : \".toLowerCase()\"})`}>\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 === ReflectionKind.string}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === ReflectionKind.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 {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 === ReflectionKind.string}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === ReflectionKind.number}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\n </Show>\n {code`); `}\n </ElseIfClause>\n </Show>\n <Show\n when={\n !(option as StringCommandOption | NumberCommandOption).variadic\n }>\n <IfStatement\n condition={`${equalsRegex}.test(arg${isCaseSensitive ? \"\" : \".toLowerCase()\"})`}>\n <Show when={option.kind === ReflectionKind.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 <Show when={option.kind === ReflectionKind.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 </IfStatement>\n </Show>\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show when={option.kind === ReflectionKind.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 <Show when={option.kind === ReflectionKind.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 </IfStatement>\n </Show>\n </ElseIfClause>\n <hbr />\n </Show>\n </Show>\n <Show when={option.kind === ReflectionKind.boolean}>\n <IfStatement\n condition={`${equalsRegex}.test(arg${isCaseSensitive ? \"\" : \".toLowerCase()\"})`}>\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 {code` = value !== \"false\" && value !== \"f\" && value !== \"no\" && value !== \"n\" && value !== \"0\" && value !== \"off\" && value !== \"disable\" && value !== \"disabled\"; `}\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, isCaseSensitive } = props;\n\n return (\n <>\n {code`arg${isCaseSensitive ? \"\" : \".toLowerCase()\"}.startsWith(\"--${\n isCaseSensitive ? name : name.toLowerCase()\n }=\") || arg${isCaseSensitive ? \"\" : \".toLowerCase()\"} === \"--${\n isCaseSensitive ? name : name.toLowerCase()\n }\" || arg.startsWith(\"-${name}=\") || arg === \"-${name}\"`}\n <Show when={alias && alias.length > 0}>\n <For each={alias ?? []}>\n {a =>\n code` || arg${isCaseSensitive ? \"\" : \".toLowerCase()\"}.startsWith(\"--${\n isCaseSensitive ? a : a.toLowerCase()\n }=\") || arg${isCaseSensitive ? \"\" : \".toLowerCase()\"} === \"--${\n isCaseSensitive ? a : a.toLowerCase()\n }\" || arg.startsWith(\"-${a}=\") || arg === \"-${a}\"`\n }\n </For>\n </Show>\n </>\n );\n}\n\nexport function OptionsInterfaceDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const options = computed(() => computedOptions(command));\n\n return (\n <InterfaceDeclaration export name={`${pascalCase(command.name)}Options`}>\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.${envPrefix}_OPTION_NAME`).\n */\n envPrefix: 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, envPrefix, isCaseSensitive = false } = props;\n\n const options = computed(() => computedOptions(command));\n\n return (\n <>\n <VarDeclaration\n const\n name=\"options\"\n initializer={code` {\n ${Object.entries(options.value)\n .map(([name, option]) => {\n if (option.kind === ReflectionKind.string) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${envPrefix}_${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 === ReflectionKind.number) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${envPrefix}_${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 === ReflectionKind.boolean) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${envPrefix}_${option.env} ?? ` : \"\"\n }${option.default ? \"true\" : \"false\"},`;\n }\n\n return \"\";\n })\n .join(\"\")}\n } as ${pascalCase(command.name)}Options;`}\n />\n <hbr />\n <hbr />\n {code`for (let i = 0; i < args.slice(${\n command.path.segments.filter(segment =>\n isPositionalCommandOption(segment)\n ).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 ? \"\" : \".toLowerCase()\"\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"],"mappings":";;;;;;;;;;;;AA0DA,SAAgBkB,6BACdC,OACA;CACA,MAAM,EAAEC,MAAMC,cAAcF;AAE5B,QAAAG,gBACGpB,KAAG;EAAA,IAACqB,OAAI;AAAA,UAAEH,KAAKI,YAAY,EAAE;;EAAAC,WAC1BC,SAASC,UAAKL,gBACbnB,MAAI;GAAA,IAACyB,OAAI;AAAA,WAAEX,0BAA0BS,QAAQ;;GAAA,IAAAD,WAAA;AAAA,WAAA;KAAAH,gBAC3Cb,gBAAc;MAAA,OAAA;MAAA,IAEboB,OAAI;AAAA,cAAElB,UAAUK,+BAA+BU,QAAQ,CAAC;;MAAA,IACxDI,OAAI;AAAA,cACFC,WAAAX,KAAKY,WAAWhB,+BAA+BU,QAAQ,GAAGO,SAC1DvB,eAAewB,OAAM,EAAA,GACjBd,KAAKY,WAAWhB,+BAA+BU,QAAQ,GACnDS,WACF,aACA,uBACFf,KAAKY,WAAWhB,+BAA+BU,QAAQ,GACjDS,WACJ,aACA;;MAAoB,IAE5BC,cAAW;AAAA,cACTL,WAAA,CAAA,CAAAX,KAAKY,WAAWhB,+BAA+BU,QAAQ,GACnDS,SAAQ,EAAA,GACVnC,IAAI,OAAI;QAAA+B,WAGL/B,IAAI,OACHqB,UAAS,GACPT,aAAaQ,KAAKY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AAA;GAIvC,CAAA;EAAAZ,gBAAA,OAAA,EAAA,CAAA;EAIFtC,IAAI;EAAKsC,gBAAA,OAAA,EAAA,CAAA;EAAA"}
1
+ {"version":3,"file":"options-parser-logic.mjs","names":["code","computed","For","Show","ElseClause","ElseIfClause","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","ReflectionKind","camelCase","pascalCase","isSetString","computedOptions","getDynamicPathSegmentName","isDynamicPathSegment","DynamicPathSegmentsParserLogic","props","path","_$createComponent","each","segments","children","segment","index","when","name","type","dynamics","variadic","optional","initializer","_$memo","default","_$createIntrinsic","condition","OptionsMember","option","doc","description","title","Boolean","kind","string","number","boolean","OptionsMemberParserLogic","isCaseSensitive","equalsRegex","length","toLowerCase","alias","map","a","join","includes","fallback","isNegativeOf","OptionsMemberParserCondition","OptionsInterfaceDeclaration","command","options","Object","values","value","hardline","OptionsParserLogic","envPrefix","entries","env","undefined","JSON","stringify","filter","i"],"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 { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { camelCase } from \"@stryke/string-format/camel-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 CommandTreePath,\n NumberCommandOption,\n StringCommandOption\n} from \"../types/command\";\n\nexport interface DynamicPathSegmentsParserLogicProps {\n /**\n * The command path to generate the dynamic path segments parser logic for.\n */\n path: CommandTreePath;\n}\n\nexport function DynamicPathSegmentsParserLogic(\n props: DynamicPathSegmentsParserLogicProps\n) {\n const { path } = props;\n\n return (\n <For each={path.segments ?? []}>\n {(segment, index) => (\n <Show when={isDynamicPathSegment(segment)}>\n <VarDeclaration\n let\n name={camelCase(getDynamicPathSegmentName(segment))}\n type={`${\n path.dynamics[getDynamicPathSegmentName(segment)]?.variadic\n ? \"string[]\"\n : \"string\"\n }${\n path.dynamics[getDynamicPathSegmentName(segment)]?.optional\n ? \" | undefined\"\n : \"\"\n }`}\n initializer={\n path.dynamics[getDynamicPathSegmentName(segment)]?.variadic ? (\n code`[]`\n ) : (\n <>\n <Show\n when={isSetString(\n path.dynamics[getDynamicPathSegmentName(segment)]?.default\n )}>\n {code`\"${\n path.dynamics[getDynamicPathSegmentName(segment)]?.default\n }\"`}\n </Show>\n {code`undefined;`}\n </>\n )\n }\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${2 + index} && args[${2 + index}]`}>\n {code`${camelCase(getDynamicPathSegmentName(segment))} = args[${2 + index}];`}\n </IfStatement>\n <hbr />\n <hbr />\n </Show>\n )}\n </For>\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 === ReflectionKind.string}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={\n (option as StringCommandOption).variadic ? \"string[]\" : \"string\"\n }\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === ReflectionKind.number}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type={\n (option as NumberCommandOption).variadic ? \"number[]\" : \"number\"\n }\n optional={option.optional}\n />\n </Show>\n <Show when={option.kind === ReflectionKind.boolean}>\n <InterfaceMember\n name={option.name}\n doc={doc}\n type=\"boolean\"\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 ? name : name.toLowerCase()\n }${option.alias && option.alias.length > 0 ? \"|\" : \"\"}${option.alias\n ?.map(a =>\n (isCaseSensitive && name.length > 1 ? a : a.toLowerCase()) === \"?\"\n ? \"\\\\?\"\n : isCaseSensitive && name.length > 1\n ? a\n : a.toLowerCase()\n )\n .join(\"|\")})=/`;\n\n return (\n <>\n <Show\n when={\n option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number\n }>\n <Show\n when={(option as StringCommandOption | NumberCommandOption).variadic}>\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(arg${isCaseSensitive ? \"\" : \".toLowerCase()\"})`}>\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 === ReflectionKind.string}>\n {code`...arg.replace(${equalsRegex}, \"\").split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === ReflectionKind.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 {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 === ReflectionKind.string}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean) `}\n </Show>\n <Show when={option.kind === ReflectionKind.number}>\n {code`...args[++i].split(\",\").map(item => item.trim().replace(/^(\"|')/, \"\").replace(/(\"|')$/, \"\")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}\n </Show>\n {code`); `}\n </ElseIfClause>\n </Show>\n <Show\n when={\n !(option as StringCommandOption | NumberCommandOption).variadic\n }>\n <IfStatement\n condition={`${equalsRegex}.test(arg${isCaseSensitive ? \"\" : \".toLowerCase()\"})`}>\n <Show when={option.kind === ReflectionKind.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 <Show when={option.kind === ReflectionKind.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 </IfStatement>\n </Show>\n </IfStatement>\n <ElseIfClause condition={`args.length > i + 1`}>\n <Show when={option.kind === ReflectionKind.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 <Show when={option.kind === ReflectionKind.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 </IfStatement>\n </Show>\n </ElseIfClause>\n <hbr />\n </Show>\n </Show>\n <Show when={option.kind === ReflectionKind.boolean}>\n <IfStatement\n condition={`${equalsRegex}.test(arg${isCaseSensitive ? \"\" : \".toLowerCase()\"})`}>\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 {code` = value !== \"false\" && value !== \"f\" && value !== \"no\" && value !== \"n\" && value !== \"0\" && value !== \"off\" && value !== \"disable\" && value !== \"disabled\"; `}\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, isCaseSensitive } = props;\n\n return (\n <>\n {code`arg${isCaseSensitive ? \"\" : \".toLowerCase()\"}.startsWith(\"--${\n isCaseSensitive ? name : name.toLowerCase()\n }=\") || arg${isCaseSensitive ? \"\" : \".toLowerCase()\"} === \"--${\n isCaseSensitive ? name : name.toLowerCase()\n }\" || arg.startsWith(\"-${name}=\") || arg === \"-${name}\"`}\n <Show when={alias && alias.length > 0}>\n <For each={alias ?? []}>\n {a =>\n code` || arg${isCaseSensitive ? \"\" : \".toLowerCase()\"}.startsWith(\"--${\n isCaseSensitive || a.length === 1 ? a : a.toLowerCase()\n }=\") || arg${isCaseSensitive ? \"\" : \".toLowerCase()\"} === \"--${\n isCaseSensitive || a.length === 1 ? a : a.toLowerCase()\n }\" || arg.startsWith(\"-${a}=\") || arg === \"-${a}\"`\n }\n </For>\n </Show>\n </>\n );\n}\n\nexport function OptionsInterfaceDeclaration(props: { command: CommandTree }) {\n const { command } = props;\n\n const options = computed(() => computedOptions(command));\n\n return (\n <InterfaceDeclaration export name={`${pascalCase(command.name)}Options`}>\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.${envPrefix}_OPTION_NAME`).\n */\n envPrefix: 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, envPrefix, isCaseSensitive = false } = props;\n\n const options = computed(() => computedOptions(command));\n\n return (\n <>\n <VarDeclaration\n const\n name=\"options\"\n initializer={code` {\n ${Object.entries(options.value)\n .map(([name, option]) => {\n if (option.kind === ReflectionKind.string) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${envPrefix}_${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 === ReflectionKind.number) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${envPrefix}_${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 === ReflectionKind.boolean) {\n return ` ${name.includes(\"?\") || name.includes(\"-\") ? `\"${name}\"` : `${name}`}: ${\n option.env ? `env.${envPrefix}_${option.env} ?? ` : \"\"\n }${option.default ? \"true\" : \"false\"},`;\n }\n\n return \"\";\n })\n .join(\"\")}\n } as ${pascalCase(command.name)}Options;`}\n />\n <hbr />\n <hbr />\n {code`for (let i = 0; i < args.slice(${\n command.path.segments.filter(segment => isDynamicPathSegment(segment))\n .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 ? \"\" : \".toLowerCase()\"\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"],"mappings":";;;;;;;;;;;AAoDA,SAAgBiB,+BACdC,OACA;CACA,MAAM,EAAEC,SAASD;AAEjB,QAAAE,gBACGlB,KAAG;EAAA,IAACmB,OAAI;AAAA,UAAEF,KAAKG,YAAY,EAAE;;EAAAC,WAC1BC,SAASC,UAAKL,gBACbjB,MAAI;GAAA,IAACuB,OAAI;AAAA,WAAEV,qBAAqBQ,QAAQ;;GAAA,IAAAD,WAAA;AAAA,WAAA;KAAAH,gBACtCX,gBAAc;MAAA,OAAA;MAAA,IAEbkB,OAAI;AAAA,cAAEhB,UAAUI,0BAA0BS,QAAQ,CAAC;;MAAA,IACnDI,OAAI;AAAA,cAAE,GACJT,KAAKU,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,8BAA4B;QACrBhC;QAAI,IACVyB,QAAK;AAAA,gBAAEd,OAAOc;;QACGJ;QAAe,CAAA;;MAAA,IAAAzB,WAAA;AAAA,cAAAH,gBAGnC2B,0BAAwB;QACjBpB;QACEW;QACSU;QAAe,CAAA;;MAAA,CAAA;;IAAA,CAAA;GAIvC,CAAA;EAAAb,gBAAA,OAAA,EAAA,CAAA;EAIFnC,IAAI;EAAKmC,gBAAA,OAAA,EAAA,CAAA;EAAA"}
@@ -32,7 +32,7 @@ function Usage(props) {
32
32
  })
33
33
  ];
34
34
  } }),
35
- (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`${bin} ${command.path.segments.map((segment) => require_plugin_utils_context_helpers.isPositionalCommandOption(segment) ? `<${(0, __stryke_string_format_snake_case.snakeCase)(command.path.positional[segment]?.name || require_plugin_utils_context_helpers.getPositionalCommandOptionName(segment))}${command.path.positional[segment]?.variadic ? "..." : ""}>` : segment).join(" ")}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options]`)
35
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`${bin} ${command.path.segments.map((segment) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment) ? `<${(0, __stryke_string_format_snake_case.snakeCase)(command.path.dynamics[segment]?.name || require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment))}${command.path.dynamics[segment]?.variadic ? "..." : ""}>` : segment).join(" ")}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options]`)
36
36
  ];
37
37
  }
38
38
 
@@ -1 +1 @@
1
- {"version":3,"file":"usage.cjs","names":["code","Match","Switch","snakeCase","getPositionalCommandOptionName","isPositionalCommandOption","Usage","props","command","bin","packageManager","_$createComponent","children","when","_$memo","path","segments","map","segment","positional","name","variadic","join","Object","values","length"],"sources":["../../src/components/usage.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, Match, Switch } from \"@alloy-js/core\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport {\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types/command\";\n\nexport interface UsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The package manager to generate the usage example for.\n *\n * @remarks\n * If not specified, examples for all supported package managers will be generated.\n *\n * @defaultValue \"npm\"\n */\n packageManager?: \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\n /**\n * The bin name to use in the usage display.\n */\n bin: string;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function Usage(props: UsageProps) {\n const { command, bin, packageManager } = props;\n\n return (\n <>\n {code`$ `}\n <Switch>\n <Match when={packageManager === \"yarn\"}>{`yarn exec `}</Match>\n <Match when={packageManager === \"pnpm\"}>{`pnpm exec `}</Match>\n <Match when={packageManager === \"bun\"}>{`bun x `}</Match>\n <Match else>{`npx `}</Match>\n </Switch>\n {code`${bin} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `<${snakeCase(\n command.path.positional[segment]?.name ||\n getPositionalCommandOptionName(segment)\n )}${command.path.positional[segment]?.variadic ? \"...\" : \"\"}>`\n : segment\n )\n .join(\" \")}${\n Object.values(command.children).length > 0 ? \" [commands]\" : \"\"\n } [options]`}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAmDA,SAAgBM,MAAMC,OAAmB;CACvC,MAAM,EAAEC,SAASC,KAAKC,mBAAmBH;AAEzC,QAAA;EAEKP,oBAAI;mDACJE,wBAAM,EAAA,IAAAU,WAAA;AAAA,UAAA;qDACJX,uBAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;qDACpDX,uBAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;qDACpDX,uBAAK;KAACY,MAAMH,mBAAmB;KAAKE,UAAG;KAAQ,CAAA;qDAC/CX,uBAAK;KAAA,QAAA;KAAAW,UAAO;KAAM,CAAA;IAAA;KAAA,CAAA;8CAEpBZ,oBAAI,GAAGS,IAAG,GAAID,QAAQO,KAAKC,SACzBC,KAAIC,YACHb,+DAA0Ba,QAAQ,GAC9B,qDACEV,QAAQO,KAAKI,WAAWD,UAAUE,QAChChB,oEAA+Bc,QACnC,CAAC,GAAGV,QAAQO,KAAKI,WAAWD,UAAUG,WAAW,QAAQ,GAAE,KAC3DH,QACL,CACAI,KAAK,IAAI,GACVC,OAAOC,OAAOhB,QAAQI,SAAS,CAACa,SAAS,IAAI,gBAAgB,GAAE,YACrD;EAAA"}
1
+ {"version":3,"file":"usage.cjs","names":["code","Match","Switch","snakeCase","getDynamicPathSegmentName","isDynamicPathSegment","Usage","props","command","bin","packageManager","_$createComponent","children","when","_$memo","path","segments","map","segment","dynamics","name","variadic","join","Object","values","length"],"sources":["../../src/components/usage.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, Match, Switch } from \"@alloy-js/core\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types/command\";\n\nexport interface UsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The package manager to generate the usage example for.\n *\n * @remarks\n * If not specified, examples for all supported package managers will be generated.\n *\n * @defaultValue \"npm\"\n */\n packageManager?: \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\n /**\n * The bin name to use in the usage display.\n */\n bin: string;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function Usage(props: UsageProps) {\n const { command, bin, packageManager } = props;\n\n return (\n <>\n {code`$ `}\n <Switch>\n <Match when={packageManager === \"yarn\"}>{`yarn exec `}</Match>\n <Match when={packageManager === \"pnpm\"}>{`pnpm exec `}</Match>\n <Match when={packageManager === \"bun\"}>{`bun x `}</Match>\n <Match else>{`npx `}</Match>\n </Switch>\n {code`${bin} ${command.path.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `<${snakeCase(\n command.path.dynamics[segment]?.name ||\n getDynamicPathSegmentName(segment)\n )}${command.path.dynamics[segment]?.variadic ? \"...\" : \"\"}>`\n : segment\n )\n .join(\" \")}${\n Object.values(command.children).length > 0 ? \" [commands]\" : \"\"\n } [options]`}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAmDA,SAAgBM,MAAMC,OAAmB;CACvC,MAAM,EAAEC,SAASC,KAAKC,mBAAmBH;AAEzC,QAAA;EAEKP,oBAAI;mDACJE,wBAAM,EAAA,IAAAU,WAAA;AAAA,UAAA;qDACJX,uBAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;qDACpDX,uBAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;qDACpDX,uBAAK;KAACY,MAAMH,mBAAmB;KAAKE,UAAG;KAAQ,CAAA;qDAC/CX,uBAAK;KAAA,QAAA;KAAAW,UAAO;KAAM,CAAA;IAAA;KAAA,CAAA;8CAEpBZ,oBAAI,GAAGS,IAAG,GAAID,QAAQO,KAAKC,SACzBC,KAAIC,YACHb,0DAAqBa,QAAQ,GACzB,qDACEV,QAAQO,KAAKI,SAASD,UAAUE,QAC9BhB,+DAA0Bc,QAC9B,CAAC,GAAGV,QAAQO,KAAKI,SAASD,UAAUG,WAAW,QAAQ,GAAE,KACzDH,QACL,CACAI,KAAK,IAAI,GACVC,OAAOC,OAAOhB,QAAQI,SAAS,CAACa,SAAS,IAAI,gBAAgB,GAAE,YACrD;EAAA"}
@@ -1,5 +1,5 @@
1
1
  import { CommandTree } from "../types/command.cjs";
2
- import * as _alloy_js_core5 from "@alloy-js/core";
2
+ import * as _alloy_js_core9 from "@alloy-js/core";
3
3
 
4
4
  //#region src/components/usage.d.ts
5
5
  interface UsageProps {
@@ -24,7 +24,7 @@ interface UsageProps {
24
24
  /**
25
25
  * A component that generates the usage display for a command.
26
26
  */
27
- declare function Usage(props: UsageProps): _alloy_js_core5.Children;
27
+ declare function Usage(props: UsageProps): _alloy_js_core9.Children;
28
28
  //#endregion
29
29
  export { Usage, UsageProps };
30
30
  //# sourceMappingURL=usage.d.cts.map
@@ -1,5 +1,5 @@
1
1
  import { CommandTree } from "../types/command.mjs";
2
- import * as _alloy_js_core5 from "@alloy-js/core";
2
+ import * as _alloy_js_core0 from "@alloy-js/core";
3
3
 
4
4
  //#region src/components/usage.d.ts
5
5
  interface UsageProps {
@@ -24,7 +24,7 @@ interface UsageProps {
24
24
  /**
25
25
  * A component that generates the usage display for a command.
26
26
  */
27
- declare function Usage(props: UsageProps): _alloy_js_core5.Children;
27
+ declare function Usage(props: UsageProps): _alloy_js_core0.Children;
28
28
  //#endregion
29
29
  export { Usage, UsageProps };
30
30
  //# sourceMappingURL=usage.d.mts.map
@@ -1,4 +1,4 @@
1
- import { getPositionalCommandOptionName, isPositionalCommandOption } from "../plugin-utils/context-helpers.mjs";
1
+ import { getDynamicPathSegmentName, isDynamicPathSegment } from "../plugin-utils/context-helpers.mjs";
2
2
  import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
3
3
  import { Match, Switch, code } from "@alloy-js/core";
4
4
  import { snakeCase } from "@stryke/string-format/snake-case";
@@ -31,7 +31,7 @@ function Usage(props) {
31
31
  })
32
32
  ];
33
33
  } }),
34
- memo(() => code`${bin} ${command.path.segments.map((segment) => isPositionalCommandOption(segment) ? `<${snakeCase(command.path.positional[segment]?.name || getPositionalCommandOptionName(segment))}${command.path.positional[segment]?.variadic ? "..." : ""}>` : segment).join(" ")}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options]`)
34
+ memo(() => code`${bin} ${command.path.segments.map((segment) => isDynamicPathSegment(segment) ? `<${snakeCase(command.path.dynamics[segment]?.name || getDynamicPathSegmentName(segment))}${command.path.dynamics[segment]?.variadic ? "..." : ""}>` : segment).join(" ")}${Object.values(command.children).length > 0 ? " [commands]" : ""} [options]`)
35
35
  ];
36
36
  }
37
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"usage.mjs","names":["code","Match","Switch","snakeCase","getPositionalCommandOptionName","isPositionalCommandOption","Usage","props","command","bin","packageManager","_$createComponent","children","when","_$memo","path","segments","map","segment","positional","name","variadic","join","Object","values","length"],"sources":["../../src/components/usage.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, Match, Switch } from \"@alloy-js/core\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport {\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types/command\";\n\nexport interface UsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The package manager to generate the usage example for.\n *\n * @remarks\n * If not specified, examples for all supported package managers will be generated.\n *\n * @defaultValue \"npm\"\n */\n packageManager?: \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\n /**\n * The bin name to use in the usage display.\n */\n bin: string;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function Usage(props: UsageProps) {\n const { command, bin, packageManager } = props;\n\n return (\n <>\n {code`$ `}\n <Switch>\n <Match when={packageManager === \"yarn\"}>{`yarn exec `}</Match>\n <Match when={packageManager === \"pnpm\"}>{`pnpm exec `}</Match>\n <Match when={packageManager === \"bun\"}>{`bun x `}</Match>\n <Match else>{`npx `}</Match>\n </Switch>\n {code`${bin} ${command.path.segments\n .map(segment =>\n isPositionalCommandOption(segment)\n ? `<${snakeCase(\n command.path.positional[segment]?.name ||\n getPositionalCommandOptionName(segment)\n )}${command.path.positional[segment]?.variadic ? \"...\" : \"\"}>`\n : segment\n )\n .join(\" \")}${\n Object.values(command.children).length > 0 ? \" [commands]\" : \"\"\n } [options]`}\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAmDA,SAAgBM,MAAMC,OAAmB;CACvC,MAAM,EAAEC,SAASC,KAAKC,mBAAmBH;AAEzC,QAAA;EAEKP,IAAI;EAAIW,gBACRT,QAAM,EAAA,IAAAU,WAAA;AAAA,UAAA;IAAAD,gBACJV,OAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;IAAAD,gBACpDV,OAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;IAAAD,gBACpDV,OAAK;KAACY,MAAMH,mBAAmB;KAAKE,UAAG;KAAQ,CAAA;IAAAD,gBAC/CV,OAAK;KAAA,QAAA;KAAAW,UAAO;KAAM,CAAA;IAAA;KAAA,CAAA;EAAAE,WAEpBd,IAAI,GAAGS,IAAG,GAAID,QAAQO,KAAKC,SACzBC,KAAIC,YACHb,0BAA0Ba,QAAQ,GAC9B,IAAIf,UACFK,QAAQO,KAAKI,WAAWD,UAAUE,QAChChB,+BAA+Bc,QACnC,CAAC,GAAGV,QAAQO,KAAKI,WAAWD,UAAUG,WAAW,QAAQ,GAAE,KAC3DH,QACL,CACAI,KAAK,IAAI,GACVC,OAAOC,OAAOhB,QAAQI,SAAS,CAACa,SAAS,IAAI,gBAAgB,GAAE,YACrD;EAAA"}
1
+ {"version":3,"file":"usage.mjs","names":["code","Match","Switch","snakeCase","getDynamicPathSegmentName","isDynamicPathSegment","Usage","props","command","bin","packageManager","_$createComponent","children","when","_$memo","path","segments","map","segment","dynamics","name","variadic","join","Object","values","length"],"sources":["../../src/components/usage.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, Match, Switch } from \"@alloy-js/core\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types/command\";\n\nexport interface UsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The package manager to generate the usage example for.\n *\n * @remarks\n * If not specified, examples for all supported package managers will be generated.\n *\n * @defaultValue \"npm\"\n */\n packageManager?: \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\n /**\n * The bin name to use in the usage display.\n */\n bin: string;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function Usage(props: UsageProps) {\n const { command, bin, packageManager } = props;\n\n return (\n <>\n {code`$ `}\n <Switch>\n <Match when={packageManager === \"yarn\"}>{`yarn exec `}</Match>\n <Match when={packageManager === \"pnpm\"}>{`pnpm exec `}</Match>\n <Match when={packageManager === \"bun\"}>{`bun x `}</Match>\n <Match else>{`npx `}</Match>\n </Switch>\n {code`${bin} ${command.path.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `<${snakeCase(\n command.path.dynamics[segment]?.name ||\n getDynamicPathSegmentName(segment)\n )}${command.path.dynamics[segment]?.variadic ? \"...\" : \"\"}>`\n : segment\n )\n .join(\" \")}${\n Object.values(command.children).length > 0 ? \" [commands]\" : \"\"\n } [options]`}\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAmDA,SAAgBM,MAAMC,OAAmB;CACvC,MAAM,EAAEC,SAASC,KAAKC,mBAAmBH;AAEzC,QAAA;EAEKP,IAAI;EAAIW,gBACRT,QAAM,EAAA,IAAAU,WAAA;AAAA,UAAA;IAAAD,gBACJV,OAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;IAAAD,gBACpDV,OAAK;KAACY,MAAMH,mBAAmB;KAAME,UAAG;KAAY,CAAA;IAAAD,gBACpDV,OAAK;KAACY,MAAMH,mBAAmB;KAAKE,UAAG;KAAQ,CAAA;IAAAD,gBAC/CV,OAAK;KAAA,QAAA;KAAAW,UAAO;KAAM,CAAA;IAAA;KAAA,CAAA;EAAAE,WAEpBd,IAAI,GAAGS,IAAG,GAAID,QAAQO,KAAKC,SACzBC,KAAIC,YACHb,qBAAqBa,QAAQ,GACzB,IAAIf,UACFK,QAAQO,KAAKI,SAASD,UAAUE,QAC9BhB,0BAA0Bc,QAC9B,CAAC,GAAGV,QAAQO,KAAKI,SAASD,UAAUG,WAAW,QAAQ,GAAE,KACzDH,QACL,CACAI,KAAK,IAAI,GACVC,OAAOC,OAAOhB,QAAQI,SAAS,CAACa,SAAS,IAAI,gBAAgB,GAAE,YACrD;EAAA"}
@@ -31,7 +31,7 @@ function resolveCommandOptionDescription(kind, optional, name, title, defaultVal
31
31
  return `A${optional && !defaultValue ? "n optional" : ""} ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "flag provided via the command-line" : "command-line option"} that allows the user to ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "set the" : kind === __powerlines_deepkit_vendor_type.ReflectionKind.array ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "indicator" : `${kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? "numeric" : "string"} value${kind === __powerlines_deepkit_vendor_type.ReflectionKind.array ? "s" : ""}`} that will be used in the application.`;
32
32
  }
33
33
  function resolveCommandId(context, file) {
34
- return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).split("/").filter((p) => Boolean(p) && !require_plugin_utils_context_helpers.isPositionalCommandOption(p)).join("/").replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").replaceAll("/", "-");
34
+ return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).split("/").filter((p) => Boolean(p) && !require_plugin_utils_context_helpers.isDynamicPathSegment(p)).join("/").replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").replaceAll("/", "-");
35
35
  }
36
36
  /**
37
37
  * Finds the command name from the given file path.
@@ -42,14 +42,14 @@ function resolveCommandId(context, file) {
42
42
  function resolveCommandName(file) {
43
43
  let path = (0, __stryke_path_file_path_fns.findFilePath)(file);
44
44
  let name = (0, __stryke_path_file_path_fns.findFolderName)(file, { requireExtension: true });
45
- while (require_plugin_utils_context_helpers.isPositionalCommandOption(name)) {
45
+ while (require_plugin_utils_context_helpers.isDynamicPathSegment(name)) {
46
46
  path = (0, __stryke_path_resolve_parent_path.resolveParentPath)(path);
47
47
  name = (0, __stryke_path_file_path_fns.findFolderName)(path, { requireExtension: true });
48
48
  }
49
49
  return name;
50
50
  }
51
51
  function resolveCommandPath(context, file) {
52
- return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "");
52
+ return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").split("/").filter((path) => path && !require_plugin_utils_context_helpers.isPathSegmentGroup(path)).join("/");
53
53
  }
54
54
  function findCommandsRoot(context) {
55
55
  if ((0, __stryke_type_checks_is_set_string.isSetString)(context.config.entry)) return (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)(context.config.entry), context.config.projectRoot), context.workspaceConfig.workspaceRoot);
@@ -92,23 +92,24 @@ function extractCommandOption(command, reflection) {
92
92
  * @param reflection - The type parameter reflection to extract information from.
93
93
  * @returns The extracted command option information.
94
94
  */
95
- function extractCommandPositionalOption(command, segment, reflection) {
96
- if (reflection.type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.string && reflection.type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.number && !(reflection.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array && (reflection.type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || reflection.type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number))) throw new Error(`Unsupported type for positional option "${segment}" in command "${command.name}". Only string and number types (or string[] and number[]) are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(reflection.type).trim().replaceAll(" | ", ", or ")}.`);
95
+ function extractCommandDynamicSegment(command, segment, reflection) {
96
+ if (reflection.type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.string && !(reflection.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array && reflection.type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string)) throw new Error(`Unsupported type for dynamic path segment "${segment}" in command "${command.name}". Only string types (or an array of strings) are supported, received ${(0, __powerlines_deepkit_vendor_type.stringifyType)(reflection.type).trim().replaceAll(" | ", ", or ")}.`);
97
97
  const option = {
98
98
  name: segment,
99
- alias: [],
100
99
  title: (0, __stryke_string_format_title_case.titleCase)(segment),
101
- description: reflection.description || resolveCommandOptionDescription(reflection.type.kind, !!reflection.optional, segment, (0, __stryke_string_format_title_case.titleCase)(segment), reflection.default),
102
- env: (0, __stryke_string_format_constant_case.constantCase)(segment),
103
- kind: reflection.type.kind,
100
+ description: reflection.description || resolveCommandOptionDescription(__powerlines_deepkit_vendor_type.ReflectionKind.string, !!reflection.optional, segment, (0, __stryke_string_format_title_case.titleCase)(segment), reflection.default),
104
101
  optional: reflection.optional,
105
102
  default: reflection.default,
106
- variadic: false
103
+ catchAll: command.path.segments.some((seg) => require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment) === seg && require_plugin_utils_context_helpers.isCatchAllPathSegment(seg))
107
104
  };
108
- if (reflection.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array) if (reflection.type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || reflection.type.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) {
105
+ if (reflection.type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array) {
106
+ if (!option.catchAll) throw new Error(`Dynamic path segment "${segment}" in command "${command.name}" is an array type but is not defined as a catch-all segment. To use an array type for a dynamic path segment, it must be defined as a catch-all segment using the "[...segment]" syntax.`);
109
107
  option.variadic = true;
110
- option.kind = reflection.type.type.kind;
111
- } else throw new Error(`Unsupported array type for option "${segment}" in command "${command.name}". Only string[] and number[] are supported.`);
108
+ }
109
+ if (option.catchAll) {
110
+ if (!option.optional && command.path.segments.some((seg) => require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment) === seg && require_plugin_utils_context_helpers.isOptionalCatchAllPathSegment(seg))) throw new Error(`Dynamic path segment "${segment}" in command "${command.name}" is defined as a catch-all segment but is not optional. To define an optional catch-all segment, use the "[[...segment]]" syntax.`);
111
+ else if (option.optional && !command.path.segments.some((seg) => require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment) === seg && require_plugin_utils_context_helpers.isOptionalCatchAllPathSegment(seg))) throw new Error(`Dynamic path segment "${segment}" in command "${command.name}" is defined as an optional segment but is not defined as an optional catch-all segment. To define an optional catch-all segment, use the "[[...segment]]" syntax.`);
112
+ }
112
113
  return option;
113
114
  }
114
115
  /**
@@ -127,7 +128,7 @@ async function reflectCommandTree(context, command, parent) {
127
128
  title,
128
129
  path: {
129
130
  ...command.path,
130
- positional: {}
131
+ dynamics: {}
131
132
  },
132
133
  options: require_utilities.getDefaultOptions(context, command),
133
134
  parent: parent ?? null,
@@ -153,11 +154,11 @@ async function reflectCommandTree(context, command, parent) {
153
154
  const optionsReflection = __powerlines_deepkit_vendor_type.ReflectionClass.from(firstParam.type);
154
155
  for (const propertyReflection of optionsReflection.getProperties()) tree.options[propertyReflection.getNameAsString()] = extractCommandOption(command, propertyReflection);
155
156
  }
156
- tree.path.positional = tree.path.segments.filter((segment) => require_plugin_utils_context_helpers.isPositionalCommandOption(segment)).reduce((obj, segment, index) => {
157
+ tree.path.dynamics = tree.path.segments.filter((segment) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment)).reduce((obj, segment, index) => {
157
158
  if (type.parameters.length < index + 2 || !type.parameters[index + 1]) return obj;
158
- const paramName = require_plugin_utils_context_helpers.getPositionalCommandOptionName(segment);
159
- obj[paramName] = extractCommandPositionalOption(command, paramName, type.parameters[index + 1]);
160
- obj[paramName].description = obj[paramName].description || `The ${paramName} positional option for the ${command.name} command.`;
159
+ const paramName = require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment);
160
+ obj[paramName] = extractCommandDynamicSegment(command, paramName, type.parameters[index + 1]);
161
+ obj[paramName].description = obj[paramName].description || `The ${paramName} ${obj[paramName].catchAll ? `${obj[paramName].optional ? "optional " : ""}catch-all` : "dynamic "} segment for the ${command.name} command.`;
161
162
  return obj;
162
163
  }, {});
163
164
  }
@@ -181,20 +182,8 @@ async function reflectCommandTree(context, command, parent) {
181
182
  }
182
183
  });
183
184
  });
184
- if (Object.values(tree.path.positional).filter((option) => option.env !== false).length > 0) Object.values(tree.path.positional).filter((option) => option.env !== false).forEach((option) => context.env.types.env.addProperty({
185
- name: (0, __stryke_string_format_constant_case.constantCase)(option.name),
186
- optional: option.optional ? true : void 0,
187
- description: option.description,
188
- visibility: __powerlines_deepkit_vendor_type.ReflectionVisibility.public,
189
- type: option.variadic ? {
190
- kind: __powerlines_deepkit_vendor_type.ReflectionKind.array,
191
- type: { kind: __powerlines_deepkit_vendor_type.ReflectionKind.string }
192
- } : { kind: __powerlines_deepkit_vendor_type.ReflectionKind.string },
193
- default: option.default,
194
- tags: { domain: "cli" }
195
- }));
196
185
  }
197
- for (const input of context.inputs.filter((input$1) => input$1.path.segments.filter((segment) => !require_plugin_utils_context_helpers.isPositionalCommandOption(segment)).length === command.path.segments.filter((segment) => !require_plugin_utils_context_helpers.isPositionalCommandOption(segment)).length + 1 && input$1.path.segments.slice(0, command.path.segments.length).every((value, index) => value === command.path.segments[index]))) tree.children[input.name] = await reflectCommandTree(context, input, tree);
186
+ for (const input of context.inputs.filter((input$1) => input$1.path.segments.filter((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment)).length === command.path.segments.filter((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment)).length + 1 && input$1.path.segments.slice(0, command.path.segments.length).every((value, index) => value === command.path.segments[index]))) tree.children[input.name] = await reflectCommandTree(context, input, tree);
198
187
  return tree;
199
188
  }
200
189
 
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-command.cjs","names":["esbuildPlugin","reflect","ReflectionClass","ReflectionKind","ReflectionVisibility","stringifyType","toArray","appendPath","commonPath","findFilePath","findFolderName","stripStars","replacePath","resolveParentPath","constantCase","titleCase","isSetObject","isSetString","resolveModule","getAppTitle","getPositionalCommandOptionName","isPositionalCommandOption","getDefaultOptions","resolveCommandOptionDescription","kind","optional","name","title","defaultValue","boolean","array","trim","number","resolveCommandId","context","file","commandsPath","split","filter","p","Boolean","join","replaceAll","resolveCommandName","path","requireExtension","resolveCommandPath","resolveCommandParams","map","findCommandsRoot","config","entry","projectRoot","workspaceConfig","workspaceRoot","Array","isArray","length","sourceRoot","extractCommandOption","command","reflection","propertyType","getType","option","getNameAsString","alias","getTags","description","getDescription","getKind","isOptional","getDefaultValue","env","default","variadic","type","string","Error","extractCommandPositionalOption","segment","reflectCommandTree","parent","isVirtual","replace","tree","positional","options","children","input","fs","existsSync","debug","id","resolved","plugins","reflectionLevel","metadata","function","parameters","firstParam","objectLiteral","class","optionsReflection","from","propertyReflection","getProperties","segments","reduce","obj","index","paramName","Object","values","forEach","types","addProperty","undefined","visibility","public","tags","domain","inputs","slice","every","value"],"sources":["../../src/helpers/resolve-command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionProperty,\n TypeParameter\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandInput,\n CommandModule,\n CommandOption,\n CommandPositionalOption,\n CommandTree,\n NumberCommandOption,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param name - The name of the command option.\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n kind: ReflectionKind,\n optional: boolean,\n name: string,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} ${\n kind === ReflectionKind.boolean\n ? \"flag provided via the command-line\"\n : \"command-line option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : kind === ReflectionKind.array\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n kind === ReflectionKind.array ? \"s\" : \"\"\n }`\n } that will be used in the application.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isPositionalCommandOption(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isPositionalCommandOption(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\");\n}\n\nexport function resolveCommandParams(context: Context, file: string): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && isPositionalCommandOption(p))\n .map(p => p.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\"));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const propertyType = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getKind(),\n reflection.isOptional(),\n reflection.getNameAsString(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: propertyType.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: false\n } as CommandOption;\n if (propertyType.kind === ReflectionKind.array) {\n if (\n propertyType.type.kind === ReflectionKind.string ||\n propertyType.type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind =\n propertyType.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported.`\n );\n }\n } else if (\n propertyType.kind !== ReflectionKind.boolean &&\n propertyType.kind !== ReflectionKind.string &&\n propertyType.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n propertyType\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param segment - The command path segment corresponding to the parameter.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandPositionalOption(\n command: CommandInput,\n segment: string,\n reflection: TypeParameter\n): CommandPositionalOption {\n if (\n reflection.type.kind !== ReflectionKind.string &&\n reflection.type.kind !== ReflectionKind.number &&\n !(\n reflection.type.kind === ReflectionKind.array &&\n (reflection.type.type.kind === ReflectionKind.string ||\n reflection.type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for positional option \"${segment}\" in command \"${\n command.name\n }\". Only string and number types (or string[] and number[]) are supported, received ${stringifyType(\n reflection.type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const option = {\n name: segment,\n alias: [],\n title: titleCase(segment),\n description:\n reflection.description ||\n resolveCommandOptionDescription(\n reflection.type.kind,\n !!reflection.optional,\n segment,\n titleCase(segment),\n reflection.default\n ),\n env: constantCase(segment),\n kind: reflection.type.kind,\n optional: reflection.optional,\n default: reflection.default,\n variadic: false\n } as CommandPositionalOption;\n\n if (reflection.type.kind === ReflectionKind.array) {\n if (\n reflection.type.type.kind === ReflectionKind.string ||\n reflection.type.type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind =\n reflection.type.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for option \"${segment}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported.`\n );\n }\n }\n\n return option;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${parent?.title ? `${parent.isVirtual ? parent.title.replace(/ Commands$/, \"\") : parent.title} - ` : \"\"}${titleCase(command.name)}${\n command.isVirtual ? \" Commands\" : \"\"\n }`;\n\n const tree = {\n alias: [],\n ...command,\n title,\n path: {\n ...command.path,\n positional: {}\n },\n options: getDefaultOptions(context, command),\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n\n const type = reflect(resolved);\n\n // const type = await reflectType<TContext>(context, command.entry.input);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title} executable command-line interface.`;\n\n if (type.parameters.length > 0 && type.parameters[0]) {\n const firstParam = type.parameters[0];\n if (\n firstParam.type.kind === ReflectionKind.objectLiteral ||\n firstParam.type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(firstParam.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n }\n\n tree.path.positional = tree.path.segments\n .filter(segment => isPositionalCommandOption(segment))\n .reduce(\n (obj, segment, index) => {\n if (\n type.parameters.length < index + 2 ||\n !type.parameters[index + 1]\n ) {\n return obj;\n }\n\n const paramName = getPositionalCommandOptionName(segment);\n obj[paramName] = extractCommandPositionalOption(\n command,\n paramName,\n type.parameters[index + 1]!\n );\n\n obj[paramName].description =\n obj[paramName].description ||\n `The ${paramName} positional option for the ${command.name} command.`;\n\n return obj;\n },\n {} as Record<string, CommandPositionalOption>\n );\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command-line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number\n ? option.variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }\n : { kind: ReflectionKind.boolean },\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 0)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n if (\n Object.values(tree.path.positional).filter(option => option.env !== false)\n .length > 0\n ) {\n Object.values(tree.path.positional)\n .filter(option => option.env !== false)\n .forEach(option =>\n context.env.types.env.addProperty({\n name: constantCase(option.name),\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: option.variadic\n ? {\n kind: ReflectionKind.array,\n type: { kind: ReflectionKind.string }\n }\n : { kind: ReflectionKind.string },\n default: option.default,\n tags: {\n domain: \"cli\"\n }\n })\n );\n }\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.path.segments.filter(segment => !isPositionalCommandOption(segment))\n .length ===\n command.path.segments.filter(\n segment => !isPositionalCommandOption(segment)\n ).length +\n 1 &&\n input.path.segments\n .slice(0, command.path.segments.length)\n .every((value, index) => value === command.path.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,SAAgBuB,gCACdC,MACAC,UACAC,MACAC,OACAC,cACQ;AACR,QAAO,IAAIH,YAAY,CAACG,eAAe,eAAe,GAAE,GACtDJ,SAASrB,gDAAe0B,UACpB,uCACA,sBAAqB,2BAEzBL,SAASrB,gDAAe0B,UACpB,YACAL,SAASrB,gDAAe2B,QACtB,mBACA,mBAAkB,GACtBH,OAAOI,MA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ACJC,QAAQ,OACV;GACD,CACH,CAAC;;AAIP,MAAK,MAAMhC,SAASvD,QAAQwF,OAAOpF,QACjCmD,YACEA,QAAM7C,KAAK+D,SAASrE,QAAO0C,YAAW,CAAC3D,+DAA0B2D,QAAQ,CAAC,CACvEvB,WACDG,QAAQhB,KAAK+D,SAASrE,QACpB0C,YAAW,CAAC3D,+DAA0B2D,QACxC,CAAC,CAACvB,SACA,KACJgC,QAAM7C,KAAK+D,SACRgB,MAAM,GAAG/D,QAAQhB,KAAK+D,SAASlD,OAAO,CACtCmE,OAAOC,OAAOf,UAAUe,UAAUjE,QAAQhB,KAAK+D,SAASG,OAC/D,CAAC,CACCzB,MAAKG,SAASC,MAAM/D,QAAQ,MAAMuD,mBAAmB/C,SAASuD,OAAOJ,KAAK;AAG5E,QAAOA"}
1
+ {"version":3,"file":"resolve-command.cjs","names":["esbuildPlugin","reflect","ReflectionClass","ReflectionKind","ReflectionVisibility","stringifyType","toArray","appendPath","commonPath","findFilePath","findFolderName","stripStars","replacePath","resolveParentPath","constantCase","titleCase","isSetObject","isSetString","resolveModule","getAppTitle","getDynamicPathSegmentName","isCatchAllPathSegment","isDynamicPathSegment","isOptionalCatchAllPathSegment","isPathSegmentGroup","getDefaultOptions","resolveCommandOptionDescription","kind","optional","name","title","defaultValue","boolean","array","trim","number","resolveCommandId","context","file","commandsPath","split","filter","p","Boolean","join","replaceAll","resolveCommandName","path","requireExtension","resolveCommandPath","resolveCommandDynamicPathSegments","map","findCommandsRoot","config","entry","projectRoot","workspaceConfig","workspaceRoot","Array","isArray","length","sourceRoot","extractCommandOption","command","reflection","propertyType","getType","option","getNameAsString","alias","getTags","description","getDescription","getKind","isOptional","getDefaultValue","env","default","variadic","type","string","Error","extractCommandDynamicSegment","segment","catchAll","segments","some","seg","reflectCommandTree","parent","isVirtual","replace","tree","dynamics","options","children","input","fs","existsSync","debug","id","resolved","plugins","reflectionLevel","metadata","function","parameters","firstParam","objectLiteral","class","optionsReflection","from","propertyReflection","getProperties","reduce","obj","index","paramName","Object","values","forEach","types","addProperty","undefined","visibility","public","tags","domain","inputs","slice","every","value"],"sources":["../../src/helpers/resolve-command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport type {\n ReflectionProperty,\n TypeParameter\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionKind,\n ReflectionVisibility,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolveModule } from \"powerlines/lib/utilities/resolve\";\nimport {\n getAppTitle,\n getDynamicPathSegmentName,\n isCatchAllPathSegment,\n isDynamicPathSegment,\n isOptionalCatchAllPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type {\n CommandDynamicSegment,\n CommandInput,\n CommandModule,\n CommandOption,\n CommandTree,\n NumberCommandOption,\n StringCommandOption\n} from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { getDefaultOptions } from \"./utilities\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param name - The name of the command option.\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n kind: ReflectionKind,\n optional: boolean,\n name: string,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} ${\n kind === ReflectionKind.boolean\n ? \"flag provided via the command-line\"\n : \"command-line option\"\n } that allows the user to ${\n kind === ReflectionKind.boolean\n ? \"set the\"\n : kind === ReflectionKind.array\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === ReflectionKind.boolean\n ? \"indicator\"\n : `${kind === ReflectionKind.number ? \"numeric\" : \"string\"} value${\n kind === ReflectionKind.array ? \"s\" : \"\"\n }`\n } that will be used in the application.`;\n}\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.entry)) {\n return appendPath(\n appendPath(stripStars(context.config.entry), context.config.projectRoot),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n isSetObject(context.config.entry) &&\n \"file\" in context.config.entry\n ) {\n return appendPath(\n appendPath(\n stripStars(context.config.entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.entry) &&\n context.config.entry.length > 0\n ) {\n return commonPath(\n context.config.entry.map(entry =>\n appendPath(\n appendPath(\n stripStars(isSetString(entry) ? entry : entry.file),\n context.config.projectRoot\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n return appendPath(\n context.config.sourceRoot || context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n );\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandOption(\n command: CommandInput,\n reflection: ReflectionProperty\n): CommandOption {\n const propertyType = reflection.getType();\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title:\n reflection.getTags().title?.trim() ||\n titleCase(reflection.getNameAsString()),\n description:\n reflection.getDescription() ||\n resolveCommandOptionDescription(\n reflection.getKind(),\n reflection.isOptional(),\n reflection.getNameAsString(),\n reflection.getTags().title,\n reflection.getDefaultValue()\n ),\n env: constantCase(reflection.getNameAsString()),\n kind: propertyType.kind as\n | ReflectionKind.string\n | ReflectionKind.number\n | ReflectionKind.boolean,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: false\n } as CommandOption;\n if (propertyType.kind === ReflectionKind.array) {\n if (\n propertyType.type.kind === ReflectionKind.string ||\n propertyType.type.kind === ReflectionKind.number\n ) {\n (option as StringCommandOption | NumberCommandOption).variadic = true;\n (option as StringCommandOption | NumberCommandOption).kind =\n propertyType.type.kind;\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string[] and number[] are supported.`\n );\n }\n } else if (\n propertyType.kind !== ReflectionKind.boolean &&\n propertyType.kind !== ReflectionKind.string &&\n propertyType.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n propertyType\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return option;\n}\n\n/**\n * Extracts command parameter information from a type parameter reflection.\n *\n * @param command - The command tree to which the parameter belongs.\n * @param segment - The command path segment corresponding to the parameter.\n * @param reflection - The type parameter reflection to extract information from.\n * @returns The extracted command option information.\n */\nexport function extractCommandDynamicSegment(\n command: CommandInput,\n segment: string,\n reflection: TypeParameter\n): CommandDynamicSegment {\n if (\n reflection.type.kind !== ReflectionKind.string &&\n !(\n reflection.type.kind === ReflectionKind.array &&\n reflection.type.type.kind === ReflectionKind.string\n )\n ) {\n throw new Error(\n `Unsupported type for dynamic path segment \"${segment}\" in command \"${\n command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n reflection.type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const option = {\n name: segment,\n title: titleCase(segment),\n description:\n reflection.description ||\n resolveCommandOptionDescription(\n ReflectionKind.string,\n !!reflection.optional,\n segment,\n titleCase(segment),\n reflection.default\n ),\n optional: reflection.optional,\n default: reflection.default,\n catchAll: command.path.segments.some(\n seg =>\n getDynamicPathSegmentName(segment) === seg && isCatchAllPathSegment(seg)\n )\n } as CommandDynamicSegment;\n\n if (reflection.type.kind === ReflectionKind.array) {\n if (!option.catchAll) {\n throw new Error(\n `Dynamic path segment \"${segment}\" in command \"${\n command.name\n }\" is an array type but is not defined as a catch-all segment. To use an array type for a dynamic path segment, it must be defined as a catch-all segment using the \"[...segment]\" syntax.`\n );\n }\n\n option.variadic = true;\n }\n\n if (option.catchAll) {\n if (\n !option.optional &&\n command.path.segments.some(\n seg =>\n getDynamicPathSegmentName(segment) === seg &&\n isOptionalCatchAllPathSegment(seg)\n )\n ) {\n throw new Error(\n `Dynamic path segment \"${segment}\" in command \"${\n command.name\n }\" is defined as a catch-all segment but is not optional. To define an optional catch-all segment, use the \"[[...segment]]\" syntax.`\n );\n } else if (\n option.optional &&\n !command.path.segments.some(\n seg =>\n getDynamicPathSegmentName(segment) === seg &&\n isOptionalCatchAllPathSegment(seg)\n )\n ) {\n throw new Error(\n `Dynamic path segment \"${segment}\" in command \"${\n command.name\n }\" is defined as an optional segment but is not defined as an optional catch-all segment. To define an optional catch-all segment, use the \"[[...segment]]\" syntax.`\n );\n }\n }\n\n return option;\n}\n\n/**\n * Reflects the command tree for a given command input.\n *\n * @param context - The context in which the command is being reflected.\n * @param command - The command input to reflect.\n * @param parent - The parent command tree, if any.\n * @returns The reflected command tree.\n */\nexport async function reflectCommandTree<TContext extends Context = Context>(\n context: TContext,\n command: CommandInput,\n parent?: CommandTree\n): Promise<CommandTree> {\n const title =\n command.title ||\n `${parent?.title ? `${parent.isVirtual ? parent.title.replace(/ Commands$/, \"\") : parent.title} - ` : \"\"}${titleCase(command.name)}${\n command.isVirtual ? \" Commands\" : \"\"\n }`;\n\n const tree = {\n alias: [],\n ...command,\n title,\n path: {\n ...command.path,\n dynamics: {}\n },\n options: getDefaultOptions(context, command),\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n const resolved = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n\n const metadata = resolved.metadata ?? {};\n if (isSetString(metadata.title)) {\n tree.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n tree.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n tree.alias = toArray(metadata.alias);\n }\n\n const type = reflect(resolved);\n\n // const type = await reflectType<TContext>(context, command.entry.input);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${command.entry.input.file}\" does not export a valid function.`\n );\n }\n\n tree.description ??=\n command.description ||\n type.description ||\n `The ${tree.title} executable command-line interface.`;\n\n if (type.parameters.length > 0 && type.parameters[0]) {\n const firstParam = type.parameters[0];\n if (\n firstParam.type.kind === ReflectionKind.objectLiteral ||\n firstParam.type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(firstParam.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n tree.options[propertyReflection.getNameAsString()] =\n extractCommandOption(command, propertyReflection);\n }\n }\n\n tree.path.dynamics = tree.path.segments\n .filter(segment => isDynamicPathSegment(segment))\n .reduce(\n (obj, segment, index) => {\n if (\n type.parameters.length < index + 2 ||\n !type.parameters[index + 1]\n ) {\n return obj;\n }\n\n const paramName = getDynamicPathSegmentName(segment);\n obj[paramName] = extractCommandDynamicSegment(\n command,\n paramName,\n type.parameters[index + 1]!\n );\n\n obj[paramName].description =\n obj[paramName].description ||\n `The ${paramName} ${\n obj[paramName].catchAll\n ? `${obj[paramName].optional ? \"optional \" : \"\"}catch-all`\n : \"dynamic \"\n } segment for the ${command.name} command.`;\n\n return obj;\n },\n {} as Record<string, CommandDynamicSegment>\n );\n }\n } else {\n tree.description ??= `A collection of available ${\n tree.title || titleCase(tree.name)\n } commands that are included in the ${getAppTitle(\n context\n )} command-line application.`;\n }\n\n if (context.env) {\n if (isSetObject(tree.options)) {\n Object.values(tree.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type:\n option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number\n ? option.variadic\n ? { kind: ReflectionKind.array, type: { kind: option.kind } }\n : { kind: option.kind }\n : { kind: ReflectionKind.boolean },\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 0)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n // if (\n // Object.values(tree.path.dynamics).filter(option => option.env !== false)\n // .length > 0\n // ) {\n // Object.values(tree.path.dynamics)\n // .filter(option => option.env !== false)\n // .forEach(option =>\n // context.env.types.env.addProperty({\n // name: constantCase(option.name),\n // optional: option.optional ? true : undefined,\n // description: option.description,\n // visibility: ReflectionVisibility.public,\n // type: option.variadic\n // ? {\n // kind: ReflectionKind.array,\n // type: { kind: ReflectionKind.string }\n // }\n // : { kind: ReflectionKind.string },\n // default: option.default,\n // tags: {\n // domain: \"cli\"\n // }\n // })\n // );\n // }\n }\n\n for (const input of context.inputs.filter(\n input =>\n input.path.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n command.path.segments.filter(segment => !isDynamicPathSegment(segment))\n .length +\n 1 &&\n input.path.segments\n .slice(0, command.path.segments.length)\n .every((value, index) => value === command.path.segments[index])\n )) {\n tree.children[input.name] = await reflectCommandTree(context, input, tree);\n }\n\n return tree;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAAgB0B,gCACdC,MACAC,UACAC,MACAC,OACAC,cACQ;AACR,QAAO,IAAIH,YAAY,CAACG,eAAe,eAAe,GAAE,GACtDJ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