@shell-shock/core 0.10.0 → 0.11.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 (131) 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/helpers.d.cts +6 -6
  7. package/dist/components/helpers.d.mts +6 -6
  8. package/dist/components/helpers.d.mts.map +1 -1
  9. package/dist/components/options-parser-logic.cjs +31 -31
  10. package/dist/components/options-parser-logic.cjs.map +1 -1
  11. package/dist/components/options-parser-logic.d.cts +9 -9
  12. package/dist/components/options-parser-logic.d.cts.map +1 -1
  13. package/dist/components/options-parser-logic.d.mts +9 -9
  14. package/dist/components/options-parser-logic.d.mts.map +1 -1
  15. package/dist/components/options-parser-logic.mjs +26 -26
  16. package/dist/components/options-parser-logic.mjs.map +1 -1
  17. package/dist/components/usage.cjs +5 -5
  18. package/dist/components/usage.cjs.map +1 -1
  19. package/dist/components/usage.d.cts +2 -2
  20. package/dist/components/usage.d.cts.map +1 -1
  21. package/dist/components/usage.d.mts +2 -2
  22. package/dist/components/usage.mjs +4 -4
  23. package/dist/components/usage.mjs.map +1 -1
  24. package/dist/components/utils-builtin.cjs +2 -2
  25. package/dist/components/utils-builtin.cjs.map +1 -1
  26. package/dist/components/utils-builtin.mjs +5 -5
  27. package/dist/components/utils-builtin.mjs.map +1 -1
  28. package/dist/contexts/options.cjs +2 -2
  29. package/dist/contexts/options.cjs.map +1 -1
  30. package/dist/contexts/options.d.cts +1 -1
  31. package/dist/contexts/options.d.cts.map +1 -1
  32. package/dist/contexts/options.d.mts +1 -1
  33. package/dist/contexts/options.d.mts.map +1 -1
  34. package/dist/contexts/options.mjs +4 -4
  35. package/dist/contexts/options.mjs.map +1 -1
  36. package/dist/helpers/automd.cjs +2 -2
  37. package/dist/helpers/automd.cjs.map +1 -1
  38. package/dist/helpers/automd.mjs.map +1 -1
  39. package/dist/helpers/paths.cjs +125 -0
  40. package/dist/helpers/paths.cjs.map +1 -0
  41. package/dist/helpers/paths.mjs +121 -0
  42. package/dist/helpers/paths.mjs.map +1 -0
  43. package/dist/helpers/persistence.cjs +68 -116
  44. package/dist/helpers/persistence.cjs.map +1 -1
  45. package/dist/helpers/persistence.mjs +68 -116
  46. package/dist/helpers/persistence.mjs.map +1 -1
  47. package/dist/helpers/update-package-json.cjs +4 -4
  48. package/dist/helpers/update-package-json.cjs.map +1 -1
  49. package/dist/helpers/utilities.cjs +1 -1
  50. package/dist/helpers/utilities.mjs +1 -1
  51. package/dist/helpers/validations.cjs +2 -3
  52. package/dist/helpers/validations.cjs.map +1 -1
  53. package/dist/helpers/validations.mjs +2 -2
  54. package/dist/helpers/validations.mjs.map +1 -1
  55. package/dist/index.cjs +14 -11
  56. package/dist/index.d.cts +2 -2
  57. package/dist/index.d.mts +2 -2
  58. package/dist/index.mjs +3 -3
  59. package/dist/plugin-utils/deepkit.cjs +72 -0
  60. package/dist/plugin-utils/deepkit.cjs.map +1 -0
  61. package/dist/plugin-utils/deepkit.d.cts +24 -0
  62. package/dist/plugin-utils/deepkit.d.cts.map +1 -0
  63. package/dist/plugin-utils/deepkit.d.mts +24 -0
  64. package/dist/plugin-utils/deepkit.d.mts.map +1 -0
  65. package/dist/plugin-utils/deepkit.mjs +70 -0
  66. package/dist/plugin-utils/deepkit.mjs.map +1 -0
  67. package/dist/plugin-utils/get-command-tree.cjs +2 -2
  68. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  69. package/dist/plugin-utils/index.cjs +27 -18
  70. package/dist/plugin-utils/index.d.cts +3 -1
  71. package/dist/plugin-utils/index.d.mts +3 -1
  72. package/dist/plugin-utils/index.mjs +3 -1
  73. package/dist/plugin-utils/reflect.cjs +4 -5
  74. package/dist/plugin-utils/reflect.cjs.map +1 -1
  75. package/dist/plugin-utils/reflect.mjs +4 -4
  76. package/dist/plugin-utils/reflect.mjs.map +1 -1
  77. package/dist/plugin-utils/type-checks.cjs +89 -0
  78. package/dist/plugin-utils/type-checks.cjs.map +1 -0
  79. package/dist/plugin-utils/type-checks.d.cts +42 -0
  80. package/dist/plugin-utils/type-checks.d.cts.map +1 -0
  81. package/dist/plugin-utils/type-checks.d.mts +42 -0
  82. package/dist/plugin-utils/type-checks.d.mts.map +1 -0
  83. package/dist/plugin-utils/type-checks.mjs +84 -0
  84. package/dist/plugin-utils/type-checks.mjs.map +1 -0
  85. package/dist/plugin.cjs +28 -24
  86. package/dist/plugin.cjs.map +1 -1
  87. package/dist/plugin.d.cts.map +1 -1
  88. package/dist/plugin.d.mts.map +1 -1
  89. package/dist/plugin.mjs +12 -8
  90. package/dist/plugin.mjs.map +1 -1
  91. package/dist/resolver/deepkit.cjs +129 -0
  92. package/dist/resolver/deepkit.cjs.map +1 -0
  93. package/dist/resolver/deepkit.mjs +128 -0
  94. package/dist/resolver/deepkit.mjs.map +1 -0
  95. package/dist/resolver/helpers.cjs +173 -0
  96. package/dist/resolver/helpers.cjs.map +1 -0
  97. package/dist/resolver/helpers.mjs +168 -0
  98. package/dist/resolver/helpers.mjs.map +1 -0
  99. package/dist/resolver/module.cjs +144 -0
  100. package/dist/resolver/module.cjs.map +1 -0
  101. package/dist/resolver/module.mjs +143 -0
  102. package/dist/resolver/module.mjs.map +1 -0
  103. package/dist/resolver/resolve.cjs +209 -0
  104. package/dist/resolver/resolve.cjs.map +1 -0
  105. package/dist/resolver/resolve.mjs +208 -0
  106. package/dist/resolver/resolve.mjs.map +1 -0
  107. package/dist/types/command.cjs +127 -104
  108. package/dist/types/command.cjs.map +1 -1
  109. package/dist/types/command.d.cts +39 -78
  110. package/dist/types/command.d.cts.map +1 -1
  111. package/dist/types/command.d.mts +39 -78
  112. package/dist/types/command.d.mts.map +1 -1
  113. package/dist/types/command.mjs +115 -95
  114. package/dist/types/command.mjs.map +1 -1
  115. package/dist/types/context.cjs +1 -1
  116. package/dist/types/context.cjs.map +1 -1
  117. package/dist/types/context.d.cts +2 -2
  118. package/dist/types/context.d.cts.map +1 -1
  119. package/dist/types/context.d.mts +2 -2
  120. package/dist/types/context.d.mts.map +1 -1
  121. package/dist/types/context.mjs +1 -1
  122. package/dist/types/context.mjs.map +1 -1
  123. package/dist/types/index.cjs +13 -10
  124. package/dist/types/index.d.cts +2 -2
  125. package/dist/types/index.d.mts +2 -2
  126. package/dist/types/index.mjs +2 -2
  127. package/package.json +24 -75
  128. package/dist/helpers/resolve-command.cjs +0 -430
  129. package/dist/helpers/resolve-command.cjs.map +0 -1
  130. package/dist/helpers/resolve-command.mjs +0 -425
  131. package/dist/helpers/resolve-command.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/plugin-utils/reflect.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 { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport type { CommandOption } from \"../types/command\";\n\n/**\n * Sort command options alphabetically by name, placing boolean options with negatives appropriately.\n *\n * @param options - The array of command options to sort.\n * @returns A new array of sorted command options.\n */\nexport function sortOptions(options: CommandOption[]): CommandOption[] {\n if (!options || options.length === 0) {\n return [];\n }\n\n return options\n .filter(arg => arg.kind !== ReflectionKind.boolean || !arg.isNegativeOf)\n .sort((a, b) => a.name.localeCompare(b.name))\n .reduce((ret, arg) => {\n ret.push(arg);\n\n if (arg.kind === ReflectionKind.boolean) {\n // Add the negative argument if it exists\n const negativeArg = options.find(\n a => a.kind === ReflectionKind.boolean && a.isNegativeOf === arg.name\n );\n if (negativeArg) {\n ret.push(negativeArg);\n }\n }\n\n return ret;\n }, [] as CommandOption[]);\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AA0BX,SAAgB,YAAY,SAAS;AACjC,KAAI,CAAC,WAAI,QAAA,WAAA,EACX,QAAA,EAAA;AAEE,QAAO,QACF,OAAO,cAAa,QAAO,IAAI,SAAS,eAAe,WAAW,CAAA,IAAA,cAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAClE,KAAK,cAAc,GAAG,MAAM,EAAE,KAAK,cAAI,EAAA,KAAA,EAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CACvC,OAAO,cAAU,KAAA,QAAA;AAClB,MAAI,KAAK,IAAE;;GAGP,MAAM,cAAc,QAAQ,KAAK,cAAG,MAAA,EAAA,SAAA,eAAA,WAAA,EAAA,iBAAA,IAAA,MAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA;AACpC,OAAI,YACA,KAAI,KAAK,YAAY;;AAG7B,SAAO;IACR;EAAC;EAAA;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/plugin-utils/reflect.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 { CommandOption } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Sort command options alphabetically by name, placing boolean options with negatives appropriately.\n *\n * @param options - The array of command options to sort.\n * @returns A new array of sorted command options.\n */\nexport function sortOptions(options: CommandOption[]): CommandOption[] {\n if (!options || options.length === 0) {\n return [];\n }\n\n return options\n .filter(\n arg => arg.kind !== CommandParameterKinds.boolean || !arg.isNegativeOf\n )\n .sort((a, b) => a.name.localeCompare(b.name))\n .reduce((ret, arg) => {\n ret.push(arg);\n\n if (arg.kind === CommandParameterKinds.boolean) {\n // Add the negative argument if it exists\n const negativeArg = options.find(\n a =>\n a.kind === CommandParameterKinds.boolean &&\n a.isNegativeOf === arg.name\n );\n if (negativeArg) {\n ret.push(negativeArg);\n }\n }\n\n return ret;\n }, [] as CommandOption[]);\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AASX,SAAgB,YAAY,SAAS;AACjC,KAAI,CAAC,WAAW,QAAQ,WAAW;gBAI9B,OAAO,cAAa,QAAO,IAAI,SAAS,sBAAqB,WAAA,CAAA,IAAA,cAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;;;;;KAE7D,OAAO,cAAc,KAAK,QAAQ;AACnC,MAAI,KAAK,IAAI;;GAGT,MAAM,cAAc,QAAQ,KAAK,cAAa,MAAK,EAAE,SAAS,sBAAsB,WAC/F,EAAA,iBAAA,IAAA,MAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA;AACW,OAAI,YACA,KAAI,KAAK,YAAY;;AAG7B,SAAO;IACR;EAAC;EAAK;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA"}
@@ -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,EAAe,GAAA,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");
@@ -54,12 +55,12 @@ const plugin = (options = {}) => {
54
55
  this.debug("Resolving the Shell Shock configuration.");
55
56
  await require_update_package_json.updatePackageJsonBinary(this);
56
57
  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),
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
+ envPrefix: (0, __stryke_string_format_constant_case.constantCase)(require_context_helpers.getAppName(this)),
63
64
  env: { prefix: [] },
64
65
  isCaseSensitive: false,
65
66
  output: {
@@ -105,18 +106,18 @@ const plugin = (options = {}) => {
105
106
  name: "shell-shock:inputs",
106
107
  async configResolved() {
107
108
  this.debug("Finding command entry point files.");
108
- this.commandsPath = require_resolve_command.findCommandsRoot(this);
109
+ this.commandsPath = require_paths.findCommandsRoot(this);
109
110
  const inputs = await (0, powerlines_utils.resolveInputs)(this, this.config.input);
110
111
  this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
111
112
  this.inputs = inputs.reduce((ret, entry) => {
112
113
  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);
114
+ const id = require_paths.resolveCommandId(this, entry.file);
114
115
  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);
116
+ const name = require_paths.resolveCommandName(entry.file);
117
+ let segments = require_paths.resolveCommandPath(this, entry.file).split("/").filter(Boolean);
117
118
  segments = segments.map((segment, index) => {
118
119
  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}`;
120
+ 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
121
  return segment;
121
122
  });
122
123
  ret.push({
@@ -162,13 +163,13 @@ const plugin = (options = {}) => {
162
163
  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
164
  if (!ret.some((existing) => (0, __stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath)) {
164
165
  const file = (0, __stryke_path_join_paths.joinPaths)(parentPath, "command.ts");
165
- const id = require_resolve_command.resolveCommandId(this, file);
166
+ const id = require_paths.resolveCommandId(this, file);
166
167
  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);
168
+ const name = require_paths.resolveCommandName(file);
169
+ let segments = require_paths.resolveCommandPath(this, file).split("/").filter(Boolean);
169
170
  segments = segments.map((segment, index) => {
170
171
  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}`;
172
+ 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
173
  return segment;
173
174
  });
174
175
  ret.push({
@@ -192,17 +193,20 @@ const plugin = (options = {}) => {
192
193
  }
193
194
  },
194
195
  {
195
- name: "shell-shock:reflect-commands",
196
+ name: "shell-shock:resolve-commands",
196
197
  prepare: {
197
198
  order: "post",
198
199
  async handler() {
199
200
  this.debug("Initializing the CLI application's command tree.");
200
201
  this.commands = {};
201
202
  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.`);
203
+ this.debug(`Skipping command resolution as the meta checksum has not changed.`);
203
204
  await require_persistence.readCommandsPersistence(this);
204
205
  } 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);
206
+ 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({
207
+ context: this,
208
+ command: input
209
+ });
206
210
  this.debug("Post-processing commands to ensure proper reflection.");
207
211
  this.options = this.options.map((option) => ({
208
212
  ...option,
@@ -210,7 +214,7 @@ const plugin = (options = {}) => {
210
214
  alias: option.alias ?? [],
211
215
  optional: option.optional ?? false
212
216
  }));
213
- await require_plugin_utils_traverse_command_tree.traverseCommands(this, (command) => {
217
+ await require_traverse_command_tree.traverseCommands(this, (command) => {
214
218
  command.options = Object.fromEntries(Object.entries(command.options).map(([name, option]) => [(0, __stryke_string_format_camel_case.camelCase)(name), {
215
219
  ...option,
216
220
  name: (0, __stryke_string_format_camel_case.camelCase)(name),
@@ -222,7 +226,7 @@ const plugin = (options = {}) => {
222
226
  }
223
227
  this.debug("Validating the CLI applications command tree.");
224
228
  let isValid = true;
225
- await require_plugin_utils_traverse_command_tree.traverseCommands(this, (command) => {
229
+ await require_traverse_command_tree.traverseCommands(this, (command) => {
226
230
  const failures = require_validations.validateCommand(command);
227
231
  if (failures.length > 0) {
228
232
  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 +272,7 @@ const plugin = (options = {}) => {
268
272
  },
269
273
  async docs() {
270
274
  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);
275
+ const commands$1 = this.inputs.map((input) => require_get_command_tree.getCommandTree(this, input.segments)).filter(Boolean);
272
276
  return (0, __powerlines_plugin_alloy_render.render)(this, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core_components.For, {
273
277
  get each() {
274
278
  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,QAAQ;MACNW,QAAQ;MACRC,KAAK;MACN;KACDC,OACE,C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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","envPrefix","env","prefix","isCaseSensitive","format","dts","input","Array","isArray","length","Object","keys","undefined","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","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 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: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;IAEnC,MAAMmB,wBACJ,EACEC,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,MAAM,OAAM,EAC/C,EACD,EACDP,SACA;KACEC,MAAMX,mCAAW,KAAK;KACtBkB,OAAOjB,oCAAY,KAAK;KACxBkB,aAAapB,0CAAkB,KAAK;KACpCqB,UAAU;KACVC,aAAa;KACbC,kEAAwBtB,mCAAW,KAAK,CAAC;KACzCuB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,iBAAiB;KACjBV,QAAQ;MACNW,QAAQ;MACRC,KA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AO;AACX,SAAKrG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK2D,OACnBoB,KAAIrC,UAASvB,wCAAe,MAAMuB,MAAMqB,SAAS,CAAC,CAClDc,OAAOC,QAAyB;AAEnC,wDACE,uDACCxG,gCAAG;KAAA,IAAC2J,OAAI;AAAA,aAAEnF,OAAOc,OAAO5D,WAAS;;KAAEkI,gBAAc;KAAAC,WAC/CC,2DACE7J,iCAAI;MAAA,IAAC8J,OAAI;AAAA,cAAE,CAACD,MAAMnE;;MAAS,IAAAkE,WAAA;AAAA,+DACzBrI,yCAAe,EAACwF,SAAS8C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe7G"}
@@ -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,GA2fjC,MA3fiC,CA2f1B,QA3f0B,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,GA2fjC,MA3fiC,CA2f1B,QA3f0B,CAAA,EAAA"}