@powerlines/plugin-env 0.15.2 → 0.15.4

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 (231) hide show
  1. package/dist/components/docs.cjs +3 -70
  2. package/dist/components/docs.d.cts +1 -8
  3. package/dist/components/docs.d.mts +1 -8
  4. package/dist/components/docs.mjs +2 -68
  5. package/dist/components/env.cjs +4 -574
  6. package/dist/components/env.d.cts +2 -19
  7. package/dist/components/env.d.mts +3 -19
  8. package/dist/components/env.mjs +2 -570
  9. package/dist/components/index.cjs +7 -5
  10. package/dist/components/index.d.cts +4 -2
  11. package/dist/components/index.d.mts +5 -2
  12. package/dist/components/index.mjs +4 -2
  13. package/dist/{plugin-alloy/src/types/components.d.cts → components-8W0Zgj0y.d.mts} +2 -1
  14. package/dist/components-C9bYrQVK.cjs +0 -0
  15. package/dist/components-CNIQFfeK.mjs +1 -0
  16. package/dist/create-reflection-resource-BNYxBgW2.mjs +9846 -0
  17. package/dist/create-reflection-resource-BWYhmX7O.cjs +10085 -0
  18. package/dist/docs-5r844zC1.d.mts +9 -0
  19. package/dist/docs-B66b9li3.mjs +219 -0
  20. package/dist/docs-_MmTNBQX.d.cts +9 -0
  21. package/dist/docs-hBlKCRWK.cjs +224 -0
  22. package/dist/env-BPodCdD1.d.cts +116 -0
  23. package/dist/env-IQvgnabX.mjs +1578 -0
  24. package/dist/env-cO4BUDn1.cjs +1596 -0
  25. package/dist/env-zhzvpUI5.d.mts +98 -0
  26. package/dist/index-BXxhKmeA.d.mts +1 -0
  27. package/dist/index-Cc7fCJU9.d.mts +1 -0
  28. package/dist/index-CqdNToYT.d.cts +1 -0
  29. package/dist/index-DWPDThxu.d.cts +1 -0
  30. package/dist/index.cjs +702 -77
  31. package/dist/index.d.cts +185 -12
  32. package/dist/index.d.mts +190 -17
  33. package/dist/index.mjs +648 -28
  34. package/dist/{deepkit/schemas/reflection.d.mts → plugin-BaInAuAh.d.mts} +326 -59
  35. package/dist/{deepkit/schemas/reflection.d.cts → plugin-BwuEBScL.d.cts} +268 -1
  36. package/dist/plugin-D3B5E_Hg.mjs +1 -0
  37. package/dist/plugin-D5qyQPqC.cjs +0 -0
  38. package/dist/resolved-BZG2cwRG.d.cts +1789 -0
  39. package/dist/resolved-V5COsfDu.d.mts +1791 -0
  40. package/dist/runtime-Bisl_1Ja.cjs +0 -0
  41. package/dist/runtime-Q8Ni8SeN.d.cts +794 -0
  42. package/dist/runtime-azNoeKr-.mjs +1 -0
  43. package/dist/runtime-qZ0Z2kEd.d.mts +794 -0
  44. package/dist/types/index.cjs +3 -0
  45. package/dist/types/index.d.cts +4 -2
  46. package/dist/types/index.d.mts +5 -2
  47. package/dist/types/index.mjs +4 -0
  48. package/dist/types/plugin.cjs +1 -0
  49. package/dist/types/plugin.d.cts +3 -156
  50. package/dist/types/plugin.d.mts +4 -158
  51. package/dist/types/plugin.mjs +2 -0
  52. package/dist/types/runtime.cjs +1 -0
  53. package/dist/types/runtime.d.cts +2 -793
  54. package/dist/types/runtime.d.mts +2 -793
  55. package/dist/types/runtime.mjs +2 -0
  56. package/dist/types-DwElXV6q.mjs +1 -0
  57. package/dist/types-MYBaygjr.cjs +0 -0
  58. package/package.json +7 -7
  59. package/dist/_virtual/rolldown_runtime.cjs +0 -37
  60. package/dist/_virtual/rolldown_runtime.mjs +0 -29
  61. package/dist/babel/index.cjs +0 -1
  62. package/dist/babel/index.d.mts +0 -1
  63. package/dist/babel/index.mjs +0 -3
  64. package/dist/babel/plugin.cjs +0 -121
  65. package/dist/babel/plugin.d.cts +0 -7
  66. package/dist/babel/plugin.d.mts +0 -9
  67. package/dist/babel/plugin.mjs +0 -119
  68. package/dist/deepkit/schemas/reflection.cjs +0 -3940
  69. package/dist/deepkit/schemas/reflection.mjs +0 -3938
  70. package/dist/deepkit/schemas/reflection2.cjs +0 -4112
  71. package/dist/deepkit/schemas/reflection2.mjs +0 -4110
  72. package/dist/deepkit/src/capnp.cjs +0 -913
  73. package/dist/deepkit/src/capnp.mjs +0 -911
  74. package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
  75. package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
  76. package/dist/deepkit/src/reflect-type.cjs +0 -22
  77. package/dist/deepkit/src/reflect-type.mjs +0 -20
  78. package/dist/deepkit/src/resolve-reflections.cjs +0 -16
  79. package/dist/deepkit/src/resolve-reflections.mjs +0 -15
  80. package/dist/deepkit/src/transformer.cjs +0 -52
  81. package/dist/deepkit/src/transformer.mjs +0 -49
  82. package/dist/deepkit/src/transpile.cjs +0 -29
  83. package/dist/deepkit/src/transpile.mjs +0 -27
  84. package/dist/deepkit/src/types.d.cts +0 -10
  85. package/dist/deepkit/src/types.d.mts +0 -10
  86. package/dist/deepkit/src/utilities.cjs +0 -66
  87. package/dist/deepkit/src/utilities.mjs +0 -65
  88. package/dist/deepkit/src/vendor/type-compiler/index.cjs +0 -38
  89. package/dist/deepkit/src/vendor/type-compiler/index.mjs +0 -19
  90. package/dist/deepkit/src/vendor/type.cjs +0 -20
  91. package/dist/deepkit/src/vendor/type.d.cts +0 -7
  92. package/dist/deepkit/src/vendor/type.d.mts +0 -7
  93. package/dist/deepkit/src/vendor/type.mjs +0 -11
  94. package/dist/helpers/automd-generator.cjs +0 -22
  95. package/dist/helpers/automd-generator.mjs +0 -21
  96. package/dist/helpers/create-reflection-resource.cjs +0 -55
  97. package/dist/helpers/create-reflection-resource.d.cts +0 -15
  98. package/dist/helpers/create-reflection-resource.d.mts +0 -15
  99. package/dist/helpers/create-reflection-resource.mjs +0 -54
  100. package/dist/helpers/index.cjs +0 -6
  101. package/dist/helpers/index.d.mts +0 -6
  102. package/dist/helpers/index.mjs +0 -8
  103. package/dist/helpers/load.cjs +0 -83
  104. package/dist/helpers/load.d.cts +0 -35
  105. package/dist/helpers/load.d.mts +0 -36
  106. package/dist/helpers/load.mjs +0 -80
  107. package/dist/helpers/persistence.cjs +0 -214
  108. package/dist/helpers/persistence.d.cts +0 -84
  109. package/dist/helpers/persistence.d.mts +0 -84
  110. package/dist/helpers/persistence.mjs +0 -202
  111. package/dist/helpers/reflect.cjs +0 -111
  112. package/dist/helpers/reflect.d.cts +0 -46
  113. package/dist/helpers/reflect.d.mts +0 -46
  114. package/dist/helpers/reflect.mjs +0 -103
  115. package/dist/helpers/source-file-env.cjs +0 -28
  116. package/dist/helpers/source-file-env.d.cts +0 -8
  117. package/dist/helpers/source-file-env.d.mts +0 -8
  118. package/dist/helpers/source-file-env.mjs +0 -26
  119. package/dist/helpers/template-helpers.cjs +0 -42
  120. package/dist/helpers/template-helpers.d.cts +0 -15
  121. package/dist/helpers/template-helpers.d.mts +0 -15
  122. package/dist/helpers/template-helpers.mjs +0 -41
  123. package/dist/plugin-alloy/src/core/components/output.cjs +0 -45
  124. package/dist/plugin-alloy/src/core/components/output.mjs +0 -44
  125. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -22
  126. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -21
  127. package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -64
  128. package/dist/plugin-alloy/src/core/components/source-file.d.cts +0 -23
  129. package/dist/plugin-alloy/src/core/components/source-file.d.mts +0 -23
  130. package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -62
  131. package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
  132. package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
  133. package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
  134. package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
  135. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
  136. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
  137. package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
  138. package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
  139. package/dist/plugin-alloy/src/index.cjs +0 -93
  140. package/dist/plugin-alloy/src/index.mjs +0 -91
  141. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -115
  142. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -114
  143. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -39
  144. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -38
  145. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -18
  146. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
  147. package/dist/plugin-alloy/src/types/components.d.mts +0 -25
  148. package/dist/plugin-alloy/src/types/index.d.mts +0 -2
  149. package/dist/plugin-alloy/src/types/plugin.d.cts +0 -37
  150. package/dist/plugin-alloy/src/types/plugin.d.mts +0 -37
  151. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -57
  152. package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +0 -25
  153. package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +0 -26
  154. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -56
  155. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -126
  156. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -124
  157. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -442
  158. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +0 -27
  159. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +0 -28
  160. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -433
  161. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -194
  162. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +0 -14
  163. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +0 -15
  164. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -191
  165. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -68
  166. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +0 -11
  167. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +0 -12
  168. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -67
  169. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -124
  170. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -123
  171. package/dist/plugin-automd/src/index.cjs +0 -101
  172. package/dist/plugin-automd/src/index.mjs +0 -98
  173. package/dist/plugin-automd/src/types/plugin.d.cts +0 -38
  174. package/dist/plugin-automd/src/types/plugin.d.mts +0 -40
  175. package/dist/plugin-automd/src/types/toc.d.cts +0 -33
  176. package/dist/plugin-automd/src/types/toc.d.mts +0 -33
  177. package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
  178. package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
  179. package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
  180. package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
  181. package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
  182. package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
  183. package/dist/plugin-babel/src/helpers/index.cjs +0 -5
  184. package/dist/plugin-babel/src/helpers/index.mjs +0 -7
  185. package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
  186. package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
  187. package/dist/plugin-babel/src/helpers/options.cjs +0 -50
  188. package/dist/plugin-babel/src/helpers/options.mjs +0 -47
  189. package/dist/plugin-babel/src/index.cjs +0 -91
  190. package/dist/plugin-babel/src/index.mjs +0 -89
  191. package/dist/plugin-babel/src/types/index.d.mts +0 -1
  192. package/dist/plugin-babel/src/types/plugin.d.cts +0 -15
  193. package/dist/plugin-babel/src/types/plugin.d.mts +0 -15
  194. package/dist/powerlines/schemas/fs.d.mts +0 -1
  195. package/dist/powerlines/src/api.d.mts +0 -7
  196. package/dist/powerlines/src/index.d.mts +0 -12
  197. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -5
  198. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
  199. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
  200. package/dist/powerlines/src/lib/entry.cjs +0 -12
  201. package/dist/powerlines/src/lib/entry.mjs +0 -14
  202. package/dist/powerlines/src/lib/logger.cjs +0 -41
  203. package/dist/powerlines/src/lib/logger.mjs +0 -39
  204. package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
  205. package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
  206. package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
  207. package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
  208. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
  209. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
  210. package/dist/powerlines/src/types/api.d.mts +0 -5
  211. package/dist/powerlines/src/types/babel.d.cts +0 -23
  212. package/dist/powerlines/src/types/babel.d.mts +0 -23
  213. package/dist/powerlines/src/types/build.d.cts +0 -145
  214. package/dist/powerlines/src/types/build.d.mts +0 -147
  215. package/dist/powerlines/src/types/commands.d.cts +0 -8
  216. package/dist/powerlines/src/types/commands.d.mts +0 -9
  217. package/dist/powerlines/src/types/config.d.cts +0 -380
  218. package/dist/powerlines/src/types/config.d.mts +0 -381
  219. package/dist/powerlines/src/types/context.d.cts +0 -414
  220. package/dist/powerlines/src/types/context.d.mts +0 -416
  221. package/dist/powerlines/src/types/fs.d.cts +0 -486
  222. package/dist/powerlines/src/types/fs.d.mts +0 -486
  223. package/dist/powerlines/src/types/hooks.d.mts +0 -2
  224. package/dist/powerlines/src/types/index.d.mts +0 -12
  225. package/dist/powerlines/src/types/plugin.d.cts +0 -231
  226. package/dist/powerlines/src/types/plugin.d.mts +0 -231
  227. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  228. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  229. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  230. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
  231. package/dist/powerlines/src/types/unplugin.d.mts +0 -7
package/dist/index.mjs CHANGED
@@ -1,33 +1,653 @@
1
- import { type_exports } from "./deepkit/src/vendor/type.mjs";
2
- import src_default$1 from "./plugin-alloy/src/index.mjs";
3
- import src_default$2 from "./plugin-automd/src/index.mjs";
4
- import src_default$3 from "./plugin-babel/src/index.mjs";
5
- import { BaseEnv, BaseSecrets, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
6
- import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.mjs";
7
- import { envBabelPlugin } from "./babel/plugin.mjs";
8
- import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.mjs";
9
- import { loadEnv, loadEnvFromContext } from "./helpers/load.mjs";
10
- import { createReflectionResource } from "./helpers/create-reflection-resource.mjs";
11
- import { EnvBuiltin, EnvTypeDefinition } from "./components/env.mjs";
12
- import { env } from "./helpers/automd-generator.mjs";
13
- import "./babel/index.mjs";
14
- import { EnvDocs } from "./components/docs.mjs";
15
- import "./components/index.mjs";
16
- import { createTemplateReflection } from "./helpers/template-helpers.mjs";
17
- import "./helpers/index.mjs";
18
- import { createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { A as reflectSecrets, C as BaseEnv, D as mergeEnvReflections, E as createSecretsReflection, M as convertFromCapnp, N as PowerlinesContext, O as mergeSecretsReflections, S as writeEnvTypeReflection, T as createEnvReflection, _ as readEnvTypeReflection, a as removeEnvPrefix, b as writeEnvReflection, f as getEnvDefaultTypeDefinition, g as readEnvReflection, h as getSecretsDefaultTypeDefinition, i as formatEnvField, j as SerializedTypes, k as reflectEnv, m as getEnvTypeReflectionsPath, n as loadEnv, p as getEnvReflectionsPath, r as loadEnvFromContext, t as createReflectionResource, v as readSecretsReflection, w as BaseSecrets, x as writeEnvReflectionSync, y as resolveRuntimeTypeFile } from "./create-reflection-resource-BNYxBgW2.mjs";
2
+ import { n as EnvTypeDefinition, r as stringifyDefaultValue, t as EnvBuiltin } from "./env-IQvgnabX.mjs";
3
+ import { t as EnvDocs } from "./docs-B66b9li3.mjs";
4
+ import "./components-CNIQFfeK.mjs";
5
+ import "./plugin-D3B5E_Hg.mjs";
6
+ import "./runtime-azNoeKr-.mjs";
7
+ import "./types-DwElXV6q.mjs";
8
+ import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
9
+ import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType, stringifyType } from "@powerlines/deepkit/vendor/type";
10
+ import { Output, Show, computed, ref, renderAsync, splitProps, traverseOutput } from "@alloy-js/core";
11
+ import alloy from "@alloy-js/rollup-plugin";
12
+ import { StormJSON } from "@stryke/json/storm-json";
13
+ import { replacePath } from "@stryke/path/replace";
19
14
  import { toArray } from "@stryke/convert/to-array";
15
+ import { isDirectory } from "@stryke/fs/is-file";
16
+ import { listFiles } from "@stryke/fs/list-files";
17
+ import { appendPath } from "@stryke/path/append";
18
+ import { isAbsolutePath } from "@stryke/path/is-type";
19
+ import { joinPaths } from "@stryke/path/join-paths";
20
+ import { defineGenerator, loadConfig, resolveConfig, transform } from "automd";
21
+ import { loadConfig as loadConfig$1 } from "c12";
20
22
  import defu from "defu";
23
+ import toc from "markdown-toc";
24
+ import { transformAsync } from "@babel/core";
21
25
  import { LogLevelLabel } from "@storm-software/config-tools/types";
26
+ import { findFileExtension, findFileExtensionSafe } from "@stryke/path/file-path-fns";
22
27
  import { isParentPath } from "@stryke/path/is-parent-path";
28
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
29
+ import { isFunction } from "@stryke/type-checks/is-function";
30
+ import "@stryke/type-checks/is-object";
31
+ import { isSetString } from "@stryke/type-checks/is-set-string";
32
+ import chalk from "chalk";
33
+ import _generate from "@babel/generator";
34
+ import "@babel/parser";
35
+ import { declare } from "@babel/helper-plugin-utils";
36
+ import "@storm-software/config-tools/logger";
37
+ import "@storm-software/config-tools/utilities/colors";
38
+ import "@stryke/helpers/noop";
39
+ import { kebabCase } from "@stryke/string-format/kebab-case";
23
40
  import { titleCase } from "@stryke/string-format/title-case";
41
+ import * as t from "@babel/types";
42
+ import { isString } from "@stryke/type-checks/is-string";
24
43
  import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
25
44
  import { ENV_PREFIXES } from "@stryke/env/types";
26
45
  import { existsSync } from "@stryke/fs/exists";
27
46
  import { createDirectory } from "@stryke/fs/helpers";
28
- import { joinPaths } from "@stryke/path/join";
47
+ import { joinPaths as joinPaths$1 } from "@stryke/path/join";
29
48
  import { constantCase } from "@stryke/string-format/constant-case";
49
+ import * as capnp from "@stryke/capnp";
50
+ import { readFileBufferSync } from "@stryke/fs/buffer";
51
+ import { existsSync as existsSync$1 } from "node:fs";
30
52
 
53
+ //#region ../plugin-alloy/src/core/components/output.tsx
54
+ /**
55
+ * Output component for rendering the Powerlines plugin's output files via templates.
56
+ */
57
+ function Output$1(props) {
58
+ const [{ children, context, meta, basePath }, rest] = splitProps(props, [
59
+ "children",
60
+ "context",
61
+ "meta",
62
+ "basePath"
63
+ ]);
64
+ const contextRef = ref(context);
65
+ const metaRef = ref(meta ?? {});
66
+ const basePathRef = computed(() => basePath ? replacePath(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
67
+ return createComponent(Output, mergeProps(rest, {
68
+ get basePath() {
69
+ return basePathRef.value;
70
+ },
71
+ get children() {
72
+ return createComponent(PowerlinesContext.Provider, {
73
+ value: {
74
+ ref: contextRef,
75
+ meta: metaRef
76
+ },
77
+ get children() {
78
+ return createComponent(Show, {
79
+ get when() {
80
+ return Boolean(contextRef.value);
81
+ },
82
+ children
83
+ });
84
+ }
85
+ });
86
+ }
87
+ }));
88
+ }
89
+
90
+ //#endregion
91
+ //#region ../plugin-alloy/src/index.tsx
92
+ /**
93
+ * Alloy-js plugin for Powerlines.
94
+ *
95
+ * @param options - The Alloy-js plugin user configuration options.
96
+ * @returns A Powerlines plugin that integrates Alloy-js transformations.
97
+ */
98
+ const plugin$3 = (options = {}) => {
99
+ return [{
100
+ name: "alloy:config",
101
+ config() {
102
+ return {
103
+ alloy: {
104
+ typescript: true,
105
+ ...options
106
+ },
107
+ build: {
108
+ inputOptions: { transform: { jsx: {
109
+ runtime: "classic",
110
+ pragma: "Alloy.createElement",
111
+ importSource: "@alloy-js/core"
112
+ } } },
113
+ plugins: [alloy()]
114
+ }
115
+ };
116
+ },
117
+ async configResolved() {
118
+ if (this.tsconfig.tsconfigJson.compilerOptions?.jsx !== "preserve" || this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !== "@alloy-js/core") {
119
+ this.tsconfig.tsconfigJson.compilerOptions ??= {};
120
+ if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
121
+ if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
122
+ await this.fs.write(this.tsconfig.tsconfigFilePath, StormJSON.stringify(this.tsconfig.tsconfigJson));
123
+ }
124
+ this.dependencies["@alloy-js/core"] = "^0.22.0";
125
+ if (this.config.alloy?.typescript !== false) this.dependencies["@alloy-js/typescript"] = "^0.22.0";
126
+ if (this.config.alloy?.json === true) this.dependencies["@alloy-js/json"] = "^0.22.0";
127
+ if (this.config.alloy?.markdown === true) this.dependencies["@alloy-js/markdown"] = "^0.22.0";
128
+ }
129
+ }, {
130
+ name: "alloy:update-context",
131
+ configResolved: {
132
+ order: "pre",
133
+ async handler() {
134
+ this.render = async (children) => {
135
+ const _self$ = this;
136
+ const meta = {};
137
+ await traverseOutput(await renderAsync(createComponent(Output$1, {
138
+ context: _self$,
139
+ meta,
140
+ get basePath() {
141
+ return _self$.workspaceConfig.workspaceRoot;
142
+ },
143
+ children
144
+ })), {
145
+ visitDirectory: (directory) => {
146
+ if (this.fs.existsSync(directory.path)) return;
147
+ this.fs.mkdirSync(directory.path);
148
+ },
149
+ visitFile: (file) => {
150
+ if ("contents" in file) {
151
+ const metadata = meta[file.path] ?? {};
152
+ if (metadata.kind === "builtin") {
153
+ if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
154
+ this.emitBuiltinSync(file.contents, metadata.id, file.path, {
155
+ skipFormat: metadata.skipFormat,
156
+ storage: metadata.storage
157
+ });
158
+ } else if (metadata.kind === "entry") this.emitEntrySync(file.contents, file.path, {
159
+ skipFormat: metadata.skipFormat,
160
+ storage: metadata.storage,
161
+ ...metadata.typeDefinition ?? {}
162
+ });
163
+ else this.emitSync(file.contents, file.path, metadata);
164
+ } else this.fs.copySync(file.sourcePath, file.path);
165
+ }
166
+ });
167
+ };
168
+ }
169
+ }
170
+ }];
171
+ };
172
+ var src_default$1 = plugin$3;
173
+
174
+ //#endregion
175
+ //#region ../plugin-automd/src/index.ts
176
+ /**
177
+ * AutoMD Plugin
178
+ *
179
+ * @remarks
180
+ * A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.
181
+ *
182
+ * @see https://automd.unjs.io/
183
+ *
184
+ * @param options - The plugin options.
185
+ * @returns A Powerlines plugin instance.
186
+ */
187
+ const plugin$2 = (options = {}) => {
188
+ return {
189
+ name: "automd",
190
+ async config() {
191
+ const config = await loadConfig(joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
192
+ if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = toArray(config.prefix ?? []);
193
+ if (!config.prefix.includes("automd")) config.prefix.push("automd");
194
+ if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
195
+ return { automd: defu(config ?? {}, {
196
+ configFile: options.configFile,
197
+ allowIssues: true,
198
+ dir: this.config.projectRoot,
199
+ watch: false,
200
+ input: "README.md",
201
+ toc: {
202
+ maxDepth: 6,
203
+ bullets: "-"
204
+ }
205
+ }) };
206
+ },
207
+ async configResolved() {
208
+ if (this.config.framework && !toArray(this.config.automd.prefix).includes(this.config.framework)) this.config.automd.prefix = toArray(this.config.automd.prefix).concat(this.config.framework);
209
+ if (this.config.automd.configFile) {
210
+ const { config } = await loadConfig$1({
211
+ cwd: this.config.automd.dir,
212
+ configFile: this.config.automd.configFile,
213
+ defaults: {
214
+ ignore: [
215
+ "**/node_modules",
216
+ "**/dist",
217
+ "**/.*"
218
+ ],
219
+ dir: this.config.automd.dir
220
+ }
221
+ });
222
+ this.config.automd = resolveConfig(defu(this.config.automd, {
223
+ ...config,
224
+ prefix: toArray(config.prefix ?? [])
225
+ }));
226
+ }
227
+ this.config.automd.input = (await Promise.all(toArray(this.config.automd.input).map(async (input) => {
228
+ if (input.includes("*")) return listFiles(isAbsolutePath(input) ? input : appendPath(input, this.config.projectRoot), { ignore: this.config.automd.ignore });
229
+ return isAbsolutePath(input) ? input : appendPath(input, this.config.projectRoot);
230
+ }))).flat();
231
+ if (this.config.automd.output && !isAbsolutePath(this.config.automd.output)) this.config.automd.output = appendPath(this.config.automd.output, this.config.projectRoot);
232
+ this.config.automd.generators ??= {};
233
+ if (this.config.automd.toc !== false) this.config.automd.generators.toc ??= {
234
+ name: "toc",
235
+ generate: (ctx) => {
236
+ const opts = this.config.automd.toc ?? {};
237
+ return { contents: toc(ctx.block.md, {
238
+ ...opts,
239
+ maxdepth: opts.maxDepth,
240
+ first1: opts.firstH1
241
+ }).content };
242
+ }
243
+ };
244
+ },
245
+ async docs() {
246
+ await Promise.all(toArray(this.config.automd.input).map(async (input) => {
247
+ const contents = await this.fs.read(input);
248
+ if (contents) {
249
+ const result = await transform(contents, this.config.automd);
250
+ 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.`);
251
+ if (result.hasChanged) await this.fs.write(appendPath(this.config.automd.output ? isDirectory(this.config.automd.output) ? replacePath(input, this.config.automd.output) : this.config.automd.output : input, this.config.projectRoot), result.contents);
252
+ }
253
+ }));
254
+ }
255
+ };
256
+ };
257
+ var src_default$2 = plugin$2;
258
+
259
+ //#endregion
260
+ //#region ../plugin-babel/src/helpers/filters.ts
261
+ function getPluginName(plugin$4) {
262
+ return isSetString(plugin$4) ? plugin$4 : Array.isArray(plugin$4) && plugin$4.length > 0 ? getPluginName(plugin$4[0]) : plugin$4.$$name || plugin$4.name ? plugin$4.$$name || plugin$4.name : void 0;
263
+ }
264
+ /**
265
+ * Check if a Babel plugin is a duplicate of another plugin in the list.
266
+ *
267
+ * @param plugins - The list of existing Babel plugins.
268
+ * @param plugin - The Babel plugin to check for duplicates.
269
+ * @returns True if the plugin is a duplicate, false otherwise.
270
+ */
271
+ function isDuplicatePlugin(plugins, plugin$4) {
272
+ return !!(getPluginName(plugin$4) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin$4)));
273
+ }
274
+
275
+ //#endregion
276
+ //#region ../plugin-babel/src/helpers/options.ts
277
+ function resolvePluginFunction(context, plugin$4) {
278
+ try {
279
+ return Array.isArray(plugin$4) && plugin$4.length > 0 && plugin$4[0] ? isFunction(plugin$4[0]) ? plugin$4[0](context) : plugin$4[0] : isFunction(plugin$4) ? plugin$4(context) : plugin$4;
280
+ } catch {
281
+ return plugin$4[0];
282
+ }
283
+ }
284
+ /**
285
+ * Resolve the [Babel](https://babeljs.io/) plugin.
286
+ *
287
+ * @param context - The context for the transformation.
288
+ * @param code - The code to be transformed.
289
+ * @param id - The ID of the source file.
290
+ * @param plugin - The Babel plugin to resolve.
291
+ * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
292
+ */
293
+ function resolveBabelPlugin(context, code$1, id, plugin$4) {
294
+ if (Array.isArray(plugin$4) && plugin$4.length > 0 && plugin$4[0]) {
295
+ if (plugin$4.length > 2 && plugin$4[2] && isFunction(plugin$4[2]) && !plugin$4[2](code$1, id)) {
296
+ context.log(LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.bold.cyanBright(getPluginName(plugin$4) || "unnamed")} for ${id}`);
297
+ return;
298
+ }
299
+ return plugin$4.length > 2 ? [
300
+ resolvePluginFunction(context, plugin$4),
301
+ plugin$4[1],
302
+ plugin$4[2]
303
+ ] : [
304
+ resolvePluginFunction(context, plugin$4),
305
+ plugin$4[1],
306
+ null
307
+ ];
308
+ }
309
+ return [
310
+ resolvePluginFunction(context, plugin$4),
311
+ {},
312
+ null
313
+ ];
314
+ }
315
+
316
+ //#endregion
317
+ //#region ../plugin-babel/src/helpers/ast-utils.ts
318
+ let generate = _generate;
319
+ if ("default" in generate) generate = generate.default;
320
+
321
+ //#endregion
322
+ //#region ../powerlines/src/lib/logger.ts
323
+ const BADGE_COLORS = [
324
+ "#00A0DD",
325
+ "#6FCE4E",
326
+ "#FBBF24",
327
+ "#F43F5E",
328
+ "#3B82F6",
329
+ "#A855F7",
330
+ "#469592",
331
+ "#288EDF",
332
+ "#D8B4FE",
333
+ "#10B981",
334
+ "#EF4444",
335
+ "#F0EC56",
336
+ "#F472B6",
337
+ "#22D3EE",
338
+ "#EAB308",
339
+ "#84CC16",
340
+ "#F87171",
341
+ "#0EA5E9",
342
+ "#D946EF",
343
+ "#FACC15",
344
+ "#34D399",
345
+ "#8B5CF6"
346
+ ];
347
+ const extendLog = (logFn, name) => {
348
+ return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
349
+ };
350
+
351
+ //#endregion
352
+ //#region ../plugin-babel/src/helpers/create-plugin.ts
353
+ /**
354
+ * Create a Babel plugin using the provided builder function.
355
+ *
356
+ * @param name - The name of the plugin.
357
+ * @param builder - The builder function that defines the plugin behavior.
358
+ * @returns A Babel plugin declaration.
359
+ */
360
+ function createBabelPlugin(name, builder) {
361
+ const plugin$4 = (context) => {
362
+ return declare((api, options, dirname) => {
363
+ api.cache.using(() => context.meta.checksum);
364
+ api.assertVersion("^7.0.0-0");
365
+ const log = extendLog(context.log, name);
366
+ log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
367
+ const result = builder({
368
+ log,
369
+ name,
370
+ api,
371
+ options,
372
+ context,
373
+ dirname
374
+ });
375
+ result.name = name;
376
+ log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
377
+ return result;
378
+ });
379
+ };
380
+ plugin$4.$$name = name;
381
+ return plugin$4;
382
+ }
383
+
384
+ //#endregion
385
+ //#region ../plugin-babel/src/helpers/module-helpers.ts
386
+ /**
387
+ * Adds an import to the program if it doesn't already exist.
388
+ *
389
+ * @param path - The current NodePath in the AST.
390
+ * @param specifier - The import specifier.
391
+ */
392
+ function addImport(path, specifier) {
393
+ addImportsToProgram(path.scope.getProgramParent().path, specifier);
394
+ }
395
+ function isNonNamespacedImport(importDeclPath) {
396
+ return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
397
+ }
398
+ function getExistingImports(program) {
399
+ const existingImports = /* @__PURE__ */ new Map();
400
+ program.traverse({ ImportDeclaration(path) {
401
+ if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
402
+ } });
403
+ return existingImports;
404
+ }
405
+ function addImportsToProgram(path, specifier) {
406
+ /**
407
+ * If an existing import of this module exists (ie \`import \{ ... \} from
408
+ * '<moduleName>'\`), inject new imported specifiers into the list of
409
+ * destructured variables.
410
+ */
411
+ if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(t.identifier(specifier.name || specifier.imported), t.identifier(specifier.imported))], t.stringLiteral(specifier.module)));
412
+ }
413
+
414
+ //#endregion
415
+ //#region ../plugin-babel/src/index.ts
416
+ /**
417
+ * Babel plugin for Powerlines.
418
+ *
419
+ * @param options - The Babel plugin user configuration options.
420
+ * @returns A Powerlines plugin that integrates Babel transformations.
421
+ */
422
+ const plugin$1 = (options = {}) => {
423
+ return {
424
+ name: "babel",
425
+ config() {
426
+ if (!isSetObject(options)) return;
427
+ return { transform: { babel: options } };
428
+ },
429
+ configResolved: {
430
+ order: "pre",
431
+ handler() {
432
+ this.devDependencies["@babel/core"] = "^7.28.4";
433
+ this.config.transform.babel = defu(this.config.transform.babel ?? {}, {
434
+ plugins: [],
435
+ presets: []
436
+ });
437
+ }
438
+ },
439
+ async transform(code$1, id) {
440
+ if (isParentPath(id, this.powerlinesPath) || code$1.includes("/* @storm-ignore */") || code$1.includes("/* @storm-disable */")) {
441
+ this.log(LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
442
+ return {
443
+ code: code$1,
444
+ id
445
+ };
446
+ }
447
+ this.log(LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
448
+ const plugins = this.config.transform.babel.plugins.map((plugin$4) => resolveBabelPlugin(this, code$1, id, plugin$4)).filter((plugin$4, _, arr) => plugin$4 && !isDuplicatePlugin(arr, plugin$4));
449
+ const presets = this.config.transform.babel.presets.map((preset) => resolveBabelPlugin(this, code$1, id, preset)).filter((preset, _, arr) => preset && !isDuplicatePlugin(arr, preset));
450
+ if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
451
+ code: code$1,
452
+ id
453
+ };
454
+ if ([
455
+ "ts",
456
+ "cts",
457
+ "mts",
458
+ "tsx"
459
+ ].includes(findFileExtensionSafe(id)) && !isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: findFileExtension(id) === ".tsx" }]);
460
+ const result = await transformAsync(code$1, {
461
+ highlightCode: true,
462
+ code: true,
463
+ ast: false,
464
+ cloneInputAst: false,
465
+ comments: true,
466
+ sourceType: "module",
467
+ configFile: false,
468
+ babelrc: false,
469
+ envName: this.config.mode,
470
+ caller: { name: this.config.framework },
471
+ ...this.config.transform.babel ?? {},
472
+ filename: id,
473
+ plugins: plugins.map((plugin$4) => {
474
+ return Array.isArray(plugin$4) && plugin$4.length >= 2 ? [plugin$4[0], defu(plugin$4.length > 1 && plugin$4[1] ? plugin$4[1] : {}, { options })] : plugin$4;
475
+ }).filter(Boolean),
476
+ presets: presets.map((preset) => {
477
+ return Array.isArray(preset) && preset.length >= 2 ? [preset[0], defu(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
478
+ }).filter(Boolean)
479
+ });
480
+ if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
481
+ return {
482
+ code: result.code,
483
+ id
484
+ };
485
+ }
486
+ };
487
+ };
488
+ var src_default$3 = plugin$1;
489
+
490
+ //#endregion
491
+ //#region src/babel/plugin.ts
492
+ const envBabelPlugin = createBabelPlugin("env", ({ log, context }) => {
493
+ function extractEnv(node, pass, isInjectable = false) {
494
+ const envTypesAliasProperties = context.env.types.env?.getProperties().filter((prop) => prop.getAlias().length > 0);
495
+ if (node.name) {
496
+ 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}_`, "")))));
497
+ let name = node.name;
498
+ if (prefix) name = node.name.replace(`${prefix}_`, "");
499
+ log(LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
500
+ if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(name))) {
501
+ const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find((prop) => prop.getAlias().includes(name));
502
+ if (!envProperty || envProperty.isIgnored()) return;
503
+ if (!context.env.used.env.hasProperty(name)) context.env.used.env.addProperty(envProperty.property);
504
+ if (context.config.env.inject && isInjectable) {
505
+ let value = context.env.parsed?.[name];
506
+ if (value === void 0) {
507
+ const prefix$1 = context.config.env.prefix.find((pre) => {
508
+ return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
509
+ });
510
+ if (prefix$1) value = context.env.parsed[`${prefix$1.replace(/_$/g, "")}_${name}`];
511
+ }
512
+ value ??= envProperty.getDefaultValue();
513
+ if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
514
+ return stringifyDefaultValue(envProperty, value);
515
+ }
516
+ } 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"}.
517
+
518
+ 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`);
519
+ }
520
+ }
521
+ return {
522
+ visitor: { MemberExpression(path, pass) {
523
+ if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "$storm" }) && path.get("property")?.isIdentifier()) {
524
+ const identifier = path.get("property")?.node;
525
+ extractEnv(identifier, pass, false);
526
+ path.replaceWithSourceString(`env.${identifier.name}`);
527
+ addImport(path, {
528
+ module: "storm:env",
529
+ name: "env",
530
+ imported: "env"
531
+ });
532
+ } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isCallExpression({ callee: {
533
+ name: "useStorm",
534
+ type: "Identifier"
535
+ } }) && path.get("property")?.isIdentifier()) {
536
+ const identifier = path.get("property")?.node;
537
+ extractEnv(identifier, pass, false);
538
+ path.replaceWithSourceString(`env.${identifier.name}`);
539
+ addImport(path, {
540
+ module: "storm:env",
541
+ name: "env",
542
+ imported: "env"
543
+ });
544
+ } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
545
+ const identifier = path.get("property")?.node;
546
+ if (!identifier.name) return;
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")?.isMetaProperty() && 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
+ }
565
+ } },
566
+ post() {
567
+ log(LogLevelLabel.TRACE, `Adding environment variables from ${this.filename || "unknown file"} to env.json.`);
568
+ let persistedEnv = ReflectionClass.from({
569
+ kind: ReflectionKind.objectLiteral,
570
+ description: `An object containing the environment variables used by the application.`,
571
+ types: []
572
+ });
573
+ const reflectionPath = getEnvReflectionsPath(context, "env");
574
+ if (reflectionPath && existsSync$1(reflectionPath)) {
575
+ log(LogLevelLabel.TRACE, `Environment reflection file found at ${reflectionPath}, reading existing reflection.`);
576
+ persistedEnv = resolveClassType(deserializeType(convertFromCapnp(new capnp.Message(readFileBufferSync(reflectionPath), false).getRoot(SerializedTypes).types)));
577
+ }
578
+ log(LogLevelLabel.TRACE, `Adding new variables to env reflection at ${reflectionPath}.`);
579
+ persistedEnv.getProperties().filter((property) => property.getNameAsString() && !context.env.used.env.hasProperty(property.getNameAsString())).forEach((property) => {
580
+ context.env.used.env.addProperty({
581
+ ...property,
582
+ name: property.getNameAsString(),
583
+ description: property.getDescription() ?? `The ${property.getNameAsString()} variable.`,
584
+ default: property.getDefaultValue(),
585
+ optional: property.isOptional() ? true : void 0,
586
+ readonly: property.isReadonly() ? true : void 0,
587
+ visibility: property.getVisibility(),
588
+ type: property.getType(),
589
+ tags: property.getTags()
590
+ });
591
+ });
592
+ }
593
+ };
594
+ });
595
+
596
+ //#endregion
597
+ //#region src/helpers/automd-generator.ts
598
+ /**
599
+ * AutoMD generator to generate environment variable documentation
600
+ *
601
+ * @param context - The generator context.
602
+ * @returns The generated documentation content.
603
+ */
604
+ const env = (context) => defineGenerator({
605
+ name: "env",
606
+ async generate() {
607
+ const envDocFile = joinPaths(context.config.projectRoot, "docs", "generated", "env.md");
608
+ if (!context.fs.existsSync(envDocFile)) return { contents: "" };
609
+ return { contents: await context.fs.read(envDocFile) || "" };
610
+ }
611
+ });
612
+
613
+ //#endregion
614
+ //#region src/helpers/template-helpers.ts
615
+ /**
616
+ * Creates the reflection data used when generating runtime template files.
617
+ *
618
+ * @param context - The context for the configuration plugin.
619
+ * @param name - The name of the configuration template.
620
+ * @returns The reflection for the specified configuration template.
621
+ */
622
+ async function createTemplateReflection(context, name) {
623
+ const reflection = await readEnvTypeReflection(context, name);
624
+ reflection.getProperties().forEach((prop) => {
625
+ prop.getAlias().filter(Boolean).forEach((alias) => {
626
+ reflection.addProperty({
627
+ name: alias,
628
+ optional: prop.isOptional() ? true : void 0,
629
+ readonly: prop.isReadonly() ? true : void 0,
630
+ description: prop.getDescription(),
631
+ visibility: prop.getVisibility(),
632
+ type: prop.getType(),
633
+ default: prop.getDefaultValue(),
634
+ tags: {
635
+ hidden: prop.isHidden(),
636
+ ignore: prop.isIgnored(),
637
+ internal: prop.isInternal(),
638
+ alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
639
+ title: prop.getTitle() || titleCase(prop.name),
640
+ readonly: prop.isReadonly(),
641
+ permission: prop.getPermission(),
642
+ domain: prop.getDomain()
643
+ }
644
+ });
645
+ });
646
+ });
647
+ return reflection;
648
+ }
649
+
650
+ //#endregion
31
651
  //#region src/index.tsx
32
652
  /**
33
653
  * A Powerlines plugin to inject environment variables into the source code.
@@ -88,10 +708,10 @@ const plugin = (options = {}) => {
88
708
  if (existsSync(getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await readEnvTypeReflection(this, "secrets");
89
709
  if (existsSync(getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await readSecretsReflection(this);
90
710
  } else {
91
- this.env.types.env = await reflectEnv(this, this.config.env.types?.file ? isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : joinPaths(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
711
+ this.env.types.env = await reflectEnv(this, this.config.env.types?.file ? isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : joinPaths$1(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
92
712
  if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
93
713
  await writeEnvTypeReflection(this, this.env.types.env, "env");
94
- this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file ? isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : joinPaths(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
714
+ this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file ? isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : joinPaths$1(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
95
715
  if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
96
716
  await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
97
717
  this.log(LogLevelLabel.TRACE, `Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
@@ -104,8 +724,8 @@ const plugin = (options = {}) => {
104
724
  const aliasKey = envWithAlias.find((prop) => prop?.getAlias().reverse().includes(unprefixedKey));
105
725
  if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
106
726
  });
107
- this.env.used.env = new type_exports.ReflectionClass({
108
- kind: type_exports.ReflectionKind.objectLiteral,
727
+ this.env.used.env = new ReflectionClass({
728
+ kind: ReflectionKind.objectLiteral,
109
729
  typeName: "Env",
110
730
  description: `An object containing the environment configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
111
731
  types: []
@@ -113,8 +733,8 @@ const plugin = (options = {}) => {
113
733
  await writeEnvReflection(this, this.env.used.env, "env");
114
734
  if (this.env.types.secrets) {
115
735
  await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
116
- this.env.used.secrets = new type_exports.ReflectionClass({
117
- kind: type_exports.ReflectionKind.objectLiteral,
736
+ this.env.used.secrets = new ReflectionClass({
737
+ kind: ReflectionKind.objectLiteral,
118
738
  typeName: "Secrets",
119
739
  description: `An object containing the secret configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
120
740
  types: []
@@ -132,10 +752,10 @@ const plugin = (options = {}) => {
132
752
  },
133
753
  async docs() {
134
754
  this.log(LogLevelLabel.TRACE, "Writing Environment documentation for the Powerlines project artifacts.");
135
- const outputPath = joinPaths(this.config.projectRoot, "docs", "generated");
755
+ const outputPath = joinPaths$1(this.config.projectRoot, "docs", "generated");
136
756
  if (!existsSync(outputPath)) await createDirectory(outputPath);
137
757
  const reflection = await readEnvTypeReflection(this, "env");
138
- const envDocFile = joinPaths(outputPath, "env.md");
758
+ const envDocFile = joinPaths$1(outputPath, "env.md");
139
759
  this.log(LogLevelLabel.TRACE, `Documenting environment variables configuration in "${envDocFile}"`);
140
760
  await this.fs.write(envDocFile, `<!-- Generated by ${titleCase(this.config.framework) || "Powerlines"} -->
141
761
 
@@ -144,7 +764,7 @@ Below is a list of environment variables used by the [${this.packageJson.name}](
144
764
  | Name | Description | Type | Default Value | Required |
145
765
  | ---- | ----------- | ---- | ------------- | :------: |
146
766
  ${reflection.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
147
- return `| ${reflectionProperty.getNameAsString().trim()} | ${(reflectionProperty.getDescription()?.replaceAll("\r", "")?.replaceAll("\n", "") ?? "").trim()} | ${(0, type_exports.stringifyType)(reflectionProperty.getType()).trim().replaceAll(" | ", ", or ")} | ${reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : ""} | ${reflectionProperty.isValueRequired() ? "" : "✔"} |`;
767
+ return `| ${reflectionProperty.getNameAsString().trim()} | ${(reflectionProperty.getDescription()?.replaceAll("\r", "")?.replaceAll("\n", "") ?? "").trim()} | ${stringifyType(reflectionProperty.getType()).trim().replaceAll(" | ", ", or ")} | ${reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : ""} | ${reflectionProperty.isValueRequired() ? "" : "✔"} |`;
148
768
  }).join("\n")}
149
769
  `);
150
770
  },