@powerlines/plugin-nodejs 0.1.0 → 0.1.1

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 (199) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/components/env.cjs +188 -2
  3. package/dist/components/env.d.cts +9 -2
  4. package/dist/components/env.d.mts +9 -2
  5. package/dist/components/env.mjs +185 -1
  6. package/dist/components/index.cjs +2 -3
  7. package/dist/components/index.d.cts +1 -3
  8. package/dist/components/index.d.mts +1 -3
  9. package/dist/components/index.mjs +1 -2
  10. package/dist/deepkit/schemas/reflection.cjs +3940 -0
  11. package/dist/{plugin-D7kBf19k.d.cts → deepkit/schemas/reflection.d.cts} +1 -1078
  12. package/dist/{plugin-JL1BtFku.d.mts → deepkit/schemas/reflection.d.mts} +59 -1136
  13. package/dist/deepkit/schemas/reflection.mjs +3938 -0
  14. package/dist/deepkit/schemas/reflection2.cjs +4112 -0
  15. package/dist/deepkit/schemas/reflection2.mjs +4110 -0
  16. package/dist/deepkit/src/capnp.cjs +913 -0
  17. package/dist/deepkit/src/capnp.mjs +911 -0
  18. package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
  19. package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
  20. package/dist/deepkit/src/reflect-type.cjs +22 -0
  21. package/dist/deepkit/src/reflect-type.mjs +20 -0
  22. package/dist/deepkit/src/resolve-reflections.cjs +16 -0
  23. package/dist/deepkit/src/resolve-reflections.mjs +15 -0
  24. package/dist/deepkit/src/transformer.cjs +52 -0
  25. package/dist/deepkit/src/transformer.mjs +49 -0
  26. package/dist/deepkit/src/transpile.cjs +29 -0
  27. package/dist/deepkit/src/transpile.mjs +27 -0
  28. package/dist/deepkit/src/types.d.cts +10 -0
  29. package/dist/deepkit/src/types.d.mts +10 -0
  30. package/dist/deepkit/src/utilities.cjs +66 -0
  31. package/dist/deepkit/src/utilities.mjs +65 -0
  32. package/dist/index.cjs +14 -813
  33. package/dist/index.d.cts +5 -5
  34. package/dist/index.d.mts +5 -5
  35. package/dist/index.mjs +11 -803
  36. package/dist/plugin-alloy/src/core/components/output.cjs +45 -0
  37. package/dist/plugin-alloy/src/core/components/output.mjs +44 -0
  38. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
  39. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
  40. package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
  41. package/dist/plugin-alloy/src/core/components/source-file.d.cts +23 -0
  42. package/dist/plugin-alloy/src/core/components/source-file.d.mts +23 -0
  43. package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
  44. package/dist/plugin-alloy/src/core/contexts/context.cjs +60 -0
  45. package/dist/plugin-alloy/src/core/contexts/context.mjs +54 -0
  46. package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
  47. package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
  48. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
  49. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
  50. package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
  51. package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
  52. package/dist/plugin-alloy/src/index.cjs +93 -0
  53. package/dist/plugin-alloy/src/index.mjs +91 -0
  54. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
  55. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
  56. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
  57. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
  58. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
  59. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
  60. package/dist/plugin-alloy/src/types/components.d.cts +22 -0
  61. package/dist/plugin-alloy/src/types/components.d.mts +24 -0
  62. package/dist/plugin-alloy/src/types/index.d.mts +2 -0
  63. package/dist/plugin-alloy/src/types/plugin.d.cts +37 -0
  64. package/dist/plugin-alloy/src/types/plugin.d.mts +37 -0
  65. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +57 -0
  66. package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +25 -0
  67. package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +26 -0
  68. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +56 -0
  69. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +126 -0
  70. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +124 -0
  71. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +442 -0
  72. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +27 -0
  73. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +28 -0
  74. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +433 -0
  75. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +194 -0
  76. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +14 -0
  77. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +15 -0
  78. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +191 -0
  79. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +68 -0
  80. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +1 -0
  81. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +4 -0
  82. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +67 -0
  83. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
  84. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
  85. package/dist/plugin-automd/src/index.cjs +101 -0
  86. package/dist/plugin-automd/src/index.mjs +98 -0
  87. package/dist/plugin-automd/src/types/plugin.d.cts +38 -0
  88. package/dist/plugin-automd/src/types/plugin.d.mts +40 -0
  89. package/dist/plugin-automd/src/types/toc.d.cts +33 -0
  90. package/dist/plugin-automd/src/types/toc.d.mts +33 -0
  91. package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
  92. package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
  93. package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
  94. package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
  95. package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
  96. package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
  97. package/dist/plugin-babel/src/helpers/index.cjs +5 -0
  98. package/dist/plugin-babel/src/helpers/index.mjs +7 -0
  99. package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
  100. package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
  101. package/dist/plugin-babel/src/helpers/options.cjs +50 -0
  102. package/dist/plugin-babel/src/helpers/options.mjs +47 -0
  103. package/dist/plugin-babel/src/index.cjs +91 -0
  104. package/dist/plugin-babel/src/index.mjs +89 -0
  105. package/dist/plugin-babel/src/types/index.d.mts +1 -0
  106. package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
  107. package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
  108. package/dist/plugin-env/src/babel/index.cjs +1 -0
  109. package/dist/plugin-env/src/babel/index.mjs +3 -0
  110. package/dist/plugin-env/src/babel/plugin.cjs +121 -0
  111. package/dist/plugin-env/src/babel/plugin.mjs +119 -0
  112. package/dist/plugin-env/src/components/docs.cjs +9 -0
  113. package/dist/plugin-env/src/components/docs.mjs +11 -0
  114. package/dist/plugin-env/src/components/env.cjs +575 -0
  115. package/dist/plugin-env/src/components/env.d.cts +11 -0
  116. package/dist/plugin-env/src/components/env.d.mts +11 -0
  117. package/dist/plugin-env/src/components/env.mjs +572 -0
  118. package/dist/plugin-env/src/components/index.cjs +2 -0
  119. package/dist/plugin-env/src/components/index.mjs +4 -0
  120. package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
  121. package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
  122. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
  123. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
  124. package/dist/plugin-env/src/helpers/index.cjs +6 -0
  125. package/dist/plugin-env/src/helpers/index.mjs +8 -0
  126. package/dist/plugin-env/src/helpers/load.cjs +83 -0
  127. package/dist/plugin-env/src/helpers/load.mjs +80 -0
  128. package/dist/plugin-env/src/helpers/persistence.cjs +199 -0
  129. package/dist/plugin-env/src/helpers/persistence.mjs +188 -0
  130. package/dist/plugin-env/src/helpers/reflect.cjs +111 -0
  131. package/dist/plugin-env/src/helpers/reflect.mjs +103 -0
  132. package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
  133. package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
  134. package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
  135. package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
  136. package/dist/plugin-env/src/index.cjs +175 -0
  137. package/dist/plugin-env/src/index.mjs +173 -0
  138. package/dist/plugin-env/src/types/plugin.d.cts +151 -0
  139. package/dist/plugin-env/src/types/plugin.d.mts +153 -0
  140. package/dist/plugin-env/src/types/runtime.d.cts +792 -0
  141. package/dist/plugin-env/src/types/runtime.d.mts +792 -0
  142. package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
  143. package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
  144. package/dist/powerlines/src/lib/entry.cjs +12 -0
  145. package/dist/powerlines/src/lib/entry.mjs +14 -0
  146. package/dist/powerlines/src/lib/logger.cjs +41 -0
  147. package/dist/powerlines/src/lib/logger.mjs +39 -0
  148. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -0
  149. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -0
  150. package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
  151. package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
  152. package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
  153. package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
  154. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
  155. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
  156. package/dist/powerlines/src/types/babel.d.cts +22 -0
  157. package/dist/powerlines/src/types/babel.d.mts +22 -0
  158. package/dist/powerlines/src/types/build.d.cts +145 -0
  159. package/dist/powerlines/src/types/build.d.mts +145 -0
  160. package/dist/powerlines/src/types/commands.d.cts +8 -0
  161. package/dist/powerlines/src/types/commands.d.mts +9 -0
  162. package/dist/powerlines/src/types/config.d.cts +387 -0
  163. package/dist/powerlines/src/types/config.d.mts +388 -0
  164. package/dist/powerlines/src/types/context.d.cts +414 -0
  165. package/dist/powerlines/src/types/context.d.mts +416 -0
  166. package/dist/powerlines/src/types/fs.d.cts +486 -0
  167. package/dist/powerlines/src/types/fs.d.mts +486 -0
  168. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  169. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  170. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  171. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  172. package/dist/powerlines/src/types/resolved.d.mts +82 -0
  173. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  174. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  175. package/dist/types/index.cjs +0 -2
  176. package/dist/types/index.d.cts +1 -3
  177. package/dist/types/index.d.mts +1 -3
  178. package/dist/types/index.mjs +0 -3
  179. package/dist/types/plugin.cjs +0 -1
  180. package/dist/types/plugin.d.cts +22 -2
  181. package/dist/types/plugin.d.mts +22 -2
  182. package/dist/types/plugin.mjs +0 -2
  183. package/package.json +6 -6
  184. package/dist/components-BWLXb7a2.cjs +0 -0
  185. package/dist/components-CXZYcH4q.d.mts +0 -1816
  186. package/dist/components-kh0CpIG2.mjs +0 -1
  187. package/dist/env-CAhIy_H3.cjs +0 -11713
  188. package/dist/env-CUyFiniR.d.cts +0 -107
  189. package/dist/env-IF4XhMjG.mjs +0 -11570
  190. package/dist/env-sRb-Y8mJ.d.mts +0 -89
  191. package/dist/index-CUbWeWHc.d.mts +0 -1
  192. package/dist/index-D6CnpA_r.d.cts +0 -1
  193. package/dist/index-DL0uimUT.d.mts +0 -1
  194. package/dist/index-DWPDThxu.d.cts +0 -1
  195. package/dist/plugin-ifZVa20V.mjs +0 -1
  196. package/dist/plugin-pBKbb5K9.cjs +0 -0
  197. package/dist/resolved-zsx09G03.d.cts +0 -1795
  198. package/dist/types-U3zd8PTP.mjs +0 -1
  199. package/dist/types-o3zWarRp.cjs +0 -0
package/dist/index.cjs CHANGED
@@ -1,832 +1,33 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_env = require('./env-CAhIy_H3.cjs');
3
- require('./components-BWLXb7a2.cjs');
4
- require('./plugin-pBKbb5K9.cjs');
5
- require('./types-o3zWarRp.cjs');
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_index = require('./plugin-babel/src/index.cjs');
4
+ const require_index$1 = require('./plugin-env/src/index.cjs');
5
+ const require_tsconfig = require('./powerlines/src/lib/typescript/tsconfig.cjs');
6
+ const require_components_env = require('./components/env.cjs');
7
+ require('./components/index.cjs');
6
8
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
7
- let __babel_core = require("@babel/core");
8
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
9
- let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
10
- let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
11
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
12
- let defu = require("defu");
13
- defu = require_env.__toESM(defu);
14
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
15
- require("@stryke/type-checks/is-object");
16
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
17
- let chalk = require("chalk");
18
- chalk = require_env.__toESM(chalk);
19
- let __babel_generator = require("@babel/generator");
20
- __babel_generator = require_env.__toESM(__babel_generator);
21
- require("@babel/parser");
22
- let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
23
- require("@storm-software/config-tools/logger");
24
- require("@storm-software/config-tools/utilities/colors");
25
- require("@stryke/helpers/noop");
26
- let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
27
- let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
28
- let __babel_types = require("@babel/types");
29
- __babel_types = require_env.__toESM(__babel_types);
30
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
31
- let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
32
- let __alloy_js_core = require("@alloy-js/core");
33
- let __alloy_js_rollup_plugin = require("@alloy-js/rollup-plugin");
34
- __alloy_js_rollup_plugin = require_env.__toESM(__alloy_js_rollup_plugin);
35
- let __stryke_json_storm_json = require("@stryke/json/storm-json");
36
- let __stryke_path_replace = require("@stryke/path/replace");
37
- let __stryke_convert_to_array = require("@stryke/convert/to-array");
38
- let __stryke_fs_is_file = require("@stryke/fs/is-file");
39
- let __stryke_fs_list_files = require("@stryke/fs/list-files");
40
- let __stryke_path_append = require("@stryke/path/append");
41
- let __stryke_path_is_type = require("@stryke/path/is-type");
42
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
43
- let automd = require("automd");
44
- let c12 = require("c12");
45
- let markdown_toc = require("markdown-toc");
46
- markdown_toc = require_env.__toESM(markdown_toc);
47
- let __stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
48
- let __stryke_env_types = require("@stryke/env/types");
49
- let __stryke_fs_exists = require("@stryke/fs/exists");
50
- let __stryke_fs_helpers = require("@stryke/fs/helpers");
51
- let __stryke_path_join = require("@stryke/path/join");
52
- let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
53
- let __stryke_capnp = require("@stryke/capnp");
54
- __stryke_capnp = require_env.__toESM(__stryke_capnp);
55
- let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
56
- let __stryke_fs_buffer = require("@stryke/fs/buffer");
57
- let node_fs = require("node:fs");
58
- let typescript = require("typescript");
59
- typescript = require_env.__toESM(typescript);
60
- require("@alloy-js/markdown");
61
- require("@stryke/fs/json");
62
9
 
63
- //#region ../plugin-babel/src/helpers/filters.ts
64
- function getPluginName(plugin$5) {
65
- return (0, __stryke_type_checks_is_set_string.isSetString)(plugin$5) ? plugin$5 : Array.isArray(plugin$5) && plugin$5.length > 0 ? getPluginName(plugin$5[0]) : plugin$5.$$name || plugin$5.name ? plugin$5.$$name || plugin$5.name : void 0;
66
- }
67
- /**
68
- * Check if a Babel plugin is a duplicate of another plugin in the list.
69
- *
70
- * @param plugins - The list of existing Babel plugins.
71
- * @param plugin - The Babel plugin to check for duplicates.
72
- * @returns True if the plugin is a duplicate, false otherwise.
73
- */
74
- function isDuplicatePlugin(plugins, plugin$5) {
75
- return !!(getPluginName(plugin$5) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin$5)));
76
- }
77
-
78
- //#endregion
79
- //#region ../plugin-babel/src/helpers/options.ts
80
- function resolvePluginFunction(context, plugin$5) {
81
- try {
82
- return Array.isArray(plugin$5) && plugin$5.length > 0 && plugin$5[0] ? (0, __stryke_type_checks_is_function.isFunction)(plugin$5[0]) ? plugin$5[0](context) : plugin$5[0] : (0, __stryke_type_checks_is_function.isFunction)(plugin$5) ? plugin$5(context) : plugin$5;
83
- } catch {
84
- return plugin$5[0];
85
- }
86
- }
87
- /**
88
- * Resolve the [Babel](https://babeljs.io/) plugin.
89
- *
90
- * @param context - The context for the transformation.
91
- * @param code - The code to be transformed.
92
- * @param id - The ID of the source file.
93
- * @param plugin - The Babel plugin to resolve.
94
- * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
95
- */
96
- function resolveBabelPlugin(context, code$3, id, plugin$5) {
97
- if (Array.isArray(plugin$5) && plugin$5.length > 0 && plugin$5[0]) {
98
- if (plugin$5.length > 2 && plugin$5[2] && (0, __stryke_type_checks_is_function.isFunction)(plugin$5[2]) && !plugin$5[2](code$3, id)) {
99
- context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.default.bold.cyanBright(getPluginName(plugin$5) || "unnamed")} for ${id}`);
100
- return;
101
- }
102
- return plugin$5.length > 2 ? [
103
- resolvePluginFunction(context, plugin$5),
104
- plugin$5[1],
105
- plugin$5[2]
106
- ] : [
107
- resolvePluginFunction(context, plugin$5),
108
- plugin$5[1],
109
- null
110
- ];
111
- }
112
- return [
113
- resolvePluginFunction(context, plugin$5),
114
- {},
115
- null
116
- ];
117
- }
118
-
119
- //#endregion
120
- //#region ../plugin-babel/src/helpers/ast-utils.ts
121
- let generate = __babel_generator.default;
122
- if ("default" in generate) generate = generate.default;
123
-
124
- //#endregion
125
- //#region ../powerlines/src/lib/logger.ts
126
- const BADGE_COLORS = [
127
- "#00A0DD",
128
- "#6FCE4E",
129
- "#FBBF24",
130
- "#F43F5E",
131
- "#3B82F6",
132
- "#A855F7",
133
- "#469592",
134
- "#288EDF",
135
- "#D8B4FE",
136
- "#10B981",
137
- "#EF4444",
138
- "#F0EC56",
139
- "#F472B6",
140
- "#22D3EE",
141
- "#EAB308",
142
- "#84CC16",
143
- "#F87171",
144
- "#0EA5E9",
145
- "#D946EF",
146
- "#FACC15",
147
- "#34D399",
148
- "#8B5CF6"
149
- ];
150
- const extendLog = (logFn, name) => {
151
- return (type, ...args) => logFn(type, ` ${chalk.default.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${(0, __stryke_string_format_title_case.titleCase)(name)} `)} ${args.join(" ")} `);
152
- };
153
-
154
- //#endregion
155
- //#region ../plugin-babel/src/helpers/create-plugin.ts
156
- /**
157
- * Create a Babel plugin using the provided builder function.
158
- *
159
- * @param name - The name of the plugin.
160
- * @param builder - The builder function that defines the plugin behavior.
161
- * @returns A Babel plugin declaration.
162
- */
163
- function createBabelPlugin(name, builder) {
164
- const plugin$5 = (context) => {
165
- return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
166
- api.cache.using(() => context.meta.checksum);
167
- api.assertVersion("^7.0.0-0");
168
- const log = extendLog(context.log, name);
169
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
170
- const result = builder({
171
- log,
172
- name,
173
- api,
174
- options,
175
- context,
176
- dirname
177
- });
178
- result.name = name;
179
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
180
- return result;
181
- });
182
- };
183
- plugin$5.$$name = name;
184
- return plugin$5;
185
- }
186
-
187
- //#endregion
188
- //#region ../plugin-babel/src/helpers/module-helpers.ts
189
- /**
190
- * Adds an import to the program if it doesn't already exist.
191
- *
192
- * @param path - The current NodePath in the AST.
193
- * @param specifier - The import specifier.
194
- */
195
- function addImport(path, specifier) {
196
- addImportsToProgram(path.scope.getProgramParent().path, specifier);
197
- }
198
- function isNonNamespacedImport(importDeclPath) {
199
- return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
200
- }
201
- function getExistingImports(program) {
202
- const existingImports = /* @__PURE__ */ new Map();
203
- program.traverse({ ImportDeclaration(path) {
204
- if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
205
- } });
206
- return existingImports;
207
- }
208
- function addImportsToProgram(path, specifier) {
209
- /**
210
- * If an existing import of this module exists (ie \`import \{ ... \} from
211
- * '<moduleName>'\`), inject new imported specifiers into the list of
212
- * destructured variables.
213
- */
214
- if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", __babel_types.importDeclaration([__babel_types.importSpecifier(__babel_types.identifier(specifier.name || specifier.imported), __babel_types.identifier(specifier.imported))], __babel_types.stringLiteral(specifier.module)));
215
- }
216
-
217
- //#endregion
218
- //#region ../plugin-babel/src/index.ts
219
- /**
220
- * Babel plugin for Powerlines.
221
- *
222
- * @param options - The Babel plugin user configuration options.
223
- * @returns A Powerlines plugin that integrates Babel transformations.
224
- */
225
- const plugin$4 = (options = {}) => {
226
- return {
227
- name: "babel",
228
- config() {
229
- if (!(0, __stryke_type_checks_is_set_object.isSetObject)(options)) return;
230
- return { transform: { babel: options } };
231
- },
232
- configResolved: {
233
- order: "pre",
234
- handler() {
235
- this.devDependencies["@babel/core"] = "^7.28.4";
236
- this.config.transform.babel = (0, defu.default)(this.config.transform.babel ?? {}, {
237
- plugins: [],
238
- presets: []
239
- });
240
- }
241
- },
242
- async transform(code$3, id) {
243
- if ((0, __stryke_path_is_parent_path.isParentPath)(id, this.powerlinesPath) || code$3.includes("/* @storm-ignore */") || code$3.includes("/* @storm-disable */")) {
244
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
245
- return {
246
- code: code$3,
247
- id
248
- };
249
- }
250
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
251
- const plugins = this.config.transform.babel.plugins.map((plugin$5) => resolveBabelPlugin(this, code$3, id, plugin$5)).filter((plugin$5, _, arr) => plugin$5 && !isDuplicatePlugin(arr, plugin$5));
252
- const presets = this.config.transform.babel.presets.map((preset) => resolveBabelPlugin(this, code$3, id, preset)).filter((preset, _, arr) => preset && !isDuplicatePlugin(arr, preset));
253
- if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
254
- code: code$3,
255
- id
256
- };
257
- if ([
258
- "ts",
259
- "cts",
260
- "mts",
261
- "tsx"
262
- ].includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(id)) && !isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: (0, __stryke_path_file_path_fns.findFileExtension)(id) === ".tsx" }]);
263
- const result = await (0, __babel_core.transformAsync)(code$3, {
264
- highlightCode: true,
265
- code: true,
266
- ast: false,
267
- cloneInputAst: false,
268
- comments: true,
269
- sourceType: "module",
270
- configFile: false,
271
- babelrc: false,
272
- envName: this.config.mode,
273
- caller: { name: this.config.framework },
274
- ...this.config.transform.babel ?? {},
275
- filename: id,
276
- plugins: plugins.map((plugin$5) => {
277
- return Array.isArray(plugin$5) && plugin$5.length >= 2 ? [plugin$5[0], (0, defu.default)(plugin$5.length > 1 && plugin$5[1] ? plugin$5[1] : {}, { options })] : plugin$5;
278
- }).filter(Boolean),
279
- presets: presets.map((preset) => {
280
- return Array.isArray(preset) && preset.length >= 2 ? [preset[0], (0, defu.default)(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
281
- }).filter(Boolean)
282
- });
283
- if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
284
- return {
285
- code: result.code,
286
- id
287
- };
288
- }
289
- };
290
- };
291
- var src_default$1 = plugin$4;
292
-
293
- //#endregion
294
- //#region ../plugin-alloy/src/core/components/output.tsx
295
- /**
296
- * Output component for rendering the Powerlines plugin's output files via templates.
297
- */
298
- function Output(props) {
299
- const [{ children, context, meta, basePath }, rest] = (0, __alloy_js_core.splitProps)(props, [
300
- "children",
301
- "context",
302
- "meta",
303
- "basePath"
304
- ]);
305
- const contextRef = (0, __alloy_js_core.ref)(context);
306
- const metaRef = (0, __alloy_js_core.ref)(meta ?? {});
307
- const basePathRef = (0, __alloy_js_core.computed)(() => basePath ? (0, __stryke_path_replace.replacePath)(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
308
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Output, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
309
- get basePath() {
310
- return basePathRef.value;
311
- },
312
- get children() {
313
- return (0, __alloy_js_core_jsx_runtime.createComponent)(require_env.PowerlinesContext.Provider, {
314
- value: {
315
- ref: contextRef,
316
- meta: metaRef
317
- },
318
- get children() {
319
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
320
- get when() {
321
- return Boolean(contextRef.value);
322
- },
323
- children
324
- });
325
- }
326
- });
327
- }
328
- }));
329
- }
330
-
331
- //#endregion
332
- //#region ../plugin-alloy/src/index.tsx
333
- /**
334
- * Alloy-js plugin for Powerlines.
335
- *
336
- * @param options - The Alloy-js plugin user configuration options.
337
- * @returns A Powerlines plugin that integrates Alloy-js transformations.
338
- */
339
- const plugin$3 = (options = {}) => {
340
- return [{
341
- name: "alloy:config",
342
- config() {
343
- return {
344
- alloy: {
345
- typescript: true,
346
- ...options
347
- },
348
- build: {
349
- inputOptions: { transform: { jsx: {
350
- runtime: "classic",
351
- pragma: "Alloy.createElement",
352
- importSource: "@alloy-js/core"
353
- } } },
354
- plugins: [(0, __alloy_js_rollup_plugin.default)()]
355
- }
356
- };
357
- },
358
- async configResolved() {
359
- if (this.tsconfig.tsconfigJson.compilerOptions?.jsx !== "preserve" || this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !== "@alloy-js/core") {
360
- this.tsconfig.tsconfigJson.compilerOptions ??= {};
361
- if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
362
- if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
363
- await this.fs.write(this.tsconfig.tsconfigFilePath, __stryke_json_storm_json.StormJSON.stringify(this.tsconfig.tsconfigJson));
364
- }
365
- this.dependencies["@alloy-js/core"] = "^0.22.0";
366
- if (this.config.alloy?.typescript !== false) this.dependencies["@alloy-js/typescript"] = "^0.22.0";
367
- if (this.config.alloy?.json === true) this.dependencies["@alloy-js/json"] = "^0.22.0";
368
- if (this.config.alloy?.markdown === true) this.dependencies["@alloy-js/markdown"] = "^0.22.0";
369
- }
370
- }, {
371
- name: "alloy:update-context",
372
- configResolved: {
373
- order: "pre",
374
- async handler() {
375
- this.render = async (children) => {
376
- const _self$ = this;
377
- const meta = {};
378
- await (0, __alloy_js_core.traverseOutput)(await (0, __alloy_js_core.renderAsync)((0, __alloy_js_core_jsx_runtime.createComponent)(Output, {
379
- context: _self$,
380
- meta,
381
- get basePath() {
382
- return _self$.workspaceConfig.workspaceRoot;
383
- },
384
- children
385
- })), {
386
- visitDirectory: (directory) => {
387
- if (this.fs.existsSync(directory.path)) return;
388
- this.fs.mkdirSync(directory.path);
389
- },
390
- visitFile: (file) => {
391
- if ("contents" in file) {
392
- const metadata = meta[file.path] ?? {};
393
- if (metadata.kind === "builtin") {
394
- if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
395
- this.emitBuiltinSync(file.contents, metadata.id, file.path, {
396
- skipFormat: metadata.skipFormat,
397
- storage: metadata.storage
398
- });
399
- } else if (metadata.kind === "entry") this.emitEntrySync(file.contents, file.path, {
400
- skipFormat: metadata.skipFormat,
401
- storage: metadata.storage,
402
- ...metadata.typeDefinition ?? {}
403
- });
404
- else this.emitSync(file.contents, file.path, metadata);
405
- } else this.fs.copySync(file.sourcePath, file.path);
406
- }
407
- });
408
- };
409
- }
410
- }
411
- }];
412
- };
413
- var src_default$3 = plugin$3;
414
-
415
- //#endregion
416
- //#region ../plugin-automd/src/index.ts
417
- /**
418
- * AutoMD Plugin
419
- *
420
- * @remarks
421
- * A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.
422
- *
423
- * @see https://automd.unjs.io/
424
- *
425
- * @param options - The plugin options.
426
- * @returns A Powerlines plugin instance.
427
- */
428
- const plugin$2 = (options = {}) => {
429
- return {
430
- name: "automd",
431
- async config() {
432
- const config = await (0, automd.loadConfig)((0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
433
- if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = (0, __stryke_convert_to_array.toArray)(config.prefix ?? []);
434
- if (!config.prefix.includes("automd")) config.prefix.push("automd");
435
- if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
436
- return { automd: (0, defu.default)(config ?? {}, {
437
- configFile: options.configFile,
438
- allowIssues: true,
439
- dir: this.config.projectRoot,
440
- watch: false,
441
- input: "README.md",
442
- toc: {
443
- maxDepth: 6,
444
- bullets: "-"
445
- }
446
- }) };
447
- },
448
- async configResolved() {
449
- if (this.config.framework && !(0, __stryke_convert_to_array.toArray)(this.config.automd.prefix).includes(this.config.framework)) this.config.automd.prefix = (0, __stryke_convert_to_array.toArray)(this.config.automd.prefix).concat(this.config.framework);
450
- if (this.config.automd.configFile) {
451
- const { config } = await (0, c12.loadConfig)({
452
- cwd: this.config.automd.dir,
453
- configFile: this.config.automd.configFile,
454
- defaults: {
455
- ignore: [
456
- "**/node_modules",
457
- "**/dist",
458
- "**/.*"
459
- ],
460
- dir: this.config.automd.dir
461
- }
462
- });
463
- this.config.automd = (0, automd.resolveConfig)((0, defu.default)(this.config.automd, {
464
- ...config,
465
- prefix: (0, __stryke_convert_to_array.toArray)(config.prefix ?? [])
466
- }));
467
- }
468
- this.config.automd.input = (await Promise.all((0, __stryke_convert_to_array.toArray)(this.config.automd.input).map(async (input) => {
469
- if (input.includes("*")) return (0, __stryke_fs_list_files.listFiles)((0, __stryke_path_is_type.isAbsolutePath)(input) ? input : (0, __stryke_path_append.appendPath)(input, this.config.projectRoot), { ignore: this.config.automd.ignore });
470
- return (0, __stryke_path_is_type.isAbsolutePath)(input) ? input : (0, __stryke_path_append.appendPath)(input, this.config.projectRoot);
471
- }))).flat();
472
- if (this.config.automd.output && !(0, __stryke_path_is_type.isAbsolutePath)(this.config.automd.output)) this.config.automd.output = (0, __stryke_path_append.appendPath)(this.config.automd.output, this.config.projectRoot);
473
- this.config.automd.generators ??= {};
474
- if (this.config.automd.toc !== false) this.config.automd.generators.toc ??= {
475
- name: "toc",
476
- generate: (ctx) => {
477
- const opts = this.config.automd.toc ?? {};
478
- return { contents: (0, markdown_toc.default)(ctx.block.md, {
479
- ...opts,
480
- maxdepth: opts.maxDepth,
481
- first1: opts.firstH1
482
- }).content };
483
- }
484
- };
485
- },
486
- async docs() {
487
- await Promise.all((0, __stryke_convert_to_array.toArray)(this.config.automd.input).map(async (input) => {
488
- const contents = await this.fs.read(input);
489
- if (contents) {
490
- const result = await (0, automd.transform)(contents, this.config.automd);
491
- if (result.hasIssues && this.config.automd.allowIssues === false) throw new Error(`AutoMD found issues in file "${input}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);
492
- if (result.hasChanged) await this.fs.write((0, __stryke_path_append.appendPath)(this.config.automd.output ? (0, __stryke_fs_is_file.isDirectory)(this.config.automd.output) ? (0, __stryke_path_replace.replacePath)(input, this.config.automd.output) : this.config.automd.output : input, this.config.projectRoot), result.contents);
493
- }
494
- }));
495
- }
496
- };
497
- };
498
- var src_default$4 = plugin$2;
499
-
500
- //#endregion
501
- //#region ../plugin-env/src/babel/plugin.ts
502
- const envBabelPlugin = createBabelPlugin("env", ({ log, context }) => {
503
- function extractEnv(node, pass, isInjectable = false) {
504
- const envTypesAliasProperties = context.env.types.env?.getProperties().filter((prop) => prop.getAlias().length > 0);
505
- if (node.name) {
506
- const prefix = context.config.env.prefix.find((pre) => node.name && node.name.startsWith(pre) && (context.env.types.env?.hasProperty(node.name.replace(`${pre}_`, "")) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(node.name.replace(`${pre}_`, "")))));
507
- let name = node.name;
508
- if (prefix) name = node.name.replace(`${prefix}_`, "");
509
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
510
- if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(name))) {
511
- const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find((prop) => prop.getAlias().includes(name));
512
- if (!envProperty || envProperty.isIgnored()) return;
513
- if (!context.env.used.env.hasProperty(name)) context.env.used.env.addProperty(envProperty.property);
514
- if (context.config.env.inject && isInjectable) {
515
- let value = context.env.parsed?.[name];
516
- if (value === void 0) {
517
- const prefix$1 = context.config.env.prefix.find((pre) => {
518
- return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
519
- });
520
- if (prefix$1) value = context.env.parsed[`${prefix$1.replace(/_$/g, "")}_${name}`];
521
- }
522
- value ??= envProperty.getDefaultValue();
523
- if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
524
- return require_env.stringifyDefaultValue(envProperty, value);
525
- }
526
- } else throw new Error(`The "${name}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${pass.filename ? pass.filename : "unknown"}.
527
-
528
- The following environment configuration names are defined in the \`env\` type definition: \n${context.env.types.env?.getPropertyNames().sort((a, b) => String(a).localeCompare(String(b))).map((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0) ? `(Alias: ${envTypesAliasProperties?.find((prop) => prop.getNameAsString() === String(typeDef))?.getAlias().join(", ")})` : ""}`).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map((prefix$1) => ` - ${prefix$1}`).join("\n")} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`);
529
- }
530
- }
531
- return {
532
- visitor: { MemberExpression(path, pass) {
533
- if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "$storm" }) && path.get("property")?.isIdentifier()) {
534
- const identifier = path.get("property")?.node;
535
- extractEnv(identifier, pass, false);
536
- path.replaceWithSourceString(`env.${identifier.name}`);
537
- addImport(path, {
538
- module: "storm:env",
539
- name: "env",
540
- imported: "env"
541
- });
542
- } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isCallExpression({ callee: {
543
- name: "useStorm",
544
- type: "Identifier"
545
- } }) && path.get("property")?.isIdentifier()) {
546
- const identifier = path.get("property")?.node;
547
- extractEnv(identifier, pass, false);
548
- path.replaceWithSourceString(`env.${identifier.name}`);
549
- addImport(path, {
550
- module: "storm:env",
551
- name: "env",
552
- imported: "env"
553
- });
554
- } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
555
- const identifier = path.get("property")?.node;
556
- if (!identifier.name) return;
557
- extractEnv(identifier, pass, false);
558
- path.replaceWithSourceString(`env.${identifier.name}`);
559
- addImport(path, {
560
- module: "storm:env",
561
- name: "env",
562
- imported: "env"
563
- });
564
- } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
565
- const identifier = path.get("property")?.node;
566
- if (!identifier.name) return;
567
- extractEnv(identifier, pass, false);
568
- path.replaceWithSourceString(`env.${identifier.name}`);
569
- addImport(path, {
570
- module: "storm:env",
571
- name: "env",
572
- imported: "env"
573
- });
574
- }
575
- } },
576
- post() {
577
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding environment variables from ${this.filename || "unknown file"} to env.json.`);
578
- let persistedEnv = __powerlines_deepkit_vendor_type.ReflectionClass.from({
579
- kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
580
- description: `An object containing the environment variables used by the application.`,
581
- types: []
582
- });
583
- const reflectionPath = require_env.getEnvReflectionsPath(context, "env");
584
- if (reflectionPath && (0, node_fs.existsSync)(reflectionPath)) {
585
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment reflection file found at ${reflectionPath}, reading existing reflection.`);
586
- persistedEnv = (0, __powerlines_deepkit_vendor_type.resolveClassType)((0, __powerlines_deepkit_vendor_type.deserializeType)(require_env.convertFromCapnp(new __stryke_capnp.Message((0, __stryke_fs_buffer.readFileBufferSync)(reflectionPath), false).getRoot(require_env.SerializedTypes).types)));
587
- }
588
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding new variables to env reflection at ${reflectionPath}.`);
589
- persistedEnv.getProperties().filter((property) => property.getNameAsString() && !context.env.used.env.hasProperty(property.getNameAsString())).forEach((property) => {
590
- context.env.used.env.addProperty({
591
- ...property,
592
- name: property.getNameAsString(),
593
- description: property.getDescription() ?? `The ${property.getNameAsString()} variable.`,
594
- default: property.getDefaultValue(),
595
- optional: property.isOptional() ? true : void 0,
596
- readonly: property.isReadonly() ? true : void 0,
597
- visibility: property.getVisibility(),
598
- type: property.getType(),
599
- tags: property.getTags()
600
- });
601
- });
602
- }
603
- };
604
- });
605
-
606
- //#endregion
607
- //#region ../plugin-env/src/helpers/automd-generator.ts
608
- /**
609
- * AutoMD generator to generate environment variable documentation
610
- *
611
- * @param context - The generator context.
612
- * @returns The generated documentation content.
613
- */
614
- const env = (context) => (0, automd.defineGenerator)({
615
- name: "env",
616
- async generate() {
617
- const envDocFile = (0, __stryke_path_join_paths.joinPaths)(context.config.projectRoot, "docs", "generated", "env.md");
618
- if (!context.fs.existsSync(envDocFile)) return { contents: "" };
619
- return { contents: await context.fs.read(envDocFile) || "" };
620
- }
621
- });
622
-
623
- //#endregion
624
- //#region ../plugin-alloy/src/markdown/contexts/markdown-table.ts
625
- /**
626
- * The Powerlines context used in template rendering.
627
- */
628
- const MarkdownTableColumnContext = (0, __alloy_js_core.createNamedContext)("markdown-table-column", {});
629
- /**
630
- * The Powerlines context used in template rendering.
631
- */
632
- const MarkdownTableContext = (0, __alloy_js_core.createContext)({
633
- columns: [],
634
- data: []
635
- });
636
-
637
- //#endregion
638
- //#region ../plugin-env/src/index.tsx
639
- /**
640
- * A Powerlines plugin to inject environment variables into the source code.
641
- */
642
- const plugin$1 = (options = {}) => {
643
- return [
644
- src_default$3(options.alloy),
645
- src_default$1(options.babel),
646
- {
647
- name: "env",
648
- async config() {
649
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `env` build plugin.");
650
- const config = {
651
- env: (0, defu.default)(options, {
652
- types: {},
653
- prefix: []
654
- }),
655
- transform: { babel: { plugins: [envBabelPlugin] } }
656
- };
657
- if (config.env.types) config.env.types = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.types);
658
- else {
659
- this.log(__storm_software_config_tools_types.LogLevelLabel.WARN, "The `env.types` configuration parameter was not provided. Please ensure this is expected.");
660
- const envDefaultTypeDefinition = await require_env.getEnvDefaultTypeDefinition(this);
661
- config.env.types = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(`${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`);
662
- }
663
- if (config.env.secrets) config.env.secrets = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.secrets);
664
- else {
665
- const secretsDefaultTypeDefinition = await require_env.getSecretsDefaultTypeDefinition(this);
666
- config.env.secrets = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(`${secretsDefaultTypeDefinition.file}#${secretsDefaultTypeDefinition.name}`);
667
- }
668
- config.env.prefix = (0, __stryke_convert_to_array.toArray)(config.env.prefix ?? []).reduce((ret, prefix) => {
669
- const formattedPrefix = (0, __stryke_string_format_constant_case.constantCase)(prefix);
670
- if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
671
- return ret;
672
- }, [...__stryke_env_types.ENV_PREFIXES, "POWERLINES_"]);
673
- config.env.prefix = config.env.prefix.reduce((ret, prefix) => {
674
- if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
675
- return ret;
676
- }, []);
677
- return config;
678
- },
679
- async configResolved() {
680
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment plugin configuration has been resolved for the Powerlines project.`);
681
- this.config.env.inject ??= this.config.projectType === "application";
682
- this.env = (0, defu.default)({ parsed: await require_env.loadEnv(this, this.config.env) }, this.env ?? {}, {
683
- types: { env: {} },
684
- used: {
685
- env: {},
686
- secrets: {}
687
- },
688
- parsed: {},
689
- injected: {}
690
- });
691
- if (this.config.command !== "prepare" && this.persistedMeta?.checksum === this.meta.checksum && (0, __stryke_fs_exists.existsSync)(require_env.getEnvTypeReflectionsPath(this, "env"))) {
692
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping reflection initialization as the meta checksum has not changed.`);
693
- this.env.types.env = await require_env.readEnvTypeReflection(this, "env");
694
- if ((0, __stryke_fs_exists.existsSync)(require_env.getEnvReflectionsPath(this, "env"))) this.env.used.env = await require_env.readEnvReflection(this);
695
- if ((0, __stryke_fs_exists.existsSync)(require_env.getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await require_env.readEnvTypeReflection(this, "secrets");
696
- if ((0, __stryke_fs_exists.existsSync)(require_env.getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await require_env.readSecretsReflection(this);
697
- } else {
698
- this.env.types.env = await require_env.reflectEnv(this, this.config.env.types?.file ? (0, __stryke_path_is_parent_path.isParentPath)(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : (0, __stryke_path_join.joinPaths)(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
699
- if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
700
- await require_env.writeEnvTypeReflection(this, this.env.types.env, "env");
701
- this.env.types.secrets = await require_env.reflectSecrets(this, this.config.env.secrets?.file ? (0, __stryke_path_is_parent_path.isParentPath)(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : (0, __stryke_path_join.joinPaths)(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
702
- if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
703
- await require_env.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
704
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
705
- const envWithAlias = this.env.types.env.getProperties().filter((prop) => prop.getAlias().length > 0);
706
- Object.entries(await require_env.loadEnv(this, this.config.env)).forEach(([key, value]) => {
707
- const unprefixedKey = this.config.env.prefix.reduce((ret, prefix) => {
708
- if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
709
- return ret;
710
- }, key);
711
- const aliasKey = envWithAlias.find((prop) => prop?.getAlias().reverse().includes(unprefixedKey));
712
- if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
713
- });
714
- this.env.used.env = new __powerlines_deepkit_vendor_type.ReflectionClass({
715
- kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
716
- typeName: "Env",
717
- description: `An object containing the environment configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
718
- types: []
719
- }, this.env.types.env);
720
- await require_env.writeEnvReflection(this, this.env.used.env, "env");
721
- if (this.env.types.secrets) {
722
- await require_env.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
723
- this.env.used.secrets = new __powerlines_deepkit_vendor_type.ReflectionClass({
724
- kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
725
- typeName: "Secrets",
726
- description: `An object containing the secret configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
727
- types: []
728
- }, this.env.types.secrets);
729
- await require_env.writeEnvReflection(this, this.env.used.secrets, "secrets");
730
- }
731
- }
732
- },
733
- async prepare() {
734
- const _self$ = this;
735
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Preparing the Environment runtime artifacts for the Powerlines project.`);
736
- return this.render((0, __alloy_js_core_jsx_runtime.createComponent)(require_env.EnvBuiltin, { get defaultConfig() {
737
- return _self$.config.env.defaultConfig;
738
- } }));
739
- },
740
- async docs() {
741
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Writing Environment documentation for the Powerlines project artifacts.");
742
- const outputPath = (0, __stryke_path_join.joinPaths)(this.config.projectRoot, "docs", "generated");
743
- if (!(0, __stryke_fs_exists.existsSync)(outputPath)) await (0, __stryke_fs_helpers.createDirectory)(outputPath);
744
- const reflection = await require_env.readEnvTypeReflection(this, "env");
745
- const envDocFile = (0, __stryke_path_join.joinPaths)(outputPath, "env.md");
746
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Documenting environment variables configuration in "${envDocFile}"`);
747
- await this.fs.write(envDocFile, `<!-- Generated by ${(0, __stryke_string_format_title_case.titleCase)(this.config.framework) || "Powerlines"} -->
748
-
749
- Below is a list of environment variables used by the [${this.packageJson.name}](https://www.npmjs.com/package/${this.packageJson.name}) package. These values can be updated in the \`.env\` file in the root of the project. The variables in the list below are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.
750
-
751
- | Name | Description | Type | Default Value | Required |
752
- | ---- | ----------- | ---- | ------------- | :------: |
753
- ${reflection.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
754
- return `| ${reflectionProperty.getNameAsString().trim()} | ${(reflectionProperty.getDescription()?.replaceAll("\r", "")?.replaceAll("\n", "") ?? "").trim()} | ${(0, __powerlines_deepkit_vendor_type.stringifyType)(reflectionProperty.getType()).trim().replaceAll(" | ", ", or ")} | ${reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : ""} | ${reflectionProperty.isValueRequired() ? "" : "✔"} |`;
755
- }).join("\n")}
756
- `);
757
- },
758
- async buildEnd() {
759
- const reflectionPath = require_env.getEnvReflectionsPath(this, "env");
760
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing env reflection types to ${reflectionPath}.`);
761
- await require_env.writeEnvReflection(this, this.env.used.env, "env");
762
- }
763
- },
764
- {
765
- name: "env:automd-generator",
766
- config() {
767
- return { automd: (0, defu.default)(options.automd ?? {}, { generators: { "env": env(this) } }) };
768
- }
769
- },
770
- {
771
- name: "env:vite",
772
- vite: { configResolved() {
773
- return { envPrefix: this.config?.env?.prefix };
774
- } }
775
- },
776
- src_default$4(options.automd)
777
- ];
778
- };
779
- var src_default$2 = plugin$1;
780
-
781
- //#endregion
782
- //#region ../powerlines/src/lib/typescript/tsconfig.ts
783
- /**
784
- * Check if the TypeScript configuration type matches any of the provided types.
785
- *
786
- * @param tsconfigType - The type from the TypeScript configuration.
787
- * @param types - An array of type names to check against.
788
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
789
- */
790
- function findMatch(tsconfigType, types, extensions = [
791
- ".ts",
792
- ".tsx",
793
- ".d.ts"
794
- ]) {
795
- return types.find((type) => tsconfigType?.toString().toLowerCase() === type?.toString().toLowerCase() || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}` || `./${tsconfigType?.toString().toLowerCase()}` === type?.toString().toLowerCase() || extensions.some((ext) => `${tsconfigType?.toString().toLowerCase()}${ext}` === type?.toString().toLowerCase() || `${tsconfigType?.toString().toLowerCase()}${ext}` === `./${type?.toString().toLowerCase()}` || `${type?.toString().toLowerCase()}${ext}` === `./${tsconfigType?.toString().toLowerCase()}` || tsconfigType?.toString().toLowerCase() === `${type?.toString().toLowerCase()}${ext}` || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}${ext}` || type?.toString().toLowerCase() === `./${tsconfigType?.toString().toLowerCase()}${ext}`));
796
- }
797
- /**
798
- * Check if the TypeScript configuration type matches any of the provided types.
799
- *
800
- * @param tsconfigType - The type from the TypeScript configuration.
801
- * @param types - An array of type names to check against.
802
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
803
- */
804
- function isMatchFound(tsconfigType, types) {
805
- return findMatch(tsconfigType, types) !== void 0;
806
- }
807
-
808
- //#endregion
809
10
  //#region src/index.tsx
810
11
  /**
811
12
  * A package containing a Powerlines plugin for building a NodeJs application.
812
13
  */
813
14
  const plugin = (options = {}) => {
814
15
  return [
815
- src_default$1(options.babel),
816
- src_default$2(options.env),
16
+ require_index.default(options.babel),
17
+ ...require_index$1.default(options.env),
817
18
  {
818
19
  name: "nodejs",
819
- config() {
820
- return (0, defu.default)({ nodejs: options }, { nodejs: { jsxImportSource: this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource } });
821
- },
822
20
  configResolved() {
823
21
  this.devDependencies["@types/node"] = "^22.14.6";
824
22
  this.tsconfig.tsconfigJson.compilerOptions ??= {};
825
23
  this.tsconfig.tsconfigJson.compilerOptions.types ??= [];
826
- if (!isMatchFound("node", this.tsconfig.tsconfigJson.compilerOptions.types)) this.tsconfig.tsconfigJson.compilerOptions.types.push("node");
24
+ if (!require_tsconfig.isMatchFound("node", this.tsconfig.tsconfigJson.compilerOptions.types)) this.tsconfig.tsconfigJson.compilerOptions.types.push("node");
827
25
  },
828
26
  async prepare() {
829
- return this.render((0, __alloy_js_core_jsx_runtime.createComponent)(require_env.NodeJsEnvBuiltin, {}));
27
+ const _self$ = this;
28
+ return this.render((0, __alloy_js_core_jsx_runtime.createComponent)(require_components_env.NodeJsEnvBuiltin, { get defaultConfig() {
29
+ return _self$.config.env.defaultConfig;
30
+ } }));
830
31
  }
831
32
  }
832
33
  ];
@@ -834,6 +35,6 @@ const plugin = (options = {}) => {
834
35
  var src_default = plugin;
835
36
 
836
37
  //#endregion
837
- exports.NodeJsEnvBuiltin = require_env.NodeJsEnvBuiltin;
38
+ exports.NodeJsEnvBuiltin = require_components_env.NodeJsEnvBuiltin;
838
39
  exports.default = src_default;
839
40
  exports.plugin = plugin;