@shell-shock/core 0.4.3 → 0.5.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 (84) hide show
  1. package/README.md +1 -1
  2. package/dist/components/docs.cjs +6 -28
  3. package/dist/components/docs.cjs.map +1 -1
  4. package/dist/components/docs.d.cts +5 -5
  5. package/dist/components/docs.d.cts.map +1 -1
  6. package/dist/components/docs.d.mts +5 -5
  7. package/dist/components/docs.d.mts.map +1 -1
  8. package/dist/components/docs.mjs +8 -30
  9. package/dist/components/docs.mjs.map +1 -1
  10. package/dist/components/index.cjs +10 -1
  11. package/dist/components/index.d.cts +3 -1
  12. package/dist/components/index.d.mts +3 -1
  13. package/dist/components/index.mjs +3 -1
  14. package/dist/components/options-parser-logic.cjs +504 -0
  15. package/dist/components/options-parser-logic.cjs.map +1 -0
  16. package/dist/components/options-parser-logic.d.cts +86 -0
  17. package/dist/components/options-parser-logic.d.cts.map +1 -0
  18. package/dist/components/options-parser-logic.d.mts +86 -0
  19. package/dist/components/options-parser-logic.d.mts.map +1 -0
  20. package/dist/components/options-parser-logic.mjs +498 -0
  21. package/dist/components/options-parser-logic.mjs.map +1 -0
  22. package/dist/components/usage.cjs +41 -0
  23. package/dist/components/usage.cjs.map +1 -0
  24. package/dist/components/usage.d.cts +30 -0
  25. package/dist/components/usage.d.cts.map +1 -0
  26. package/dist/components/usage.d.mts +30 -0
  27. package/dist/components/usage.d.mts.map +1 -0
  28. package/dist/components/usage.mjs +40 -0
  29. package/dist/components/usage.mjs.map +1 -0
  30. package/dist/contexts/index.cjs +5 -1
  31. package/dist/contexts/index.d.cts +2 -1
  32. package/dist/contexts/index.d.mts +2 -1
  33. package/dist/contexts/index.mjs +2 -1
  34. package/dist/contexts/options.cjs +43 -0
  35. package/dist/contexts/options.cjs.map +1 -0
  36. package/dist/contexts/options.d.cts +22 -0
  37. package/dist/contexts/options.d.cts.map +1 -0
  38. package/dist/contexts/options.d.mts +22 -0
  39. package/dist/contexts/options.d.mts.map +1 -0
  40. package/dist/contexts/options.mjs +39 -0
  41. package/dist/contexts/options.mjs.map +1 -0
  42. package/dist/helpers/resolve-command.cjs +91 -61
  43. package/dist/helpers/resolve-command.cjs.map +1 -1
  44. package/dist/helpers/resolve-command.mjs +93 -63
  45. package/dist/helpers/resolve-command.mjs.map +1 -1
  46. package/dist/helpers/validations.cjs +20 -48
  47. package/dist/helpers/validations.cjs.map +1 -1
  48. package/dist/helpers/validations.mjs +21 -49
  49. package/dist/helpers/validations.mjs.map +1 -1
  50. package/dist/index.d.cts +3 -3
  51. package/dist/index.d.mts +3 -3
  52. package/dist/plugin-utils/context-helpers.cjs +5 -5
  53. package/dist/plugin-utils/context-helpers.cjs.map +1 -1
  54. package/dist/plugin-utils/context-helpers.d.cts +3 -3
  55. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  56. package/dist/plugin-utils/context-helpers.d.mts +3 -3
  57. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  58. package/dist/plugin-utils/context-helpers.mjs +4 -4
  59. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  60. package/dist/plugin-utils/get-command-tree.cjs +1 -1
  61. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  62. package/dist/plugin-utils/get-command-tree.mjs +2 -2
  63. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  64. package/dist/plugin-utils/index.cjs +2 -2
  65. package/dist/plugin-utils/index.d.cts +2 -2
  66. package/dist/plugin-utils/index.d.mts +2 -2
  67. package/dist/plugin-utils/index.mjs +2 -2
  68. package/dist/plugin.cjs +1 -1
  69. package/dist/plugin.cjs.map +1 -1
  70. package/dist/plugin.mjs +2 -2
  71. package/dist/plugin.mjs.map +1 -1
  72. package/dist/types/command.d.cts +14 -10
  73. package/dist/types/command.d.cts.map +1 -1
  74. package/dist/types/command.d.mts +14 -10
  75. package/dist/types/command.d.mts.map +1 -1
  76. package/dist/types/index.d.cts +2 -2
  77. package/dist/types/index.d.mts +2 -2
  78. package/package.json +57 -28
  79. package/dist/types/internal.cjs +0 -0
  80. package/dist/types/internal.d.cts +0 -24
  81. package/dist/types/internal.d.cts.map +0 -1
  82. package/dist/types/internal.d.mts +0 -24
  83. package/dist/types/internal.d.mts.map +0 -1
  84. package/dist/types/internal.mjs +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"validations.cjs","names":["getVariableCommandPathName","isVariableCommandPath","validateCommandVariablePaths","command","failures","isVirtual","path","segments","length","variablePathNames","Set","segment","filter","has","push","code","details","add","Object","keys","variables","join","missing","prototype","hasOwnProperty","call","map","varName","find","forEach","index","variadic","validateCommandOptions","optionNames","option","values","options","name","alias","validateCommandParams","params","paramNames","param","optional","slice","nextParam","default","validateCommand","results"],"sources":["../../src/helpers/validations.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 {\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types\";\n\nexport interface ValidationFailure {\n code: string;\n details: string;\n}\n\nexport function validateCommandVariablePaths(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n if (!command.isVirtual && command.path.segments.length > 0) {\n const variablePathNames = new Set<string>();\n for (const segment of command.path.segments.filter(isVariableCommandPath) ??\n []) {\n if (variablePathNames.has(segment)) {\n failures.push({\n code: \"DUPLICATE_VARIABLE_PATH_NAME\",\n details: `Duplicate variable path name \"${getVariableCommandPathName(segment)}\" found in command.`\n });\n }\n variablePathNames.add(getVariableCommandPathName(segment));\n }\n\n if (\n command.path.segments.filter(isVariableCommandPath).length !==\n Object.keys(command.path.variables ?? {}).length\n ) {\n failures.push({\n code: \"VARIABLE_PATH_MISMATCH\",\n details: `Mismatch between variable path segments and defined path variables in command (found ${\n command.path.segments.filter(isVariableCommandPath).length\n } variables in the command folder path \"${command.path.segments.join(\"/\")}\", but ${\n Object.keys(command.path.variables ?? {}).length\n } potential variable path(s) could be determined from the command's function signature).`\n });\n }\n\n const missing = command.path.segments\n .filter(isVariableCommandPath)\n .filter(\n segment =>\n Object.prototype.hasOwnProperty.call(\n command.path.variables ?? {},\n getVariableCommandPathName(segment)\n ) === false\n );\n if (missing.length > 0) {\n failures.push({\n code: \"MISSING_VARIABLE_PATH\",\n details: `${missing.length} variable path segment${missing.length > 1 ? \"s\" : \"\"} in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\" do${missing.length > 1 ? \"\" : \"es\"} not have corresponding entr${\n missing.length > 1 ? \"ies\" : \"y\"\n } in the command's path variables: \\n- ${missing\n .map(segment => `\"${getVariableCommandPathName(segment)}\"`)\n .join(\"\\n- \")}`\n });\n } else {\n for (const varName of Object.keys(command.path.variables ?? {})) {\n if (\n !command.path.segments\n .filter(isVariableCommandPath)\n .find(segment => getVariableCommandPathName(segment) === varName)\n ) {\n failures.push({\n code: \"UNUSED_VARIABLE_PATH\",\n details: `The variable path name \"${varName}\" defined in the command's path variables is not used in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\".`\n });\n }\n }\n\n command.path.segments.forEach((segment, index) => {\n if (\n isVariableCommandPath(segment) &&\n command.path.variables[getVariableCommandPathName(segment)]\n ?.variadic === true &&\n index + 1 < command.path.segments.length &&\n command.path.segments[index + 1] &&\n command.path.variables[\n getVariableCommandPathName(command.path.segments[index + 1]!)\n ]?.variadic === true\n ) {\n failures.push({\n code: \"MULTIPLE_VARIADIC_VARIABLE_PATHS\",\n details: `The variable path segment \"${getVariableCommandPathName(\n segment\n )}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is marked as variadic, and it is followed by another variadic variable path segment \"${getVariableCommandPathName(\n command.path.segments[index + 1]!\n )}\". Only one variadic variable path segment is allowed per command, and it must be the final path segment.`\n });\n }\n });\n }\n }\n\n return failures;\n}\n\nexport function validateCommandOptions(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n const optionNames = new Set<string>();\n for (const option of Object.values(command.options ?? {})) {\n if (optionNames.has(option.name)) {\n failures.push({\n code: \"DUPLICATE_OPTION_NAME\",\n details: `Duplicate option name \"${option.name}\" found in command.`\n });\n }\n optionNames.add(option.name);\n\n for (const alias of option.alias) {\n if (optionNames.has(alias)) {\n failures.push({\n code: \"DUPLICATE_OPTION_ALIAS\",\n details: `Duplicate option name \"${alias}\" (an alias of \"${\n option.name\n }\") found in command.`\n });\n }\n optionNames.add(alias);\n }\n }\n\n return failures;\n}\n\nexport function validateCommandParams(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n if (!command.isVirtual && command.params.length > 0) {\n const paramNames = new Set<string>();\n command.params.forEach((param, index) => {\n if (paramNames.has(param.name)) {\n failures.push({\n code: \"DUPLICATE_PARAM_NAME\",\n details: `Duplicate parameter name \"${param.name}\" found in command.`\n });\n }\n paramNames.add(param.name);\n\n if (param.optional) {\n command.params.slice(index + 1).forEach(nextParam => {\n if (nextParam.optional && !nextParam.default) {\n failures.push({\n code: \"OPTIONAL_PARAM_NOT_LAST\",\n details: `The parameter \"${nextParam.name}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is required, but it follows an optional parameter \"${\n param.name\n }\". All required parameters must come before any optional parameters.`\n });\n }\n });\n }\n\n if (param.variadic && index + 1 < command.params.length) {\n if (command.params[index + 1]?.variadic) {\n failures.push({\n code: \"MULTIPLE_VARIADIC_PARAMS\",\n details: `The parameter \"${param.name}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is variadic, and it is followed by another variadic parameter \"${\n command.params[index + 1]?.name\n }\". Only one variadic parameter is allowed per command, and it must be the final parameter.`\n });\n }\n }\n });\n }\n\n return failures;\n}\n\nexport function validateCommand(command: CommandTree): ValidationFailure[] {\n const results: ValidationFailure[] = [];\n\n let failures = validateCommandVariablePaths(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateCommandParams(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateCommandOptions(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n return results;\n}\n"],"mappings":";;;AA6BA,SAAgBE,6BACdC,SACqB;CACrB,MAAMC,WAAgC,EAAE;AACxC,KAAI,CAACD,QAAQE,aAAaF,QAAQG,KAAKC,SAASC,SAAS,GAAG;EAC1D,MAAMC,oCAAoB,IAAIC,KAAa;AAC3C,OAAK,MAAMC,WAAWR,QAAQG,KAAKC,SAASK,OAAOX,2DAAsB,IACvE,EAAE,EAAE;AACJ,OAAIQ,kBAAkBI,IAAIF,QAAQ,CAChCP,UAASU,KAAK;IACZC,MAAM;IACNC,SAAS,iCAAiChB,gEAA2BW,QAAQ,CAAA;IAC9E,CAAC;AAEJF,qBAAkBQ,IAAIjB,gEAA2BW,QAAQ,CAAC;;AAG5D,MACER,QAAQG,KAAKC,SAASK,OAAOX,2DAAsB,CAACO,WACpDU,OAAOC,KAAKhB,QAAQG,KAAKc,aAAa,EAAE,CAAC,CAACZ,OAE1CJ,UAASU,KAAK;GACZC,MAAM;GACNC,SAAS,wFACPb,QAAQG,KAAKC,SAASK,OAAOX,2DAAsB,CAACO,OAAM,yCAClBL,QAAQG,KAAKC,SAASc,KAAK,IAAI,CAAA,SACvEH,OAAOC,KAAKhB,QAAQG,KAAKc,aAAa,EAAE,CAAC,CAACZ,OAAM;GAEnD,CAAC;EAGJ,MAAMc,UAAUnB,QAAQG,KAAKC,SAC1BK,OAAOX,2DAAsB,CAC7BW,QACCD,YACEO,OAAOK,UAAUC,eAAeC,KAC9BtB,QAAQG,KAAKc,aAAa,EAAE,E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YD,QAAQ,IAAI3B,QAAQqC,OAAOhC,QAC/C;QAAIL,QAAQqC,OAAOV,QAAQ,IAAIC,SAC7B3B,UAASU,KAAK;KACZC,MAAM;KACNC,SAAS,kBAAkB0B,MAAML,KAAI,4BAA6BlC,QAAQG,KAAKC,SAASc,KACtF,IACD,CAAA,mEACClB,QAAQqC,OAAOV,QAAQ,IAAIO,KAAI;KAElC,CAAC;;IAGN;;AAGJ,QAAOjC;;AAGT,SAAgB2C,gBAAgB5C,SAA2C;CACzE,MAAM6C,UAA+B,EAAE;CAEvC,IAAI5C,WAAWF,6BAA6BC,QAAQ;AACpD,KAAIC,SAASI,SAAS,EACpBwC,SAAQlC,KAAK,GAAGV,SAAS;AAG3BA,YAAWmC,sBAAsBpC,QAAQ;AACzC,KAAIC,SAASI,SAAS,EACpBwC,SAAQlC,KAAK,GAAGV,SAAS;AAG3BA,YAAW4B,uBAAuB7B,QAAQ;AAC1C,KAAIC,SAASI,SAAS,EACpBwC,SAAQlC,KAAK,GAAGV,SAAS;AAG3B,QAAO4C"}
1
+ {"version":3,"file":"validations.cjs","names":["getPositionalCommandOptionName","isPositionalCommandOption","validateCommandPositionalOptions","command","failures","isVirtual","path","segments","length","positionalOptionPathNames","Set","segment","filter","has","push","code","details","add","Object","keys","positional","join","missing","prototype","hasOwnProperty","call","map","varName","find","forEach","index","variadic","validateCommandOptions","optionNames","option","values","options","name","alias","validateCommand","results"],"sources":["../../src/helpers/validations.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 {\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types\";\n\nexport interface ValidationFailure {\n code: string;\n details: string;\n}\n\nexport function validateCommandPositionalOptions(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n if (!command.isVirtual && command.path.segments.length > 0) {\n const positionalOptionPathNames = new Set<string>();\n for (const segment of command.path.segments.filter(\n isPositionalCommandOption\n ) ?? []) {\n if (positionalOptionPathNames.has(segment)) {\n failures.push({\n code: \"DUPLICATE_POSITIONAL_OPTION_PATH_NAME\",\n details: `Duplicate positional option path name \"${getPositionalCommandOptionName(segment)}\" found in command.`\n });\n }\n positionalOptionPathNames.add(getPositionalCommandOptionName(segment));\n }\n\n if (\n command.path.segments.filter(isPositionalCommandOption).length !==\n Object.keys(command.path.positional ?? {}).length\n ) {\n failures.push({\n code: \"POSITIONAL_OPTION_PATH_MISMATCH\",\n details: `Mismatch between positional options path segments and defined path positional options in command (found ${\n command.path.segments.filter(isPositionalCommandOption).length\n } positional options in the command folder path \"${command.path.segments.join(\"/\")}\", but ${\n Object.keys(command.path.positional ?? {}).length\n } potential positional option path(s) could be determined from the command's function signature).`\n });\n }\n\n const missing = command.path.segments\n .filter(isPositionalCommandOption)\n .filter(\n segment =>\n Object.prototype.hasOwnProperty.call(\n command.path.positional ?? {},\n getPositionalCommandOptionName(segment)\n ) === false\n );\n if (missing.length > 0) {\n failures.push({\n code: \"MISSING_POSITIONAL_OPTION_PATH\",\n details: `${missing.length} positional option path segment${missing.length > 1 ? \"s\" : \"\"} in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\" do${missing.length > 1 ? \"\" : \"es\"} not have corresponding entr${\n missing.length > 1 ? \"ies\" : \"y\"\n } in the command's path positional options: \\n- ${missing\n .map(segment => `\"${getPositionalCommandOptionName(segment)}\"`)\n .join(\"\\n- \")}`\n });\n } else {\n for (const varName of Object.keys(command.path.positional ?? {})) {\n if (\n !command.path.segments\n .filter(isPositionalCommandOption)\n .find(\n segment => getPositionalCommandOptionName(segment) === varName\n )\n ) {\n failures.push({\n code: \"UNUSED_POSITIONAL_OPTION_PATH\",\n details: `The positional option path name \"${varName}\" defined in the command's path positional options is not used in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\".`\n });\n }\n }\n\n command.path.segments.forEach((segment, index) => {\n if (\n isPositionalCommandOption(segment) &&\n command.path.positional[getPositionalCommandOptionName(segment)]\n ?.variadic === true &&\n index + 1 < command.path.segments.length &&\n command.path.segments[index + 1] &&\n command.path.positional[\n getPositionalCommandOptionName(command.path.segments[index + 1]!)\n ]?.variadic === true\n ) {\n failures.push({\n code: \"MULTIPLE_VARIADIC_POSITIONAL_OPTION_PATHS\",\n details: `The positional option path segment \"${getPositionalCommandOptionName(\n segment\n )}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is marked as variadic, and it is followed by another variadic positional option path segment \"${getPositionalCommandOptionName(\n command.path.segments[index + 1]!\n )}\". Only one variadic positional option path segment is allowed per command, and it must be the final path segment.`\n });\n }\n });\n }\n }\n\n return failures;\n}\n\nexport function validateCommandOptions(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n const optionNames = new Set<string>();\n for (const option of Object.values(command.options ?? {})) {\n if (optionNames.has(option.name)) {\n failures.push({\n code: \"DUPLICATE_OPTION_NAME\",\n details: `Duplicate option name \"${option.name}\" found in command.`\n });\n }\n optionNames.add(option.name);\n\n for (const alias of option.alias) {\n if (optionNames.has(alias)) {\n failures.push({\n code: \"DUPLICATE_OPTION_ALIAS\",\n details: `Duplicate option name \"${alias}\" (an alias of \"${\n option.name\n }\") found in command.`\n });\n }\n optionNames.add(alias);\n }\n }\n\n return failures;\n}\n\nexport function validateCommand(command: CommandTree): ValidationFailure[] {\n const results: ValidationFailure[] = [];\n\n let failures = validateCommandPositionalOptions(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateCommandOptions(command);\n if (fail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KAAI;GAC/C,CAAC;AAEJJ,cAAYhB,IAAIiB,OAAOG,KAAK;AAE5B,OAAK,MAAMC,SAASJ,OAAOI,OAAO;AAChC,OAAIL,YAAYpB,IAAIyB,MAAM,CACxBlC,UAASU,KAAK;IACZC,MAAM;IACNC,SAAS,0BAA0BsB,MAAK,kBACtCJ,OAAOG,KAAI;IAEd,CAAC;AAEJJ,eAAYhB,IAAIqB,MAAM;;;AAI1B,QAAOlC;;AAGT,SAAgBmC,gBAAgBpC,SAA2C;CACzE,MAAMqC,UAA+B,EAAE;CAEvC,IAAIpC,WAAWF,iCAAiCC,QAAQ;AACxD,KAAIC,SAASI,SAAS,EACpBgC,SAAQ1B,KAAK,GAAGV,SAAS;AAG3BA,YAAW4B,uBAAuB7B,QAAQ;AAC1C,KAAIC,SAASI,SAAS,EACpBgC,SAAQ1B,KAAK,GAAGV,SAAS;AAG3B,QAAOoC"}
@@ -1,35 +1,35 @@
1
- import { getVariableCommandPathName, isVariableCommandPath } from "../plugin-utils/context-helpers.mjs";
1
+ import { getPositionalCommandOptionName, isPositionalCommandOption } from "../plugin-utils/context-helpers.mjs";
2
2
 
3
3
  //#region src/helpers/validations.ts
4
- function validateCommandVariablePaths(command) {
4
+ function validateCommandPositionalOptions(command) {
5
5
  const failures = [];
6
6
  if (!command.isVirtual && command.path.segments.length > 0) {
7
- const variablePathNames = /* @__PURE__ */ new Set();
8
- for (const segment of command.path.segments.filter(isVariableCommandPath) ?? []) {
9
- if (variablePathNames.has(segment)) failures.push({
10
- code: "DUPLICATE_VARIABLE_PATH_NAME",
11
- details: `Duplicate variable path name "${getVariableCommandPathName(segment)}" found in command.`
7
+ const positionalOptionPathNames = /* @__PURE__ */ new Set();
8
+ for (const segment of command.path.segments.filter(isPositionalCommandOption) ?? []) {
9
+ if (positionalOptionPathNames.has(segment)) failures.push({
10
+ code: "DUPLICATE_POSITIONAL_OPTION_PATH_NAME",
11
+ details: `Duplicate positional option path name "${getPositionalCommandOptionName(segment)}" found in command.`
12
12
  });
13
- variablePathNames.add(getVariableCommandPathName(segment));
13
+ positionalOptionPathNames.add(getPositionalCommandOptionName(segment));
14
14
  }
15
- if (command.path.segments.filter(isVariableCommandPath).length !== Object.keys(command.path.variables ?? {}).length) failures.push({
16
- code: "VARIABLE_PATH_MISMATCH",
17
- details: `Mismatch between variable path segments and defined path variables in command (found ${command.path.segments.filter(isVariableCommandPath).length} variables in the command folder path "${command.path.segments.join("/")}", but ${Object.keys(command.path.variables ?? {}).length} potential variable path(s) could be determined from the command's function signature).`
15
+ if (command.path.segments.filter(isPositionalCommandOption).length !== Object.keys(command.path.positional ?? {}).length) failures.push({
16
+ code: "POSITIONAL_OPTION_PATH_MISMATCH",
17
+ details: `Mismatch between positional options path segments and defined path positional options in command (found ${command.path.segments.filter(isPositionalCommandOption).length} positional options in the command folder path "${command.path.segments.join("/")}", but ${Object.keys(command.path.positional ?? {}).length} potential positional option path(s) could be determined from the command's function signature).`
18
18
  });
19
- const missing = command.path.segments.filter(isVariableCommandPath).filter((segment) => Object.prototype.hasOwnProperty.call(command.path.variables ?? {}, getVariableCommandPathName(segment)) === false);
19
+ const missing = command.path.segments.filter(isPositionalCommandOption).filter((segment) => Object.prototype.hasOwnProperty.call(command.path.positional ?? {}, getPositionalCommandOptionName(segment)) === false);
20
20
  if (missing.length > 0) failures.push({
21
- code: "MISSING_VARIABLE_PATH",
22
- details: `${missing.length} variable path segment${missing.length > 1 ? "s" : ""} in the command folder path "${command.path.segments.join("/")}" do${missing.length > 1 ? "" : "es"} not have corresponding entr${missing.length > 1 ? "ies" : "y"} in the command's path variables: \n- ${missing.map((segment) => `"${getVariableCommandPathName(segment)}"`).join("\n- ")}`
21
+ code: "MISSING_POSITIONAL_OPTION_PATH",
22
+ details: `${missing.length} positional option path segment${missing.length > 1 ? "s" : ""} in the command folder path "${command.path.segments.join("/")}" do${missing.length > 1 ? "" : "es"} not have corresponding entr${missing.length > 1 ? "ies" : "y"} in the command's path positional options: \n- ${missing.map((segment) => `"${getPositionalCommandOptionName(segment)}"`).join("\n- ")}`
23
23
  });
24
24
  else {
25
- for (const varName of Object.keys(command.path.variables ?? {})) if (!command.path.segments.filter(isVariableCommandPath).find((segment) => getVariableCommandPathName(segment) === varName)) failures.push({
26
- code: "UNUSED_VARIABLE_PATH",
27
- details: `The variable path name "${varName}" defined in the command's path variables is not used in the command folder path "${command.path.segments.join("/")}".`
25
+ for (const varName of Object.keys(command.path.positional ?? {})) if (!command.path.segments.filter(isPositionalCommandOption).find((segment) => getPositionalCommandOptionName(segment) === varName)) failures.push({
26
+ code: "UNUSED_POSITIONAL_OPTION_PATH",
27
+ details: `The positional option path name "${varName}" defined in the command's path positional options is not used in the command folder path "${command.path.segments.join("/")}".`
28
28
  });
29
29
  command.path.segments.forEach((segment, index) => {
30
- if (isVariableCommandPath(segment) && command.path.variables[getVariableCommandPathName(segment)]?.variadic === true && index + 1 < command.path.segments.length && command.path.segments[index + 1] && command.path.variables[getVariableCommandPathName(command.path.segments[index + 1])]?.variadic === true) failures.push({
31
- code: "MULTIPLE_VARIADIC_VARIABLE_PATHS",
32
- details: `The variable path segment "${getVariableCommandPathName(segment)}" in the command at path "${command.path.segments.join("/")}" is marked as variadic, and it is followed by another variadic variable path segment "${getVariableCommandPathName(command.path.segments[index + 1])}". Only one variadic variable path segment is allowed per command, and it must be the final path segment.`
30
+ if (isPositionalCommandOption(segment) && command.path.positional[getPositionalCommandOptionName(segment)]?.variadic === true && index + 1 < command.path.segments.length && command.path.segments[index + 1] && command.path.positional[getPositionalCommandOptionName(command.path.segments[index + 1])]?.variadic === true) failures.push({
31
+ code: "MULTIPLE_VARIADIC_POSITIONAL_OPTION_PATHS",
32
+ details: `The positional option path segment "${getPositionalCommandOptionName(segment)}" in the command at path "${command.path.segments.join("/")}" is marked as variadic, and it is followed by another variadic positional option path segment "${getPositionalCommandOptionName(command.path.segments[index + 1])}". Only one variadic positional option path segment is allowed per command, and it must be the final path segment.`
33
33
  });
34
34
  });
35
35
  }
@@ -55,37 +55,9 @@ function validateCommandOptions(command) {
55
55
  }
56
56
  return failures;
57
57
  }
58
- function validateCommandParams(command) {
59
- const failures = [];
60
- if (!command.isVirtual && command.params.length > 0) {
61
- const paramNames = /* @__PURE__ */ new Set();
62
- command.params.forEach((param, index) => {
63
- if (paramNames.has(param.name)) failures.push({
64
- code: "DUPLICATE_PARAM_NAME",
65
- details: `Duplicate parameter name "${param.name}" found in command.`
66
- });
67
- paramNames.add(param.name);
68
- if (param.optional) command.params.slice(index + 1).forEach((nextParam) => {
69
- if (nextParam.optional && !nextParam.default) failures.push({
70
- code: "OPTIONAL_PARAM_NOT_LAST",
71
- details: `The parameter "${nextParam.name}" in the command at path "${command.path.segments.join("/")}" is required, but it follows an optional parameter "${param.name}". All required parameters must come before any optional parameters.`
72
- });
73
- });
74
- if (param.variadic && index + 1 < command.params.length) {
75
- if (command.params[index + 1]?.variadic) failures.push({
76
- code: "MULTIPLE_VARIADIC_PARAMS",
77
- details: `The parameter "${param.name}" in the command at path "${command.path.segments.join("/")}" is variadic, and it is followed by another variadic parameter "${command.params[index + 1]?.name}". Only one variadic parameter is allowed per command, and it must be the final parameter.`
78
- });
79
- }
80
- });
81
- }
82
- return failures;
83
- }
84
58
  function validateCommand(command) {
85
59
  const results = [];
86
- let failures = validateCommandVariablePaths(command);
87
- if (failures.length > 0) results.push(...failures);
88
- failures = validateCommandParams(command);
60
+ let failures = validateCommandPositionalOptions(command);
89
61
  if (failures.length > 0) results.push(...failures);
90
62
  failures = validateCommandOptions(command);
91
63
  if (failures.length > 0) results.push(...failures);
@@ -1 +1 @@
1
- {"version":3,"file":"validations.mjs","names":["getVariableCommandPathName","isVariableCommandPath","validateCommandVariablePaths","command","failures","isVirtual","path","segments","length","variablePathNames","Set","segment","filter","has","push","code","details","add","Object","keys","variables","join","missing","prototype","hasOwnProperty","call","map","varName","find","forEach","index","variadic","validateCommandOptions","optionNames","option","values","options","name","alias","validateCommandParams","params","paramNames","param","optional","slice","nextParam","default","validateCommand","results"],"sources":["../../src/helpers/validations.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 {\n getVariableCommandPathName,\n isVariableCommandPath\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types\";\n\nexport interface ValidationFailure {\n code: string;\n details: string;\n}\n\nexport function validateCommandVariablePaths(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n if (!command.isVirtual && command.path.segments.length > 0) {\n const variablePathNames = new Set<string>();\n for (const segment of command.path.segments.filter(isVariableCommandPath) ??\n []) {\n if (variablePathNames.has(segment)) {\n failures.push({\n code: \"DUPLICATE_VARIABLE_PATH_NAME\",\n details: `Duplicate variable path name \"${getVariableCommandPathName(segment)}\" found in command.`\n });\n }\n variablePathNames.add(getVariableCommandPathName(segment));\n }\n\n if (\n command.path.segments.filter(isVariableCommandPath).length !==\n Object.keys(command.path.variables ?? {}).length\n ) {\n failures.push({\n code: \"VARIABLE_PATH_MISMATCH\",\n details: `Mismatch between variable path segments and defined path variables in command (found ${\n command.path.segments.filter(isVariableCommandPath).length\n } variables in the command folder path \"${command.path.segments.join(\"/\")}\", but ${\n Object.keys(command.path.variables ?? {}).length\n } potential variable path(s) could be determined from the command's function signature).`\n });\n }\n\n const missing = command.path.segments\n .filter(isVariableCommandPath)\n .filter(\n segment =>\n Object.prototype.hasOwnProperty.call(\n command.path.variables ?? {},\n getVariableCommandPathName(segment)\n ) === false\n );\n if (missing.length > 0) {\n failures.push({\n code: \"MISSING_VARIABLE_PATH\",\n details: `${missing.length} variable path segment${missing.length > 1 ? \"s\" : \"\"} in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\" do${missing.length > 1 ? \"\" : \"es\"} not have corresponding entr${\n missing.length > 1 ? \"ies\" : \"y\"\n } in the command's path variables: \\n- ${missing\n .map(segment => `\"${getVariableCommandPathName(segment)}\"`)\n .join(\"\\n- \")}`\n });\n } else {\n for (const varName of Object.keys(command.path.variables ?? {})) {\n if (\n !command.path.segments\n .filter(isVariableCommandPath)\n .find(segment => getVariableCommandPathName(segment) === varName)\n ) {\n failures.push({\n code: \"UNUSED_VARIABLE_PATH\",\n details: `The variable path name \"${varName}\" defined in the command's path variables is not used in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\".`\n });\n }\n }\n\n command.path.segments.forEach((segment, index) => {\n if (\n isVariableCommandPath(segment) &&\n command.path.variables[getVariableCommandPathName(segment)]\n ?.variadic === true &&\n index + 1 < command.path.segments.length &&\n command.path.segments[index + 1] &&\n command.path.variables[\n getVariableCommandPathName(command.path.segments[index + 1]!)\n ]?.variadic === true\n ) {\n failures.push({\n code: \"MULTIPLE_VARIADIC_VARIABLE_PATHS\",\n details: `The variable path segment \"${getVariableCommandPathName(\n segment\n )}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is marked as variadic, and it is followed by another variadic variable path segment \"${getVariableCommandPathName(\n command.path.segments[index + 1]!\n )}\". Only one variadic variable path segment is allowed per command, and it must be the final path segment.`\n });\n }\n });\n }\n }\n\n return failures;\n}\n\nexport function validateCommandOptions(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n const optionNames = new Set<string>();\n for (const option of Object.values(command.options ?? {})) {\n if (optionNames.has(option.name)) {\n failures.push({\n code: \"DUPLICATE_OPTION_NAME\",\n details: `Duplicate option name \"${option.name}\" found in command.`\n });\n }\n optionNames.add(option.name);\n\n for (const alias of option.alias) {\n if (optionNames.has(alias)) {\n failures.push({\n code: \"DUPLICATE_OPTION_ALIAS\",\n details: `Duplicate option name \"${alias}\" (an alias of \"${\n option.name\n }\") found in command.`\n });\n }\n optionNames.add(alias);\n }\n }\n\n return failures;\n}\n\nexport function validateCommandParams(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n if (!command.isVirtual && command.params.length > 0) {\n const paramNames = new Set<string>();\n command.params.forEach((param, index) => {\n if (paramNames.has(param.name)) {\n failures.push({\n code: \"DUPLICATE_PARAM_NAME\",\n details: `Duplicate parameter name \"${param.name}\" found in command.`\n });\n }\n paramNames.add(param.name);\n\n if (param.optional) {\n command.params.slice(index + 1).forEach(nextParam => {\n if (nextParam.optional && !nextParam.default) {\n failures.push({\n code: \"OPTIONAL_PARAM_NOT_LAST\",\n details: `The parameter \"${nextParam.name}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is required, but it follows an optional parameter \"${\n param.name\n }\". All required parameters must come before any optional parameters.`\n });\n }\n });\n }\n\n if (param.variadic && index + 1 < command.params.length) {\n if (command.params[index + 1]?.variadic) {\n failures.push({\n code: \"MULTIPLE_VARIADIC_PARAMS\",\n details: `The parameter \"${param.name}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is variadic, and it is followed by another variadic parameter \"${\n command.params[index + 1]?.name\n }\". Only one variadic parameter is allowed per command, and it must be the final parameter.`\n });\n }\n }\n });\n }\n\n return failures;\n}\n\nexport function validateCommand(command: CommandTree): ValidationFailure[] {\n const results: ValidationFailure[] = [];\n\n let failures = validateCommandVariablePaths(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateCommandParams(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateCommandOptions(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n return results;\n}\n"],"mappings":";;;AA6BA,SAAgBE,6BACdC,SACqB;CACrB,MAAMC,WAAgC,EAAE;AACxC,KAAI,CAACD,QAAQE,aAAaF,QAAQG,KAAKC,SAASC,SAAS,GAAG;EAC1D,MAAM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AsBpC,QAAQ;AACzC,KAAIC,SAASI,SAAS,EACpBwC,SAAQlC,KAAK,GAAGV,SAAS;AAG3BA,YAAW4B,uBAAuB7B,QAAQ;AAC1C,KAAIC,SAASI,SAAS,EACpBwC,SAAQlC,KAAK,GAAGV,SAAS;AAG3B,QAAO4C"}
1
+ {"version":3,"file":"validations.mjs","names":["getPositionalCommandOptionName","isPositionalCommandOption","validateCommandPositionalOptions","command","failures","isVirtual","path","segments","length","positionalOptionPathNames","Set","segment","filter","has","push","code","details","add","Object","keys","positional","join","missing","prototype","hasOwnProperty","call","map","varName","find","forEach","index","variadic","validateCommandOptions","optionNames","option","values","options","name","alias","validateCommand","results"],"sources":["../../src/helpers/validations.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 {\n getPositionalCommandOptionName,\n isPositionalCommandOption\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandTree } from \"../types\";\n\nexport interface ValidationFailure {\n code: string;\n details: string;\n}\n\nexport function validateCommandPositionalOptions(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n if (!command.isVirtual && command.path.segments.length > 0) {\n const positionalOptionPathNames = new Set<string>();\n for (const segment of command.path.segments.filter(\n isPositionalCommandOption\n ) ?? []) {\n if (positionalOptionPathNames.has(segment)) {\n failures.push({\n code: \"DUPLICATE_POSITIONAL_OPTION_PATH_NAME\",\n details: `Duplicate positional option path name \"${getPositionalCommandOptionName(segment)}\" found in command.`\n });\n }\n positionalOptionPathNames.add(getPositionalCommandOptionName(segment));\n }\n\n if (\n command.path.segments.filter(isPositionalCommandOption).length !==\n Object.keys(command.path.positional ?? {}).length\n ) {\n failures.push({\n code: \"POSITIONAL_OPTION_PATH_MISMATCH\",\n details: `Mismatch between positional options path segments and defined path positional options in command (found ${\n command.path.segments.filter(isPositionalCommandOption).length\n } positional options in the command folder path \"${command.path.segments.join(\"/\")}\", but ${\n Object.keys(command.path.positional ?? {}).length\n } potential positional option path(s) could be determined from the command's function signature).`\n });\n }\n\n const missing = command.path.segments\n .filter(isPositionalCommandOption)\n .filter(\n segment =>\n Object.prototype.hasOwnProperty.call(\n command.path.positional ?? {},\n getPositionalCommandOptionName(segment)\n ) === false\n );\n if (missing.length > 0) {\n failures.push({\n code: \"MISSING_POSITIONAL_OPTION_PATH\",\n details: `${missing.length} positional option path segment${missing.length > 1 ? \"s\" : \"\"} in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\" do${missing.length > 1 ? \"\" : \"es\"} not have corresponding entr${\n missing.length > 1 ? \"ies\" : \"y\"\n } in the command's path positional options: \\n- ${missing\n .map(segment => `\"${getPositionalCommandOptionName(segment)}\"`)\n .join(\"\\n- \")}`\n });\n } else {\n for (const varName of Object.keys(command.path.positional ?? {})) {\n if (\n !command.path.segments\n .filter(isPositionalCommandOption)\n .find(\n segment => getPositionalCommandOptionName(segment) === varName\n )\n ) {\n failures.push({\n code: \"UNUSED_POSITIONAL_OPTION_PATH\",\n details: `The positional option path name \"${varName}\" defined in the command's path positional options is not used in the command folder path \"${command.path.segments.join(\n \"/\"\n )}\".`\n });\n }\n }\n\n command.path.segments.forEach((segment, index) => {\n if (\n isPositionalCommandOption(segment) &&\n command.path.positional[getPositionalCommandOptionName(segment)]\n ?.variadic === true &&\n index + 1 < command.path.segments.length &&\n command.path.segments[index + 1] &&\n command.path.positional[\n getPositionalCommandOptionName(command.path.segments[index + 1]!)\n ]?.variadic === true\n ) {\n failures.push({\n code: \"MULTIPLE_VARIADIC_POSITIONAL_OPTION_PATHS\",\n details: `The positional option path segment \"${getPositionalCommandOptionName(\n segment\n )}\" in the command at path \"${command.path.segments.join(\n \"/\"\n )}\" is marked as variadic, and it is followed by another variadic positional option path segment \"${getPositionalCommandOptionName(\n command.path.segments[index + 1]!\n )}\". Only one variadic positional option path segment is allowed per command, and it must be the final path segment.`\n });\n }\n });\n }\n }\n\n return failures;\n}\n\nexport function validateCommandOptions(\n command: CommandTree\n): ValidationFailure[] {\n const failures: ValidationFailure[] = [];\n\n const optionNames = new Set<string>();\n for (const option of Object.values(command.options ?? {})) {\n if (optionNames.has(option.name)) {\n failures.push({\n code: \"DUPLICATE_OPTION_NAME\",\n details: `Duplicate option name \"${option.name}\" found in command.`\n });\n }\n optionNames.add(option.name);\n\n for (const alias of option.alias) {\n if (optionNames.has(alias)) {\n failures.push({\n code: \"DUPLICATE_OPTION_ALIAS\",\n details: `Duplicate option name \"${alias}\" (an alias of \"${\n option.name\n }\") found in command.`\n });\n }\n optionNames.add(alias);\n }\n }\n\n return failures;\n}\n\nexport function validateCommand(command: CommandTree): ValidationFailure[] {\n const results: ValidationFailure[] = [];\n\n let failures = validateCommandPositionalOptions(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n failures = validateCommandOptions(command);\n if (failures.length > 0) {\n results.push(...failures);\n }\n\n return results;\n}\n"],"mappings":";;;AA6BA,SAAgBE,iCACdC,SACqB;CACrB,MAAMC,WAAgC,EAAE;AACxC,KAAI,CAACD,QAAQE,aAAaF,QAAQG,KAAKC,SAASC,SAAS,GAAG;EAC1D,MAAMC,4CAA4B,IAAIC,KAAa;AACnD,OAAK,MAAMC,WAAWR,QAAQG,KAAKC,SAASK,OAC1CX,0BACD,IAAI,EAAE,EAAE;AACP,OAAIQ,0BAA0BI,IAAIF,QAAQ,CACxCP,UAASU,KAAK;IACZC,MAAM;IACNC,SAAS,0CAA0ChB,+BAA+BW,QAAQ,CAAA;IAC3F,CAAC;AAEJF,6BAA0BQ,IAAIjB,+BAA+BW,QAAQ,CA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,uBAAuB7B,QAAQ;AAC1C,KAAIC,SAASI,SAAS,EACpBgC,SAAQ1B,KAAK,GAAGV,SAAS;AAG3B,QAAOoC"}
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandPath, CommandTree, CommandTreePath, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.cjs";
1
+ import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandModule, CommandOption, CommandPath, CommandPositionalOption, CommandTree, CommandTreePath, Metadata, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.cjs";
2
2
  import { Context, UnresolvedContext } from "./types/context.cjs";
3
3
  import { BaseConfig, Options, OutputConfig, ResolvedConfig, UserConfig } from "./types/config.cjs";
4
4
  import { ShellShockAPI, createShellShock } from "./api.cjs";
5
5
  import { defineConfig } from "./config.cjs";
6
- import plugin from "./plugin.cjs";
7
6
  import { BaseCommandOptions } from "./types/options.cjs";
8
7
  import "./types/index.cjs";
9
- export { BaseCommandOption, BaseCommandOptions, BaseConfig, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandPath, CommandTree, CommandTreePath, Context, NumberCommandOption, Options, OutputConfig, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandOption, UnresolvedContext, UserConfig, createShellShock, defineConfig, plugin, plugin as shellShock };
8
+ import plugin from "./plugin.cjs";
9
+ export { BaseCommandOption, BaseCommandOptions, BaseConfig, BooleanCommandOption, CommandBase, CommandInput, CommandModule, CommandOption, CommandPath, CommandPositionalOption, CommandTree, CommandTreePath, Context, Metadata, NumberCommandOption, Options, OutputConfig, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandOption, UnresolvedContext, UserConfig, createShellShock, defineConfig, plugin, plugin as shellShock };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandPath, CommandTree, CommandTreePath, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.mjs";
1
+ import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandModule, CommandOption, CommandPath, CommandPositionalOption, CommandTree, CommandTreePath, Metadata, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.mjs";
2
2
  import { Context, UnresolvedContext } from "./types/context.mjs";
3
3
  import { BaseConfig, Options, OutputConfig, ResolvedConfig, UserConfig } from "./types/config.mjs";
4
4
  import { ShellShockAPI, createShellShock } from "./api.mjs";
5
5
  import { defineConfig } from "./config.mjs";
6
- import plugin from "./plugin.mjs";
7
6
  import { BaseCommandOptions } from "./types/options.mjs";
8
7
  import "./types/index.mjs";
9
- export { BaseCommandOption, BaseCommandOptions, BaseConfig, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandPath, CommandTree, CommandTreePath, Context, NumberCommandOption, Options, OutputConfig, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandOption, UnresolvedContext, UserConfig, createShellShock, defineConfig, plugin, plugin as shellShock };
8
+ import plugin from "./plugin.mjs";
9
+ export { BaseCommandOption, BaseCommandOptions, BaseConfig, BooleanCommandOption, CommandBase, CommandInput, CommandModule, CommandOption, CommandPath, CommandPositionalOption, CommandTree, CommandTreePath, Context, Metadata, NumberCommandOption, Options, OutputConfig, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandOption, UnresolvedContext, UserConfig, createShellShock, defineConfig, plugin, plugin as shellShock };
@@ -62,7 +62,7 @@ function getAppBin(context) {
62
62
  * @param path - The command path segment to check.
63
63
  * @returns True if the path is variable, false otherwise.
64
64
  */
65
- function isVariableCommandPath(path) {
65
+ function isPositionalCommandOption(path) {
66
66
  return path.startsWith("[") && path.endsWith("]");
67
67
  }
68
68
  /**
@@ -71,8 +71,8 @@ function isVariableCommandPath(path) {
71
71
  * @param path - The command path segment.
72
72
  * @returns The variable name without square brackets.
73
73
  */
74
- function getVariableCommandPathName(path) {
75
- return path.replaceAll(/^\[+/g, "").replaceAll(/\]+$/g, "");
74
+ function getPositionalCommandOptionName(path) {
75
+ return path.replaceAll(/^\[+(?:\.\.\.)*/g, "").replaceAll(/\]+$/g, "");
76
76
  }
77
77
 
78
78
  //#endregion
@@ -80,7 +80,7 @@ exports.getAppBin = getAppBin;
80
80
  exports.getAppDescription = getAppDescription;
81
81
  exports.getAppName = getAppName;
82
82
  exports.getAppTitle = getAppTitle;
83
- exports.getVariableCommandPathName = getVariableCommandPathName;
84
- exports.isVariableCommandPath = isVariableCommandPath;
83
+ exports.getPositionalCommandOptionName = getPositionalCommandOptionName;
84
+ exports.isPositionalCommandOption = isPositionalCommandOption;
85
85
  exports.sortArgAliases = sortArgAliases;
86
86
  //# sourceMappingURL=context-helpers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.cjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","getAppDescription","description","getAppBin","Object","keys","isVariableCommandPath","path","startsWith","endsWith","getVariableCommandPathName","replaceAll"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-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 type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return titleCase(context.config.name || getAppName(context));\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isVariableCommandPath(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getVariableCommandPathName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,6DACFF,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,yDAChBU,QAAQC,OAAOE,IAAI,GAAI,uDACrBH,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,qDAAaX,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,yDAAiBhB,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,yDAAiBA,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAS9D,SAAgBS,kBACdT,SACQ;AACR,QACEA,QAAQC,OAAOS,eACfV,QAAQM,aAAaI,eACrB,OAAOF,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBW,UAAUX,SAA0B;AAClD,4DAAmBA,QAAQC,OAAOE,IAAI,GAClCS,OAAOC,KAAKb,QAAQC,OAAOE,IAAI,CAAC,sDACtBJ,WAAWC,QAAQ,CAAC;;;;;;;;AASpC,SAAgBc,sBAAsBC,MAAuB;AAC3D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;AASnD,SAAgBC,2BAA2BH,MAAsB;AAC/D,QAAOA,KAAKI,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG"}
1
+ {"version":3,"file":"context-helpers.cjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","getAppDescription","description","getAppBin","Object","keys","isPositionalCommandOption","path","startsWith","endsWith","getPositionalCommandOptionName","replaceAll"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-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 type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return titleCase(context.config.name || getAppName(context));\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isPositionalCommandOption(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPositionalCommandOptionName(path: string): string {\n return path.replaceAll(/^\\[+(?:\\.\\.\\.)*/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,6DACFF,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,yDAChBU,QAAQC,OAAOE,IAAI,GAAI,uDACrBH,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,qDAAaX,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,yDAAiBhB,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,yDAAiBA,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAS9D,SAAgBS,kBACdT,SACQ;AACR,QACEA,QAAQC,OAAOS,eACfV,QAAQM,aAAaI,eACrB,OAAOF,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBW,UAAUX,SAA0B;AAClD,4DAAmBA,QAAQC,OAAOE,IAAI,GAClCS,OAAOC,KAAKb,QAAQC,OAAOE,IAAI,CAAC,sDACtBJ,WAAWC,QAAQ,CAAC;;;;;;;;AASpC,SAAgBc,0BAA0BC,MAAuB;AAC/D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;AASnD,SAAgBC,+BAA+BH,MAAsB;AACnE,QAAOA,KAAKI,WAAW,oBAAoB,GAAG,CAACA,WAAW,SAAS,GAAG"}
@@ -45,14 +45,14 @@ declare function getAppBin(context: Context): string;
45
45
  * @param path - The command path segment to check.
46
46
  * @returns True if the path is variable, false otherwise.
47
47
  */
48
- declare function isVariableCommandPath(path: string): boolean;
48
+ declare function isPositionalCommandOption(path: string): boolean;
49
49
  /**
50
50
  * Extracts the variable name from a command path segment by removing enclosing square brackets.
51
51
  *
52
52
  * @param path - The command path segment.
53
53
  * @returns The variable name without square brackets.
54
54
  */
55
- declare function getVariableCommandPathName(path: string): string;
55
+ declare function getPositionalCommandOptionName(path: string): string;
56
56
  //#endregion
57
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases };
57
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases };
58
58
  //# sourceMappingURL=context-helpers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAUgB,iBAtDA,cAAA,CAuDL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAYA;AAUA;;;;;iBA1EgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAUzC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;iBAYnB,qBAAA;;;;;;;iBAUA,0BAAA"}
1
+ {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAUgB,iBAtDA,cAAA,CAuDL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAYA;AAUA;;;;;iBA1EgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAUzC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;iBAYnB,yBAAA;;;;;;;iBAUA,8BAAA"}
@@ -45,14 +45,14 @@ declare function getAppBin(context: Context): string;
45
45
  * @param path - The command path segment to check.
46
46
  * @returns True if the path is variable, false otherwise.
47
47
  */
48
- declare function isVariableCommandPath(path: string): boolean;
48
+ declare function isPositionalCommandOption(path: string): boolean;
49
49
  /**
50
50
  * Extracts the variable name from a command path segment by removing enclosing square brackets.
51
51
  *
52
52
  * @param path - The command path segment.
53
53
  * @returns The variable name without square brackets.
54
54
  */
55
- declare function getVariableCommandPathName(path: string): string;
55
+ declare function getPositionalCommandOptionName(path: string): string;
56
56
  //#endregion
57
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases };
57
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases };
58
58
  //# sourceMappingURL=context-helpers.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAUgB,iBAtDA,cAAA,CAuDL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAYA;AAUA;;;;;iBA1EgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAUzC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;iBAYnB,qBAAA;;;;;;;iBAUA,0BAAA"}
1
+ {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAUgB,iBAtDA,cAAA,CAuDL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAYA;AAUA;;;;;iBA1EgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAUzC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;iBAYnB,yBAAA;;;;;;;iBAUA,8BAAA"}
@@ -61,7 +61,7 @@ function getAppBin(context) {
61
61
  * @param path - The command path segment to check.
62
62
  * @returns True if the path is variable, false otherwise.
63
63
  */
64
- function isVariableCommandPath(path) {
64
+ function isPositionalCommandOption(path) {
65
65
  return path.startsWith("[") && path.endsWith("]");
66
66
  }
67
67
  /**
@@ -70,10 +70,10 @@ function isVariableCommandPath(path) {
70
70
  * @param path - The command path segment.
71
71
  * @returns The variable name without square brackets.
72
72
  */
73
- function getVariableCommandPathName(path) {
74
- return path.replaceAll(/^\[+/g, "").replaceAll(/\]+$/g, "");
73
+ function getPositionalCommandOptionName(path) {
74
+ return path.replaceAll(/^\[+(?:\.\.\.)*/g, "").replaceAll(/\]+$/g, "");
75
75
  }
76
76
 
77
77
  //#endregion
78
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases };
78
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases };
79
79
  //# sourceMappingURL=context-helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","getAppDescription","description","getAppBin","Object","keys","isVariableCommandPath","path","startsWith","endsWith","getVariableCommandPathName","replaceAll"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-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 type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return titleCase(context.config.name || getAppName(context));\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isVariableCommandPath(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getVariableCommandPathName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QAAOf,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAS9D,SAAgBS,kBACdT,SACQ;AACR,QACEA,QAAQC,OAAOS,eACfV,QAAQM,aAAaI,eACrB,OAAOF,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBW,UAAUX,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCS,OAAOC,KAAKb,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;AASpC,SAAgBc,sBAAsBC,MAAuB;AAC3D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;AASnD,SAAgBC,2BAA2BH,MAAsB;AAC/D,QAAOA,KAAKI,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG"}
1
+ {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","getAppDescription","description","getAppBin","Object","keys","isPositionalCommandOption","path","startsWith","endsWith","getPositionalCommandOptionName","replaceAll"],"sources":["../../src/plugin-utils/context-helpers.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 { kebabCase } from \"@stryke/string-format/kebab-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 type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return titleCase(context.config.name || getAppName(context));\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isPositionalCommandOption(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPositionalCommandOptionName(path: string): string {\n return path.replaceAll(/^\\[+(?:\\.\\.\\.)*/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QAAOf,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAS9D,SAAgBS,kBACdT,SACQ;AACR,QACEA,QAAQC,OAAOS,eACfV,QAAQM,aAAaI,eACrB,OAAOF,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBW,UAAUX,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCS,OAAOC,KAAKb,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;AASpC,SAAgBc,0BAA0BC,MAAuB;AAC/D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;AASnD,SAAgBC,+BAA+BH,MAAsB;AACnE,QAAOA,KAAKI,WAAW,oBAAoB,GAAG,CAACA,WAAW,SAAS,GAAG"}
@@ -12,7 +12,7 @@ function getCommandTree(context, path = []) {
12
12
  if (path.length === 0) return null;
13
13
  let currentTree = context.commands[path[0]] ?? null;
14
14
  if (path.length > 1) {
15
- const segments = path.slice(1).filter((segment) => !require_plugin_utils_context_helpers.isVariableCommandPath(segment));
15
+ const segments = path.slice(1).filter((segment) => !require_plugin_utils_context_helpers.isPositionalCommandOption(segment));
16
16
  for (const segment of segments) if (currentTree?.children && Object.prototype.hasOwnProperty.call(currentTree.children, segment)) currentTree = currentTree.children[segment] ?? null;
17
17
  else return null;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-command-tree.cjs","names":["isVariableCommandPath","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isVariableCommandPath } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isVariableCommandPath(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,2DAAsBU,QAAQ,CAAC;AACrD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}
1
+ {"version":3,"file":"get-command-tree.cjs","names":["isPositionalCommandOption","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isPositionalCommandOption } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isPositionalCommandOption(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,+DAA0BU,QAAQ,CAAC;AACzD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}
@@ -1,4 +1,4 @@
1
- import { isVariableCommandPath } from "./context-helpers.mjs";
1
+ import { isPositionalCommandOption } from "./context-helpers.mjs";
2
2
 
3
3
  //#region src/plugin-utils/get-command-tree.ts
4
4
  /**
@@ -12,7 +12,7 @@ function getCommandTree(context, path = []) {
12
12
  if (path.length === 0) return null;
13
13
  let currentTree = context.commands[path[0]] ?? null;
14
14
  if (path.length > 1) {
15
- const segments = path.slice(1).filter((segment) => !isVariableCommandPath(segment));
15
+ const segments = path.slice(1).filter((segment) => !isPositionalCommandOption(segment));
16
16
  for (const segment of segments) if (currentTree?.children && Object.prototype.hasOwnProperty.call(currentTree.children, segment)) currentTree = currentTree.children[segment] ?? null;
17
17
  else return null;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-command-tree.mjs","names":["isVariableCommandPath","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isVariableCommandPath } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isVariableCommandPath(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,sBAAsBU,QAAQ,CAAC;AACrD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}
1
+ {"version":3,"file":"get-command-tree.mjs","names":["isPositionalCommandOption","getCommandTree","context","path","length","currentTree","commands","segments","slice","filter","segment","children","Object","prototype","hasOwnProperty","call"],"sources":["../../src/plugin-utils/get-command-tree.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { CommandTree } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport { isPositionalCommandOption } from \"./context-helpers\";\n\n/**\n * Retrieves a specific command tree based on the provided path.\n *\n * @param context - The build context containing the command definitions.\n * @param path - An array of strings representing the command path.\n * @returns The command tree at the specified path, or null if not found.\n */\nexport function getCommandTree(\n context: Context,\n path = [] as string[]\n): CommandTree | null {\n if (path.length === 0) {\n return null;\n }\n\n let currentTree: CommandTree | null = context.commands[path[0]!] ?? null;\n if (path.length > 1) {\n const segments = path\n .slice(1)\n .filter(segment => !isPositionalCommandOption(segment));\n for (const segment of segments) {\n if (\n currentTree?.children &&\n Object.prototype.hasOwnProperty.call(currentTree.children, segment)\n ) {\n currentTree = currentTree.children[segment] ?? null;\n } else {\n return null;\n }\n }\n }\n\n return currentTree;\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgBC,eACdC,SACAC,OAAO,EAAc,EACD;AACpB,KAAIA,KAAKC,WAAW,EAClB,QAAO;CAGT,IAAIC,cAAkCH,QAAQI,SAASH,KAAK,OAAQ;AACpE,KAAIA,KAAKC,SAAS,GAAG;EACnB,MAAMG,WAAWJ,KACdK,MAAM,EAAE,CACRC,QAAOC,YAAW,CAACV,0BAA0BU,QAAQ,CAAC;AACzD,OAAK,MAAMA,WAAWH,SACpB,KACEF,aAAaM,YACbC,OAAOC,UAAUC,eAAeC,KAAKV,YAAYM,UAAUD,QAAQ,CAEnEL,eAAcA,YAAYM,SAASD,YAAY;MAE/C,QAAO;;AAKb,QAAOL"}
@@ -8,8 +8,8 @@ exports.getAppDescription = require_plugin_utils_context_helpers.getAppDescripti
8
8
  exports.getAppName = require_plugin_utils_context_helpers.getAppName;
9
9
  exports.getAppTitle = require_plugin_utils_context_helpers.getAppTitle;
10
10
  exports.getCommandTree = require_plugin_utils_get_command_tree.getCommandTree;
11
- exports.getVariableCommandPathName = require_plugin_utils_context_helpers.getVariableCommandPathName;
12
- exports.isVariableCommandPath = require_plugin_utils_context_helpers.isVariableCommandPath;
11
+ exports.getPositionalCommandOptionName = require_plugin_utils_context_helpers.getPositionalCommandOptionName;
12
+ exports.isPositionalCommandOption = require_plugin_utils_context_helpers.isPositionalCommandOption;
13
13
  exports.sortArgAliases = require_plugin_utils_context_helpers.sortArgAliases;
14
14
  exports.sortOptions = require_plugin_utils_reflect.sortOptions;
15
15
  exports.traverseCommandTree = require_plugin_utils_traverse_command_tree.traverseCommandTree;
@@ -1,5 +1,5 @@
1
- import { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases } from "./context-helpers.cjs";
1
+ import { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases } from "./context-helpers.cjs";
2
2
  import { getCommandTree } from "./get-command-tree.cjs";
3
3
  import { sortOptions } from "./reflect.cjs";
4
4
  import { traverseCommandTree, traverseCommands } from "./traverse-command-tree.cjs";
5
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getVariableCommandPathName, isVariableCommandPath, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
5
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
@@ -1,5 +1,5 @@
1
- import { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases } from "./context-helpers.mjs";
1
+ import { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases } from "./context-helpers.mjs";
2
2
  import { getCommandTree } from "./get-command-tree.mjs";
3
3
  import { sortOptions } from "./reflect.mjs";
4
4
  import { traverseCommandTree, traverseCommands } from "./traverse-command-tree.mjs";
5
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getVariableCommandPathName, isVariableCommandPath, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
5
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
@@ -1,6 +1,6 @@
1
- import { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases } from "./context-helpers.mjs";
1
+ import { getAppBin, getAppDescription, getAppName, getAppTitle, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases } from "./context-helpers.mjs";
2
2
  import { sortOptions } from "./reflect.mjs";
3
3
  import { getCommandTree } from "./get-command-tree.mjs";
4
4
  import { traverseCommandTree, traverseCommands } from "./traverse-command-tree.mjs";
5
5
 
6
- export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getVariableCommandPathName, isVariableCommandPath, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
6
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getPositionalCommandOptionName, isPositionalCommandOption, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
package/dist/plugin.cjs CHANGED
@@ -190,7 +190,7 @@ const plugin = (options = {}) => {
190
190
  this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
191
191
  await require_persistence.readCommandsPersistence(this);
192
192
  } else {
193
- for (const input of this.inputs.filter((input$1) => input$1.path.segments.filter((segment) => !require_plugin_utils_context_helpers.isVariableCommandPath(segment)).length === 1)) this.commands[input.name] = await require_resolve_command.reflectCommandTree(this, input);
193
+ for (const input of this.inputs.filter((input$1) => input$1.path.segments.filter((segment) => !require_plugin_utils_context_helpers.isPositionalCommandOption(segment)).length === 1)) this.commands[input.name] = await require_resolve_command.reflectCommandTree(this, input);
194
194
  this.debug("Post-processing commands to ensure proper reflection.");
195
195
  this.options = this.options.map((option) => ({
196
196
  ...option,