@shell-shock/core 0.17.7 → 0.17.8

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 (145) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/api.cjs +1 -95
  3. package/dist/api.d.cts +52 -4
  4. package/dist/api.d.cts.map +1 -1
  5. package/dist/api.d.mts +52 -4
  6. package/dist/api.d.mts.map +1 -1
  7. package/dist/api.mjs +1 -92
  8. package/dist/api.mjs.map +1 -1
  9. package/dist/components/command-validation-logic.cjs +1 -292
  10. package/dist/components/command-validation-logic.mjs +1 -289
  11. package/dist/components/command-validation-logic.mjs.map +1 -1
  12. package/dist/components/docs.cjs +1 -265
  13. package/dist/components/docs.d.cts.map +1 -1
  14. package/dist/components/docs.d.mts.map +1 -1
  15. package/dist/components/docs.mjs +1 -256
  16. package/dist/components/docs.mjs.map +1 -1
  17. package/dist/components/exec-builtin.cjs +13 -429
  18. package/dist/components/exec-builtin.mjs +13 -425
  19. package/dist/components/exec-builtin.mjs.map +1 -1
  20. package/dist/components/helpers.cjs +1 -120
  21. package/dist/components/helpers.mjs +1 -112
  22. package/dist/components/helpers.mjs.map +1 -1
  23. package/dist/components/index.cjs +1 -58
  24. package/dist/components/index.mjs +1 -10
  25. package/dist/components/options-parser-logic.cjs +5 -960
  26. package/dist/components/options-parser-logic.d.cts +1 -1
  27. package/dist/components/options-parser-logic.mjs +5 -945
  28. package/dist/components/options-parser-logic.mjs.map +1 -1
  29. package/dist/components/state-builtin.cjs +8 -629
  30. package/dist/components/state-builtin.d.cts.map +1 -1
  31. package/dist/components/state-builtin.d.mts.map +1 -1
  32. package/dist/components/state-builtin.mjs +8 -622
  33. package/dist/components/state-builtin.mjs.map +1 -1
  34. package/dist/components/usage.cjs +1 -117
  35. package/dist/components/usage.mjs +1 -114
  36. package/dist/components/usage.mjs.map +1 -1
  37. package/dist/components/utils-builtin.cjs +33 -838
  38. package/dist/components/utils-builtin.d.cts.map +1 -1
  39. package/dist/components/utils-builtin.d.mts.map +1 -1
  40. package/dist/components/utils-builtin.mjs +33 -828
  41. package/dist/components/utils-builtin.mjs.map +1 -1
  42. package/dist/config.cjs +1 -31
  43. package/dist/config.mjs +1 -29
  44. package/dist/config.mjs.map +1 -1
  45. package/dist/contexts/command.cjs +1 -26
  46. package/dist/contexts/command.mjs +1 -23
  47. package/dist/contexts/command.mjs.map +1 -1
  48. package/dist/contexts/index.cjs +1 -9
  49. package/dist/contexts/index.mjs +1 -4
  50. package/dist/contexts/options.cjs +1 -63
  51. package/dist/contexts/options.mjs +1 -58
  52. package/dist/contexts/options.mjs.map +1 -1
  53. package/dist/helpers/automd.cjs +1 -71
  54. package/dist/helpers/automd.mjs +1 -70
  55. package/dist/helpers/automd.mjs.map +1 -1
  56. package/dist/helpers/docs-helpers.cjs +1 -23
  57. package/dist/helpers/docs-helpers.mjs +1 -22
  58. package/dist/helpers/docs-helpers.mjs.map +1 -1
  59. package/dist/helpers/paths.cjs +1 -137
  60. package/dist/helpers/paths.mjs +1 -133
  61. package/dist/helpers/paths.mjs.map +1 -1
  62. package/dist/helpers/persistence.cjs +1 -113
  63. package/dist/helpers/persistence.mjs +1 -110
  64. package/dist/helpers/persistence.mjs.map +1 -1
  65. package/dist/helpers/update-package-json.cjs +1 -59
  66. package/dist/helpers/update-package-json.mjs +1 -57
  67. package/dist/helpers/update-package-json.mjs.map +1 -1
  68. package/dist/helpers/utilities.cjs +1 -95
  69. package/dist/helpers/utilities.mjs +1 -93
  70. package/dist/helpers/utilities.mjs.map +1 -1
  71. package/dist/helpers/validations.cjs +1 -71
  72. package/dist/helpers/validations.mjs +1 -71
  73. package/dist/helpers/validations.mjs.map +1 -1
  74. package/dist/index.cjs +1 -52
  75. package/dist/index.d.cts +1 -1
  76. package/dist/index.d.mts +1 -1
  77. package/dist/index.mjs +1 -7
  78. package/dist/plugin-utils/compute-bin.cjs +1 -50
  79. package/dist/plugin-utils/compute-bin.mjs +1 -49
  80. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  81. package/dist/plugin-utils/context-helpers.cjs +1 -231
  82. package/dist/plugin-utils/context-helpers.mjs +1 -221
  83. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  84. package/dist/plugin-utils/deepkit.cjs +1 -71
  85. package/dist/plugin-utils/deepkit.mjs +1 -69
  86. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  87. package/dist/plugin-utils/description-helpers.cjs +2 -111
  88. package/dist/plugin-utils/description-helpers.mjs +2 -107
  89. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  90. package/dist/plugin-utils/get-command-tree.cjs +1 -117
  91. package/dist/plugin-utils/get-command-tree.mjs +1 -114
  92. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  93. package/dist/plugin-utils/index.cjs +1 -39
  94. package/dist/plugin-utils/index.mjs +1 -10
  95. package/dist/plugin-utils/reflect.cjs +1 -52
  96. package/dist/plugin-utils/reflect.mjs +1 -52
  97. package/dist/plugin-utils/reflect.mjs.map +1 -1
  98. package/dist/plugin-utils/traverse-command-tree.cjs +1 -64
  99. package/dist/plugin-utils/traverse-command-tree.mjs +1 -62
  100. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  101. package/dist/plugin-utils/type-checks.cjs +1 -93
  102. package/dist/plugin-utils/type-checks.mjs +1 -88
  103. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  104. package/dist/plugin.cjs +4 -429
  105. package/dist/plugin.d.cts.map +1 -1
  106. package/dist/plugin.d.mts.map +1 -1
  107. package/dist/plugin.mjs +4 -423
  108. package/dist/plugin.mjs.map +1 -1
  109. package/dist/resolver/deepkit.cjs +1 -135
  110. package/dist/resolver/deepkit.mjs +1 -134
  111. package/dist/resolver/deepkit.mjs.map +1 -1
  112. package/dist/resolver/helpers.cjs +1 -173
  113. package/dist/resolver/helpers.mjs +1 -168
  114. package/dist/resolver/helpers.mjs.map +1 -1
  115. package/dist/resolver/module.cjs +1 -145
  116. package/dist/resolver/module.mjs +1 -144
  117. package/dist/resolver/module.mjs.map +1 -1
  118. package/dist/resolver/resolve.cjs +1 -222
  119. package/dist/resolver/resolve.mjs +1 -221
  120. package/dist/resolver/resolve.mjs.map +1 -1
  121. package/dist/types/command.cjs +1 -441
  122. package/dist/types/command.mjs +1 -405
  123. package/dist/types/command.mjs.map +1 -1
  124. package/dist/types/config.cjs +1 -144
  125. package/dist/types/config.d.cts +3 -2
  126. package/dist/types/config.d.cts.map +1 -1
  127. package/dist/types/config.d.mts +3 -2
  128. package/dist/types/config.d.mts.map +1 -1
  129. package/dist/types/config.mjs +1 -138
  130. package/dist/types/config.mjs.map +1 -1
  131. package/dist/types/context.cjs +1 -37
  132. package/dist/types/context.d.cts +3 -2
  133. package/dist/types/context.d.cts.map +1 -1
  134. package/dist/types/context.d.mts +3 -2
  135. package/dist/types/context.d.mts.map +1 -1
  136. package/dist/types/context.mjs +1 -34
  137. package/dist/types/context.mjs.map +1 -1
  138. package/dist/types/env.cjs +1 -52
  139. package/dist/types/env.mjs +1 -50
  140. package/dist/types/env.mjs.map +1 -1
  141. package/dist/types/index.cjs +1 -49
  142. package/dist/types/index.mjs +1 -6
  143. package/dist/types/options.cjs +1 -12
  144. package/dist/types/options.mjs +1 -10
  145. package/package.json +23 -23
@@ -1,70 +1,2 @@
1
- import { CommandParameterKinds } from "../types/command.mjs";
2
- import { isCommandParameterKind } from "./type-checks.mjs";
3
- import { isSetObject } from "@stryke/type-checks/is-set-object";
4
- import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
5
-
6
- //#region src/plugin-utils/deepkit.ts
7
- /**
8
- * Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.
9
- *
10
- * @param command - The command parameter or kind to extract the reflection kind from.
11
- * @param checkVariadic - Whether to check for variadic parameters (arrays).
12
- * @returns The extracted {@link ReflectionKind}.
13
- */
14
- function extractReflectionKind(command, checkVariadic = true) {
15
- if (isCommandParameterKind(command) && command === CommandParameterKinds.string || isSetObject(command) && command.kind === CommandParameterKinds.string) return checkVariadic && command.variadic ? ReflectionKind.array : ReflectionKind.string;
16
- else if (isCommandParameterKind(command) && command === CommandParameterKinds.number || isSetObject(command) && command.kind === CommandParameterKinds.number) return checkVariadic && command.variadic ? ReflectionKind.array : ReflectionKind.number;
17
- else if (isCommandParameterKind(command) && command === CommandParameterKinds.boolean || isSetObject(command) && command.kind === CommandParameterKinds.boolean) return ReflectionKind.boolean;
18
- else return ReflectionKind.string;
19
- }
20
- extractReflectionKind.__type = [
21
- "BaseCommandParameter",
22
- "CommandParameterKind",
23
- "command",
24
- "checkVariadic",
25
- "extractReflectionKind",
26
- "Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.",
27
- "PP\"w!\"w\"J2#\"2$!/%?&"
28
- ];
29
- /**
30
- * Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.
31
- *
32
- * @param command - The command parameter or kind to extract the type from.
33
- * @param checkVariadic - Whether to check for variadic parameters (arrays).
34
- * @returns The extracted {@link Type}.
35
- */
36
- function extractType(command, checkVariadic = true) {
37
- const reflectionKind = extractReflectionKind(command, checkVariadic);
38
- if (reflectionKind === ReflectionKind.string) return { kind: ReflectionKind.string };
39
- else if (reflectionKind === ReflectionKind.number) return { kind: ReflectionKind.number };
40
- else if (reflectionKind === ReflectionKind.boolean) return { kind: ReflectionKind.boolean };
41
- else if (reflectionKind === ReflectionKind.array) if (isCommandParameterKind(command)) return {
42
- kind: ReflectionKind.array,
43
- type: extractType({ kind: command }, false)
44
- };
45
- else if (isSetObject(command)) return {
46
- kind: ReflectionKind.array,
47
- type: extractType({
48
- ...command,
49
- kind: command.kind
50
- }, false)
51
- };
52
- else return {
53
- kind: ReflectionKind.array,
54
- type: { kind: ReflectionKind.string }
55
- };
56
- else return { kind: ReflectionKind.string };
57
- }
58
- extractType.__type = [
59
- "BaseCommandParameter",
60
- "CommandParameterKind",
61
- "command",
62
- "checkVariadic",
63
- "extractType",
64
- "Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.",
65
- "PP\"w!\"w\"J2#\"2$!/%?&"
66
- ];
67
-
68
- //#endregion
69
- export { extractReflectionKind, extractType };
1
+ import{CommandParameterKinds as e}from"../types/command.mjs";import{isCommandParameterKind as t}from"./type-checks.mjs";import{ReflectionKind as n}from"@powerlines/deepkit/vendor/type";import{isSetObject as r}from"@stryke/type-checks/is-set-object";function i(i,a=!0){return t(i)&&i===e.string||r(i)&&i.kind===e.string?a&&i.variadic?n.array:n.string:t(i)&&i===e.number||r(i)&&i.kind===e.number?a&&i.variadic?n.array:n.number:t(i)&&i===e.boolean||r(i)&&i.kind===e.boolean?n.boolean:n.string}i.__type=[`BaseCommandParameter`,`CommandParameterKind`,`command`,`checkVariadic`,`extractReflectionKind`,`Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.`,`PP"w!"w"J2#"2$!/%?&`];function a(e,o=!0){let s=i(e,o);return s===n.string?{kind:n.string}:s===n.number?{kind:n.number}:s===n.boolean?{kind:n.boolean}:s===n.array?t(e)?{kind:n.array,type:a({kind:e},!1)}:r(e)?{kind:n.array,type:a({...e,kind:e.kind},!1)}:{kind:n.array,type:{kind:n.string}}:{kind:n.string}}a.__type=[`BaseCommandParameter`,`CommandParameterKind`,`command`,`checkVariadic`,`extractType`,`Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.`,`PP"w!"w"J2#"2$!/%?&`];export{i as extractReflectionKind,a as extractType};
70
2
  //# sourceMappingURL=deepkit.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/plugin-utils/deepkit.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 { Type } from \"@powerlines/deepkit/vendor/type\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n BaseCommandParameter,\n CommandParameterKind,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { isCommandParameterKind } from \"./type-checks\";\n\n/**\n * Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the reflection kind from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link ReflectionKind}.\n */\nexport function extractReflectionKind(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): ReflectionKind {\n if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.string) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.string)\n ) {\n return checkVariadic && (command as StringCommandParameter).variadic\n ? ReflectionKind.array\n : ReflectionKind.string;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.number) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.number)\n ) {\n return checkVariadic && (command as any).variadic\n ? ReflectionKind.array\n : ReflectionKind.number;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.boolean) ||\n (isSetObject(command) && command.kind === CommandParameterKinds.boolean)\n ) {\n return ReflectionKind.boolean;\n } else {\n return ReflectionKind.string;\n }\n}\n\n/**\n * Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the type from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link Type}.\n */\nexport function extractType(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): Type {\n const reflectionKind = extractReflectionKind(command, checkVariadic);\n if (reflectionKind === ReflectionKind.string) {\n return { kind: ReflectionKind.string };\n } else if (reflectionKind === ReflectionKind.number) {\n return { kind: ReflectionKind.number };\n } else if (reflectionKind === ReflectionKind.boolean) {\n return { kind: ReflectionKind.boolean };\n } else if (reflectionKind === ReflectionKind.array) {\n if (isCommandParameterKind(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n kind: command\n } as BaseCommandParameter,\n false\n )\n };\n } else if (isSetObject(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n ...command,\n kind: command.kind\n } as BaseCommandParameter,\n false\n )\n };\n } else {\n return {\n kind: ReflectionKind.array,\n type: { kind: ReflectionKind.string }\n };\n }\n } else {\n return { kind: ReflectionKind.string };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BE,KAAA,uBAAA,QAAA,IACC,YAAiB,sBAAsB,UACzC,YAAA,QAAA,IACS,QAAU,SAAI,sBAA0B,OAC9C,QAAM,iBAAgB,QAAW,WACzB,eAAgB,QAC1B,eAAA;UAES,uBAAuB,QAAA,IAChC,YAAgB,sBAAA,UACf,YAAe,QAAA,IACb,QAAA,SAAA,sBAAA,OACA,QAAA,iBAAuB,QAAU,WACxB,eAAI,QACb,eAAuB;UAExB,uBAAA,QAAA,IACA,YAAO,sBAA6B,WAChC,YAAA,QAAe,IAAA,QAAA,SAAA,sBAAA,QACf,QAAA,eAAqB;KAGvB,QAAS,eAAG;;AAGlB,sBAAI,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQJ,SAAI,YAAA,SAAA,gBAAA,MAAA;CACA,MAAM,iBAAgB,sBAAO,SAAA,cAAA;AAC7B,KAAI,mBAAC,eAAA,OACL,QAAO,EAAA,MAAA,eAAqB,QAAA;UAEhC,mBAAA,eAAA;UAGa,mBAAmB,eAAS,QACxC,QAAA,EAAA,MAAA,eAAA,SAAA;UAES,mBAAgB,eAAqB,MAC3C,KAAQ,uBAAqB,QAAK,CACpC,QAAA;EACc,MAAA,eAAW;EAChB,MAAA,YAAuB,EAChB,MAAA,SACV,EAAA,MAAA;EACA;UAES,YAAE,QAAe,CACtB,QAAC;EACA,MAAM,eAAe;EACrB,MAAA,YAAmB;GACb,GAAA;GACN,MAAA,QAAmB;GACxB,EAAA,MAAA;EACK;KAGH,QAAA;EACM,MAAE,eAAA;EACH,MAAA,EAAA,MAAA,eAAoB,QAAA;EACzB;KAIJ,QAAO,EAAA,MAAA,eAAA,QAAA;;AAGb,YAAU,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/plugin-utils/deepkit.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 { Type } from \"@powerlines/deepkit/vendor/type\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n BaseCommandParameter,\n CommandParameterKind,\n StringCommandParameter\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport { isCommandParameterKind } from \"./type-checks\";\n\n/**\n * Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the reflection kind from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link ReflectionKind}.\n */\nexport function extractReflectionKind(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): ReflectionKind {\n if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.string) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.string)\n ) {\n return checkVariadic && (command as StringCommandParameter).variadic\n ? ReflectionKind.array\n : ReflectionKind.string;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.number) ||\n (isSetObject(command as BaseCommandParameter) &&\n (command as BaseCommandParameter).kind === CommandParameterKinds.number)\n ) {\n return checkVariadic && (command as any).variadic\n ? ReflectionKind.array\n : ReflectionKind.number;\n } else if (\n (isCommandParameterKind(command) &&\n command === CommandParameterKinds.boolean) ||\n (isSetObject(command) && command.kind === CommandParameterKinds.boolean)\n ) {\n return ReflectionKind.boolean;\n } else {\n return ReflectionKind.string;\n }\n}\n\n/**\n * Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterKind}.\n *\n * @param command - The command parameter or kind to extract the type from.\n * @param checkVariadic - Whether to check for variadic parameters (arrays).\n * @returns The extracted {@link Type}.\n */\nexport function extractType(\n command: BaseCommandParameter | CommandParameterKind,\n checkVariadic = true\n): Type {\n const reflectionKind = extractReflectionKind(command, checkVariadic);\n if (reflectionKind === ReflectionKind.string) {\n return { kind: ReflectionKind.string };\n } else if (reflectionKind === ReflectionKind.number) {\n return { kind: ReflectionKind.number };\n } else if (reflectionKind === ReflectionKind.boolean) {\n return { kind: ReflectionKind.boolean };\n } else if (reflectionKind === ReflectionKind.array) {\n if (isCommandParameterKind(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n kind: command\n } as BaseCommandParameter,\n false\n )\n };\n } else if (isSetObject(command)) {\n return {\n kind: ReflectionKind.array,\n type: extractType(\n {\n ...command,\n kind: command.kind\n } as BaseCommandParameter,\n false\n )\n };\n } else {\n return {\n kind: ReflectionKind.array,\n type: { kind: ReflectionKind.string }\n };\n }\n } else {\n return { kind: ReflectionKind.string };\n }\n}\n"],"mappings":"4QAoCA,OAPE,EAAA,EAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,OACS,GAAU,EAAe,SAAU,EAAK,MAAA,EAAgC,OAClF,EAAA,EAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,OACS,GAAc,EAAQ,SAAa,EAAgB,MAAI,EAAoB,OAC3E,EAA0B,EAAO,EAAI,IAAS,EAAmB,SAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,QAChE,EAAe,QAEnB,EAAS,OAGhB,EAAkB,OAAA,CAAA,uBAAA,uBAAA,UAAA,gBAAA,wBAAA,yGAAA,sBAAA,CAQlB,SAAQ,EAAe,EAAA,EAAA,GAAA,CACrB,IAAM,EAAe,EAAM,EAAA,EAAA,CAsCzB,OArCA,IAAQ,EAAA,OACP,CACC,KAAA,EAAY,OACb,CACE,IAAW,EAA6B,OAC3C,CACA,KAAO,EAAgB,OACtB,CACG,IAAqB,EAAA,QAClB,CACN,KAAA,EAAsB,QACtB,CACA,IAAwB,EAAiB,MAC1C,EAAA,EAAA,CACO,CACH,KAAC,EAAA,MACL,KAAO,EAAe,CACxB,KAAA,EACF,CAAA,GAAA,EAEE,EAAA,EAAA,CACW,CACZ,KAAA,EAAA,MACG,KAAM,EAAc,CACd,GAAA,EACN,KAAY,EAAA,KACd,CAAA,GAAA,CACK,CAEL,CACM,KAAA,EAAA,MACA,KAAA,CACF,KAAA,EAAmB,OACrB,CACA,CAGO,CACP,KAAQ,EAAe,OACvB,CAGJ,EAAY,OAAE,CAAA,uBAAW,uBAAA,UAAA,gBAAA,cAAA,+FAAA,sBAAA"}
@@ -1,111 +1,2 @@
1
-
2
- //#region src/plugin-utils/description-helpers.ts
3
- const __ΩFormatDescriptionOptions = [
4
- "replaceNewlines",
5
- true,
6
- "If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.",
7
- "collapseWhitespace",
8
- "If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.",
9
- "FormatDescriptionOptions",
10
- "P)4!8>\"?#)4$8>\"?%Mw&y"
11
- ];
12
- /**
13
- * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
14
- *
15
- * @remarks
16
- * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
17
- *
18
- * @param description - The full description string.
19
- * @returns The formatted description string.
20
- */
21
- function formatDescriptionWhitespace(description, options = {}) {
22
- let formattedDescription = description.trim();
23
- if (options.replaceNewlines) formattedDescription = formattedDescription.replace(/\s*\n\s*/g, " ");
24
- if (options.collapseWhitespace) formattedDescription = formattedDescription.replace(/\s{2,}/g, " ");
25
- return formattedDescription.trim();
26
- }
27
- formatDescriptionWhitespace.__type = [
28
- "description",
29
- () => __ΩFormatDescriptionOptions,
30
- "options",
31
- () => ({}),
32
- "formatDescriptionWhitespace",
33
- "Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.",
34
- "P&2!n\"2#>$&/%?&"
35
- ];
36
- /**
37
- * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
38
- *
39
- * @remarks
40
- * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
41
- *
42
- * @param description - The full description string.
43
- * @returns The formatted description string.
44
- */
45
- function formatDescriptionEscapes(description) {
46
- return description.replaceAll("'", "\\'").replaceAll("\"", "\\\"").replaceAll("`", "\\`").replace(/\$\{/g, "\\${");
47
- }
48
- formatDescriptionEscapes.__type = [
49
- "description",
50
- "formatDescriptionEscapes",
51
- "Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.",
52
- "P&2!&/\"?#"
53
- ];
54
- /**
55
- * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
56
- *
57
- * @remarks
58
- * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
59
- *
60
- * @param description - The full description string.
61
- * @returns The formatted description string.
62
- */
63
- function formatDescription(description, options = {}) {
64
- return formatDescriptionEscapes(formatDescriptionWhitespace(description, options));
65
- }
66
- formatDescription.__type = [
67
- "description",
68
- () => __ΩFormatDescriptionOptions,
69
- "options",
70
- () => ({}),
71
- "formatDescription",
72
- "Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.",
73
- "P&2!n\"2#>$&/%?&"
74
- ];
75
- const __ΩFormatShortDescriptionOptions = [
76
- () => __ΩFormatDescriptionOptions,
77
- "length",
78
- 62,
79
- "The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.",
80
- "FormatShortDescriptionOptions",
81
- "Pn!'4\"8>#?$Mw%y"
82
- ];
83
- /**
84
- * Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.
85
- *
86
- * @param description - The full description string.
87
- * @param options - Options for formatting the short description, including the maximum length.
88
- * @returns The extracted short description.
89
- */
90
- function formatShortDescription(description, options = {}) {
91
- const length = options.length ?? 62;
92
- const formattedDescription = formatDescriptionWhitespace(description, options);
93
- let result = ((formattedDescription.indexOf("\n") < length - 3 || formattedDescription.search(/[.!?\n]\s*\S/) > length - 3 ? formattedDescription.match(/^.*[.!?\n]\s?\S/)?.[0]?.trim()?.slice(0, -1)?.trim() : void 0) || formattedDescription).trim();
94
- if (result.trim().length > length) result = `${result.substring(0, Math.max(0, length - 3)).trim()}...`;
95
- return formatDescriptionEscapes(result);
96
- }
97
- formatShortDescription.__type = [
98
- "description",
99
- () => __ΩFormatShortDescriptionOptions,
100
- "options",
101
- () => ({}),
102
- "formatShortDescription",
103
- "Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.",
104
- "P&2!n\"2#>$&/%?&"
105
- ];
106
-
107
- //#endregion
108
- exports.__ΩFormatDescriptionOptions = __ΩFormatDescriptionOptions;
109
- exports.__ΩFormatShortDescriptionOptions = __ΩFormatShortDescriptionOptions;
110
- exports.formatDescription = formatDescription;
111
- exports.formatShortDescription = formatShortDescription;
1
+ const e=[`replaceNewlines`,!0,`If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.`,`collapseWhitespace`,`If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.`,`FormatDescriptionOptions`,`P)4!8>"?#)4$8>"?%Mw&y`];function t(e,t={}){let n=e.trim();return t.replaceNewlines&&(n=n.replace(/\s*\n\s*/g,` `)),t.collapseWhitespace&&(n=n.replace(/\s{2,}/g,` `)),n.trim()}t.__type=[`description`,()=>e,`options`,()=>({}),`formatDescriptionWhitespace`,`Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.`,`P&2!n"2#>$&/%?&`];function n(e){return e.replaceAll(`'`,`\\'`).replaceAll(`"`,`\\"`).replaceAll("`","\\`").replace(/\$\{/g,"\\${")}n.__type=[`description`,`formatDescriptionEscapes`,`Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.`,`P&2!&/"?#`];function r(e,r={}){return n(t(e,r))}r.__type=[`description`,()=>e,`options`,()=>({}),`formatDescription`,`Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.`,`P&2!n"2#>$&/%?&`];const i=[()=>e,`length`,62,`The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.`,`FormatShortDescriptionOptions`,`Pn!'4"8>#?$Mw%y`];function a(e,r={}){let i=r.length??62,a=t(e,r),o=((a.indexOf(`
2
+ `)<i-3||a.search(/[.!?\n]\s*\S/)>i-3?a.match(/^.*[.!?\n]\s?\S/)?.[0]?.trim()?.slice(0,-1)?.trim():void 0)||a).trim();return o.trim().length>i&&(o=`${o.substring(0,Math.max(0,i-3)).trim()}...`),n(o)}a.__type=[`description`,()=>i,`options`,()=>({}),`formatShortDescription`,`Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.`,`P&2!n"2#>$&/%?&`],exports.__ΩFormatDescriptionOptions=e,exports.__ΩFormatShortDescriptionOptions=i,exports.formatDescription=r,exports.formatShortDescription=a;
@@ -1,108 +1,3 @@
1
- //#region src/plugin-utils/description-helpers.ts
2
- const __ΩFormatDescriptionOptions = [
3
- "replaceNewlines",
4
- true,
5
- "If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.",
6
- "collapseWhitespace",
7
- "If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.",
8
- "FormatDescriptionOptions",
9
- "P)4!8>\"?#)4$8>\"?%Mw&y"
10
- ];
11
- /**
12
- * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
13
- *
14
- * @remarks
15
- * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
16
- *
17
- * @param description - The full description string.
18
- * @returns The formatted description string.
19
- */
20
- function formatDescriptionWhitespace(description, options = {}) {
21
- let formattedDescription = description.trim();
22
- if (options.replaceNewlines) formattedDescription = formattedDescription.replace(/\s*\n\s*/g, " ");
23
- if (options.collapseWhitespace) formattedDescription = formattedDescription.replace(/\s{2,}/g, " ");
24
- return formattedDescription.trim();
25
- }
26
- formatDescriptionWhitespace.__type = [
27
- "description",
28
- () => __ΩFormatDescriptionOptions,
29
- "options",
30
- () => ({}),
31
- "formatDescriptionWhitespace",
32
- "Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.",
33
- "P&2!n\"2#>$&/%?&"
34
- ];
35
- /**
36
- * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
37
- *
38
- * @remarks
39
- * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
40
- *
41
- * @param description - The full description string.
42
- * @returns The formatted description string.
43
- */
44
- function formatDescriptionEscapes(description) {
45
- return description.replaceAll("'", "\\'").replaceAll("\"", "\\\"").replaceAll("`", "\\`").replace(/\$\{/g, "\\${");
46
- }
47
- formatDescriptionEscapes.__type = [
48
- "description",
49
- "formatDescriptionEscapes",
50
- "Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.",
51
- "P&2!&/\"?#"
52
- ];
53
- /**
54
- * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
55
- *
56
- * @remarks
57
- * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
58
- *
59
- * @param description - The full description string.
60
- * @returns The formatted description string.
61
- */
62
- function formatDescription(description, options = {}) {
63
- return formatDescriptionEscapes(formatDescriptionWhitespace(description, options));
64
- }
65
- formatDescription.__type = [
66
- "description",
67
- () => __ΩFormatDescriptionOptions,
68
- "options",
69
- () => ({}),
70
- "formatDescription",
71
- "Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.",
72
- "P&2!n\"2#>$&/%?&"
73
- ];
74
- const __ΩFormatShortDescriptionOptions = [
75
- () => __ΩFormatDescriptionOptions,
76
- "length",
77
- 62,
78
- "The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.",
79
- "FormatShortDescriptionOptions",
80
- "Pn!'4\"8>#?$Mw%y"
81
- ];
82
- /**
83
- * Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.
84
- *
85
- * @param description - The full description string.
86
- * @param options - Options for formatting the short description, including the maximum length.
87
- * @returns The extracted short description.
88
- */
89
- function formatShortDescription(description, options = {}) {
90
- const length = options.length ?? 62;
91
- const formattedDescription = formatDescriptionWhitespace(description, options);
92
- let result = ((formattedDescription.indexOf("\n") < length - 3 || formattedDescription.search(/[.!?\n]\s*\S/) > length - 3 ? formattedDescription.match(/^.*[.!?\n]\s?\S/)?.[0]?.trim()?.slice(0, -1)?.trim() : void 0) || formattedDescription).trim();
93
- if (result.trim().length > length) result = `${result.substring(0, Math.max(0, length - 3)).trim()}...`;
94
- return formatDescriptionEscapes(result);
95
- }
96
- formatShortDescription.__type = [
97
- "description",
98
- () => __ΩFormatShortDescriptionOptions,
99
- "options",
100
- () => ({}),
101
- "formatShortDescription",
102
- "Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.",
103
- "P&2!n\"2#>$&/%?&"
104
- ];
105
-
106
- //#endregion
107
- export { __ΩFormatDescriptionOptions, __ΩFormatShortDescriptionOptions, formatDescription, formatShortDescription };
1
+ const e=[`replaceNewlines`,!0,`If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.`,`collapseWhitespace`,`If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.`,`FormatDescriptionOptions`,`P)4!8>"?#)4$8>"?%Mw&y`];function t(e,t={}){let n=e.trim();return t.replaceNewlines&&(n=n.replace(/\s*\n\s*/g,` `)),t.collapseWhitespace&&(n=n.replace(/\s{2,}/g,` `)),n.trim()}t.__type=[`description`,()=>e,`options`,()=>({}),`formatDescriptionWhitespace`,`Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.`,`P&2!n"2#>$&/%?&`];function n(e){return e.replaceAll(`'`,`\\'`).replaceAll(`"`,`\\"`).replaceAll("`","\\`").replace(/\$\{/g,"\\${")}n.__type=[`description`,`formatDescriptionEscapes`,`Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.`,`P&2!&/"?#`];function r(e,r={}){return n(t(e,r))}r.__type=[`description`,()=>e,`options`,()=>({}),`formatDescription`,`Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.`,`P&2!n"2#>$&/%?&`];const i=[()=>e,`length`,62,`The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.`,`FormatShortDescriptionOptions`,`Pn!'4"8>#?$Mw%y`];function a(e,r={}){let i=r.length??62,a=t(e,r),o=((a.indexOf(`
2
+ `)<i-3||a.search(/[.!?\n]\s*\S/)>i-3?a.match(/^.*[.!?\n]\s?\S/)?.[0]?.trim()?.slice(0,-1)?.trim():void 0)||a).trim();return o.trim().length>i&&(o=`${o.substring(0,Math.max(0,i-3)).trim()}...`),n(o)}a.__type=[`description`,()=>i,`options`,()=>({}),`formatShortDescription`,`Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.`,`P&2!n"2#>$&/%?&`];export{e as __ΩFormatDescriptionOptions,i as __ΩFormatShortDescriptionOptions,r as formatDescription,a as formatShortDescription};
108
3
  //# sourceMappingURL=description-helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"description-helpers.mjs","names":[],"sources":["../../src/plugin-utils/description-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\nexport interface FormatDescriptionOptions {\n /**\n * If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.\n *\n * @defaultValue false\n */\n replaceNewlines?: boolean;\n\n /**\n * If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.\n *\n * @defaultValue false\n */\n collapseWhitespace?: boolean;\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionWhitespace(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n let formattedDescription = description.trim();\n if (options.replaceNewlines) {\n formattedDescription = formattedDescription.replace(/\\s*\\n\\s*/g, \" \");\n }\n if (options.collapseWhitespace) {\n formattedDescription = formattedDescription.replace(/\\s{2,}/g, \" \");\n }\n\n return formattedDescription.trim();\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionEscapes(description: string): string {\n return description\n .replaceAll(\"'\", \"\\\\'\")\n .replaceAll('\"', '\\\\\"')\n .replaceAll(\"`\", \"\\\\`\")\n .replace(/\\$\\{/g, \"\\\\${\");\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nexport function formatDescription(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n return formatDescriptionEscapes(\n formatDescriptionWhitespace(description, options)\n );\n}\n\nexport interface FormatShortDescriptionOptions extends FormatDescriptionOptions {\n /**\n * The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.\n *\n * @defaultValue 62\n */\n length?: number;\n}\n\n/**\n * Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.\n *\n * @param description - The full description string.\n * @param options - Options for formatting the short description, including the maximum length.\n * @returns The extracted short description.\n */\nexport function formatShortDescription(\n description: string,\n options: FormatShortDescriptionOptions = {}\n): string {\n const length = options.length ?? 62;\n const formattedDescription = formatDescriptionWhitespace(\n description,\n options\n );\n\n const firstSentenceMatch =\n formattedDescription.indexOf(\"\\n\") < length - 3 ||\n formattedDescription.search(/[.!?\\n]\\s*\\S/) > length - 3\n ? formattedDescription\n .match(/^.*[.!?\\n]\\s?\\S/)?.[0]\n ?.trim()\n ?.slice(0, -1)\n ?.trim()\n : undefined;\n\n let result = (firstSentenceMatch || formattedDescription).trim();\n if (result.trim().length > length) {\n result = `${result.substring(0, Math.max(0, length - 3)).trim()}...`;\n }\n\n return formatDescriptionEscapes(result);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,SAAG,4BAAA,aAAA,UAAA,EAAA,EAAA;CACC,IAAE,uBAAa,YAAA,MAAA;AACf,KAAA,QAAA,gBACF,wBAA4B,qBAAA,QAAA,aAAA,IAAA;gCAG5B,wBAAA,qBAAA,QAAA,WAAA,IAAA;AAED,QAAA,qBAAA,MAAA;;AAED,4BAAsB,SAAc;CAAA;OAAiB;CAAgC;QAAqB,EAAE;CAAC;CAAa;CAAA;CAAA;;;;;;;;;;AAU1H,SAAM,yBAAyB,aAAA;AAC3B,QAAA,YACF,WAAA,KAAA,MAAA,CACI,WAAQ,MAAA,OAAA,CACV,WAAA,KAAqB,MAAE,CACzB,QAAA,SAAA,OAAA;;AAEF,yBAAS,SAAyB;CAAC;CAAC;CAAA;CAAA;CAAA;;;;;;;;;;AAUpC,SAAgB,kBAAU,aAAkB,UAAA,EAAA,EAAA;AAC1C,QAAA,yBAAA,4BAAA,aAAA,QAAA,CAAA;;AAEF,kBAAS,SAAA;CAAA;OAAA;CAAA;QAAA,EAAA;CAAA;CAAA;CAAA;CAAA;AACT,MAAK,mCAAqB;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAS1B,SAAI,uBAAA,aAAA,UAAA,EAAA,EAAA;CACD,MAAO,SAAQ,QAAI,UAAc;CACnC,MAAA,uBAAA,4BAAA,aAAA,QAAA;CASG,IAAA,WARwB,qBAAuB,QAAA,KAAA,GAAA,SAAA,KAC/C,qBAAsB,OAAA,eAAkB,GAAA,SAAA,IAC1C,qBACK,MAAS,kBAAiB,GAAA,IACnB,MAAC,EACJ,MAAA,GAAA,GAAA,EACD,MAAA,GACD,WACuB,sBAAoB,MAAA;AACjD,KAAA,OAAA,MAAA,CAAA,SAAA,OACH,UAAA,GAAA,OAAA,UAAA,GAAA,KAAA,IAAA,GAAA,SAAA,EAAA,CAAA,CAAA,MAAA,CAAA;AAEA,QAAO,yBAAU,OAAA;;AAEjB,uBAAuB,SAAQ;CAAA;OAAsB;CAAgC;QAAmB,EAAA;CAAA;CAAS;CAAA;CAAA"}
1
+ {"version":3,"file":"description-helpers.mjs","names":[],"sources":["../../src/plugin-utils/description-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\nexport interface FormatDescriptionOptions {\n /**\n * If true, replaces newlines in the description with spaces. This is useful for ensuring that descriptions are displayed as a single line in contexts where multiline descriptions may not be supported or may cause formatting issues.\n *\n * @defaultValue false\n */\n replaceNewlines?: boolean;\n\n /**\n * If true, collapses multiple consecutive spaces in the description into a single space. This helps to ensure that descriptions are concise and do not contain unnecessary whitespace.\n *\n * @defaultValue false\n */\n collapseWhitespace?: boolean;\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionWhitespace(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n let formattedDescription = description.trim();\n if (options.replaceNewlines) {\n formattedDescription = formattedDescription.replace(/\\s*\\n\\s*/g, \" \");\n }\n if (options.collapseWhitespace) {\n formattedDescription = formattedDescription.replace(/\\s{2,}/g, \" \");\n }\n\n return formattedDescription.trim();\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nfunction formatDescriptionEscapes(description: string): string {\n return description\n .replaceAll(\"'\", \"\\\\'\")\n .replaceAll('\"', '\\\\\"')\n .replaceAll(\"`\", \"\\\\`\")\n .replace(/\\$\\{/g, \"\\\\${\");\n}\n\n/**\n * Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.\n *\n * @remarks\n * This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.\n *\n * @param description - The full description string.\n * @returns The formatted description string.\n */\nexport function formatDescription(\n description: string,\n options: FormatDescriptionOptions = {}\n): string {\n return formatDescriptionEscapes(\n formatDescriptionWhitespace(description, options)\n );\n}\n\nexport interface FormatShortDescriptionOptions extends FormatDescriptionOptions {\n /**\n * The maximum length of the short description. If the first sentence exceeds this length, it will be truncated.\n *\n * @defaultValue 62\n */\n length?: number;\n}\n\n/**\n * Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.\n *\n * @param description - The full description string.\n * @param options - Options for formatting the short description, including the maximum length.\n * @returns The extracted short description.\n */\nexport function formatShortDescription(\n description: string,\n options: FormatShortDescriptionOptions = {}\n): string {\n const length = options.length ?? 62;\n const formattedDescription = formatDescriptionWhitespace(\n description,\n options\n );\n\n const firstSentenceMatch =\n formattedDescription.indexOf(\"\\n\") < length - 3 ||\n formattedDescription.search(/[.!?\\n]\\s*\\S/) > length - 3\n ? formattedDescription\n .match(/^.*[.!?\\n]\\s?\\S/)?.[0]\n ?.trim()\n ?.slice(0, -1)\n ?.trim()\n : undefined;\n\n let result = (firstSentenceMatch || formattedDescription).trim();\n if (result.trim().length > length) {\n result = `${result.substring(0, Math.max(0, length - 3)).trim()}...`;\n }\n\n return formatDescriptionEscapes(result);\n}\n"],"mappings":"sgBA4BA,SAAG,EAAA,EAAA,EAAA,EAAA,CAAA,CACD,IAAI,EAAa,EAAA,MAAA,CAOlB,OANG,EAAA,kBACF,EAAqB,EAAO,QAAA,YAAA,IAAA,yBAG5B,EAAA,EAAA,QAAA,UAAA,IAAA,EAED,EAAA,MAAA,CAED,EAAsB,OAAc,CAAA,kBAAiB,EAAgC,eAAqB,EAAE,EAAC,8BAAa,kMAAA,kBAAA,CAU1H,SAAM,EAAyB,EAAA,CAC7B,OAAE,EAAA,WAAuB,IAAA,MAAA,CAAA,WAA4B,IAAK,MAAM,CAAC,WAAM,IAAA,MAAA,CAAA,QAAA,QAAA,OAAA,CAEzE,EAAc,OAAoB,CAAA,cAAA,2BAAA,kMAAA,YAAA,CAUlC,SAAI,EAAA,EAAA,EAAA,EAAA,CAAA,CACF,OAAM,EAAuB,EAA8B,EAAS,EAAU,CAAI,CAEpF,EAAU,OAAiB,CAAC,kBAAiB,EAAM,eAAA,EAAA,EAAA,oBAAA,kMAAA,kBAAA,CACnD,MAAI,EAAkC,KAAM,EAAA,SAAA,GAAA,gHAAA,gCAAA,kBAAA,oBAU1C,IAAA,EAAA,EAAA,QAAA,GACC,EAA4B,EAAyB,EAAU,EAAc,CAE5E,IADH,EAAA,QAAA;EAAA,CAAA,EAAA,GAAA,EAAA,OAAA,eAAA,CAAA,EAAA,EAAA,EAAA,MAAA,kBAAA,GAAA,IAAA,MAAA,EAAA,MAAA,EAAA,GAAA,EAAA,MAAA,CAAA,IAAA,KACG,GAAA,MAAA,CAIF,OAHC,EAAQ,MAAO,CAAA,OAAI,IACrB,EAAA,GAAA,EAAA,UAAA,EAAA,KAAA,IAAA,EAAA,EAAA,EAAA,CAAA,CAAA,MAAA,CAAA,MAEG,EAAsB,EAAY,CAEtC,EAAgB,OAAA,CAAiB,kBAAA,EAAA,eAAA,EAAA,EAAA,yBAAA,+JAAA,kBAAA"}
@@ -1,117 +1 @@
1
- const require_context_helpers = require('./context-helpers.cjs');
2
- const require_traverse_command_tree = require('./traverse-command-tree.cjs');
3
-
4
- //#region src/plugin-utils/get-command-tree.ts
5
- function __assignType(fn, args) {
6
- fn.__type = args;
7
- return fn;
8
- }
9
- /**
10
- * Retrieves a specific command tree based on the provided path.
11
- *
12
- * @param context - The build context containing the command definitions.
13
- * @param path - An array of strings representing the command path.
14
- * @returns The command tree at the specified path, or null if not found.
15
- */
16
- function getCommandTree(context, path = []) {
17
- if (path.length === 0) return null;
18
- let currentTree = context.commands[path[0]] ?? null;
19
- if (path.length > 1) {
20
- const segments = path.slice(1).filter(__assignType((segment) => !require_context_helpers.isDynamicPathSegment(segment), [
21
- "segment",
22
- "",
23
- "P\"2!\"/\""
24
- ]));
25
- for (const segment of segments) if (currentTree?.children && Object.prototype.hasOwnProperty.call(currentTree.children, segment)) currentTree = currentTree.children[segment] ?? null;
26
- else return null;
27
- }
28
- return currentTree;
29
- }
30
- getCommandTree.__type = [
31
- "Context",
32
- "context",
33
- "path",
34
- "CommandTree",
35
- "getCommandTree",
36
- "Retrieves a specific command tree based on the provided path.",
37
- "P\"w!2\"\"2#P\"w$,J/%?&"
38
- ];
39
- /**
40
- * Retrieves a list of all command trees defined in the context.
41
- *
42
- * @param context - The build context containing the command definitions.
43
- * @returns A promise that resolves to an array of all command trees in the context.
44
- */
45
- async function getCommandList(context) {
46
- const commandList = [];
47
- await require_traverse_command_tree.traverseCommands(context, __assignType((commandTree) => {
48
- commandList.push(commandTree);
49
- }, [
50
- "commandTree",
51
- "",
52
- "P\"2!\"/\""
53
- ]));
54
- return commandList;
55
- }
56
- getCommandList.__type = [
57
- "Context",
58
- "context",
59
- "CommandTree",
60
- "getCommandList",
61
- "Retrieves a list of all command trees defined in the context.",
62
- "P\"w!2\"\"w#F`/$?%"
63
- ];
64
- /**
65
- * Retrieves a list of all command paths defined in the context.
66
- *
67
- * @param context - The build context containing the command definitions.
68
- * @returns A promise that resolves to an array of all command paths in the context.
69
- */
70
- async function getCommandPaths(context) {
71
- const commandPaths = [];
72
- await require_traverse_command_tree.traverseCommands(context, __assignType((commandTree) => {
73
- if (commandTree.path) commandPaths.push(commandTree.path);
74
- }, [
75
- "commandTree",
76
- "",
77
- "P\"2!\"/\""
78
- ]));
79
- return commandPaths;
80
- }
81
- getCommandPaths.__type = [
82
- "Context",
83
- "context",
84
- "getCommandPaths",
85
- "Retrieves a list of all command paths defined in the context.",
86
- "P\"w!2\"&F`/#?$"
87
- ];
88
- /**
89
- * Retrieves a list of all command segments defined in the context.
90
- *
91
- * @param context - The build context containing the command definitions.
92
- * @returns A promise that resolves to an array of all command segments in the context.
93
- */
94
- async function getCommandSegments(context) {
95
- const commandSegments = [];
96
- await require_traverse_command_tree.traverseCommands(context, __assignType((commandTree) => {
97
- if (commandTree.path) commandSegments.push(commandTree.segments);
98
- }, [
99
- "commandTree",
100
- "",
101
- "P\"2!\"/\""
102
- ]));
103
- return commandSegments;
104
- }
105
- getCommandSegments.__type = [
106
- "Context",
107
- "context",
108
- "getCommandSegments",
109
- "Retrieves a list of all command segments defined in the context.",
110
- "P\"w!2\"&FF`/#?$"
111
- ];
112
-
113
- //#endregion
114
- exports.getCommandList = getCommandList;
115
- exports.getCommandPaths = getCommandPaths;
116
- exports.getCommandSegments = getCommandSegments;
117
- exports.getCommandTree = getCommandTree;
1
+ const e=require(`./context-helpers.cjs`),t=require(`./traverse-command-tree.cjs`);function n(e,t){return e.__type=t,e}function r(t,r=[]){if(r.length===0)return null;let i=t.commands[r[0]]??null;if(r.length>1){let t=r.slice(1).filter(n(t=>!e.isDynamicPathSegment(t),[`segment`,``,`P"2!"/"`]));for(let e of t)if(i?.children&&Object.prototype.hasOwnProperty.call(i.children,e))i=i.children[e]??null;else return null}return i}r.__type=[`Context`,`context`,`path`,`CommandTree`,`getCommandTree`,`Retrieves a specific command tree based on the provided path.`,`P"w!2""2#P"w$,J/%?&`];async function i(e){let r=[];return await t.traverseCommands(e,n(e=>{r.push(e)},[`commandTree`,``,`P"2!"/"`])),r}i.__type=[`Context`,`context`,`CommandTree`,`getCommandList`,`Retrieves a list of all command trees defined in the context.`,'P"w!2""w#F`/$?%'];async function a(e){let r=[];return await t.traverseCommands(e,n(e=>{e.path&&r.push(e.path)},[`commandTree`,``,`P"2!"/"`])),r}a.__type=[`Context`,`context`,`getCommandPaths`,`Retrieves a list of all command paths defined in the context.`,'P"w!2"&F`/#?$'];async function o(e){let r=[];return await t.traverseCommands(e,n(e=>{e.path&&r.push(e.segments)},[`commandTree`,``,`P"2!"/"`])),r}o.__type=[`Context`,`context`,`getCommandSegments`,`Retrieves a list of all command segments defined in the context.`,'P"w!2"&FF`/#?$'],exports.getCommandList=i,exports.getCommandPaths=a,exports.getCommandSegments=o,exports.getCommandTree=r;
@@ -1,115 +1,2 @@
1
- import { isDynamicPathSegment } from "./context-helpers.mjs";
2
- import { traverseCommands } from "./traverse-command-tree.mjs";
3
-
4
- //#region src/plugin-utils/get-command-tree.ts
5
- function __assignType(fn, args) {
6
- fn.__type = args;
7
- return fn;
8
- }
9
- /**
10
- * Retrieves a specific command tree based on the provided path.
11
- *
12
- * @param context - The build context containing the command definitions.
13
- * @param path - An array of strings representing the command path.
14
- * @returns The command tree at the specified path, or null if not found.
15
- */
16
- function getCommandTree(context, path = []) {
17
- if (path.length === 0) return null;
18
- let currentTree = context.commands[path[0]] ?? null;
19
- if (path.length > 1) {
20
- const segments = path.slice(1).filter(__assignType((segment) => !isDynamicPathSegment(segment), [
21
- "segment",
22
- "",
23
- "P\"2!\"/\""
24
- ]));
25
- for (const segment of segments) if (currentTree?.children && Object.prototype.hasOwnProperty.call(currentTree.children, segment)) currentTree = currentTree.children[segment] ?? null;
26
- else return null;
27
- }
28
- return currentTree;
29
- }
30
- getCommandTree.__type = [
31
- "Context",
32
- "context",
33
- "path",
34
- "CommandTree",
35
- "getCommandTree",
36
- "Retrieves a specific command tree based on the provided path.",
37
- "P\"w!2\"\"2#P\"w$,J/%?&"
38
- ];
39
- /**
40
- * Retrieves a list of all command trees defined in the context.
41
- *
42
- * @param context - The build context containing the command definitions.
43
- * @returns A promise that resolves to an array of all command trees in the context.
44
- */
45
- async function getCommandList(context) {
46
- const commandList = [];
47
- await traverseCommands(context, __assignType((commandTree) => {
48
- commandList.push(commandTree);
49
- }, [
50
- "commandTree",
51
- "",
52
- "P\"2!\"/\""
53
- ]));
54
- return commandList;
55
- }
56
- getCommandList.__type = [
57
- "Context",
58
- "context",
59
- "CommandTree",
60
- "getCommandList",
61
- "Retrieves a list of all command trees defined in the context.",
62
- "P\"w!2\"\"w#F`/$?%"
63
- ];
64
- /**
65
- * Retrieves a list of all command paths defined in the context.
66
- *
67
- * @param context - The build context containing the command definitions.
68
- * @returns A promise that resolves to an array of all command paths in the context.
69
- */
70
- async function getCommandPaths(context) {
71
- const commandPaths = [];
72
- await traverseCommands(context, __assignType((commandTree) => {
73
- if (commandTree.path) commandPaths.push(commandTree.path);
74
- }, [
75
- "commandTree",
76
- "",
77
- "P\"2!\"/\""
78
- ]));
79
- return commandPaths;
80
- }
81
- getCommandPaths.__type = [
82
- "Context",
83
- "context",
84
- "getCommandPaths",
85
- "Retrieves a list of all command paths defined in the context.",
86
- "P\"w!2\"&F`/#?$"
87
- ];
88
- /**
89
- * Retrieves a list of all command segments defined in the context.
90
- *
91
- * @param context - The build context containing the command definitions.
92
- * @returns A promise that resolves to an array of all command segments in the context.
93
- */
94
- async function getCommandSegments(context) {
95
- const commandSegments = [];
96
- await traverseCommands(context, __assignType((commandTree) => {
97
- if (commandTree.path) commandSegments.push(commandTree.segments);
98
- }, [
99
- "commandTree",
100
- "",
101
- "P\"2!\"/\""
102
- ]));
103
- return commandSegments;
104
- }
105
- getCommandSegments.__type = [
106
- "Context",
107
- "context",
108
- "getCommandSegments",
109
- "Retrieves a list of all command segments defined in the context.",
110
- "P\"w!2\"&FF`/#?$"
111
- ];
112
-
113
- //#endregion
114
- export { getCommandList, getCommandPaths, getCommandSegments, getCommandTree };
1
+ import{isDynamicPathSegment as e}from"./context-helpers.mjs";import{traverseCommands as t}from"./traverse-command-tree.mjs";function n(e,t){return e.__type=t,e}function r(t,r=[]){if(r.length===0)return null;let i=t.commands[r[0]]??null;if(r.length>1){let t=r.slice(1).filter(n(t=>!e(t),[`segment`,``,`P"2!"/"`]));for(let e of t)if(i?.children&&Object.prototype.hasOwnProperty.call(i.children,e))i=i.children[e]??null;else return null}return i}r.__type=[`Context`,`context`,`path`,`CommandTree`,`getCommandTree`,`Retrieves a specific command tree based on the provided path.`,`P"w!2""2#P"w$,J/%?&`];async function i(e){let r=[];return await t(e,n(e=>{r.push(e)},[`commandTree`,``,`P"2!"/"`])),r}i.__type=[`Context`,`context`,`CommandTree`,`getCommandList`,`Retrieves a list of all command trees defined in the context.`,'P"w!2""w#F`/$?%'];async function a(e){let r=[];return await t(e,n(e=>{e.path&&r.push(e.path)},[`commandTree`,``,`P"2!"/"`])),r}a.__type=[`Context`,`context`,`getCommandPaths`,`Retrieves a list of all command paths defined in the context.`,'P"w!2"&F`/#?$'];async function o(e){let r=[];return await t(e,n(e=>{e.path&&r.push(e.segments)},[`commandTree`,``,`P"2!"/"`])),r}o.__type=[`Context`,`context`,`getCommandSegments`,`Retrieves a list of all command segments defined in the context.`,'P"w!2"&FF`/#?$'];export{i as getCommandList,a as getCommandPaths,o as getCommandSegments,r as getCommandTree};
115
2
  //# sourceMappingURL=get-command-tree.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-command-tree.mjs","names":[],"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 { isDynamicPathSegment } from \"./context-helpers\";\nimport { traverseCommands } from \"./traverse-command-tree\";\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 => !isDynamicPathSegment(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\n/**\n * Retrieves a list of all command trees defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command trees in the context.\n */\nexport async function getCommandList(context: Context): Promise<CommandTree[]> {\n const commandList: CommandTree[] = [];\n await traverseCommands(context, commandTree => {\n commandList.push(commandTree);\n });\n\n return commandList;\n}\n\n/**\n * Retrieves a list of all command paths defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command paths in the context.\n */\nexport async function getCommandPaths(context: Context): Promise<string[]> {\n const commandPaths: string[] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandPaths.push(commandTree.path);\n }\n });\n\n return commandPaths;\n}\n\n/**\n * Retrieves a list of all command segments defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command segments in the context.\n */\nexport async function getCommandSegments(\n context: Context\n): Promise<string[][]> {\n const commandSegments: string[][] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandSegments.push(commandTree.segments);\n }\n });\n\n return commandSegments;\n}\n"],"mappings":";;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;AAYV,KAAK,KAAO,WAAW;;AAIxB,KAAO,KAAM,SAAC,GAAW;EAClB,MAAO,WAAU,KACf,MAAA,EAAA,CACA,OAAA,cAAwB,YAAW,CAAC,qBAAa,QAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;iCAExD,KAAA,aAAA,YACa,OAAQ,UAAS,eAAc,KAAI,YAAa,UAAA,QAAA,CAC9D,eAAA,YAAA,SAAA,YAAA;MAGe,QAAO;;AAIrB,QAAS;;AAEX,eAAW,SAAa;CAAC;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOzB,eAAc,eAAA,SAAA;CACV,MAAG,cAAiB,EAAE;AACtB,OAAK,iBAAiB,SAAU,cAAA,gBAAA;AAC5B,cAAC,KAAA,YAAA;IACF;EAAC;EAAa;EAAA;EAAU,CAAA,CAAA;AAC3B,QAAI;;AAER,eAAQ,SAAc;CAAA;CAAY;CAAS;CAAgB;CAAA;CAAA;CAAA;;;;;;;AAO3D,eAAoB,gBAAA,SAAA;CACpB,MAAA,eAAA,EAAA;;AAEE,MAAA,YAAA,KACU,cAAW,KAAI,YAAc,KAAA;IAErC;EAAA;EAAmB;EAAC;EAAa,CAAC,CAAA;AAClC,QAAO;;AAEX,gBAAa,SAAS;CAAA;CAAe;CAAS;CAAkB;CAAe;CAAA;;;;;;;AAO/E,eAAA,mBAAA,SAAA;;AAEE,OAAA,iBAAA,SAAA,cAAA,gBAAA;AACC,MAAS,YAAW,KACtB,iBAAA,KAAA,YAAA,SAAA;IAEG;EAAA;EAAkB;EAAK;EAAS,CAAE,CAAC;AACrC,QAAA;;AAEF,mBAAQ,SAAoB;CAAC;CAAM;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"get-command-tree.mjs","names":[],"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 { isDynamicPathSegment } from \"./context-helpers\";\nimport { traverseCommands } from \"./traverse-command-tree\";\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 => !isDynamicPathSegment(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\n/**\n * Retrieves a list of all command trees defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command trees in the context.\n */\nexport async function getCommandList(context: Context): Promise<CommandTree[]> {\n const commandList: CommandTree[] = [];\n await traverseCommands(context, commandTree => {\n commandList.push(commandTree);\n });\n\n return commandList;\n}\n\n/**\n * Retrieves a list of all command paths defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command paths in the context.\n */\nexport async function getCommandPaths(context: Context): Promise<string[]> {\n const commandPaths: string[] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandPaths.push(commandTree.path);\n }\n });\n\n return commandPaths;\n}\n\n/**\n * Retrieves a list of all command segments defined in the context.\n *\n * @param context - The build context containing the command definitions.\n * @returns A promise that resolves to an array of all command segments in the context.\n */\nexport async function getCommandSegments(\n context: Context\n): Promise<string[][]> {\n const commandSegments: string[][] = [];\n await traverseCommands(context, commandTree => {\n if (commandTree.path) {\n commandSegments.push(commandTree.segments);\n }\n });\n\n return commandSegments;\n}\n"],"mappings":"4HAAA,SAAS,EAAa,EAAI,EAAM,CAE9B,kBAAO,qBAYR,GAAK,EAAA,SAAQ,EAAA,OAAA,kCAId,GAAM,EAAK,OAAG,EAAA,CACd,IAAO,EAAc,EAAG,MAAQ,EAAC,CAAA,OAAM,EAAQ,GAAA,CAAA,EAAA,EAAA,CAAA,CAAA,UAAA,GAAA,UAAA,CAAA,CAAA,CAC/C,IAAS,IAAA,KAAA,EACH,GAAG,GAAA,UAA0B,OAAC,UAAgB,eAAM,KAAA,EAAA,SAAA,EAAA,CAAA,EAAA,EAAA,SAAA,IAAA,UAGvD,OAAY,KAIb,OAAE,EAEJ,EAAe,OAAC,CAAA,UAAc,UAAA,OAAA,cAAA,iBAAA,gEAAA,sBAAA,qBAQ5B,IAAI,EAAa,EAAA,CAIjB,OAHA,MAAI,EAAiB,EAAA,EAAA,GAAA,CACnB,EAAM,KAAW,EAAA,EAChB,CAAC,cAAQ,GAAA,UAAA,CAAA,CAAA,CACP,EAEP,EAAS,OAAA,CAAA,UAAA,UAAA,cAAA,iBAAA,gEAAA,kBAAA,CAOT,eAAM,EAAA,EAAA,CACJ,IAAE,EAAA,EAAA,CAMF,OALA,MAAA,EAAA,EAAA,EAAA,GAAA,SAEA,EAAO,KAAW,EAAA,KAAA,iCAGlB,EAEF,EAAC,OAAA,CAAA,UAAA,UAAA,kBAAA,gEAAA,gBAAA,CAOD,eAAqB,EAAY,EAAA,CAC/B,IAAE,EAAA,EAAA,CAMF,uBAJM,EAAY,MACpB,EAAA,KAAA,EAAA,SAAA,EAEE,CAAA,cAAA,GAAA,UAAA,CAAA,CAAA,CACC,EAEH,EAAmB,OAAK,CAAK,UAAS,UAAW,qBAAuB,mEAAA,iBAAA"}