@shell-shock/core 0.10.0 → 0.12.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 (161) hide show
  1. package/dist/components/docs.cjs +4 -4
  2. package/dist/components/docs.cjs.map +1 -1
  3. package/dist/components/docs.d.cts +5 -5
  4. package/dist/components/docs.d.cts.map +1 -1
  5. package/dist/components/docs.d.mts +5 -5
  6. package/dist/components/docs.d.mts.map +1 -1
  7. package/dist/components/helpers.cjs +9 -0
  8. package/dist/components/helpers.cjs.map +1 -1
  9. package/dist/components/helpers.d.cts +15 -7
  10. package/dist/components/helpers.d.cts.map +1 -1
  11. package/dist/components/helpers.d.mts +15 -7
  12. package/dist/components/helpers.d.mts.map +1 -1
  13. package/dist/components/helpers.mjs +9 -1
  14. package/dist/components/helpers.mjs.map +1 -1
  15. package/dist/components/index.cjs +1 -0
  16. package/dist/components/index.d.cts +2 -2
  17. package/dist/components/index.d.mts +2 -2
  18. package/dist/components/index.mjs +2 -2
  19. package/dist/components/options-parser-logic.cjs +167 -87
  20. package/dist/components/options-parser-logic.cjs.map +1 -1
  21. package/dist/components/options-parser-logic.d.cts +15 -15
  22. package/dist/components/options-parser-logic.d.cts.map +1 -1
  23. package/dist/components/options-parser-logic.d.mts +15 -15
  24. package/dist/components/options-parser-logic.d.mts.map +1 -1
  25. package/dist/components/options-parser-logic.mjs +163 -83
  26. package/dist/components/options-parser-logic.mjs.map +1 -1
  27. package/dist/components/usage.cjs +5 -5
  28. package/dist/components/usage.cjs.map +1 -1
  29. package/dist/components/usage.d.cts +2 -2
  30. package/dist/components/usage.d.cts.map +1 -1
  31. package/dist/components/usage.d.mts +2 -2
  32. package/dist/components/usage.mjs +4 -4
  33. package/dist/components/usage.mjs.map +1 -1
  34. package/dist/components/utils-builtin.cjs +2 -2
  35. package/dist/components/utils-builtin.cjs.map +1 -1
  36. package/dist/components/utils-builtin.d.cts +9 -9
  37. package/dist/components/utils-builtin.d.cts.map +1 -1
  38. package/dist/components/utils-builtin.d.mts +9 -9
  39. package/dist/components/utils-builtin.d.mts.map +1 -1
  40. package/dist/components/utils-builtin.mjs +5 -5
  41. package/dist/components/utils-builtin.mjs.map +1 -1
  42. package/dist/contexts/options.cjs +2 -2
  43. package/dist/contexts/options.cjs.map +1 -1
  44. package/dist/contexts/options.d.cts +1 -1
  45. package/dist/contexts/options.d.cts.map +1 -1
  46. package/dist/contexts/options.d.mts +1 -1
  47. package/dist/contexts/options.d.mts.map +1 -1
  48. package/dist/contexts/options.mjs +4 -4
  49. package/dist/contexts/options.mjs.map +1 -1
  50. package/dist/helpers/automd.cjs +2 -2
  51. package/dist/helpers/automd.cjs.map +1 -1
  52. package/dist/helpers/automd.mjs.map +1 -1
  53. package/dist/helpers/paths.cjs +125 -0
  54. package/dist/helpers/paths.cjs.map +1 -0
  55. package/dist/helpers/paths.mjs +121 -0
  56. package/dist/helpers/paths.mjs.map +1 -0
  57. package/dist/helpers/persistence.cjs +68 -116
  58. package/dist/helpers/persistence.cjs.map +1 -1
  59. package/dist/helpers/persistence.mjs +68 -116
  60. package/dist/helpers/persistence.mjs.map +1 -1
  61. package/dist/helpers/update-package-json.cjs +4 -4
  62. package/dist/helpers/update-package-json.cjs.map +1 -1
  63. package/dist/helpers/utilities.cjs +1 -1
  64. package/dist/helpers/utilities.mjs +1 -1
  65. package/dist/helpers/validations.cjs +2 -3
  66. package/dist/helpers/validations.cjs.map +1 -1
  67. package/dist/helpers/validations.mjs +2 -2
  68. package/dist/helpers/validations.mjs.map +1 -1
  69. package/dist/index.cjs +14 -11
  70. package/dist/index.d.cts +2 -2
  71. package/dist/index.d.mts +2 -2
  72. package/dist/index.mjs +3 -3
  73. package/dist/plugin-utils/deepkit.cjs +72 -0
  74. package/dist/plugin-utils/deepkit.cjs.map +1 -0
  75. package/dist/plugin-utils/deepkit.d.cts +24 -0
  76. package/dist/plugin-utils/deepkit.d.cts.map +1 -0
  77. package/dist/plugin-utils/deepkit.d.mts +24 -0
  78. package/dist/plugin-utils/deepkit.d.mts.map +1 -0
  79. package/dist/plugin-utils/deepkit.mjs +70 -0
  80. package/dist/plugin-utils/deepkit.mjs.map +1 -0
  81. package/dist/plugin-utils/description-helpers.cjs +105 -0
  82. package/dist/plugin-utils/description-helpers.cjs.map +1 -0
  83. package/dist/plugin-utils/description-helpers.d.cts +44 -0
  84. package/dist/plugin-utils/description-helpers.d.cts.map +1 -0
  85. package/dist/plugin-utils/description-helpers.d.mts +44 -0
  86. package/dist/plugin-utils/description-helpers.d.mts.map +1 -0
  87. package/dist/plugin-utils/description-helpers.mjs +101 -0
  88. package/dist/plugin-utils/description-helpers.mjs.map +1 -0
  89. package/dist/plugin-utils/get-command-tree.cjs +2 -2
  90. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  91. package/dist/plugin-utils/index.cjs +32 -18
  92. package/dist/plugin-utils/index.d.cts +4 -1
  93. package/dist/plugin-utils/index.d.mts +4 -1
  94. package/dist/plugin-utils/index.mjs +4 -1
  95. package/dist/plugin-utils/reflect.cjs +4 -5
  96. package/dist/plugin-utils/reflect.cjs.map +1 -1
  97. package/dist/plugin-utils/reflect.mjs +4 -4
  98. package/dist/plugin-utils/reflect.mjs.map +1 -1
  99. package/dist/plugin-utils/type-checks.cjs +89 -0
  100. package/dist/plugin-utils/type-checks.cjs.map +1 -0
  101. package/dist/plugin-utils/type-checks.d.cts +42 -0
  102. package/dist/plugin-utils/type-checks.d.cts.map +1 -0
  103. package/dist/plugin-utils/type-checks.d.mts +42 -0
  104. package/dist/plugin-utils/type-checks.d.mts.map +1 -0
  105. package/dist/plugin-utils/type-checks.mjs +84 -0
  106. package/dist/plugin-utils/type-checks.mjs.map +1 -0
  107. package/dist/plugin.cjs +31 -29
  108. package/dist/plugin.cjs.map +1 -1
  109. package/dist/plugin.d.cts.map +1 -1
  110. package/dist/plugin.d.mts.map +1 -1
  111. package/dist/plugin.mjs +15 -13
  112. package/dist/plugin.mjs.map +1 -1
  113. package/dist/resolver/deepkit.cjs +132 -0
  114. package/dist/resolver/deepkit.cjs.map +1 -0
  115. package/dist/resolver/deepkit.mjs +131 -0
  116. package/dist/resolver/deepkit.mjs.map +1 -0
  117. package/dist/resolver/helpers.cjs +167 -0
  118. package/dist/resolver/helpers.cjs.map +1 -0
  119. package/dist/resolver/helpers.mjs +162 -0
  120. package/dist/resolver/helpers.mjs.map +1 -0
  121. package/dist/resolver/module.cjs +144 -0
  122. package/dist/resolver/module.cjs.map +1 -0
  123. package/dist/resolver/module.mjs +143 -0
  124. package/dist/resolver/module.mjs.map +1 -0
  125. package/dist/resolver/resolve.cjs +209 -0
  126. package/dist/resolver/resolve.cjs.map +1 -0
  127. package/dist/resolver/resolve.mjs +208 -0
  128. package/dist/resolver/resolve.mjs.map +1 -0
  129. package/dist/types/command.cjs +127 -104
  130. package/dist/types/command.cjs.map +1 -1
  131. package/dist/types/command.d.cts +39 -78
  132. package/dist/types/command.d.cts.map +1 -1
  133. package/dist/types/command.d.mts +39 -78
  134. package/dist/types/command.d.mts.map +1 -1
  135. package/dist/types/command.mjs +115 -95
  136. package/dist/types/command.mjs.map +1 -1
  137. package/dist/types/config.cjs +5 -3
  138. package/dist/types/config.cjs.map +1 -1
  139. package/dist/types/config.d.cts +7 -3
  140. package/dist/types/config.d.cts.map +1 -1
  141. package/dist/types/config.d.mts +7 -3
  142. package/dist/types/config.d.mts.map +1 -1
  143. package/dist/types/config.mjs +5 -3
  144. package/dist/types/config.mjs.map +1 -1
  145. package/dist/types/context.cjs +1 -1
  146. package/dist/types/context.cjs.map +1 -1
  147. package/dist/types/context.d.cts +2 -2
  148. package/dist/types/context.d.cts.map +1 -1
  149. package/dist/types/context.d.mts +2 -2
  150. package/dist/types/context.d.mts.map +1 -1
  151. package/dist/types/context.mjs +1 -1
  152. package/dist/types/context.mjs.map +1 -1
  153. package/dist/types/index.cjs +13 -10
  154. package/dist/types/index.d.cts +2 -2
  155. package/dist/types/index.d.mts +2 -2
  156. package/dist/types/index.mjs +2 -2
  157. package/package.json +24 -75
  158. package/dist/helpers/resolve-command.cjs +0 -430
  159. package/dist/helpers/resolve-command.cjs.map +0 -1
  160. package/dist/helpers/resolve-command.mjs +0 -425
  161. package/dist/helpers/resolve-command.mjs.map +0 -1
@@ -0,0 +1,89 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_types_command = require('../types/command.cjs');
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_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
6
+
7
+ //#region src/plugin-utils/type-checks.ts
8
+ /**
9
+ * Type guard to check if a value is a valid {@link CommandParameterKind} type.
10
+ *
11
+ * @param obj - The value to check.
12
+ * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
13
+ */
14
+ function isCommandParameterKind(obj) {
15
+ return (0, __stryke_type_checks_is_set_string.isSetString)(obj) && [
16
+ require_types_command.CommandParameterKinds.string,
17
+ require_types_command.CommandParameterKinds.number,
18
+ require_types_command.CommandParameterKinds.boolean
19
+ ].includes(obj);
20
+ }
21
+ isCommandParameterKind.__type = [
22
+ "obj",
23
+ "isCommandParameterKind",
24
+ "P\"2!!/\""
25
+ ];
26
+ /**
27
+ * Type guard to check if a value is a valid {@link CommandParameterConfig} type.
28
+ *
29
+ * @param obj - The value to check.
30
+ * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
31
+ */
32
+ function isCommandParameterConfig(obj) {
33
+ return (0, __stryke_type_checks_is_set_object.isSetObject)(obj) && "kind" in obj && isCommandParameterKind(obj.kind);
34
+ }
35
+ isCommandParameterConfig.__type = [
36
+ "obj",
37
+ "isCommandParameterConfig",
38
+ "P\"2!!/\""
39
+ ];
40
+ /**
41
+ * Type guard to check if a value is a valid {@link CommandParameter} type.
42
+ *
43
+ * @param obj - The value to check.
44
+ * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
45
+ */
46
+ function isCommandParameter(obj) {
47
+ return isCommandParameterConfig(obj) && "name" in obj && (0, __stryke_type_checks_is_set_string.isSetString)(obj.name) && "title" in obj && (0, __stryke_type_checks_is_set_string.isSetString)(obj.title) && "description" in obj && (0, __stryke_type_checks_is_set_string.isSetString)(obj.description) && "alias" in obj && Array.isArray(obj.alias) && "env" in obj && ((0, __stryke_type_checks_is_set_string.isSetString)(obj.env) || obj.env === false) && "optional" in obj && (0, __stryke_type_checks_is_boolean.isBoolean)(obj.optional) && "variadic" in obj && (0, __stryke_type_checks_is_boolean.isBoolean)(obj.variadic);
48
+ }
49
+ isCommandParameter.__type = [
50
+ "obj",
51
+ "isCommandParameter",
52
+ "P\"2!!/\""
53
+ ];
54
+ /**
55
+ * Type guard to check if a value is a valid {@link CommandOption} type.
56
+ *
57
+ * @param obj - The value to check.
58
+ * @returns True if the value is a valid {@link CommandOption} type, false otherwise.
59
+ */
60
+ function isCommandOption(obj) {
61
+ return isCommandParameterConfig(obj) && isCommandParameter(obj) && "default" in obj;
62
+ }
63
+ isCommandOption.__type = [
64
+ "obj",
65
+ "isCommandOption",
66
+ "P\"2!!/\""
67
+ ];
68
+ /**
69
+ * Type guard to check if a value is a valid {@link CommandArgument} type.
70
+ *
71
+ * @param obj - The value to check.
72
+ * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
73
+ */
74
+ function isCommandArgument(obj) {
75
+ return isCommandParameterConfig(obj) && isCommandParameter(obj);
76
+ }
77
+ isCommandArgument.__type = [
78
+ "obj",
79
+ "isCommandArgument",
80
+ "P\"2!!/\""
81
+ ];
82
+
83
+ //#endregion
84
+ exports.isCommandArgument = isCommandArgument;
85
+ exports.isCommandOption = isCommandOption;
86
+ exports.isCommandParameter = isCommandParameter;
87
+ exports.isCommandParameterConfig = isCommandParameterConfig;
88
+ exports.isCommandParameterKind = isCommandParameterKind;
89
+ //# sourceMappingURL=type-checks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-checks.cjs","names":[],"sources":["../../src/plugin-utils/type-checks.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 { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameter,\n CommandParameterConfig,\n CommandParameterKind\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterKind} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.\n */\nexport function isCommandParameterKind(obj: any): obj is CommandParameterKind {\n return (\n isSetString(obj) &&\n [\n CommandParameterKinds.string,\n CommandParameterKinds.number,\n CommandParameterKinds.boolean\n ].includes(obj as CommandParameterKind)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterConfig} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.\n */\nexport function isCommandParameterConfig(\n obj: any\n): obj is CommandParameterConfig {\n return isSetObject(obj) && \"kind\" in obj && isCommandParameterKind(obj.kind);\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameter} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.\n */\nexport function isCommandParameter(obj: any): obj is CommandParameter {\n return (\n isCommandParameterConfig(obj) &&\n \"name\" in obj &&\n isSetString(obj.name) &&\n \"title\" in obj &&\n isSetString(obj.title) &&\n \"description\" in obj &&\n isSetString(obj.description) &&\n \"alias\" in obj &&\n Array.isArray(obj.alias) &&\n \"env\" in obj &&\n (isSetString(obj.env) || obj.env === false) &&\n \"optional\" in obj &&\n isBoolean(obj.optional) &&\n \"variadic\" in obj &&\n isBoolean(obj.variadic)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandOption} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandOption} type, false otherwise.\n */\nexport function isCommandOption(obj: any): obj is CommandOption {\n return (\n isCommandParameterConfig(obj) && isCommandParameter(obj) && \"default\" in obj\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandArgument} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.\n */\nexport function isCommandArgument(obj: any): obj is CommandArgument {\n return isCommandParameterConfig(obj) && isCommandParameter(obj);\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,uBAAS,KAAA;AACrB,4DAAoB,IAAI;EAE1B,4CAAA;EACU,4CAAsB;EACjC,4CAAA;EACQ,CAAC,SAAS,IAAI;;AAEvB,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,SAAgB,yBAAkB,KAAA;AAC9B,4DAAmB,IAAI,IAAI,UAAU,OAAC,uBAAA,IAAA,KAAA;;AAE1C,yBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOA,SAAE,mBAAA,KAAA;AACE,QAAQ,yBAAyB,IAAG,IAChC,UAAC,2DACW,IAAI,KAAK,IACrB,WAAW,2DACnB,IAAA,MAAA,gFAEE,IAAA,YAAA,IACM,WAAW,OAClB,MAAA,QAAA,IAAA,MAAA,IACO,SAAS,4DACI,IAAI,IAAI,IAAI,IAAI,QAAQ,UAC3C,cAAA,sDACgB,IAAI,SAAS,IACvB,cAAC,sDACS,IAAI,SAAS;;AAE/B,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO3B,SAAgB,gBAAE,KAAA;AACd,QAAQ,yBAAyB,IAAI,IAAI,mBAAI,IAAA,IAAA,aAAA;;AAEjD,gBAAgB,SAAS;CAAC;CAAG;CAAA;CAAA;;;;;;;AAO7B,SAAgB,kBAAkB,KAAK;AACtC,QAAA,yBAAA,IAAA,IAAA,mBAAA,IAAA;;AAED,kBAAkB,SAAS;CAAC;CAAO;CAAqB;CAAU"}
@@ -0,0 +1,42 @@
1
+ import { CommandArgument, CommandOption, CommandParameter, CommandParameterConfig, CommandParameterKind } from "../types/command.cjs";
2
+
3
+ //#region src/plugin-utils/type-checks.d.ts
4
+
5
+ /**
6
+ * Type guard to check if a value is a valid {@link CommandParameterKind} type.
7
+ *
8
+ * @param obj - The value to check.
9
+ * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
10
+ */
11
+ declare function isCommandParameterKind(obj: any): obj is CommandParameterKind;
12
+ /**
13
+ * Type guard to check if a value is a valid {@link CommandParameterConfig} type.
14
+ *
15
+ * @param obj - The value to check.
16
+ * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
17
+ */
18
+ declare function isCommandParameterConfig(obj: any): obj is CommandParameterConfig;
19
+ /**
20
+ * Type guard to check if a value is a valid {@link CommandParameter} type.
21
+ *
22
+ * @param obj - The value to check.
23
+ * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
24
+ */
25
+ declare function isCommandParameter(obj: any): obj is CommandParameter;
26
+ /**
27
+ * Type guard to check if a value is a valid {@link CommandOption} type.
28
+ *
29
+ * @param obj - The value to check.
30
+ * @returns True if the value is a valid {@link CommandOption} type, false otherwise.
31
+ */
32
+ declare function isCommandOption(obj: any): obj is CommandOption;
33
+ /**
34
+ * Type guard to check if a value is a valid {@link CommandArgument} type.
35
+ *
36
+ * @param obj - The value to check.
37
+ * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
38
+ */
39
+ declare function isCommandArgument(obj: any): obj is CommandArgument;
40
+ //#endregion
41
+ export { isCommandArgument, isCommandOption, isCommandParameter, isCommandParameterConfig, isCommandParameterKind };
42
+ //# sourceMappingURL=type-checks.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-checks.d.cts","names":[],"sources":["../../src/plugin-utils/type-checks.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;AAiBA;AAYA;AA0BA;AAYgB,iBAnEA,sBAAA,CAmEoC,GAAA,EAAe,GAAA,CAAA,EAAA,GAAA,IAnEV,oBAmEU;;;;;;;iBAlDnD,wBAAA,mBAEN;;;;;;;iBAUM,kBAAA,mBAAqC;;;;;;;iBA0BrC,eAAA,mBAAkC;;;;;;;iBAYlC,iBAAA,mBAAoC"}
@@ -0,0 +1,42 @@
1
+ import { CommandArgument, CommandOption, CommandParameter, CommandParameterConfig, CommandParameterKind } from "../types/command.mjs";
2
+
3
+ //#region src/plugin-utils/type-checks.d.ts
4
+
5
+ /**
6
+ * Type guard to check if a value is a valid {@link CommandParameterKind} type.
7
+ *
8
+ * @param obj - The value to check.
9
+ * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
10
+ */
11
+ declare function isCommandParameterKind(obj: any): obj is CommandParameterKind;
12
+ /**
13
+ * Type guard to check if a value is a valid {@link CommandParameterConfig} type.
14
+ *
15
+ * @param obj - The value to check.
16
+ * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
17
+ */
18
+ declare function isCommandParameterConfig(obj: any): obj is CommandParameterConfig;
19
+ /**
20
+ * Type guard to check if a value is a valid {@link CommandParameter} type.
21
+ *
22
+ * @param obj - The value to check.
23
+ * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
24
+ */
25
+ declare function isCommandParameter(obj: any): obj is CommandParameter;
26
+ /**
27
+ * Type guard to check if a value is a valid {@link CommandOption} type.
28
+ *
29
+ * @param obj - The value to check.
30
+ * @returns True if the value is a valid {@link CommandOption} type, false otherwise.
31
+ */
32
+ declare function isCommandOption(obj: any): obj is CommandOption;
33
+ /**
34
+ * Type guard to check if a value is a valid {@link CommandArgument} type.
35
+ *
36
+ * @param obj - The value to check.
37
+ * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
38
+ */
39
+ declare function isCommandArgument(obj: any): obj is CommandArgument;
40
+ //#endregion
41
+ export { isCommandArgument, isCommandOption, isCommandParameter, isCommandParameterConfig, isCommandParameterKind };
42
+ //# sourceMappingURL=type-checks.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-checks.d.mts","names":[],"sources":["../../src/plugin-utils/type-checks.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;AAiBA;AAYA;AA0BA;AAYgB,iBAnEA,sBAAA,CAmEoC,GAAA,EAAA,GAAe,CAAA,EAAA,GAAA,IAnEV,oBAmEU;;;;;;;iBAlDnD,wBAAA,mBAEN;;;;;;;iBAUM,kBAAA,mBAAqC;;;;;;;iBA0BrC,eAAA,mBAAkC;;;;;;;iBAYlC,iBAAA,mBAAoC"}
@@ -0,0 +1,84 @@
1
+ import { CommandParameterKinds } from "../types/command.mjs";
2
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
3
+ import { isSetString } from "@stryke/type-checks/is-set-string";
4
+ import { isBoolean } from "@stryke/type-checks/is-boolean";
5
+
6
+ //#region src/plugin-utils/type-checks.ts
7
+ /**
8
+ * Type guard to check if a value is a valid {@link CommandParameterKind} type.
9
+ *
10
+ * @param obj - The value to check.
11
+ * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
12
+ */
13
+ function isCommandParameterKind(obj) {
14
+ return isSetString(obj) && [
15
+ CommandParameterKinds.string,
16
+ CommandParameterKinds.number,
17
+ CommandParameterKinds.boolean
18
+ ].includes(obj);
19
+ }
20
+ isCommandParameterKind.__type = [
21
+ "obj",
22
+ "isCommandParameterKind",
23
+ "P\"2!!/\""
24
+ ];
25
+ /**
26
+ * Type guard to check if a value is a valid {@link CommandParameterConfig} type.
27
+ *
28
+ * @param obj - The value to check.
29
+ * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
30
+ */
31
+ function isCommandParameterConfig(obj) {
32
+ return isSetObject(obj) && "kind" in obj && isCommandParameterKind(obj.kind);
33
+ }
34
+ isCommandParameterConfig.__type = [
35
+ "obj",
36
+ "isCommandParameterConfig",
37
+ "P\"2!!/\""
38
+ ];
39
+ /**
40
+ * Type guard to check if a value is a valid {@link CommandParameter} type.
41
+ *
42
+ * @param obj - The value to check.
43
+ * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
44
+ */
45
+ function isCommandParameter(obj) {
46
+ return isCommandParameterConfig(obj) && "name" in obj && isSetString(obj.name) && "title" in obj && isSetString(obj.title) && "description" in obj && isSetString(obj.description) && "alias" in obj && Array.isArray(obj.alias) && "env" in obj && (isSetString(obj.env) || obj.env === false) && "optional" in obj && isBoolean(obj.optional) && "variadic" in obj && isBoolean(obj.variadic);
47
+ }
48
+ isCommandParameter.__type = [
49
+ "obj",
50
+ "isCommandParameter",
51
+ "P\"2!!/\""
52
+ ];
53
+ /**
54
+ * Type guard to check if a value is a valid {@link CommandOption} type.
55
+ *
56
+ * @param obj - The value to check.
57
+ * @returns True if the value is a valid {@link CommandOption} type, false otherwise.
58
+ */
59
+ function isCommandOption(obj) {
60
+ return isCommandParameterConfig(obj) && isCommandParameter(obj) && "default" in obj;
61
+ }
62
+ isCommandOption.__type = [
63
+ "obj",
64
+ "isCommandOption",
65
+ "P\"2!!/\""
66
+ ];
67
+ /**
68
+ * Type guard to check if a value is a valid {@link CommandArgument} type.
69
+ *
70
+ * @param obj - The value to check.
71
+ * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
72
+ */
73
+ function isCommandArgument(obj) {
74
+ return isCommandParameterConfig(obj) && isCommandParameter(obj);
75
+ }
76
+ isCommandArgument.__type = [
77
+ "obj",
78
+ "isCommandArgument",
79
+ "P\"2!!/\""
80
+ ];
81
+
82
+ //#endregion
83
+ export { isCommandArgument, isCommandOption, isCommandParameter, isCommandParameterConfig, isCommandParameterKind };
84
+ //# sourceMappingURL=type-checks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-checks.mjs","names":[],"sources":["../../src/plugin-utils/type-checks.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 { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameter,\n CommandParameterConfig,\n CommandParameterKind\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterKind} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.\n */\nexport function isCommandParameterKind(obj: any): obj is CommandParameterKind {\n return (\n isSetString(obj) &&\n [\n CommandParameterKinds.string,\n CommandParameterKinds.number,\n CommandParameterKinds.boolean\n ].includes(obj as CommandParameterKind)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterConfig} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.\n */\nexport function isCommandParameterConfig(\n obj: any\n): obj is CommandParameterConfig {\n return isSetObject(obj) && \"kind\" in obj && isCommandParameterKind(obj.kind);\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameter} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.\n */\nexport function isCommandParameter(obj: any): obj is CommandParameter {\n return (\n isCommandParameterConfig(obj) &&\n \"name\" in obj &&\n isSetString(obj.name) &&\n \"title\" in obj &&\n isSetString(obj.title) &&\n \"description\" in obj &&\n isSetString(obj.description) &&\n \"alias\" in obj &&\n Array.isArray(obj.alias) &&\n \"env\" in obj &&\n (isSetString(obj.env) || obj.env === false) &&\n \"optional\" in obj &&\n isBoolean(obj.optional) &&\n \"variadic\" in obj &&\n isBoolean(obj.variadic)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandOption} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandOption} type, false otherwise.\n */\nexport function isCommandOption(obj: any): obj is CommandOption {\n return (\n isCommandParameterConfig(obj) && isCommandParameter(obj) && \"default\" in obj\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandArgument} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.\n */\nexport function isCommandArgument(obj: any): obj is CommandArgument {\n return isCommandParameterConfig(obj) && isCommandParameter(obj);\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAgB,uBAAS,KAAA;AACrB,QAAQ,YAAY,IAAI;EAE1B,sBAAA;EACU,sBAAsB;EACjC,sBAAA;EACQ,CAAC,SAAS,IAAI;;AAEvB,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,SAAgB,yBAAkB,KAAA;AAC9B,QAAO,YAAY,IAAI,IAAI,UAAU,OAAC,uBAAA,IAAA,KAAA;;AAE1C,yBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOA,SAAE,mBAAA,KAAA;AACE,QAAQ,yBAAyB,IAAG,IAChC,UAAC,OACD,YAAY,IAAI,KAAK,IACrB,WAAW,OACnB,YAAA,IAAA,MAAA,4BAEE,YAAA,IAAA,YAAA,IACM,WAAW,OAClB,MAAA,QAAA,IAAA,MAAA,IACO,SAAS,QACR,YAAY,IAAI,IAAI,IAAI,IAAI,QAAQ,UAC3C,cAAA,OACM,UAAU,IAAI,SAAS,IACvB,cAAC,OACD,UAAU,IAAI,SAAS;;AAE/B,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO3B,SAAgB,gBAAE,KAAA;AACd,QAAQ,yBAAyB,IAAI,IAAI,mBAAI,IAAA,IAAA,aAAA;;AAEjD,gBAAgB,SAAS;CAAC;CAAG;CAAA;CAAA;;;;;;;AAO7B,SAAgB,kBAAkB,KAAK;AACtC,QAAA,yBAAA,IAAA,IAAA,mBAAA,IAAA;;AAED,kBAAkB,SAAS;CAAC;CAAO;CAAqB;CAAU"}
package/dist/plugin.cjs CHANGED
@@ -1,16 +1,17 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
- const require_plugin_utils_context_helpers = require('./plugin-utils/context-helpers.cjs');
3
+ const require_context_helpers = require('./plugin-utils/context-helpers.cjs');
4
4
  const require_components_docs = require('./components/docs.cjs');
5
5
  const require_components_utils_builtin = require('./components/utils-builtin.cjs');
6
- const require_plugin_utils_get_command_tree = require('./plugin-utils/get-command-tree.cjs');
7
- const require_plugin_utils_traverse_command_tree = require('./plugin-utils/traverse-command-tree.cjs');
6
+ const require_get_command_tree = require('./plugin-utils/get-command-tree.cjs');
7
+ const require_traverse_command_tree = require('./plugin-utils/traverse-command-tree.cjs');
8
8
  const require_automd = require('./helpers/automd.cjs');
9
+ const require_paths = require('./helpers/paths.cjs');
9
10
  const require_persistence = require('./helpers/persistence.cjs');
10
- const require_utilities = require('./helpers/utilities.cjs');
11
- const require_resolve_command = require('./helpers/resolve-command.cjs');
12
11
  const require_update_package_json = require('./helpers/update-package-json.cjs');
12
+ const require_utilities = require('./helpers/utilities.cjs');
13
13
  const require_validations = require('./helpers/validations.cjs');
14
+ const require_resolve = require('./resolver/resolve.cjs');
14
15
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
15
16
  let __alloy_js_core_components = require("@alloy-js/core/components");
16
17
  let __powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
@@ -53,14 +54,12 @@ const plugin = (options = {}) => {
53
54
  async config() {
54
55
  this.debug("Resolving the Shell Shock configuration.");
55
56
  await require_update_package_json.updatePackageJsonBinary(this);
56
- const result = (0, defu.defu)({ output: { buildPath: (0, __stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
57
- name: require_plugin_utils_context_helpers.getAppName(this),
58
- title: require_plugin_utils_context_helpers.getAppTitle(this),
59
- description: require_plugin_utils_context_helpers.getAppDescription(this),
57
+ return (0, defu.defu)({ output: { buildPath: (0, __stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
58
+ name: require_context_helpers.getAppName(this),
59
+ title: require_context_helpers.getAppTitle(this),
60
+ description: require_context_helpers.getAppDescription(this),
60
61
  platform: "node",
61
62
  projectType: "application",
62
- envPrefix: (0, __stryke_string_format_constant_case.constantCase)(require_plugin_utils_context_helpers.getAppName(this)),
63
- env: { prefix: [] },
64
63
  isCaseSensitive: false,
65
64
  output: {
66
65
  format: "esm",
@@ -74,14 +73,14 @@ const plugin = (options = {}) => {
74
73
  unbundle: false
75
74
  }
76
75
  });
77
- if (!result.env.prefix || !Array.isArray(result.env.prefix)) result.env.prefix = (0, __stryke_convert_to_array.toArray)(result.env.prefix);
78
- if (!result.env.prefix.includes(result.envPrefix)) result.env.prefix.push(result.envPrefix);
79
- return result;
80
76
  },
81
77
  configResolved: {
82
78
  order: "pre",
83
79
  async handler() {
84
80
  this.debug("Shell Shock configuration has been resolved.");
81
+ this.config.appSpecificEnvPrefix = (0, __stryke_type_checks_is_set_string.isSetString)(this.config.autoAssignEnv) ? this.config.autoAssignEnv : (0, __stryke_string_format_constant_case.constantCase)(require_context_helpers.getAppName(this));
82
+ if (!this.config.env.prefix || !Array.isArray(this.config.env.prefix)) this.config.env.prefix = (0, __stryke_convert_to_array.toArray)(this.config.env.prefix);
83
+ if (!this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)) this.config.env.prefix.push(this.config.appSpecificEnvPrefix);
85
84
  this.config.bin = ((0, __stryke_type_checks_is_set_string.isSetString)(this.packageJson.bin) ? { [(0, __stryke_string_format_kebab_case.kebabCase)(this.config.name)]: this.packageJson.bin } : this.packageJson.bin) ?? { [(0, __stryke_string_format_kebab_case.kebabCase)(this.config.name)]: require_update_package_json.formatBinaryPath(this.config.output.format) };
86
85
  this.inputs ??= [];
87
86
  this.options = Object.values(require_utilities.getDefaultOptions(this, {
@@ -105,18 +104,18 @@ const plugin = (options = {}) => {
105
104
  name: "shell-shock:inputs",
106
105
  async configResolved() {
107
106
  this.debug("Finding command entry point files.");
108
- this.commandsPath = require_resolve_command.findCommandsRoot(this);
107
+ this.commandsPath = require_paths.findCommandsRoot(this);
109
108
  const inputs = await (0, powerlines_utils.resolveInputs)(this, this.config.input);
110
109
  this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
111
110
  this.inputs = inputs.reduce((ret, entry) => {
112
111
  if (entry.file !== this.commandsPath && !(0, __stryke_path_is_parent_path.isParentPath)(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
113
- const id = require_resolve_command.resolveCommandId(this, entry.file);
112
+ const id = require_paths.resolveCommandId(this, entry.file);
114
113
  if (!ret.some((existing) => existing.id === id)) {
115
- const name = require_resolve_command.resolveCommandName(entry.file);
116
- let segments = require_resolve_command.resolveCommandPath(this, entry.file).split("/").filter(Boolean);
114
+ const name = require_paths.resolveCommandName(entry.file);
115
+ let segments = require_paths.resolveCommandPath(this, entry.file).split("/").filter(Boolean);
117
116
  segments = segments.map((segment, index) => {
118
117
  const found = segments.findIndex((existing) => existing === segment);
119
- if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment$1) && require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
118
+ if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => require_context_helpers.isDynamicPathSegment(segment$1) && require_context_helpers.getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
120
119
  return segment;
121
120
  });
122
121
  ret.push({
@@ -162,13 +161,13 @@ const plugin = (options = {}) => {
162
161
  if (depth++ > MAX_DEPTH) throw new Error(`Unable to process virtual commands for ${command.name} \n\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`);
163
162
  if (!ret.some((existing) => (0, __stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath)) {
164
163
  const file = (0, __stryke_path_join_paths.joinPaths)(parentPath, "command.ts");
165
- const id = require_resolve_command.resolveCommandId(this, file);
164
+ const id = require_paths.resolveCommandId(this, file);
166
165
  if (!ret.some((existing) => existing.id === id)) {
167
- const name = require_resolve_command.resolveCommandName(file);
168
- let segments = require_resolve_command.resolveCommandPath(this, file).split("/").filter(Boolean);
166
+ const name = require_paths.resolveCommandName(file);
167
+ let segments = require_paths.resolveCommandPath(this, file).split("/").filter(Boolean);
169
168
  segments = segments.map((segment, index) => {
170
169
  const found = segments.findIndex((existing) => existing === segment);
171
- if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => require_plugin_utils_context_helpers.isDynamicPathSegment(segment$1) && require_plugin_utils_context_helpers.getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
170
+ if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => require_context_helpers.isDynamicPathSegment(segment$1) && require_context_helpers.getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
172
171
  return segment;
173
172
  });
174
173
  ret.push({
@@ -192,17 +191,20 @@ const plugin = (options = {}) => {
192
191
  }
193
192
  },
194
193
  {
195
- name: "shell-shock:reflect-commands",
194
+ name: "shell-shock:resolve-commands",
196
195
  prepare: {
197
196
  order: "post",
198
197
  async handler() {
199
198
  this.debug("Initializing the CLI application's command tree.");
200
199
  this.commands = {};
201
200
  if (this.config.command !== "prepare" && this.config.skipCache !== true && this.persistedMeta?.checksum === this.meta.checksum && this.fs.existsSync(require_persistence.getCommandsPersistencePath(this))) {
202
- this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
201
+ this.debug(`Skipping command resolution as the meta checksum has not changed.`);
203
202
  await require_persistence.readCommandsPersistence(this);
204
203
  } else {
205
- for (const input of this.inputs.filter((input$1) => input$1.segments.filter((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment) && !require_plugin_utils_context_helpers.isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await require_resolve_command.reflectCommandTree(this, input);
204
+ for (const input of this.inputs.filter((input$1) => input$1.segments.filter((segment) => !require_context_helpers.isDynamicPathSegment(segment) && !require_context_helpers.isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await require_resolve.resolve({
205
+ context: this,
206
+ command: input
207
+ });
206
208
  this.debug("Post-processing commands to ensure proper reflection.");
207
209
  this.options = this.options.map((option) => ({
208
210
  ...option,
@@ -210,7 +212,7 @@ const plugin = (options = {}) => {
210
212
  alias: option.alias ?? [],
211
213
  optional: option.optional ?? false
212
214
  }));
213
- await require_plugin_utils_traverse_command_tree.traverseCommands(this, (command) => {
215
+ await require_traverse_command_tree.traverseCommands(this, (command) => {
214
216
  command.options = Object.fromEntries(Object.entries(command.options).map(([name, option]) => [(0, __stryke_string_format_camel_case.camelCase)(name), {
215
217
  ...option,
216
218
  name: (0, __stryke_string_format_camel_case.camelCase)(name),
@@ -222,7 +224,7 @@ const plugin = (options = {}) => {
222
224
  }
223
225
  this.debug("Validating the CLI applications command tree.");
224
226
  let isValid = true;
225
- await require_plugin_utils_traverse_command_tree.traverseCommands(this, (command) => {
227
+ await require_traverse_command_tree.traverseCommands(this, (command) => {
226
228
  const failures = require_validations.validateCommand(command);
227
229
  if (failures.length > 0) {
228
230
  this.error(`Found ${failures.length} issue${failures.length > 1 ? "s" : ""} with the ${command.title} command: \n${failures.map((failure) => ` - ${failure.code}: ${failure.details}`).join("\n")}\n`);
@@ -268,7 +270,7 @@ const plugin = (options = {}) => {
268
270
  },
269
271
  async docs() {
270
272
  this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
271
- const commands$1 = this.inputs.map((input) => require_plugin_utils_get_command_tree.getCommandTree(this, input.segments)).filter(Boolean);
273
+ const commands$1 = this.inputs.map((input) => require_get_command_tree.getCommandTree(this, input.segments)).filter(Boolean);
272
274
  return (0, __powerlines_plugin_alloy_render.render)(this, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core_components.For, {
273
275
  get each() {
274
276
  return Object.values(commands$1);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isObject","isSetObject","isSetString","defu","tsdown","resolveInputs","CommandDocsFile","UtilsBuiltin","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","root","title","description","platform","projectType","envPrefix","env","prefix","isCaseSensitive","format","dts","input","Array","isArray","length","Object","keys","undefined","resolve","external","nodeProtocol","unbundle","includes","push","configResolved","order","handler","bin","packageJson","inputs","values","id","path","segments","alias","isVirtual","types","validate","commandsPath","reduce","ret","entry","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","command","prepare","_$createComponent","warn","cmd","depth","parentPath","sort","a","b","skipCache","persistedMeta","checksum","meta","fs","existsSync","option","optional","fromEntries","entries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"]\n },\n tsdown: {\n dts: true,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n if (!result.env.prefix || !Array.isArray(result.env.prefix)) {\n result.env.prefix = toArray(result.env.prefix);\n }\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.outputOptions ??= {} as any;\n if (isObject(this.config.tsdown.outputOptions)) {\n (\n this.config.tsdown.outputOptions as NonNullable<OutputOptions>\n ).banner = (chunk: RenderedChunk) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${\n chunk.fileName\n }`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n }\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAMgD,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;iCACG;4CACC;2CACD;EACR;GACEC,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,oDAAwB,KAAK;IAEnC,MAAMkB,wBACJ,EACEC,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,MAAM,OAAM,EAC/C,EACD,EACDP,SACA;KACEC,MAAMV,gDAAW,KAAK;KACtBiB,OAAOhB,iDAAY,KAAK;KACxBiB,aAAanB,uDAAkB,KAAK;KACpCoB,UAAU;KACVC,aAAa;KACbC,kEAAwBrB,gDAAW,KAAK,CAAC;KACzCsB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,iBAAiB;KACjBV,QAA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O;AACX,SAAKrG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBoB,KAAItC,UAAStB,qDAAe,MAAMsB,MAAMsB,SAAS,CAAC,CAClDc,OAAOC,QAAyB;AAEnC,wDACE,uDACCzG,gCAAG;KAAA,IAAC2J,OAAI;AAAA,aAAEnF,OAAOe,OAAO7D,WAAS;;KAAEkI,gBAAc;KAAAC,WAC/CC,2DACE7J,iCAAI;MAAA,IAAC8J,OAAI;AAAA,cAAE,CAACD,MAAMlE;;MAAS,IAAAiE,WAAA;AAAA,+DACzBrI,yCAAe,EAACyF,SAAS6C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe7G"}
1
+ {"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isObject","isSetObject","isSetString","defu","tsdown","resolveInputs","CommandDocsFile","UtilsBuiltin","commands","findCommandsRoot","resolveCommandId","resolveCommandName","resolveCommandPath","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","resolve","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","root","title","description","platform","projectType","isCaseSensitive","format","dts","input","Array","isArray","length","Object","keys","undefined","external","nodeProtocol","unbundle","configResolved","order","handler","appSpecificEnvPrefix","autoAssignEnv","env","prefix","includes","push","bin","packageJson","inputs","values","id","path","segments","alias","isVirtual","types","validate","commandsPath","reduce","ret","entry","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","command","prepare","_$createComponent","warn","cmd","depth","parentPath","sort","a","b","skipCache","persistedMeta","checksum","meta","fs","existsSync","context","option","optional","fromEntries","entries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"]\n },\n tsdown: {\n dts: true,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.outputOptions ??= {} as any;\n if (isObject(this.config.tsdown.outputOptions)) {\n (\n this.config.tsdown.outputOptions as NonNullable<OutputOptions>\n ).banner = (chunk: RenderedChunk) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${\n chunk.fileName\n }`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n }\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAMgD,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;iCACG;4CACC;2CACD;EACR;GACEC,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMlB,oDAAwB,KAAK;AA0CnC,0BAvCE,EACEoB,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,MAAM,OAAM,EAC/C,EACD,EACDP,SACA;KACEC,MAAMX,mCAAW,KAAK;KACtBkB,OAAOjB,oCAAY,KAAK;KACxBkB,aAAapB,0CAAkB,KAAK;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ACD;GACEtC,MAAM;GACNwB,iBAAiB;AACf,SAAKvB,OAAOjD,WAAW,EAAE;AACzB,SAAKiD,OAAOjD,OAAOuJ,aAAa;KAC9B,GAAI,KAAKtG,OAAOjD,OAAOuJ,cAAc,EAAE;KACvChI,UAAUA,wBAAS,KAAI;KACxB;;GAEH,MAAMiI,OAAO;AACX,SAAKtG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBoB,KAAIzC,UAASpB,wCAAe,MAAMoB,MAAMyB,SAAS,CAAC,CAClDc,OAAOC,QAAyB;AAEnC,wDACE,uDACCzG,gCAAG;KAAA,IAAC4J,OAAI;AAAA,aAAEvF,OAAOkB,OAAO7D,WAAS;;KAAEmI,gBAAc;KAAAC,WAC/CC,2DACE9J,iCAAI;MAAA,IAAC+J,OAAI;AAAA,cAAE,CAACD,MAAMnE;;MAAS,IAAAkE,WAAA;AAAA,+DACzBtI,yCAAe,EAACyF,SAAS8C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe9G"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAkFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAwfjC,MAxfiC,CAwf1B,QAxf0B,CAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAkFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAkgBjC,MAlgBiC,CAkgB1B,QAlgB0B,CAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAkFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAwfjC,MAxfiC,CAwf1B,QAxf0B,CAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAkFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAkgBjC,MAlgBiC,CAkgB1B,QAlgB0B,CAAA,EAAA"}