@shell-shock/core 0.2.1 → 0.3.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 (148) hide show
  1. package/README.md +1 -1
  2. package/dist/api.cjs +15 -3
  3. package/dist/api.cjs.map +1 -0
  4. package/dist/api.d.cts +9 -1
  5. package/dist/api.d.cts.map +1 -0
  6. package/dist/api.d.mts +9 -1
  7. package/dist/api.d.mts.map +1 -0
  8. package/dist/api.mjs +14 -3
  9. package/dist/api.mjs.map +1 -0
  10. package/dist/components/docs.cjs +105 -0
  11. package/dist/components/docs.cjs.map +1 -0
  12. package/dist/components/docs.d.cts +56 -0
  13. package/dist/components/docs.d.cts.map +1 -0
  14. package/dist/components/docs.d.mts +56 -0
  15. package/dist/components/docs.d.mts.map +1 -0
  16. package/dist/components/docs.mjs +102 -0
  17. package/dist/components/docs.mjs.map +1 -0
  18. package/dist/components/index.cjs +4 -6
  19. package/dist/components/index.d.cts +2 -2
  20. package/dist/components/index.d.mts +2 -2
  21. package/dist/components/index.mjs +2 -2
  22. package/dist/config.cjs +2 -1
  23. package/dist/config.cjs.map +1 -0
  24. package/dist/config.d.cts +2 -1
  25. package/dist/config.d.cts.map +1 -0
  26. package/dist/config.d.mts +2 -1
  27. package/dist/config.d.mts.map +1 -0
  28. package/dist/config.mjs +2 -1
  29. package/dist/config.mjs.map +1 -0
  30. package/dist/contexts/command.cjs +21 -0
  31. package/dist/contexts/command.cjs.map +1 -0
  32. package/dist/contexts/command.d.cts +18 -0
  33. package/dist/contexts/command.d.cts.map +1 -0
  34. package/dist/contexts/command.d.mts +18 -0
  35. package/dist/contexts/command.d.mts.map +1 -0
  36. package/dist/contexts/command.mjs +19 -0
  37. package/dist/contexts/command.mjs.map +1 -0
  38. package/dist/contexts/index.cjs +4 -0
  39. package/dist/contexts/index.d.cts +2 -0
  40. package/dist/contexts/index.d.mts +2 -0
  41. package/dist/contexts/index.mjs +3 -0
  42. package/dist/helpers/docs-helpers.cjs +17 -0
  43. package/dist/helpers/docs-helpers.cjs.map +1 -0
  44. package/dist/helpers/docs-helpers.mjs +16 -0
  45. package/dist/helpers/docs-helpers.mjs.map +1 -0
  46. package/dist/helpers/persistence.cjs +2 -1
  47. package/dist/helpers/persistence.cjs.map +1 -0
  48. package/dist/helpers/persistence.mjs +2 -1
  49. package/dist/helpers/persistence.mjs.map +1 -0
  50. package/dist/helpers/resolve-command.cjs +118 -33
  51. package/dist/helpers/resolve-command.cjs.map +1 -0
  52. package/dist/helpers/resolve-command.mjs +116 -32
  53. package/dist/helpers/resolve-command.mjs.map +1 -0
  54. package/dist/helpers/update-package-json.cjs +18 -10
  55. package/dist/helpers/update-package-json.cjs.map +1 -0
  56. package/dist/helpers/update-package-json.mjs +17 -10
  57. package/dist/helpers/update-package-json.mjs.map +1 -0
  58. package/dist/helpers/utilities.cjs +30 -30
  59. package/dist/helpers/utilities.cjs.map +1 -0
  60. package/dist/helpers/utilities.mjs +29 -28
  61. package/dist/helpers/utilities.mjs.map +1 -0
  62. package/dist/helpers/validations.cjs +97 -0
  63. package/dist/helpers/validations.cjs.map +1 -0
  64. package/dist/helpers/validations.mjs +97 -0
  65. package/dist/helpers/validations.mjs.map +1 -0
  66. package/dist/index.cjs +5 -13
  67. package/dist/index.cjs.map +1 -0
  68. package/dist/index.d.cts +6 -17
  69. package/dist/index.d.mts +6 -17
  70. package/dist/index.mjs +4 -13
  71. package/dist/index.mjs.map +1 -0
  72. package/dist/plugin-utils/context-helpers.cjs +86 -0
  73. package/dist/plugin-utils/context-helpers.cjs.map +1 -0
  74. package/dist/plugin-utils/context-helpers.d.cts +58 -0
  75. package/dist/plugin-utils/context-helpers.d.cts.map +1 -0
  76. package/dist/plugin-utils/context-helpers.d.mts +58 -0
  77. package/dist/plugin-utils/context-helpers.d.mts.map +1 -0
  78. package/dist/plugin-utils/context-helpers.mjs +79 -0
  79. package/dist/plugin-utils/context-helpers.mjs.map +1 -0
  80. package/dist/plugin-utils/get-command-tree.cjs +4 -2
  81. package/dist/plugin-utils/get-command-tree.cjs.map +1 -0
  82. package/dist/plugin-utils/get-command-tree.d.cts +2 -1
  83. package/dist/plugin-utils/get-command-tree.d.cts.map +1 -0
  84. package/dist/plugin-utils/get-command-tree.d.mts +2 -1
  85. package/dist/plugin-utils/get-command-tree.d.mts.map +1 -0
  86. package/dist/plugin-utils/get-command-tree.mjs +5 -2
  87. package/dist/plugin-utils/get-command-tree.mjs.map +1 -0
  88. package/dist/plugin-utils/index.cjs +14 -1
  89. package/dist/plugin-utils/index.d.cts +4 -1
  90. package/dist/plugin-utils/index.d.mts +4 -1
  91. package/dist/plugin-utils/index.mjs +4 -1
  92. package/dist/plugin-utils/reflect.cjs +25 -0
  93. package/dist/plugin-utils/reflect.cjs.map +1 -0
  94. package/dist/plugin-utils/reflect.d.cts +14 -0
  95. package/dist/plugin-utils/reflect.d.cts.map +1 -0
  96. package/dist/plugin-utils/reflect.d.mts +14 -0
  97. package/dist/plugin-utils/reflect.d.mts.map +1 -0
  98. package/dist/plugin-utils/reflect.mjs +24 -0
  99. package/dist/plugin-utils/reflect.mjs.map +1 -0
  100. package/dist/plugin-utils/traverse-command-tree.cjs +33 -0
  101. package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -0
  102. package/dist/plugin-utils/traverse-command-tree.d.cts +23 -0
  103. package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -0
  104. package/dist/plugin-utils/traverse-command-tree.d.mts +23 -0
  105. package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -0
  106. package/dist/plugin-utils/traverse-command-tree.mjs +31 -0
  107. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -0
  108. package/dist/plugin.cjs +267 -0
  109. package/dist/plugin.cjs.map +1 -0
  110. package/dist/plugin.d.cts +13 -0
  111. package/dist/plugin.d.cts.map +1 -0
  112. package/dist/plugin.d.mts +13 -0
  113. package/dist/plugin.d.mts.map +1 -0
  114. package/dist/plugin.mjs +261 -0
  115. package/dist/plugin.mjs.map +1 -0
  116. package/dist/types/command.d.cts +13 -4
  117. package/dist/types/command.d.cts.map +1 -0
  118. package/dist/types/command.d.mts +13 -4
  119. package/dist/types/command.d.mts.map +1 -0
  120. package/dist/types/config.d.cts +73 -10
  121. package/dist/types/config.d.cts.map +1 -0
  122. package/dist/types/config.d.mts +73 -10
  123. package/dist/types/config.d.mts.map +1 -0
  124. package/dist/types/context.d.cts +7 -4
  125. package/dist/types/context.d.cts.map +1 -0
  126. package/dist/types/context.d.mts +7 -4
  127. package/dist/types/context.d.mts.map +1 -0
  128. package/dist/types/index.d.cts +4 -4
  129. package/dist/types/index.d.mts +4 -4
  130. package/dist/types/internal.cjs +0 -0
  131. package/dist/types/internal.d.cts +24 -0
  132. package/dist/types/internal.d.cts.map +1 -0
  133. package/dist/types/internal.d.mts +24 -0
  134. package/dist/types/internal.d.mts.map +1 -0
  135. package/dist/types/internal.mjs +1 -0
  136. package/dist/types/options.d.cts +2 -1
  137. package/dist/types/options.d.cts.map +1 -0
  138. package/dist/types/options.d.mts +2 -1
  139. package/dist/types/options.d.mts.map +1 -0
  140. package/package.json +207 -92
  141. package/dist/components/utils-builtin.cjs +0 -453
  142. package/dist/components/utils-builtin.d.cts +0 -27
  143. package/dist/components/utils-builtin.d.mts +0 -27
  144. package/dist/components/utils-builtin.mjs +0 -447
  145. package/dist/powerlines.cjs +0 -172
  146. package/dist/powerlines.d.cts +0 -12
  147. package/dist/powerlines.d.mts +0 -12
  148. package/dist/powerlines.mjs +0 -168
@@ -0,0 +1,97 @@
1
+ const require_plugin_utils_context_helpers = require('../plugin-utils/context-helpers.cjs');
2
+
3
+ //#region src/helpers/validations.ts
4
+ function validateCommandVariablePaths(command) {
5
+ const failures = [];
6
+ if (!command.isVirtual && command.path.segments.length > 0) {
7
+ const variablePathNames = /* @__PURE__ */ new Set();
8
+ for (const segment of command.path.segments.filter(require_plugin_utils_context_helpers.isVariableCommandPath) ?? []) {
9
+ if (variablePathNames.has(segment)) failures.push({
10
+ code: "DUPLICATE_VARIABLE_PATH_NAME",
11
+ details: `Duplicate variable path name "${require_plugin_utils_context_helpers.getVariableCommandPathName(segment)}" found in command.`
12
+ });
13
+ variablePathNames.add(require_plugin_utils_context_helpers.getVariableCommandPathName(segment));
14
+ }
15
+ if (command.path.segments.filter(require_plugin_utils_context_helpers.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(require_plugin_utils_context_helpers.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).`
18
+ });
19
+ const missing = command.path.segments.filter(require_plugin_utils_context_helpers.isVariableCommandPath).filter((segment) => Object.prototype.hasOwnProperty.call(command.path.variables ?? {}, require_plugin_utils_context_helpers.getVariableCommandPathName(segment)) === false);
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) => `"${require_plugin_utils_context_helpers.getVariableCommandPathName(segment)}"`).join("\n- ")}`
23
+ });
24
+ else {
25
+ for (const varName of Object.keys(command.path.variables ?? {})) if (!command.path.segments.filter(require_plugin_utils_context_helpers.isVariableCommandPath).find((segment) => require_plugin_utils_context_helpers.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("/")}".`
28
+ });
29
+ command.path.segments.forEach((segment, index) => {
30
+ if (require_plugin_utils_context_helpers.isVariableCommandPath(segment) && command.path.variables[require_plugin_utils_context_helpers.getVariableCommandPathName(segment)]?.variadic === true && index + 1 < command.path.segments.length && command.path.segments[index + 1] && command.path.variables[require_plugin_utils_context_helpers.getVariableCommandPathName(command.path.segments[index + 1])]?.variadic === true) failures.push({
31
+ code: "MULTIPLE_VARIADIC_VARIABLE_PATHS",
32
+ details: `The variable path segment "${require_plugin_utils_context_helpers.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 "${require_plugin_utils_context_helpers.getVariableCommandPathName(command.path.segments[index + 1])}". Only one variadic variable path segment is allowed per command, and it must be the final path segment.`
33
+ });
34
+ });
35
+ }
36
+ }
37
+ return failures;
38
+ }
39
+ function validateCommandOptions(command) {
40
+ const failures = [];
41
+ const optionNames = /* @__PURE__ */ new Set();
42
+ for (const option of Object.values(command.options ?? {})) {
43
+ if (optionNames.has(option.name)) failures.push({
44
+ code: "DUPLICATE_OPTION_NAME",
45
+ details: `Duplicate option name "${option.name}" found in command.`
46
+ });
47
+ optionNames.add(option.name);
48
+ for (const alias of option.alias) {
49
+ if (optionNames.has(alias)) failures.push({
50
+ code: "DUPLICATE_OPTION_ALIAS",
51
+ details: `Duplicate option name "${alias}" (an alias of "${option.name}") found in command.`
52
+ });
53
+ optionNames.add(alias);
54
+ }
55
+ }
56
+ return failures;
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
+ function validateCommand(command) {
85
+ const results = [];
86
+ let failures = validateCommandVariablePaths(command);
87
+ if (failures.length > 0) results.push(...failures);
88
+ failures = validateCommandParams(command);
89
+ if (failures.length > 0) results.push(...failures);
90
+ failures = validateCommandOptions(command);
91
+ if (failures.length > 0) results.push(...failures);
92
+ return results;
93
+ }
94
+
95
+ //#endregion
96
+ exports.validateCommand = validateCommand;
97
+ //# sourceMappingURL=validations.cjs.map
@@ -0,0 +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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CAAC;AAEJI,cAAWxB,IAAIyB,MAAML,KAAK;AAE1B,OAAIK,MAAMC,SACRxC,SAAQqC,OAAOI,MAAMd,QAAQ,EAAE,CAACD,SAAQgB,cAAa;AACnD,QAAIA,UAAUF,YAAY,CAACE,UAAUC,QACnC1C,UAASU,KAAK;KACZC,MAAM;KACNC,SAAS,kBAAkB6B,UAAUR,KAAI,4BAA6BlC,QAAQG,KAAKC,SAASc,KAC1F,IACD,CAAA,uDACCqB,MAAML,KAAI;KAEb,CAAC;KAEJ;AAGJ,OAAIK,MAAMX,YAAYD,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"}
@@ -0,0 +1,97 @@
1
+ import { getVariableCommandPathName, isVariableCommandPath } from "../plugin-utils/context-helpers.mjs";
2
+
3
+ //#region src/helpers/validations.ts
4
+ function validateCommandVariablePaths(command) {
5
+ const failures = [];
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.`
12
+ });
13
+ variablePathNames.add(getVariableCommandPathName(segment));
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).`
18
+ });
19
+ const missing = command.path.segments.filter(isVariableCommandPath).filter((segment) => Object.prototype.hasOwnProperty.call(command.path.variables ?? {}, getVariableCommandPathName(segment)) === false);
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- ")}`
23
+ });
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("/")}".`
28
+ });
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.`
33
+ });
34
+ });
35
+ }
36
+ }
37
+ return failures;
38
+ }
39
+ function validateCommandOptions(command) {
40
+ const failures = [];
41
+ const optionNames = /* @__PURE__ */ new Set();
42
+ for (const option of Object.values(command.options ?? {})) {
43
+ if (optionNames.has(option.name)) failures.push({
44
+ code: "DUPLICATE_OPTION_NAME",
45
+ details: `Duplicate option name "${option.name}" found in command.`
46
+ });
47
+ optionNames.add(option.name);
48
+ for (const alias of option.alias) {
49
+ if (optionNames.has(alias)) failures.push({
50
+ code: "DUPLICATE_OPTION_ALIAS",
51
+ details: `Duplicate option name "${alias}" (an alias of "${option.name}") found in command.`
52
+ });
53
+ optionNames.add(alias);
54
+ }
55
+ }
56
+ return failures;
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
+ function validateCommand(command) {
85
+ const results = [];
86
+ let failures = validateCommandVariablePaths(command);
87
+ if (failures.length > 0) results.push(...failures);
88
+ failures = validateCommandParams(command);
89
+ if (failures.length > 0) results.push(...failures);
90
+ failures = validateCommandOptions(command);
91
+ if (failures.length > 0) results.push(...failures);
92
+ return results;
93
+ }
94
+
95
+ //#endregion
96
+ export { validateCommand };
97
+ //# sourceMappingURL=validations.mjs.map
@@ -0,0 +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,MAAMC,oCAAoB,IAAIC,KAAa;AAC3C,OAAK,MAAMC,WAAWR,QAAQG,KAAKC,SAASK,OAAOX,sBAAsB,IACvE,EAAE,EAAE;AACJ,OAAIQ,kBAAkBI,IAAIF,QAAQ,CAChCP,UAASU,KAAK;IACZC,MAAM;IACNC,SAAS,iCAAiChB,2BAA2BW,QAAQ,CAAA;IAC9E,CAAC;AAEJF,qBAAkBQ,IAAIjB,2BAA2BW,QAAQ,CAAC;;AAG5D,MACER,QAAQG,KAAKC,SAASK,OAAOX,sBAAsB,CAACO,WACpDU,OAAOC,KAAKhB,QAAQG,KAAKc,aAAa,EAAE,CAAC,CAACZ,OAE1CJ,UAASU,KAAK;GACZC,MAAM;GACNC,SAAS,wFACPb,QAAQG,KAAKC,SAASK,OAAOX,sBAAsB,CAACO,OAAM,yCAClBL,QAAQG,KAAKC,SAASc,KAAK,IAAI,CAAA,SACvEH,OAAOC,KAAKhB,QAAQG,KAAKc,aAAa,EAAE,CAAC,CAACZ,OAAM;GAEnD,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C,SAAS,kBAAkB6B,UAAUR,KAAI,4BAA6BlC,QAAQG,KAAKC,SAASc,KAC1F,IACD,CAAA,uDACCqB,MAAML,KAAI;KAEb,CAAC;KAEJ;AAGJ,OAAIK,MAAMX,YAAYD,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"}
package/dist/index.cjs CHANGED
@@ -1,24 +1,16 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_powerlines = require('./powerlines.cjs');
2
+ const require_plugin = require('./plugin.cjs');
3
3
  const require_api = require('./api.cjs');
4
4
  const require_config = require('./config.cjs');
5
5
 
6
6
  //#region src/index.ts
7
- /**
8
- * Creates a new {@link ShellShockAPI} instance.
9
- *
10
- * @param options - The user configuration options.
11
- * @returns A promise that resolves to a {@link ShellShockAPI} instance.
12
- */
13
- async function createShellShock(options = {}) {
14
- options.root ??= process.cwd();
15
- return require_api.ShellShockAPI.from(options);
16
- }
17
7
  var src_default = require_api.ShellShockAPI;
18
8
 
19
9
  //#endregion
20
10
  exports.ShellShockAPI = require_api.ShellShockAPI;
21
- exports.createShellShock = createShellShock;
11
+ exports.createShellShock = require_api.createShellShock;
22
12
  exports.default = src_default;
23
13
  exports.defineConfig = require_config.defineConfig;
24
- exports.shellShock = require_powerlines.shellShock;
14
+ exports.plugin = require_plugin.plugin;
15
+ exports.shellShock = require_plugin.plugin;
16
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["ShellShockAPI","createShellShock","plugin","shellShock"],"sources":["../src/index.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 { ShellShockAPI, createShellShock } from \"./api\";\n\nexport * from \"./config\";\n\nexport { plugin, shellShock } from \"./plugin\";\nexport * from \"./types\";\n\n// eslint-disable-next-line perfectionist/sort-named-exports\nexport { ShellShockAPI, createShellShock };\nexport default ShellShockAPI;\n"],"mappings":";;;;;;AA2BA,kBAAeA"}
package/dist/index.d.cts CHANGED
@@ -1,20 +1,9 @@
1
- import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandTree, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.cjs";
2
- import { Context } from "./types/context.cjs";
3
- import { Options, ResolvedConfig, UserConfig } from "./types/config.cjs";
4
- import { ShellShockAPI } from "./api.cjs";
1
+ import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandPath, CommandTree, CommandTreePath, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.cjs";
2
+ import { Context, UnresolvedContext } from "./types/context.cjs";
3
+ import { BaseConfig, Options, OutputConfig, ResolvedConfig, UserConfig } from "./types/config.cjs";
4
+ import { ShellShockAPI, createShellShock } from "./api.cjs";
5
5
  import { defineConfig } from "./config.cjs";
6
- import shellShock from "./powerlines.cjs";
6
+ import plugin from "./plugin.cjs";
7
7
  import { BaseCommandOptions } from "./types/options.cjs";
8
8
  import "./types/index.cjs";
9
-
10
- //#region src/index.d.ts
11
-
12
- /**
13
- * Creates a new {@link ShellShockAPI} instance.
14
- *
15
- * @param options - The user configuration options.
16
- * @returns A promise that resolves to a {@link ShellShockAPI} instance.
17
- */
18
- declare function createShellShock(options?: Partial<UserConfig>): Promise<ShellShockAPI>;
19
- //#endregion
20
- export { BaseCommandOption, BaseCommandOptions, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandTree, Context, NumberCommandOption, Options, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandOption, UserConfig, createShellShock, defineConfig, shellShock };
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 };
package/dist/index.d.mts CHANGED
@@ -1,20 +1,9 @@
1
- import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandTree, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.mjs";
2
- import { Context } from "./types/context.mjs";
3
- import { Options, ResolvedConfig, UserConfig } from "./types/config.mjs";
4
- import { ShellShockAPI } from "./api.mjs";
1
+ import { BaseCommandOption, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandPath, CommandTree, CommandTreePath, NumberCommandOption, SerializedCommandTree, StringCommandOption } from "./types/command.mjs";
2
+ import { Context, UnresolvedContext } from "./types/context.mjs";
3
+ import { BaseConfig, Options, OutputConfig, ResolvedConfig, UserConfig } from "./types/config.mjs";
4
+ import { ShellShockAPI, createShellShock } from "./api.mjs";
5
5
  import { defineConfig } from "./config.mjs";
6
- import shellShock from "./powerlines.mjs";
6
+ import plugin from "./plugin.mjs";
7
7
  import { BaseCommandOptions } from "./types/options.mjs";
8
8
  import "./types/index.mjs";
9
-
10
- //#region src/index.d.ts
11
-
12
- /**
13
- * Creates a new {@link ShellShockAPI} instance.
14
- *
15
- * @param options - The user configuration options.
16
- * @returns A promise that resolves to a {@link ShellShockAPI} instance.
17
- */
18
- declare function createShellShock(options?: Partial<UserConfig>): Promise<ShellShockAPI>;
19
- //#endregion
20
- export { BaseCommandOption, BaseCommandOptions, BooleanCommandOption, CommandBase, CommandInput, CommandOption, CommandParam, CommandTree, Context, NumberCommandOption, Options, ResolvedConfig, SerializedCommandTree, ShellShockAPI, ShellShockAPI as default, StringCommandOption, UserConfig, createShellShock, defineConfig, shellShock };
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 };
package/dist/index.mjs CHANGED
@@ -1,19 +1,10 @@
1
- import { shellShock } from "./powerlines.mjs";
2
- import { ShellShockAPI } from "./api.mjs";
1
+ import { plugin } from "./plugin.mjs";
2
+ import { ShellShockAPI, createShellShock } from "./api.mjs";
3
3
  import { defineConfig } from "./config.mjs";
4
4
 
5
5
  //#region src/index.ts
6
- /**
7
- * Creates a new {@link ShellShockAPI} instance.
8
- *
9
- * @param options - The user configuration options.
10
- * @returns A promise that resolves to a {@link ShellShockAPI} instance.
11
- */
12
- async function createShellShock(options = {}) {
13
- options.root ??= process.cwd();
14
- return ShellShockAPI.from(options);
15
- }
16
6
  var src_default = ShellShockAPI;
17
7
 
18
8
  //#endregion
19
- export { ShellShockAPI, createShellShock, src_default as default, defineConfig, shellShock };
9
+ export { ShellShockAPI, createShellShock, src_default as default, defineConfig, plugin, plugin as shellShock };
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["ShellShockAPI","createShellShock","plugin","shellShock"],"sources":["../src/index.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 { ShellShockAPI, createShellShock } from \"./api\";\n\nexport * from \"./config\";\n\nexport { plugin, shellShock } from \"./plugin\";\nexport * from \"./types\";\n\n// eslint-disable-next-line perfectionist/sort-named-exports\nexport { ShellShockAPI, createShellShock };\nexport default ShellShockAPI;\n"],"mappings":";;;;;AA2BA,kBAAeA"}
@@ -0,0 +1,86 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
3
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
4
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
5
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
6
+
7
+ //#region src/plugin-utils/context-helpers.ts
8
+ /**
9
+ * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.
10
+ *
11
+ * @param aliases - An array of argument aliases to sort.
12
+ * @returns A new array of sorted aliases.
13
+ */
14
+ function sortArgAliases(aliases) {
15
+ if (aliases.length === 0) return [];
16
+ const result = aliases.filter((alias) => alias.length === 1);
17
+ result.push(...aliases.filter((alias) => alias.length > 1));
18
+ return result.sort((a, b) => a.localeCompare(b));
19
+ }
20
+ /**
21
+ * Retrieves the application name from the context and configuration.
22
+ *
23
+ * @param context - The build context containing workspace and package information.
24
+ * @returns The application name in kebab-case format.
25
+ * @throws An error if no valid application name is found.
26
+ */
27
+ function getAppName(context) {
28
+ const result = context.config.name || ((0, __stryke_type_checks_is_set_string.isSetString)(context.config.bin) || Array.isArray(context.config.bin) && context.config.bin.length > 0 && (0, __stryke_type_checks_is_set_string.isSetString)(context.config.bin[0]) ? (0, __stryke_type_checks_is_set_string.isSetString)(context.config.bin) ? context.config.bin : context.config.bin[0] : context.packageJson?.name);
29
+ if (!(0, __stryke_type_checks_is_set_string.isSetString)(result)) throw new Error("No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.");
30
+ return (0, __stryke_string_format_kebab_case.kebabCase)(result);
31
+ }
32
+ /**
33
+ * Retrieves the application title from the context and configuration.
34
+ *
35
+ * @param context - The build context containing workspace and package information.
36
+ * @returns The application title in title-case format.
37
+ */
38
+ function getAppTitle(context) {
39
+ return (0, __stryke_string_format_title_case.titleCase)(context.config.name || getAppName(context));
40
+ }
41
+ /**
42
+ * Retrieves the application description from the context and configuration.
43
+ *
44
+ * @param context - The build context containing workspace and package information.
45
+ * @returns The application description.
46
+ */
47
+ function getAppDescription(context) {
48
+ return context.config.description || context.packageJson?.description || `The ${getAppTitle(context)} command-line interface application.`;
49
+ }
50
+ /**
51
+ * Retrieves the primary binary name for the application.
52
+ *
53
+ * @param context - The build context containing workspace and package information.
54
+ * @returns The primary binary name as a string.
55
+ */
56
+ function getAppBin(context) {
57
+ return (0, __stryke_type_checks_is_set_object.isSetObject)(context.config.bin) ? Object.keys(context.config.bin)[0] : (0, __stryke_string_format_kebab_case.kebabCase)(getAppName(context));
58
+ }
59
+ /**
60
+ * Determines if a given command path segment is variable (enclosed in square brackets).
61
+ *
62
+ * @param path - The command path segment to check.
63
+ * @returns True if the path is variable, false otherwise.
64
+ */
65
+ function isVariableCommandPath(path) {
66
+ return path.startsWith("[") && path.endsWith("]");
67
+ }
68
+ /**
69
+ * Extracts the variable name from a command path segment by removing enclosing square brackets.
70
+ *
71
+ * @param path - The command path segment.
72
+ * @returns The variable name without square brackets.
73
+ */
74
+ function getVariableCommandPathName(path) {
75
+ return path.replaceAll(/^\[+/g, "").replaceAll(/\]+$/g, "");
76
+ }
77
+
78
+ //#endregion
79
+ exports.getAppBin = getAppBin;
80
+ exports.getAppDescription = getAppDescription;
81
+ exports.getAppName = getAppName;
82
+ exports.getAppTitle = getAppTitle;
83
+ exports.getVariableCommandPathName = getVariableCommandPathName;
84
+ exports.isVariableCommandPath = isVariableCommandPath;
85
+ exports.sortArgAliases = sortArgAliases;
86
+ //# sourceMappingURL=context-helpers.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,58 @@
1
+ import { Context, UnresolvedContext } from "../types/context.cjs";
2
+ import "../types/index.cjs";
3
+
4
+ //#region src/plugin-utils/context-helpers.d.ts
5
+
6
+ /**
7
+ * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.
8
+ *
9
+ * @param aliases - An array of argument aliases to sort.
10
+ * @returns A new array of sorted aliases.
11
+ */
12
+ declare function sortArgAliases(aliases: string[]): string[];
13
+ /**
14
+ * Retrieves the application name from the context and configuration.
15
+ *
16
+ * @param context - The build context containing workspace and package information.
17
+ * @returns The application name in kebab-case format.
18
+ * @throws An error if no valid application name is found.
19
+ */
20
+ declare function getAppName(context: UnresolvedContext | Context): string;
21
+ /**
22
+ * Retrieves the application title from the context and configuration.
23
+ *
24
+ * @param context - The build context containing workspace and package information.
25
+ * @returns The application title in title-case format.
26
+ */
27
+ declare function getAppTitle(context: UnresolvedContext | Context): string;
28
+ /**
29
+ * Retrieves the application description from the context and configuration.
30
+ *
31
+ * @param context - The build context containing workspace and package information.
32
+ * @returns The application description.
33
+ */
34
+ declare function getAppDescription(context: UnresolvedContext | Context): string;
35
+ /**
36
+ * Retrieves the primary binary name for the application.
37
+ *
38
+ * @param context - The build context containing workspace and package information.
39
+ * @returns The primary binary name as a string.
40
+ */
41
+ declare function getAppBin(context: Context): string;
42
+ /**
43
+ * Determines if a given command path segment is variable (enclosed in square brackets).
44
+ *
45
+ * @param path - The command path segment to check.
46
+ * @returns True if the path is variable, false otherwise.
47
+ */
48
+ declare function isVariableCommandPath(path: string): boolean;
49
+ /**
50
+ * Extracts the variable name from a command path segment by removing enclosing square brackets.
51
+ *
52
+ * @param path - The command path segment.
53
+ * @returns The variable name without square brackets.
54
+ */
55
+ declare function getVariableCommandPathName(path: string): string;
56
+ //#endregion
57
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases };
58
+ //# sourceMappingURL=context-helpers.d.cts.map
@@ -0,0 +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"}
@@ -0,0 +1,58 @@
1
+ import { Context, UnresolvedContext } from "../types/context.mjs";
2
+ import "../types/index.mjs";
3
+
4
+ //#region src/plugin-utils/context-helpers.d.ts
5
+
6
+ /**
7
+ * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.
8
+ *
9
+ * @param aliases - An array of argument aliases to sort.
10
+ * @returns A new array of sorted aliases.
11
+ */
12
+ declare function sortArgAliases(aliases: string[]): string[];
13
+ /**
14
+ * Retrieves the application name from the context and configuration.
15
+ *
16
+ * @param context - The build context containing workspace and package information.
17
+ * @returns The application name in kebab-case format.
18
+ * @throws An error if no valid application name is found.
19
+ */
20
+ declare function getAppName(context: UnresolvedContext | Context): string;
21
+ /**
22
+ * Retrieves the application title from the context and configuration.
23
+ *
24
+ * @param context - The build context containing workspace and package information.
25
+ * @returns The application title in title-case format.
26
+ */
27
+ declare function getAppTitle(context: UnresolvedContext | Context): string;
28
+ /**
29
+ * Retrieves the application description from the context and configuration.
30
+ *
31
+ * @param context - The build context containing workspace and package information.
32
+ * @returns The application description.
33
+ */
34
+ declare function getAppDescription(context: UnresolvedContext | Context): string;
35
+ /**
36
+ * Retrieves the primary binary name for the application.
37
+ *
38
+ * @param context - The build context containing workspace and package information.
39
+ * @returns The primary binary name as a string.
40
+ */
41
+ declare function getAppBin(context: Context): string;
42
+ /**
43
+ * Determines if a given command path segment is variable (enclosed in square brackets).
44
+ *
45
+ * @param path - The command path segment to check.
46
+ * @returns True if the path is variable, false otherwise.
47
+ */
48
+ declare function isVariableCommandPath(path: string): boolean;
49
+ /**
50
+ * Extracts the variable name from a command path segment by removing enclosing square brackets.
51
+ *
52
+ * @param path - The command path segment.
53
+ * @returns The variable name without square brackets.
54
+ */
55
+ declare function getVariableCommandPathName(path: string): string;
56
+ //#endregion
57
+ export { getAppBin, getAppDescription, getAppName, getAppTitle, getVariableCommandPathName, isVariableCommandPath, sortArgAliases };
58
+ //# sourceMappingURL=context-helpers.d.mts.map
@@ -0,0 +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"}