@powerlines/plugin-env 0.13.53 → 0.13.54

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 (198) hide show
  1. package/dist/babel/index.cjs +1 -1
  2. package/dist/babel/index.d.cts +17 -31
  3. package/dist/babel/index.d.mts +17 -0
  4. package/dist/babel/index.mjs +1 -0
  5. package/dist/babel/plugin.cjs +1 -19
  6. package/dist/babel/plugin.d.cts +17 -34
  7. package/dist/babel/plugin.d.mts +17 -0
  8. package/dist/babel/plugin.mjs +1 -0
  9. package/dist/babel-CE47sTzg.mjs +1 -0
  10. package/dist/chunk-CbqXBSoN.mjs +1 -0
  11. package/dist/chunk-DT2f8AgL.cjs +1 -0
  12. package/dist/components/docs.cjs +1 -0
  13. package/dist/components/docs.d.cts +2 -0
  14. package/dist/components/docs.d.mts +2 -0
  15. package/dist/components/docs.mjs +1 -0
  16. package/dist/components/env.cjs +1 -40
  17. package/dist/components/env.d.cts +4 -105
  18. package/dist/components/env.d.mts +4 -0
  19. package/dist/components/env.mjs +1 -0
  20. package/dist/components/index.cjs +1 -1
  21. package/dist/components/index.d.cts +6 -8
  22. package/dist/components/index.d.mts +6 -0
  23. package/dist/components/index.mjs +1 -0
  24. package/dist/components-LyHNrcZE.mjs +1 -0
  25. package/dist/config-D2esSp2r.d.mts +1681 -0
  26. package/dist/config-D2esSp2r.d.mts.map +1 -0
  27. package/dist/config-Dli3ofDp.d.cts +1680 -0
  28. package/dist/config-Dli3ofDp.d.cts.map +1 -0
  29. package/dist/create-reflection-resource-CQHJrkQi.cjs +1 -0
  30. package/dist/create-reflection-resource-D7go0-VG.d.mts +16 -0
  31. package/dist/create-reflection-resource-D7go0-VG.d.mts.map +1 -0
  32. package/dist/create-reflection-resource-DOZmUtSi.d.cts +16 -0
  33. package/dist/create-reflection-resource-DOZmUtSi.d.cts.map +1 -0
  34. package/dist/create-reflection-resource-UtOwX4Ml.mjs +2 -0
  35. package/dist/create-reflection-resource-UtOwX4Ml.mjs.map +1 -0
  36. package/dist/docs-BDiEhcDa.mjs +2 -0
  37. package/dist/docs-BDiEhcDa.mjs.map +1 -0
  38. package/dist/docs-Bhi9smBO.cjs +1 -0
  39. package/dist/docs-BoZkRBO4.d.cts +10 -0
  40. package/dist/docs-BoZkRBO4.d.cts.map +1 -0
  41. package/dist/docs-BwK6pC_c.d.mts +10 -0
  42. package/dist/docs-BwK6pC_c.d.mts.map +1 -0
  43. package/dist/env-0C9Vc_CF.cjs +34 -0
  44. package/dist/env-BQWQzimx.d.cts +113 -0
  45. package/dist/env-BQWQzimx.d.cts.map +1 -0
  46. package/dist/env-D4MK9BWK.mjs +32 -0
  47. package/dist/env-D4MK9BWK.mjs.map +1 -0
  48. package/dist/env-DMqCnKB2.d.mts +113 -0
  49. package/dist/env-DMqCnKB2.d.mts.map +1 -0
  50. package/dist/helpers/create-reflection-resource.cjs +1 -0
  51. package/dist/helpers/create-reflection-resource.d.cts +6 -0
  52. package/dist/helpers/create-reflection-resource.d.mts +6 -0
  53. package/dist/helpers/create-reflection-resource.mjs +1 -0
  54. package/dist/helpers/index.cjs +1 -1
  55. package/dist/helpers/index.d.cts +12 -35
  56. package/dist/helpers/index.d.mts +12 -0
  57. package/dist/helpers/index.mjs +1 -0
  58. package/dist/helpers/load.cjs +1 -7
  59. package/dist/helpers/load.d.cts +6 -60
  60. package/dist/helpers/load.d.mts +6 -0
  61. package/dist/helpers/load.mjs +1 -0
  62. package/dist/helpers/persistence.cjs +1 -7
  63. package/dist/helpers/persistence.d.cts +6 -108
  64. package/dist/helpers/persistence.d.mts +6 -0
  65. package/dist/helpers/persistence.mjs +1 -0
  66. package/dist/helpers/reflect.cjs +1 -7
  67. package/dist/helpers/reflect.d.cts +6 -72
  68. package/dist/helpers/reflect.d.mts +6 -0
  69. package/dist/helpers/reflect.mjs +1 -0
  70. package/dist/helpers/source-file-env.cjs +1 -7
  71. package/dist/helpers/source-file-env.d.cts +2 -7
  72. package/dist/helpers/source-file-env.d.mts +2 -0
  73. package/dist/helpers/source-file-env.mjs +1 -0
  74. package/dist/helpers/template-helpers.cjs +1 -7
  75. package/dist/helpers/template-helpers.d.cts +6 -41
  76. package/dist/helpers/template-helpers.d.mts +6 -0
  77. package/dist/helpers/template-helpers.mjs +1 -0
  78. package/dist/helpers-DfMThUgD.mjs +1 -0
  79. package/dist/helpers-YGhXHw5G.cjs +0 -0
  80. package/dist/index-B3G-X5Fc.d.mts +42 -0
  81. package/dist/index-B3G-X5Fc.d.mts.map +1 -0
  82. package/dist/index-BRBK9zG-.d.cts +1 -0
  83. package/dist/index-Bt4QNofW.d.mts +1 -0
  84. package/dist/index-CRo77wc3.d.mts +1 -0
  85. package/dist/index-CspKFJM1.d.cts +1 -0
  86. package/dist/index-Dpmi5zcN.d.cts +1 -0
  87. package/dist/index-E1euY2F8.d.cts +42 -0
  88. package/dist/index-E1euY2F8.d.cts.map +1 -0
  89. package/dist/index-Wc1llEvP.d.mts +1 -0
  90. package/dist/index.cjs +5 -10
  91. package/dist/index.d.cts +17 -71
  92. package/dist/index.d.mts +17 -0
  93. package/dist/index.mjs +18 -0
  94. package/dist/index.mjs.map +1 -0
  95. package/dist/load-BZTlThWg.mjs +2 -0
  96. package/dist/load-BZTlThWg.mjs.map +1 -0
  97. package/dist/load-CWOZ3u-s.d.cts +36 -0
  98. package/dist/load-CWOZ3u-s.d.cts.map +1 -0
  99. package/dist/load-Dzf30s_a.d.mts +39 -0
  100. package/dist/load-Dzf30s_a.d.mts.map +1 -0
  101. package/dist/load-nUlit5lR.cjs +1 -0
  102. package/dist/{helpers/persistence.d.ts → persistence-BSorOnu8.d.cts} +15 -38
  103. package/dist/persistence-BSorOnu8.d.cts.map +1 -0
  104. package/dist/persistence-Br-YMVb1.mjs +15 -0
  105. package/dist/persistence-Br-YMVb1.mjs.map +1 -0
  106. package/dist/persistence-KaP3-ka1.cjs +14 -0
  107. package/dist/persistence-sVp1g7Mp.d.mts +85 -0
  108. package/dist/persistence-sVp1g7Mp.d.mts.map +1 -0
  109. package/dist/plugin-CRYQ682C.cjs +0 -0
  110. package/dist/plugin-Cl-yPswT.d.cts +1716 -0
  111. package/dist/plugin-Cl-yPswT.d.cts.map +1 -0
  112. package/dist/plugin-Cx61c9gw.mjs +6 -0
  113. package/dist/plugin-Cx61c9gw.mjs.map +1 -0
  114. package/dist/plugin-DrnPbdzR.mjs +1 -0
  115. package/dist/plugin-VRahDLZZ.d.mts +1716 -0
  116. package/dist/plugin-VRahDLZZ.d.mts.map +1 -0
  117. package/dist/plugin-v-FJGggy.cjs +5 -0
  118. package/dist/reflect-C1joiXZ1.d.mts +47 -0
  119. package/dist/reflect-C1joiXZ1.d.mts.map +1 -0
  120. package/dist/reflect-CFNlkro0.d.cts +47 -0
  121. package/dist/reflect-CFNlkro0.d.cts.map +1 -0
  122. package/dist/runtime-BaZivi6m.cjs +0 -0
  123. package/dist/runtime-CIWxfv47.d.cts +795 -0
  124. package/dist/runtime-CIWxfv47.d.cts.map +1 -0
  125. package/dist/runtime-ChZa5p23.d.mts +795 -0
  126. package/dist/runtime-ChZa5p23.d.mts.map +1 -0
  127. package/dist/runtime-DqCYc37d.mjs +1 -0
  128. package/dist/source-file-CLCTB4C7.cjs +1 -0
  129. package/dist/source-file-CjFSCK1w.mjs +2 -0
  130. package/dist/source-file-CjFSCK1w.mjs.map +1 -0
  131. package/dist/source-file-env-BDFTs5WJ.mjs +2 -0
  132. package/dist/source-file-env-BDFTs5WJ.mjs.map +1 -0
  133. package/dist/source-file-env-C6uYyxww.cjs +1 -0
  134. package/dist/{helpers/source-file-env.d.ts → source-file-env-DonDJDV1.d.cts} +5 -3
  135. package/dist/source-file-env-DonDJDV1.d.cts.map +1 -0
  136. package/dist/source-file-env-DzpWKluw.d.mts +9 -0
  137. package/dist/source-file-env-DzpWKluw.d.mts.map +1 -0
  138. package/dist/template-helpers-BDDg5jaw.d.cts +16 -0
  139. package/dist/template-helpers-BDDg5jaw.d.cts.map +1 -0
  140. package/dist/template-helpers-BSbamu0U.cjs +1 -0
  141. package/dist/template-helpers-CLrM_TtO.mjs +2 -0
  142. package/dist/template-helpers-CLrM_TtO.mjs.map +1 -0
  143. package/dist/template-helpers-DmfAtQIT.d.mts +16 -0
  144. package/dist/template-helpers-DmfAtQIT.d.mts.map +1 -0
  145. package/dist/type-CnPIyotQ.d.mts +4 -0
  146. package/dist/type-CnPIyotQ.d.mts.map +1 -0
  147. package/dist/type-D6dRgWJT.d.cts +4 -0
  148. package/dist/type-D6dRgWJT.d.cts.map +1 -0
  149. package/dist/types/index.cjs +1 -1
  150. package/dist/types/index.d.cts +6 -30
  151. package/dist/types/index.d.mts +6 -0
  152. package/dist/types/index.mjs +1 -0
  153. package/dist/types/plugin.cjs +1 -1
  154. package/dist/types/plugin.d.cts +5 -1733
  155. package/dist/types/plugin.d.mts +5 -0
  156. package/dist/types/plugin.mjs +1 -0
  157. package/dist/types/runtime.cjs +1 -1
  158. package/dist/types/runtime.d.cts +3 -25
  159. package/dist/types/runtime.d.mts +3 -0
  160. package/dist/types/runtime.mjs +1 -0
  161. package/dist/types-BCto_Rzj.mjs +1 -0
  162. package/dist/types-DS7T32tb.cjs +0 -0
  163. package/dist/utilities-4S--uN0L.mjs +2 -0
  164. package/dist/utilities-4S--uN0L.mjs.map +1 -0
  165. package/dist/utilities-CxyT2chk.cjs +1 -0
  166. package/package.json +66 -55
  167. package/dist/babel/index.d.ts +0 -31
  168. package/dist/babel/index.js +0 -1
  169. package/dist/babel/plugin.d.ts +0 -34
  170. package/dist/babel/plugin.js +0 -19
  171. package/dist/chunk-FBBMZ4NC.cjs +0 -7
  172. package/dist/chunk-UCUR73HG.js +0 -7
  173. package/dist/components/env.d.ts +0 -105
  174. package/dist/components/env.js +0 -40
  175. package/dist/components/index.d.ts +0 -8
  176. package/dist/components/index.js +0 -1
  177. package/dist/fs-ECFlqnPg.d.cts +0 -378
  178. package/dist/fs-ECFlqnPg.d.ts +0 -378
  179. package/dist/helpers/index.d.ts +0 -35
  180. package/dist/helpers/index.js +0 -1
  181. package/dist/helpers/load.d.ts +0 -60
  182. package/dist/helpers/load.js +0 -7
  183. package/dist/helpers/persistence.js +0 -7
  184. package/dist/helpers/reflect.d.ts +0 -72
  185. package/dist/helpers/reflect.js +0 -7
  186. package/dist/helpers/source-file-env.js +0 -7
  187. package/dist/helpers/template-helpers.d.ts +0 -41
  188. package/dist/helpers/template-helpers.js +0 -7
  189. package/dist/index.d.ts +0 -71
  190. package/dist/index.js +0 -22
  191. package/dist/runtime-B75FziIk.d.ts +0 -2011
  192. package/dist/runtime-DqYFxAEo.d.cts +0 -2011
  193. package/dist/types/index.d.ts +0 -30
  194. package/dist/types/index.js +0 -1
  195. package/dist/types/plugin.d.ts +0 -1733
  196. package/dist/types/runtime.d.ts +0 -25
  197. /package/dist/{types/plugin.js → babel-Bmzkjy1p.cjs} +0 -0
  198. /package/dist/{types/runtime.js → components-BWruXLSx.cjs} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,71 +1,17 @@
1
- import { P as PluginContext, b as Plugin } from './runtime-DqYFxAEo.cjs';
2
- export { E as EnvInterface, S as SecretsInterface, _ as __ΩEnvInterface, c as __ΩSecretsInterface } from './runtime-DqYFxAEo.cjs';
3
- import { Children } from '@alloy-js/core/jsx-runtime';
4
- import { PrintTreeOptions } from '@alloy-js/core';
5
- import { EnvPluginContext, EnvPluginResolvedConfig } from './types/plugin.cjs';
6
- export { EnvPluginOptions, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from './types/plugin.cjs';
7
- export { envBabelPlugin } from './babel/plugin.cjs';
8
- export { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from './components/env.cjs';
9
- export { loadEnv, loadEnvFromContext } from './helpers/load.cjs';
10
- export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from './helpers/persistence.cjs';
11
- export { BaseEnv, BaseSecrets, CreateEnvReflectionOptions, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from './helpers/reflect.cjs';
12
- export { formatEnvField, removeEnvPrefix } from './helpers/source-file-env.cjs';
13
- export { createTemplateReflection } from './helpers/template-helpers.cjs';
14
- import '@stryke/env/get-env-paths';
15
- import '@stryke/http/fetch';
16
- import '@stryke/types/base';
17
- import '@stryke/types/package-json';
18
- import 'jiti';
19
- import 'magic-string';
20
- import 'oxc-parser';
21
- import 'semver';
22
- import 'ts-morph';
23
- import 'undici';
24
- import 'unplugin';
25
- import '@babel/core';
26
- import '@storm-software/build-tools/types';
27
- import '@storm-software/config-tools/types';
28
- import '@storm-software/config/types';
29
- import '@stryke/types/configuration';
30
- import '@stryke/types/file';
31
- import 'vite';
32
- import '@babel/helper-plugin-utils';
33
- import './fs-ECFlqnPg.cjs';
34
- import '@stryke/fs/resolve';
35
- import '@stryke/types/array';
36
- import '@stryke/types/tsconfig';
37
- import 'typescript';
38
- import '@deepkit/type';
39
- import '@stryke/capnp';
40
- import '@stryke/env/types';
41
- import '@alloy-js/typescript';
42
-
43
- type PluginPluginAlloyOptions = Partial<PrintTreeOptions> & {
44
- /**
45
- * If true, the Alloy framework is used to generate JSON output files.
46
- *
47
- * @defaultValue false
48
- */
49
- generatesJson?: boolean;
50
- /**
51
- * If true, the Alloy framework is used to generate Markdown output files.
52
- *
53
- * @defaultValue false
54
- */
55
- generatesMarkdown?: boolean;
56
- };
57
-
58
- interface AlloyPluginOptions {
59
- alloy?: PluginPluginAlloyOptions;
60
- }
61
- type AlloyPluginBuilderResult<TContext extends PluginContext = PluginContext> = Plugin<TContext> & {
62
- render: (this: TContext) => Children;
63
- };
64
- type AlloyPluginBuilder<TContext extends PluginContext = PluginContext, TOptions = any> = <T extends TContext>(options: TOptions) => AlloyPluginBuilderResult<T>;
65
-
66
- /**
67
- * A Powerlines plugin to inject environment variables into the source code.
68
- */
69
- declare const plugin: <T extends EnvPluginContext<EnvPluginResolvedConfig>>(options: Parameters<AlloyPluginBuilder<EnvPluginContext<EnvPluginResolvedConfig>>>[0] & AlloyPluginOptions) => Plugin<T>;
70
-
71
- export { EnvPluginContext, EnvPluginResolvedConfig, plugin as default, plugin };
1
+ import "./type-D6dRgWJT.cjs";
2
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-Cl-yPswT.cjs";
3
+ import "./config-Dli3ofDp.cjs";
4
+ import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-CIWxfv47.cjs";
5
+ import "./index-CspKFJM1.cjs";
6
+ import { n as plugin, t as envBabelPlugin } from "./index-E1euY2F8.cjs";
7
+ import { t as EnvDocs } from "./docs-BoZkRBO4.cjs";
8
+ import { i as __ΩEnvBuiltinProps, n as EnvBuiltinProps, r as EnvTypeDefinition, t as EnvBuiltin } from "./env-BQWQzimx.cjs";
9
+ import "./index-Dpmi5zcN.cjs";
10
+ import { t as createReflectionResource } from "./create-reflection-resource-DOZmUtSi.cjs";
11
+ import { n as loadEnvFromContext, t as loadEnv } from "./load-CWOZ3u-s.cjs";
12
+ import { a as readEnvReflection, c as resolveRuntimeTypeFile, d as writeEnvTypeReflection, i as getSecretsDefaultTypeDefinition, l as writeEnvReflection, n as getEnvReflectionsPath, o as readEnvTypeReflection, r as getEnvTypeReflectionsPath, s as readSecretsReflection, t as getEnvDefaultTypeDefinition, u as writeEnvReflectionSync } from "./persistence-BSorOnu8.cjs";
13
+ import { a as createEnvReflection, c as mergeSecretsReflections, i as __ΩCreateEnvReflectionOptions, l as reflectEnv, n as BaseSecrets, o as createSecretsReflection, r as CreateEnvReflectionOptions, s as mergeEnvReflections, t as BaseEnv, u as reflectSecrets } from "./reflect-CFNlkro0.cjs";
14
+ import { n as removeEnvPrefix, t as formatEnvField } from "./source-file-env-DonDJDV1.cjs";
15
+ import { t as createTemplateReflection } from "./template-helpers-BDDg5jaw.cjs";
16
+ import "./index-BRBK9zG-.cjs";
17
+ export { BaseEnv, BaseSecrets, CreateEnvReflectionOptions, EnvBuiltin, EnvBuiltinProps, EnvDocs, EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, EnvTypeDefinition, SecretsInterface, __ΩCreateEnvReflectionOptions, __ΩEnvBuiltinProps, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface, createEnvReflection, createReflectionResource, createSecretsReflection, createTemplateReflection, plugin as default, plugin, envBabelPlugin, formatEnvField, getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, loadEnv, loadEnvFromContext, mergeEnvReflections, mergeSecretsReflections, readEnvReflection, readEnvTypeReflection, readSecretsReflection, reflectEnv, reflectSecrets, removeEnvPrefix, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
@@ -0,0 +1,17 @@
1
+ import "./type-CnPIyotQ.mjs";
2
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-VRahDLZZ.mjs";
3
+ import "./config-D2esSp2r.mjs";
4
+ import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-ChZa5p23.mjs";
5
+ import "./index-CRo77wc3.mjs";
6
+ import { n as plugin, t as envBabelPlugin } from "./index-B3G-X5Fc.mjs";
7
+ import { n as loadEnvFromContext, t as loadEnv } from "./load-Dzf30s_a.mjs";
8
+ import { t as EnvDocs } from "./docs-BwK6pC_c.mjs";
9
+ import { i as __ΩEnvBuiltinProps, n as EnvBuiltinProps, r as EnvTypeDefinition, t as EnvBuiltin } from "./env-DMqCnKB2.mjs";
10
+ import "./index-Wc1llEvP.mjs";
11
+ import { t as createReflectionResource } from "./create-reflection-resource-D7go0-VG.mjs";
12
+ import { a as readEnvReflection, c as resolveRuntimeTypeFile, d as writeEnvTypeReflection, i as getSecretsDefaultTypeDefinition, l as writeEnvReflection, n as getEnvReflectionsPath, o as readEnvTypeReflection, r as getEnvTypeReflectionsPath, s as readSecretsReflection, t as getEnvDefaultTypeDefinition, u as writeEnvReflectionSync } from "./persistence-sVp1g7Mp.mjs";
13
+ import { a as createEnvReflection, c as mergeSecretsReflections, i as __ΩCreateEnvReflectionOptions, l as reflectEnv, n as BaseSecrets, o as createSecretsReflection, r as CreateEnvReflectionOptions, s as mergeEnvReflections, t as BaseEnv, u as reflectSecrets } from "./reflect-C1joiXZ1.mjs";
14
+ import { n as removeEnvPrefix, t as formatEnvField } from "./source-file-env-DzpWKluw.mjs";
15
+ import { t as createTemplateReflection } from "./template-helpers-DmfAtQIT.mjs";
16
+ import "./index-Bt4QNofW.mjs";
17
+ export { BaseEnv, BaseSecrets, CreateEnvReflectionOptions, EnvBuiltin, EnvBuiltinProps, EnvDocs, EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, EnvTypeDefinition, SecretsInterface, __ΩCreateEnvReflectionOptions, __ΩEnvBuiltinProps, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface, createEnvReflection, createReflectionResource, createSecretsReflection, createTemplateReflection, plugin as default, plugin, envBabelPlugin, formatEnvField, getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, loadEnv, loadEnvFromContext, mergeEnvReflections, mergeSecretsReflections, readEnvReflection, readEnvTypeReflection, readSecretsReflection, reflectEnv, reflectSecrets, removeEnvPrefix, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
package/dist/index.mjs ADDED
@@ -0,0 +1,18 @@
1
+ import{r as e}from"./source-file-CjFSCK1w.mjs";import{S as t,_ as n,a as r,c as i,d as a,f as o,g as s,h as ee,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as te,v as _,y as v}from"./persistence-Br-YMVb1.mjs";import{t as y}from"./plugin-Cx61c9gw.mjs";import"./utilities-4S--uN0L.mjs";import{n as b,t as x}from"./env-D4MK9BWK.mjs";import{n as ne,t as re}from"./source-file-env-BDFTs5WJ.mjs";import{n as ie,t as S}from"./load-BZTlThWg.mjs";import{t as C}from"./create-reflection-resource-UtOwX4Ml.mjs";import"./babel-CE47sTzg.mjs";import{t as w}from"./docs-BDiEhcDa.mjs";import"./components-LyHNrcZE.mjs";import{t as T}from"./template-helpers-CLrM_TtO.mjs";import"./helpers-DfMThUgD.mjs";import"./plugin-DrnPbdzR.mjs";import"./runtime-DqCYc37d.mjs";import"./types-BCto_Rzj.mjs";import{createComponent as E,mergeProps as ae}from"@alloy-js/core/jsx-runtime";import{Output as oe,Show as se,computed as ce,flushJobsAsync as D,getContextForRenderNode as le,isPrintHook as ue,ref as de,renderTree as fe,splitProps as pe}from"@alloy-js/core";import{LogLevelLabel as O}from"@storm-software/config-tools/types";import{isParentPath as k}from"@stryke/path/is-parent-path";import{replacePath as A}from"@stryke/path/replace";import{isSetString as j}from"@stryke/type-checks/is-set-string";import{isFunction as M}from"@stryke/type-checks/is-function";import{isSetObject as N}from"@stryke/type-checks/is-set-object";import{isUndefined as me}from"@stryke/type-checks/is-undefined";import{printer as P}from"prettier/doc.js";import{transformAsync as F}from"@babel/core";import{findFileExtension as I,findFileExtensionSafe as L}from"@stryke/path/file-path-fns";import R from"defu";import"@stryke/type-checks/is-object";import z from"chalk";import{parseTypeDefinition as B}from"@stryke/convert/parse-type-definition";import{toArray as he}from"@stryke/convert/to-array";import{ENV_PREFIXES as ge}from"@stryke/env/types";import{existsSync as V}from"@stryke/fs/exists";import{createDirectory as _e}from"@stryke/fs/helpers";import{joinPaths as H}from"@stryke/path/join";import{constantCase as ve}from"@stryke/string-format/constant-case";function U(e){return M(e)||N(e)&&`handler`in e&&M(e.handler)}function W(e){return N(e)&&`handler`in e&&M(e.handler)}function G(e){return U(e)||W(e)}function K(e){return M(e)?e:e.handler}function ye(t){let[{children:n,context:r,basePath:i},a]=pe(t,[`children`,`context`,`basePath`]),o=de(r),s=ce(()=>i?A(i,o.value.workspaceConfig.workspaceRoot):o.value.workspaceConfig.workspaceRoot);return E(oe,ae(a,{get basePath(){return s.value},get children(){return E(e.Provider,{value:{ref:o},get children(){return E(se,{get when(){return!!o.value},children:n})}})}}))}function be(e){return t=>{let n=e(t);return{...n,async prepare(){let e=this;if(G(n.prepare)&&n.enforce!==`post`&&(U(n.prepare)||W(n.prepare)&&n.prepare.order!==`post`)&&await Promise.resolve(K(n.prepare).call(this)),G(n.render)){let r=fe(E(ye,{context:e,get basePath(){return e.workspaceConfig.workspaceRoot},get children(){return n.render.call(e)}}));await xe(this,r,t?.alloy)}G(n.prepare)&&(n.enforce===`post`||W(n.prepare)&&n.prepare.order===`post`)&&await Promise.resolve(K(n.prepare).call(this))}}}}async function xe(e,t,n={}){await D();let r,i=async(t,a)=>{if(!Array.isArray(a))return;let o=async e=>{for(let t of a)await i(e,t)},s=le(a);if(!s)return o(t);if(s.meta?.directory){let e={kind:`directory`,path:s.meta.directory.path,contents:[]};t?t.contents.push(e):r=e,await o(e)}else if(s.meta?.sourceFile){if(!t)throw Error(`Source file doesn't have parent directory. Make sure you have used the Output component.`);let r;if(s.meta?.builtin){if(!s.meta.builtin.id)throw Error("Built-in runtime module doesn't have an ID. Make sure you have used the `<BuiltinFile />` component.");e.log(O.TRACE,`Rendering built-in runtime module with ID: ${s.meta.builtin.id}`),r={kind:`builtin`,id:s.meta.builtin.id,path:A(s.meta.sourceFile.path,e.builtinsPath),filetype:s.meta.sourceFile.filetype,preset:s.meta.output?.mode,contents:await q(e,a,n)}}else s.meta?.entry||k(e.entryPath,s.meta.sourceFile.path)?(e.log(O.TRACE,`Rendering entry module at path: ${s.meta.sourceFile.path}`),r={kind:`entry`,typeDefinition:s.meta.entry?.typeDefinition,path:s.meta.sourceFile.path,filetype:s.meta.sourceFile.filetype,preset:s.meta.output?.mode,contents:await q(e,a,n)}):(e.log(O.TRACE,`Rendering source file at path: ${s.meta.sourceFile.path}`),r={kind:`file`,path:s.meta.sourceFile.path,filetype:s.meta.sourceFile.filetype,preset:s.meta.output?.mode,contents:await q(e,a,n)});t.contents.push(r)}else if(s.meta?.copyFile){if(!t)throw Error(`Copy file doesn't have parent directory. Make sure you have used the Output component.`);if(e.log(O.TRACE,`Processing copy file operation from "${s.meta.copyFile.sourcePath}" to "${s.meta.copyFile.path}"`),!s.meta.copyFile.sourcePath)throw Error("Copy file doesn't have a source path. Make sure you have provided a `sourcePath` property to the `meta.copyFile` context.");if(!s.meta.copyFile.path)throw Error("Copy file doesn't have a destination path. Make sure you have provided a `path` property to the `meta.copyFile` context.");t.contents.push({kind:`file`,path:s.meta.copyFile.path,sourcePath:s.meta.copyFile.sourcePath,preset:s.meta.output?.preset})}else await o(t)};await i(void 0,t);let a=async(e,t)=>{for(let n of t.contents)if(n.kind===`directory`)await a(e,n);else if(n.kind===`builtin`)await e.emitBuiltin(n.contents,n.id,n.path);else if(n.kind===`entry`)await e.emitEntry(n.contents,n.path);else if(n.kind===`file`)if(`sourcePath`in n&&n.sourcePath){if(!e.fs.existsSync(n.sourcePath))throw Error(`Source file "${n.sourcePath}" for copy operation does not exist.`);let t=await e.fs.read(n.sourcePath);if(!j(t))throw Error(`Source file "${n.sourcePath}" for copy operation is empty.`);await e.fs.write(n.path,t)}else if(`contents`in n&&j(n.contents))await e.fs.write(n.path,n.contents);else throw Error(`Unexpected output extracted from the render tree: \n\n${JSON.stringify(n,null,2)}`)};await a(e,r)}async function q(e,t,n={}){n.printWidth??=160,n.tabWidth??=2,n.useTabs??=!1,n.insertFinalNewLine??=!0,await D();let r=P.printDocToString(J(t),n).formatted;return n.insertFinalNewLine&&!r.endsWith(`
2
+ `)?`${r}\n`:r}function J(e){let t=[];for(let n of e)if(typeof n==`string`){let e=n.split(/\r?\n/).flatMap((e,t,n)=>(n.length-1,[e]));t.push(e)}else ue(n)?t.push(n.print(n.subtree,J)):t.push(J(n));return t}function Y(e){return j(e)?e:Array.isArray(e)&&e.length>0?Y(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function X(e,t){return!!(Y(t)&&e.some(e=>Array.isArray(e)&&Y(e[0])===Y(t)))}function Z(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?M(t[0])?t[0](e):t[0]:M(t)?t(e):t}catch{return t[0]}}function Q(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&M(r[2])&&!r[2](t,n)){e.log(O.TRACE,`Skipping filtered Babel plugin ${z.bold.cyanBright(Y(r)||`unnamed`)} for ${n}`);return}return r.length>2?[Z(e,r),r[1],r[2]]:[Z(e,r),r[1],null]}return[Z(e,r),{},null]}var Se=(e={})=>({name:`babel`,config(){if(N(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=R(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if(k(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(O.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(O.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>Q(this,t,n,e)).filter((e,t,n)=>e&&!X(n,e)),i=this.config.transform.babel.presets.map(e=>Q(this,t,n,e)).filter((e,t,n)=>e&&!X(n,e));if(Array.isArray(r)&&r.length===0&&Array.isArray(i)&&i.length===0)return{code:t,id:n};[`ts`,`cts`,`mts`,`tsx`].includes(L(n))&&!X(r,`@babel/plugin-syntax-typescript`)&&!X(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:I(n)===`.tsx`}]);let a=await F(t,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:n,plugins:r.map(t=>Array.isArray(t)&&t.length>=2?[t[0],R(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:i.map(t=>Array.isArray(t)&&t.length>=2?[t[0],R(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!a?.code)throw Error(`Powerlines - Babel plugin failed to compile ${n}`);return{code:a.code,id:n}}});const $=be((e={})=>({name:`env`,dependsOn:[Se(e.babel)],async config(){this.log(O.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:R(e,{types:{},prefix:[]}),transform:{babel:{plugins:[y]}}};if(t.env.types)t.env.types=B(t.env.types);else{this.log(O.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let e=await g(this);t.env.types=B(`${e.file}#${e.name}`)}if(t.env.secrets)t.env.secrets=B(t.env.secrets);else{let e=await c(this);t.env.secrets=B(`${e.file}#${e.name}`)}return t.env.prefix=he(t.env.prefix??[]).reduce((e,t)=>{let n=ve(t);return e.includes(n)||e.push(n),e},[...ge,`POWERLINES_`]),t.env.prefix=t.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),t},async configResolved(){if(this.log(O.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=R({parsed:await S(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&V(m(this,`env`)))this.log(O.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await f(this,`env`),V(d(this,`env`))&&(this.env.used.env=await r(this)),V(m(this,`secrets`))&&(this.env.types.secrets=await f(this,`secrets`)),V(d(this,`secrets`))&&(this.env.used.secrets=await h(this));else{if(this.env.types.env=await _(this,this.config.env.types?.file?k(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:H(this.config.projectRoot,this.config.env.types?.file):void 0,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await a(this,this.env.types.env,`env`),this.env.types.secrets=await v(this,this.config.env.secrets?.file?k(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:H(this.config.projectRoot,this.config.env.secrets?.file):void 0,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await a(this,this.env.types.secrets,`secrets`),this.log(O.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let e=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await S(this,this.config.env)).forEach(([t,n])=>{let r=this.config.env.prefix.reduce((e,n)=>t.replace(/_$/g,``).startsWith(n)?t.replace(/_$/g,``).slice(n.length):e,t),i=e.find(e=>e?.getAlias().reverse().includes(r));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(n)}),this.env.used.env=new t.ReflectionClass({kind:t.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await l(this,this.env.used.env,`env`),this.env.types.secrets&&(await a(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new t.ReflectionClass({kind:t.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await l(this,this.env.used.secrets,`secrets`))}},render(){let e=this;return this.log(O.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),E(x,{get defaultConfig(){return e.config.env.defaultConfig}})},async docs(){this.log(O.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let e=H(this.config.projectRoot,`docs`,`generated`);V(e)||await _e(e);let n=await f(this,`env`),r=H(e,`env.md`);this.log(O.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by Powerlines -->
3
+
4
+ # Environment variables configuration
5
+
6
+ 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.
7
+
8
+ ## Environment Configuration
9
+
10
+ The below list of environment variables 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.
11
+
12
+ | Name | Description | Type | Default Value | Required |
13
+ | ---- | ----------- | ---- | ------------- | :------: |
14
+ ${n.getProperties().filter(e=>e.getNameAsString()!==`__STORM_INJECTED__`).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString())).map(e=>`| ${e.getNameAsString().trim()} | ${(e.getDescription()?.replaceAll(`\r`,``)?.replaceAll(`
15
+ `,``)??``).trim()} | ${(0,t.stringifyType)(e.getType()).trim().replaceAll(` | `,`, or `)} | ${e.hasDefault()?String(e.getDefaultValue())?.includes(`"`)?e.getDefaultValue():`\`${e.getDefaultValue()}\``:``} | ${e.isValueRequired()?``:`✔`} |`).join(`
16
+ `)}
17
+ `)},async buildEnd(){let e=d(this,`env`);this.log(O.TRACE,`Writing env reflection types to ${e}.`),await l(this,this.env.used.env,`env`)}}));var Ce=$;export{o as BaseEnv,p as BaseSecrets,x as EnvBuiltin,w as EnvDocs,b as EnvTypeDefinition,u as createEnvReflection,C as createReflectionResource,ee as createSecretsReflection,T as createTemplateReflection,Ce as default,y as envBabelPlugin,re as formatEnvField,g as getEnvDefaultTypeDefinition,d as getEnvReflectionsPath,m as getEnvTypeReflectionsPath,c as getSecretsDefaultTypeDefinition,S as loadEnv,ie as loadEnvFromContext,s as mergeEnvReflections,n as mergeSecretsReflections,$ as plugin,r as readEnvReflection,f as readEnvTypeReflection,h as readSecretsReflection,_ as reflectEnv,v as reflectSecrets,ne as removeEnvPrefix,i as resolveRuntimeTypeFile,l as writeEnvReflection,te as writeEnvReflectionSync,a as writeEnvTypeReflection};
18
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["isFunction","isSetObject","isSetString","isUndefined","SUPPORTED_COMMANDS","isPlugin","value","name","applyToEnvironment","dedupe","dependsOn","Array","isArray","every","isPluginConfig","command","handler","isPluginConfigObject","plugin","options","isPluginConfigTuple","length","isPluginHookFunction","isPluginHookObject","isPluginHook","getHookHandler","pluginHook","extractPluginHook","context","hook","undefined","normal","bind","order","isHookExternal","startsWith","isHookInternal","checkDedupe","plugins","some","p","addPluginHook","hooksList","map","push","computed","Output","OutputExternal","ref","Show","splitProps","replacePath","PowerlinesContext","props","children","context","basePath","rest","contextRef","basePathRef","value","workspaceConfig","workspaceRoot","_$createComponent","_$mergeProps","Provider","when","Boolean","flushJobsAsync","getContextForRenderNode","isPrintHook","renderTree","LogLevelLabel","isParentPath","replacePath","isSetString","getHookHandler","isPluginHook","isPluginHookFunction","isPluginHookObject","printer","Output","createAlloyPlugin","builder","options","result","prepare","_self$","enforce","order","Promise","resolve","call","render","tree","_$createComponent","context","basePath","workspaceConfig","workspaceRoot","children","writeTree","alloy","generateOutput","currentDirectory","root","Array","isArray","recurse","cwd","child","renderContext","meta","directory","kind","path","contents","push","sourceFile","Error","outputFile","builtin","id","log","TRACE","builtinsPath","filetype","preset","output","mode","printTree","entry","entryPath","typeDefinition","copyFile","sourcePath","undefined","writeOutput","sub","emitBuiltin","emitEntry","fs","existsSync","source","read","write","JSON","stringify","printWidth","tabWidth","useTabs","insertFinalNewLine","printDocToString","printTreeWorker","formatted","endsWith","doc","node","normalizedNode","split","flatMap","line","index","array","length","print","subtree","isFunction","isObject","isSetString","getPluginName","plugin","Array","isArray","length","$$name","name","undefined","isDuplicatePlugin","plugins","some","existing","filterPluginByFileId","context","fileId","code","id","fs","ids","addPluginFilter","pluginOrPlugins","filter","Error","foundIndex","findIndex","toLowerCase","LogLevelLabel","isFunction","chalk","getPluginName","resolvePluginFunction","context","plugin","Array","isArray","length","resolveBabelPlugin","code","id","log","TRACE","bold","cyanBright","undefined","transformAsync","LogLevelLabel","findFileExtension","findFileExtensionSafe","isParentPath","isSetObject","defu","isDuplicatePlugin","resolveBabelPlugin","plugin","options","name","config","undefined","transform","babel","configResolved","order","handler","devDependencies","plugins","presets","code","id","powerlinesPath","includes","log","TRACE","map","filter","_","arr","preset","Array","isArray","length","unshift","isTSX","result","highlightCode","ast","cloneInputAst","comments","sourceType","configFile","babelrc","envName","mode","caller","framework","filename","Boolean","Error","createAlloyPlugin","ReflectionClass","ReflectionKind","stringifyType","babel","LogLevelLabel","parseTypeDefinition","toArray","ENV_PREFIXES","existsSync","createDirectory","isParentPath","joinPaths","constantCase","defu","envBabelPlugin","EnvBuiltin","loadEnv","getEnvDefaultTypeDefinition","getEnvReflectionsPath","getEnvTypeReflectionsPath","getSecretsDefaultTypeDefinition","readEnvReflection","readEnvTypeReflection","readSecretsReflection","writeEnvReflection","writeEnvTypeReflection","reflectEnv","reflectSecrets","plugin","options","name","dependsOn","config","log","TRACE","env","types","prefix","transform","plugins","WARN","envDefaultTypeDefinition","file","secrets","secretsDefaultTypeDefinition","reduce","ret","formattedPrefix","includes","push","replace","configResolved","inject","projectType","parsed","used","injected","command","persistedMeta","checksum","meta","workspaceConfig","workspaceRoot","projectRoot","undefined","Error","getProperties","length","envWithAlias","filter","prop","getAlias","Object","entries","forEach","key","value","unprefixedKey","startsWith","slice","aliasKey","find","reverse","hasProperty","getProperty","setDefaultValue","kind","objectLiteral","typeName","description","render","_self$","_$createComponent","defaultConfig","docs","outputPath","reflection","envDocFile","fs","write","packageJson","property","getNameAsString","sort","a","b","localeCompare","map","reflectionProperty","trim","getDescription","replaceAll","getType","hasDefault","String","getDefaultValue","isValueRequired","join","buildEnd","reflectionPath"],"sources":["../../powerlines/src/plugin-utils/helpers.ts","../../alloy/src/core/components/output.tsx","../../alloy/src/create-plugin.tsx","../../plugin-babel/src/helpers/filters.ts","../../plugin-babel/src/helpers/options.ts","../../plugin-babel/src/index.ts","../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { AnyFunction } from \"@stryke/types/base\";\nimport { SUPPORTED_COMMANDS } from \"../types/commands\";\nimport {\n PluginConfig,\n PluginConfigObject,\n PluginConfigTuple\n} from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport {\n BaseHookKeys,\n BaseHooksListItem,\n ExternalHookKeys,\n HookKeys\n} from \"../types/hooks\";\nimport { Plugin, PluginHook, PluginHookObject } from \"../types/plugin\";\nimport { ResolvedConfig } from \"../types/resolved\";\n\n/**\n * Type guard to check if an object is a {@link Plugin}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link Plugin}, false otherwise\n */\nexport function isPlugin<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(value: unknown): value is Plugin<PluginContext<TResolvedConfig>> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined(\n (value as Plugin<PluginContext<TResolvedConfig>>).applyToEnvironment\n ) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<PluginContext<TResolvedConfig>>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n (isUndefined((value as Plugin<PluginContext<TResolvedConfig>>).dependsOn) ||\n (\"dependsOn\" in value &&\n Array.isArray(value.dependsOn) &&\n value.dependsOn.every(isPluginConfig))) &&\n SUPPORTED_COMMANDS.every(\n command =>\n isUndefined(\n (value as Plugin<PluginContext<TResolvedConfig>>)[command]\n ) ||\n (command in value &&\n (isFunction((value as Record<string, any>)[command]) ||\n (isSetObject((value as Record<string, any>)[command]) &&\n \"handler\" in (value as Record<string, any>)[command] &&\n isFunction((value as Record<string, any>)[command].handler))))\n )\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigObject}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigObject}, false otherwise\n */\nexport function isPluginConfigObject(\n value: unknown\n): value is PluginConfigObject {\n return (\n isSetObject(value) &&\n \"plugin\" in value &&\n (((isSetString(value.plugin) || isFunction(value.plugin)) &&\n \"options\" in value &&\n isSetObject(value.options)) ||\n isPlugin(value.plugin))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigTuple}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigTuple}, false otherwise\n */\nexport function isPluginConfigTuple(\n value: unknown\n): value is PluginConfigTuple {\n return (\n Array.isArray(value) &&\n (value.length === 1 || value.length === 2) &&\n (((isSetString(value[0]) || isFunction(value[0])) &&\n value.length > 1 &&\n isSetObject(value[1])) ||\n isPlugin(value[0]))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfig}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfig}, false otherwise\n */\nexport function isPluginConfig(value: unknown): value is PluginConfig {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value)\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookFunction(value: unknown): value is AnyFunction {\n return (\n isFunction(value) ||\n (isSetObject(value) && \"handler\" in value && isFunction(value.handler))\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookObject(\n value: unknown\n): value is PluginHookObject<AnyFunction> {\n return isSetObject(value) && \"handler\" in value && isFunction(value.handler);\n}\n\n/**\n * Type guard to check if an object is a {@link PluginHook}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginHook}, false otherwise\n */\nexport function isPluginHook(value: unknown): value is PluginHook<AnyFunction> {\n return isPluginHookFunction(value) || isPluginHookObject(value);\n}\n\n/**\n * Extract the hook handler function from a plugin hook\n *\n * @param pluginHook - The plugin hook to extract the handler function from\n * @returns The hook handler function\n */\nexport function getHookHandler(\n pluginHook: PluginHook<AnyFunction>\n): AnyFunction {\n return isFunction(pluginHook) ? pluginHook : pluginHook.handler;\n}\n\n/**\n * Extract a plugin hook from a plugin\n *\n * @param context - The build context\n * @param plugin - The plugin to extract the hook from\n * @param hook - The name of the hook to extract\n * @returns The extracted hook, or undefined if the hook does not exist\n */\nexport function extractPluginHook<\n TContext extends PluginContext = PluginContext,\n TPlugin extends Plugin<TContext> = Plugin<TContext>\n>(context: TContext, plugin: TPlugin, hook: BaseHookKeys<TContext>) {\n const pluginHook = plugin[hook];\n if (!isPluginHook(pluginHook)) {\n return undefined;\n }\n\n return isFunction(pluginHook)\n ? {\n normal: pluginHook.bind(context)\n }\n : {\n [pluginHook.order ? pluginHook.order : \"normal\"]:\n pluginHook.handler.bind(context)\n };\n}\n\n/**\n * Check if a hook is external.\n *\n * @param hook - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isHookExternal(hook: HookKeys): hook is ExternalHookKeys {\n return (\n hook.startsWith(\"vite:\") ||\n hook.startsWith(\"esbuild:\") ||\n hook.startsWith(\"rolldown:\") ||\n hook.startsWith(\"rollup:\") ||\n hook.startsWith(\"webpack:\") ||\n hook.startsWith(\"rspack:\") ||\n hook.startsWith(\"farm:\")\n );\n}\n\n/**\n * Check if a hook is internal.\n *\n * @param hook - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isHookInternal(hook: HookKeys): hook is BaseHookKeys {\n return !isHookExternal(hook);\n}\n\n/**\n * Check if a plugin should be deduplicated.\n *\n * @param plugin - The plugin to check\n * @param plugins - The list of plugins to check against\n * @returns True if the plugin should be deduplicated, false otherwise\n */\nexport function checkDedupe<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TContext extends PluginContext<TResolvedConfig> =\n PluginContext<TResolvedConfig>\n>(plugin: Plugin<TContext>, plugins: Plugin<TContext>[]) {\n return (\n plugin.dedupe === false ||\n plugins.some(\n p =>\n p.dedupe !== false &&\n ((isFunction(p.dedupe) && p.dedupe(plugin)) || p.name === plugin.name)\n )\n );\n}\n\n/**\n * Add a plugin hook to the hooks list.\n *\n * @param context - The plugin context\n * @param plugin - The plugin to add the hook from\n * @param pluginHook - The plugin hook to add\n * @param hooksList - The list of hooks to add to\n */\nexport function addPluginHook<TContext extends PluginContext = PluginContext>(\n context: TContext,\n plugin: Plugin<TContext>,\n pluginHook: PluginHook<AnyFunction>,\n hooksList: BaseHooksListItem<TContext, BaseHookKeys<TContext>>[]\n) {\n if (\n !checkDedupe(\n plugin,\n hooksList.map(hook => hook.plugin)\n )\n ) {\n hooksList.push(\n isFunction(pluginHook)\n ? {\n plugin,\n handler: getHookHandler(pluginHook).bind(context)\n }\n : {\n plugin,\n ...pluginHook,\n handler: getHookHandler(pluginHook).bind(context)\n }\n );\n }\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { OutputProps as OutputPropsExternal } from \"@alloy-js/core\";\nimport {\n computed,\n Output as OutputExternal,\n ref,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport type { PluginContext } from \"powerlines/types/context\";\nimport { PowerlinesContext } from \"../contexts/context\";\n\nexport interface OutputProps<TContext extends PluginContext = PluginContext>\n extends OutputPropsExternal {\n /**\n * The current Powerlines process context.\n */\n context: TContext;\n}\n\n/**\n * Output component for rendering the Powerlines plugin's output files via templates.\n */\nexport function Output<TContext extends PluginContext = PluginContext>(\n props: OutputProps<TContext>\n) {\n const [{ children, context, basePath }, rest] = splitProps(props, [\n \"children\",\n \"context\",\n \"basePath\"\n ]);\n\n const contextRef = ref(context);\n const basePathRef = computed(() =>\n basePath\n ? replacePath(basePath, contextRef.value.workspaceConfig.workspaceRoot)\n : contextRef.value.workspaceConfig.workspaceRoot\n );\n\n return (\n <OutputExternal {...rest} basePath={basePathRef.value}>\n <PowerlinesContext.Provider value={{ ref: contextRef }}>\n <Show when={Boolean(contextRef.value)}>{children}</Show>\n </PowerlinesContext.Provider>\n </OutputExternal>\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n flushJobsAsync,\n getContextForRenderNode,\n isPrintHook,\n RenderedTextTree,\n renderTree\n} from \"@alloy-js/core\";\nimport { PluginPluginAlloyOptions } from \"@powerlines/plugin-plugin/types/plugin\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n getHookHandler,\n isPluginHook,\n isPluginHookFunction,\n isPluginHookObject\n} from \"powerlines/plugin-utils/helpers\";\nimport { PluginContext } from \"powerlines/types/context\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { Doc } from \"prettier\";\nimport { printer } from \"prettier/doc.js\";\nimport { Output } from \"./core/components/output\";\nimport { OutputDirectory, OutputFile } from \"./types/components\";\nimport { AlloyPluginBuilder, AlloyPluginOptions } from \"./types/plugin\";\n\n/**\n * Creates an Alloy plugin using a plugin builder function.\n *\n * @param builder - The Alloy plugin builder function.\n * @returns An object representing the Alloy plugin.\n */\nexport function createAlloyPlugin<\n TContext extends PluginContext = PluginContext\n>(builder: AlloyPluginBuilder<TContext>) {\n return <T extends TContext>(\n options: Parameters<typeof builder>[0] & AlloyPluginOptions\n ) => {\n const result = builder(options);\n\n return {\n ...result,\n async prepare() {\n if (\n isPluginHook(result.prepare) &&\n result.enforce !== \"post\" &&\n (isPluginHookFunction(result.prepare) ||\n (isPluginHookObject(result.prepare) &&\n result.prepare.order !== \"post\"))\n ) {\n await Promise.resolve(getHookHandler(result.prepare).call(this));\n }\n\n if (isPluginHook(result.render)) {\n const tree = renderTree(\n <Output<TContext>\n context={this}\n basePath={this.workspaceConfig.workspaceRoot}>\n {result.render.call(this)}\n </Output>\n );\n\n await writeTree(this, tree, options?.alloy);\n }\n\n if (\n isPluginHook(result.prepare) &&\n (result.enforce === \"post\" ||\n (isPluginHookObject(result.prepare) &&\n result.prepare.order === \"post\"))\n ) {\n await Promise.resolve(getHookHandler(result.prepare).call(this));\n }\n }\n } as Plugin<T>;\n };\n}\n\n/**\n * Writes the rendered output files to the virtual file system.\n *\n * @param context - The context of the current build.\n * @param tree - The rendered output files.\n */\nasync function writeTree<TContext extends PluginContext = PluginContext>(\n context: TContext,\n tree: RenderedTextTree,\n options: PluginPluginAlloyOptions = {}\n) {\n await flushJobsAsync();\n\n let result!: OutputDirectory;\n const generateOutput = async (\n currentDirectory: OutputDirectory | undefined,\n root: RenderedTextTree\n ) => {\n if (!Array.isArray(root)) {\n return;\n }\n\n const recurse = async (cwd: OutputDirectory | undefined) => {\n for (const child of root) {\n await generateOutput(cwd, child as RenderedTextTree);\n }\n };\n\n const renderContext = getContextForRenderNode(root);\n if (!renderContext) {\n return recurse(currentDirectory);\n }\n\n if (renderContext.meta?.directory) {\n const directory: OutputDirectory = {\n kind: \"directory\",\n path: renderContext.meta.directory.path,\n contents: []\n };\n\n if (currentDirectory) {\n currentDirectory.contents.push(directory);\n } else {\n result = directory;\n }\n\n await recurse(directory);\n } else if (renderContext.meta?.sourceFile) {\n if (!currentDirectory) {\n // This shouldn't happen if you're using the Output component.\n throw new Error(\n \"Source file doesn't have parent directory. Make sure you have used the Output component.\"\n );\n }\n\n let outputFile!: OutputFile;\n if (renderContext.meta?.builtin) {\n if (!renderContext.meta.builtin.id) {\n throw new Error(\n \"Built-in runtime module doesn't have an ID. Make sure you have used the `<BuiltinFile />` component.\"\n );\n }\n\n context.log(\n LogLevelLabel.TRACE,\n `Rendering built-in runtime module with ID: ${renderContext.meta.builtin.id}`\n );\n\n outputFile = {\n kind: \"builtin\",\n id: renderContext.meta.builtin.id,\n path: replacePath(\n renderContext.meta.sourceFile.path,\n context.builtinsPath\n ),\n filetype: renderContext.meta.sourceFile.filetype,\n preset: renderContext.meta.output?.mode,\n contents: await printTree(context, root, options)\n };\n } else if (\n renderContext.meta?.entry ||\n isParentPath(context.entryPath, renderContext.meta.sourceFile.path)\n ) {\n context.log(\n LogLevelLabel.TRACE,\n `Rendering entry module at path: ${renderContext.meta.sourceFile.path}`\n );\n\n outputFile = {\n kind: \"entry\",\n typeDefinition: renderContext.meta.entry?.typeDefinition,\n path: renderContext.meta.sourceFile.path,\n filetype: renderContext.meta.sourceFile.filetype,\n preset: renderContext.meta.output?.mode,\n contents: await printTree(context, root, options)\n };\n } else {\n context.log(\n LogLevelLabel.TRACE,\n `Rendering source file at path: ${renderContext.meta.sourceFile.path}`\n );\n\n outputFile = {\n kind: \"file\",\n path: renderContext.meta.sourceFile.path,\n filetype: renderContext.meta.sourceFile.filetype,\n preset: renderContext.meta.output?.mode,\n contents: await printTree(context, root, options)\n };\n }\n\n currentDirectory.contents.push(outputFile);\n } else if (renderContext.meta?.copyFile) {\n if (!currentDirectory) {\n // This shouldn't happen if you're using the Output component.\n throw new Error(\n \"Copy file doesn't have parent directory. Make sure you have used the Output component.\"\n );\n }\n\n context.log(\n LogLevelLabel.TRACE,\n `Processing copy file operation from \"${\n renderContext.meta.copyFile.sourcePath\n }\" to \"${renderContext.meta.copyFile.path}\"`\n );\n\n if (!renderContext.meta.copyFile.sourcePath) {\n throw new Error(\n \"Copy file doesn't have a source path. Make sure you have provided a `sourcePath` property to the `meta.copyFile` context.\"\n );\n }\n\n if (!renderContext.meta.copyFile.path) {\n throw new Error(\n \"Copy file doesn't have a destination path. Make sure you have provided a `path` property to the `meta.copyFile` context.\"\n );\n }\n\n currentDirectory.contents.push({\n kind: \"file\",\n path: renderContext.meta.copyFile.path,\n sourcePath: renderContext.meta.copyFile.sourcePath,\n preset: renderContext.meta.output?.preset\n });\n } else {\n await recurse(currentDirectory);\n }\n };\n\n await generateOutput(undefined, tree);\n\n const writeOutput = async (context: TContext, output: OutputDirectory) => {\n for (const sub of output.contents) {\n if (sub.kind === \"directory\") {\n await writeOutput(context, sub);\n } else if (sub.kind === \"builtin\") {\n await context.emitBuiltin(sub.contents, sub.id, sub.path);\n } else if (sub.kind === \"entry\") {\n await context.emitEntry(sub.contents, sub.path);\n } else if (sub.kind === \"file\") {\n if (\"sourcePath\" in sub && sub.sourcePath) {\n if (!context.fs.existsSync(sub.sourcePath)) {\n throw new Error(\n `Source file \"${sub.sourcePath}\" for copy operation does not exist.`\n );\n }\n\n const source = await context.fs.read(sub.sourcePath);\n if (!isSetString(source)) {\n throw new Error(\n `Source file \"${sub.sourcePath}\" for copy operation is empty.`\n );\n }\n\n await context.fs.write(sub.path, source);\n } else if (\"contents\" in sub && isSetString(sub.contents)) {\n await context.fs.write(sub.path, sub.contents);\n } else {\n throw new Error(\n `Unexpected output extracted from the render tree: \\n\\n${JSON.stringify(sub, null, 2)}`\n );\n }\n }\n }\n };\n\n await writeOutput(context, result);\n}\n\nasync function printTree<TContext extends PluginContext = PluginContext>(\n context: TContext,\n tree: RenderedTextTree,\n options: PluginPluginAlloyOptions = {}\n) {\n options.printWidth ??= 160;\n options.tabWidth ??= 2;\n options.useTabs ??= false;\n options.insertFinalNewLine ??= true;\n\n await flushJobsAsync();\n\n const result = printer.printDocToString(\n printTreeWorker(tree),\n options as printer.Options\n ).formatted;\n\n return options.insertFinalNewLine && !result.endsWith(\"\\n\")\n ? `${result}\\n`\n : result;\n}\n\nfunction printTreeWorker(tree: RenderedTextTree): Doc {\n const doc: Doc = [];\n for (const node of tree) {\n if (typeof node === \"string\") {\n const normalizedNode = node\n .split(/\\r?\\n/)\n .flatMap((line, index, array) =>\n index < array.length - 1 ? [line] : [line]\n );\n doc.push(normalizedNode);\n } else if (isPrintHook(node)) {\n doc.push(node.print!(node.subtree, printTreeWorker));\n } else {\n doc.push(printTreeWorker(node));\n }\n }\n\n return doc;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { Context } from \"powerlines/types\";\nimport {\n BabelTransformPlugin,\n BabelTransformPluginFilter,\n BabelTransformPluginOptions,\n ResolvedBabelTransformPluginOptions\n} from \"powerlines/types/babel\";\n\nexport function getPluginName(\n plugin: BabelTransformPluginOptions\n): string | undefined {\n return isSetString(plugin)\n ? plugin\n : Array.isArray(plugin) && plugin.length > 0\n ? getPluginName(plugin[0])\n : (plugin as BabelTransformPlugin).$$name ||\n (plugin as BabelTransformPlugin).name\n ? (plugin as BabelTransformPlugin).$$name ||\n (plugin as BabelTransformPlugin).name\n : undefined;\n}\n\n/**\n * Check if a Babel plugin is a duplicate of another plugin in the list.\n *\n * @param plugins - The list of existing Babel plugins.\n * @param plugin - The Babel plugin to check for duplicates.\n * @returns True if the plugin is a duplicate, false otherwise.\n */\nexport function isDuplicatePlugin(\n plugins: (ResolvedBabelTransformPluginOptions | undefined)[],\n plugin: BabelTransformPluginOptions\n): boolean {\n return !!(\n getPluginName(plugin) &&\n plugins.some(\n existing =>\n Array.isArray(existing) &&\n getPluginName(existing[0]) === getPluginName(plugin)\n )\n );\n}\n\n/**\n * Filters a Babel plugin by its runtime ID.\n *\n * @param context - The context in which the filter is applied.\n * @param fileId - The file ID to filter by.\n * @returns A filter function that checks if a plugin's ID matches the runtime ID.\n */\nexport function filterPluginByFileId<TContext extends Context = Context>(\n context: TContext,\n fileId: string\n): BabelTransformPluginFilter {\n return (code: string, id: string): boolean =>\n fileId !== id &&\n context.fs.ids[fileId] !== id &&\n fileId !== context.fs.ids[id] &&\n context.fs.ids[fileId] !== context.fs.ids[id];\n}\n\n/**\n * Adds a filter to a Babel plugin or a list of Babel plugins.\n *\n * @param context - The context in which the plugin is being added.\n * @param plugins - The Babel plugins to add the filter to.\n * @param filter - The filter function to apply to the plugins.\n * @param name - The name of the plugin to add the filter to.\n * @returns The updated list of Babel plugins with the filter applied.\n */\nexport function addPluginFilter(\n context: Context,\n plugins: BabelTransformPluginOptions[],\n filter: BabelTransformPluginFilter | null | undefined,\n name: string\n): BabelTransformPluginOptions[];\n\n/**\n * Adds a filter to a Babel plugin or a list of Babel plugins.\n *\n * @param context - The context in which the plugin is being added.\n * @param plugin - The Babel plugin to add the filter to.\n * @param filter - The filter function to apply to the plugin.\n * @returns The updated Babel plugin with the filter applied.\n */\nexport function addPluginFilter(\n context: Context,\n plugin: BabelTransformPlugin | BabelTransformPluginOptions,\n filter: NonNullable<BabelTransformPluginFilter>\n): BabelTransformPluginOptions;\n\n/**\n * Adds a filter to a Babel plugin or a list of Babel plugins.\n *\n * @param context - The context in which the plugin is being added.\n * @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.\n * @param filter - The filter function to apply to the plugins.\n * @param name - The name of the plugin to add the filter to.\n * @returns The updated list of Babel plugins with the filter applied.\n */\nexport function addPluginFilter<\n T extends\n | BabelTransformPlugin\n | BabelTransformPluginOptions\n | BabelTransformPluginOptions[]\n>(\n context: Context,\n pluginOrPlugins: T,\n filter: NonNullable<BabelTransformPluginFilter>,\n name?: string\n): T extends BabelTransformPluginOptions[]\n ? BabelTransformPluginOptions[]\n : BabelTransformPluginOptions {\n if (\n !Array.isArray(pluginOrPlugins) ||\n (!pluginOrPlugins.some(plugin => Array.isArray(plugin)) &&\n pluginOrPlugins.length < 4 &&\n pluginOrPlugins.length > 0 &&\n (isSetString(pluginOrPlugins[0]) ||\n isFunction(pluginOrPlugins[0]) ||\n (pluginOrPlugins.length > 1 && isObject(pluginOrPlugins[1])) ||\n (pluginOrPlugins.length > 2 && isObject(pluginOrPlugins[2]))))\n ) {\n return Array.isArray(pluginOrPlugins)\n ? [\n pluginOrPlugins[0],\n pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},\n {\n filter: (code, id) =>\n filter(code, id) &&\n (pluginOrPlugins.length < 2 ||\n !isFunction(pluginOrPlugins[2]) ||\n pluginOrPlugins[2]?.(code, id))\n }\n ]\n : [\n pluginOrPlugins,\n {},\n {\n filter\n }\n ];\n }\n\n if (!name) {\n throw new Error(\n \"No name was provided to \\`addPluginFilter\\`, could not find babel plugin without it.\"\n );\n }\n\n const foundIndex = pluginOrPlugins.findIndex(\n plugin => getPluginName(plugin)?.toLowerCase() === name.toLowerCase()\n );\n if (foundIndex > -1) {\n pluginOrPlugins[foundIndex] = addPluginFilter(\n context,\n pluginOrPlugins[foundIndex],\n filter,\n name\n );\n }\n\n return pluginOrPlugins;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { PluginOptions, PluginTarget } from \"@babel/core\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport chalk from \"chalk\";\nimport {\n BabelTransformPluginOptions,\n ResolvedBabelTransformPluginOptions\n} from \"powerlines/types/babel\";\nimport { Context } from \"powerlines/types/context\";\nimport { getPluginName } from \"./filters\";\n\nexport function resolvePluginFunction(\n context: Context,\n plugin:\n | any\n | PluginTarget\n | any[]\n | [PluginTarget, PluginOptions]\n | [PluginTarget, PluginOptions, string | undefined]\n): BabelTransformPluginOptions {\n try {\n return Array.isArray(plugin) && plugin.length > 0 && plugin[0]\n ? isFunction(plugin[0])\n ? plugin[0](context)\n : plugin[0]\n : isFunction(plugin)\n ? plugin(context)\n : plugin;\n } catch {\n return plugin[0];\n }\n}\n\n/**\n * Resolve the [Babel](https://babeljs.io/) plugin.\n *\n * @param context - The context for the transformation.\n * @param code - The code to be transformed.\n * @param id - The ID of the source file.\n * @param plugin - The Babel plugin to resolve.\n * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.\n */\nexport function resolveBabelPlugin(\n context: Context,\n code: string,\n id: string,\n plugin: BabelTransformPluginOptions\n): ResolvedBabelTransformPluginOptions | undefined {\n if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {\n if (\n plugin.length > 2 &&\n plugin[2] &&\n isFunction(plugin[2]) &&\n !plugin[2](code, id)\n ) {\n context.log(\n LogLevelLabel.TRACE,\n `Skipping filtered Babel plugin ${chalk.bold.cyanBright(\n getPluginName(plugin) || \"unnamed\"\n )} for ${id}`\n );\n\n return undefined;\n }\n\n return plugin.length > 2\n ? [resolvePluginFunction(context, plugin), plugin[1], plugin[2]]\n : [resolvePluginFunction(context, plugin), plugin[1], null];\n }\n\n return [resolvePluginFunction(context, plugin), {}, null];\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { transformAsync } from \"@babel/core\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport {\n findFileExtension,\n findFileExtensionSafe\n} from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport defu from \"defu\";\nimport { ResolvedBabelTransformPluginOptions } from \"powerlines/types/babel\";\nimport { UserConfig } from \"powerlines/types/config\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { isDuplicatePlugin } from \"./helpers/filters\";\nimport { resolveBabelPlugin } from \"./helpers/options\";\nimport { BabelPluginContext, BabelPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * Babel plugin for Powerlines.\n *\n * @param options - The Babel plugin user configuration options.\n * @returns A Powerlines plugin that integrates Babel transformations.\n */\nexport const plugin = (\n options: BabelPluginOptions = {}\n): Plugin<BabelPluginContext> => {\n return {\n name: \"babel\",\n config() {\n if (!isSetObject(options)) {\n return undefined;\n }\n\n return {\n transform: { babel: options }\n } as Partial<UserConfig>;\n },\n configResolved: {\n order: \"pre\",\n handler() {\n this.devDependencies[\"@babel/core\"] = \"^7.28.4\";\n\n this.config.transform.babel = defu(this.config.transform.babel ?? {}, {\n plugins: [],\n presets: []\n });\n }\n },\n async transform(code: string, id: string) {\n if (\n isParentPath(id, this.powerlinesPath) ||\n code.includes(\"/* @storm-ignore */\") ||\n code.includes(\"/* @storm-disable */\")\n ) {\n this.log(\n LogLevelLabel.TRACE,\n `Skipping Babel transformation for: ${id}`\n );\n\n return { code, id };\n }\n\n this.log(LogLevelLabel.TRACE, `Babel transforming file: ${id}`);\n\n const plugins = this.config.transform.babel.plugins\n .map(plugin => resolveBabelPlugin(this, code, id, plugin))\n .filter(\n (plugin, _, arr) => plugin && !isDuplicatePlugin(arr, plugin)\n ) as ResolvedBabelTransformPluginOptions[];\n const presets = this.config.transform.babel.presets\n .map(preset => resolveBabelPlugin(this, code, id, preset))\n .filter(\n (preset, _, arr) => preset && !isDuplicatePlugin(arr, preset)\n ) as ResolvedBabelTransformPluginOptions[];\n\n if (\n Array.isArray(plugins) &&\n plugins.length === 0 &&\n Array.isArray(presets) &&\n presets.length === 0\n ) {\n return { code, id };\n }\n\n if (\n [\"ts\", \"cts\", \"mts\", \"tsx\"].includes(findFileExtensionSafe(id)) &&\n !isDuplicatePlugin(plugins, \"@babel/plugin-syntax-typescript\") &&\n !isDuplicatePlugin(presets, \"@babel/preset-typescript\")\n ) {\n plugins.unshift([\n \"@babel/plugin-syntax-typescript\",\n { isTSX: findFileExtension(id) === \".tsx\" }\n ]);\n }\n\n const result = await transformAsync(code, {\n highlightCode: true,\n code: true,\n ast: false,\n cloneInputAst: false,\n comments: true,\n sourceType: \"module\",\n configFile: false,\n babelrc: false,\n envName: this.config.mode,\n caller: {\n name: this.config.framework\n },\n ...(this.config.transform.babel ?? {}),\n filename: id,\n plugins: plugins\n .map(plugin => {\n return Array.isArray(plugin) && plugin.length >= 2\n ? [\n plugin[0],\n defu(plugin.length > 1 && plugin[1] ? plugin[1] : {}, {\n options\n })\n ]\n : plugin;\n })\n .filter(Boolean),\n presets: presets\n .map(preset => {\n return Array.isArray(preset) && preset.length >= 2\n ? [\n preset[0],\n defu(preset.length > 1 && preset[1] ? preset[1] : {}, {\n options\n })\n ]\n : preset;\n })\n .filter(Boolean)\n });\n if (!result?.code) {\n throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);\n }\n\n return { code: result.code, id };\n }\n } as Plugin<BabelPluginContext>;\n};\n\nexport default plugin;\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { createAlloyPlugin } from \"@powerlines/alloy/create-plugin\";\nimport {\n ReflectionClass,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { createDirectory } from \"@stryke/fs/helpers\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvBuiltin } from \"./components/env\";\nimport { loadEnv } from \"./helpers/load\";\nimport {\n getEnvDefaultTypeDefinition,\n getEnvReflectionsPath,\n getEnvTypeReflectionsPath,\n getSecretsDefaultTypeDefinition,\n readEnvReflection,\n readEnvTypeReflection,\n readSecretsReflection,\n writeEnvReflection,\n writeEnvTypeReflection\n} from \"./helpers/persistence\";\nimport { reflectEnv, reflectSecrets } from \"./helpers/reflect\";\nimport { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport * from \"./babel\";\nexport * from \"./components\";\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = createAlloyPlugin<EnvPluginContext>(\n (options: EnvPluginOptions = {}) => {\n return {\n name: \"env\",\n dependsOn: [babel(options.babel)],\n async config() {\n this.log(\n LogLevelLabel.TRACE,\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n prefix: []\n }),\n transform: {\n babel: {\n plugins: [envBabelPlugin]\n }\n }\n };\n\n if (config.env.types) {\n config.env.types = parseTypeDefinition(\n config.env.types\n ) as TypeDefinition;\n } else {\n this.log(\n LogLevelLabel.WARN,\n \"The `env.types` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n const envDefaultTypeDefinition =\n await getEnvDefaultTypeDefinition(this);\n config.env.types = parseTypeDefinition(\n `${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n\n if (config.env.secrets) {\n config.env.secrets = parseTypeDefinition(\n config.env.secrets\n ) as TypeDefinition;\n } else {\n const secretsDefaultTypeDefinition =\n await getSecretsDefaultTypeDefinition(this);\n config.env.secrets = parseTypeDefinition(\n `${secretsDefaultTypeDefinition.file}#${\n secretsDefaultTypeDefinition.name\n }`\n ) as TypeDefinition;\n }\n\n config.env.prefix = toArray(\n (config.env.prefix ?? []) as string[]\n ).reduce(\n (ret: string[], prefix: string) => {\n const formattedPrefix = constantCase(prefix);\n if (!ret.includes(formattedPrefix)) {\n ret.push(formattedPrefix);\n }\n\n return ret;\n },\n [...ENV_PREFIXES, \"POWERLINES_\"] as string[]\n );\n\n config.env.prefix = config.env.prefix.reduce((ret, prefix) => {\n if (!ret.includes(prefix.replace(/_$/g, \"\"))) {\n ret.push(prefix.replace(/_$/g, \"\"));\n }\n return ret;\n }, [] as string[]);\n\n return config;\n },\n async configResolved() {\n this.log(\n LogLevelLabel.TRACE,\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n this.config.env.inject ??= this.config.projectType === \"application\";\n this.env = defu(\n {\n parsed: await loadEnv(this, this.config.env)\n },\n this.env ?? {},\n {\n types: {\n env: {}\n },\n used: {\n env: {},\n secrets: {}\n },\n parsed: {},\n injected: {}\n }\n ) as EnvPluginContext[\"env\"];\n\n if (\n this.config.command !== \"prepare\" &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n existsSync(getEnvTypeReflectionsPath(this, \"env\"))\n ) {\n this.log(\n LogLevelLabel.TRACE,\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n this.env.types.env = await readEnvTypeReflection(this, \"env\");\n\n if (existsSync(getEnvReflectionsPath(this, \"env\"))) {\n this.env.used.env = await readEnvReflection(this);\n }\n\n if (existsSync(getEnvTypeReflectionsPath(this, \"secrets\"))) {\n this.env.types.secrets = await readEnvTypeReflection(\n this,\n \"secrets\"\n );\n }\n\n if (existsSync(getEnvReflectionsPath(this, \"secrets\"))) {\n this.env.used.secrets = await readSecretsReflection(this);\n }\n } else {\n this.env.types.env = await reflectEnv(\n this,\n this.config.env.types?.file\n ? isParentPath(\n this.config.env.types?.file,\n this.workspaceConfig.workspaceRoot\n )\n ? this.config.env.types?.file\n : joinPaths(\n this.config.projectRoot,\n this.config.env.types?.file\n )\n : undefined,\n this.config.env.types?.name\n );\n if (!this.env.types.env) {\n throw new Error(\n \"Failed to find the environment configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.env, \"env\");\n\n this.env.types.secrets = await reflectSecrets(\n this,\n this.config.env.secrets?.file\n ? isParentPath(\n this.config.env.secrets?.file,\n this.workspaceConfig.workspaceRoot\n )\n ? this.config.env.secrets?.file\n : joinPaths(\n this.config.projectRoot,\n this.config.env.secrets?.file\n )\n : undefined,\n this.config.env.secrets?.name\n );\n if (!this.env.types.secrets) {\n throw new Error(\n \"Failed to find the secrets configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.secrets, \"secrets\");\n\n this.log(\n LogLevelLabel.TRACE,\n `Resolved ${\n this.env.types.env.getProperties().length ?? 0\n } environment configuration parameters and ${\n this.env.types.secrets?.getProperties().length ?? 0\n } secret configuration parameters`\n );\n\n const envWithAlias = this.env.types.env\n .getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n Object.entries(await loadEnv(this, this.config.env)).forEach(\n ([key, value]) => {\n const unprefixedKey = this.config.env.prefix.reduce(\n (ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n },\n key\n );\n\n const aliasKey = envWithAlias.find(prop =>\n prop?.getAlias().reverse().includes(unprefixedKey)\n );\n if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) {\n this.env.types.env\n .getProperty(unprefixedKey)\n .setDefaultValue(value);\n }\n }\n );\n\n this.env.used.env = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.env\n );\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n\n if (this.env.types.secrets) {\n await writeEnvTypeReflection(\n this,\n this.env.types.secrets,\n \"secrets\"\n );\n\n this.env.used.secrets = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.secrets\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n render() {\n this.log(\n LogLevelLabel.TRACE,\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n return <EnvBuiltin defaultConfig={this.config.env.defaultConfig} />;\n },\n async docs() {\n this.log(\n LogLevelLabel.TRACE,\n \"Writing Environment documentation for the Powerlines project artifacts.\"\n );\n\n // Clean and recreate the output directories\n const outputPath = joinPaths(\n this.config.projectRoot,\n \"docs\",\n \"generated\"\n );\n\n if (!existsSync(outputPath)) {\n await createDirectory(outputPath);\n }\n\n const reflection = await readEnvTypeReflection(this, \"env\");\n const envDocFile = joinPaths(outputPath, \"env.md\");\n\n this.log(\n LogLevelLabel.TRACE,\n `Documenting environment variables configuration in \"${envDocFile}\"`\n );\n\n await this.fs.write(\n envDocFile,\n `<!-- Generated by Powerlines -->\n\n # Environment variables configuration\n\n Below is a list of environment variables used by the [${\n this.packageJson.name\n }](https://www.npmjs.com/package/${\n this.packageJson.name\n }) package. These values can be updated in the \\`.env\\` file in the root of the project.\n\n ## Environment Configuration\n\n The below list of environment variables 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.\n\n | Name | Description | Type | Default Value | Required |\n | ---- | ----------- | ---- | ------------- | :------: |\n ${reflection\n .getProperties()\n .filter(property => property.getNameAsString() !== \"__STORM_INJECTED__\")\n .sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString()))\n .map(reflectionProperty => {\n return `| ${reflectionProperty.getNameAsString().trim()} | ${(\n reflectionProperty\n .getDescription()\n ?.replaceAll(\"\\r\", \"\")\n ?.replaceAll(\"\\n\", \"\") ?? \"\"\n ).trim()} | ${stringifyType(reflectionProperty.getType())\n .trim()\n .replaceAll(\" | \", \", or \")} | ${\n reflectionProperty.hasDefault()\n ? String(reflectionProperty.getDefaultValue())?.includes('\"')\n ? reflectionProperty.getDefaultValue()\n : `\\`${reflectionProperty.getDefaultValue()}\\``\n : \"\"\n } | ${reflectionProperty.isValueRequired() ? \"\" : \"✔\"} |`;\n })\n .join(\"\\n\")}\n `\n );\n },\n async buildEnd() {\n const reflectionPath = getEnvReflectionsPath(this, \"env\");\n\n this.log(\n LogLevelLabel.TRACE,\n `Writing env reflection types to ${reflectionPath}.`\n );\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n // vite: {\n // config(config: ViteUserConfig, env: ViteConfigEnv) {\n // this.log(\n // LogLevelLabel.TRACE,\n // \"Writing Vite environment variables configuration for the Powerlines project artifacts.\"\n // );\n\n // return {\n // envPrefix: this.config.env.prefix\n // };\n // }\n // }\n };\n }\n);\n\nexport default plugin;\n"],"mappings":"0kEAyIA,SAAgBsB,EAAqBhB,EAAsC,CACzE,OACEN,EAAWM,EA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OAAON,EAAmBO,iBAAiB,CAAC,EAAEnE,SAAS,IAAI,CACzD4D,EAAmBO,iBAAiB,CACpC,KAAKP,EAAmBO,iBAAiB,CAAA,IAC3C,GAAE,KACFP,EAAmBQ,iBAAiB,CAAG,GAAK,IAAG,IACrD,CACDC,KAAK;EAAK,CAAA;QAEV,EAEH,MAAMC,UAAW,CACf,IAAMC,EAAiBrG,EAAsB,KAAM,MAAM,CAEzD,KAAKe,IACH7B,EAAc8B,MACd,mCAAmCqF,EAAc,GAClD,CAED,MAAM/F,EAAmB,KAAM,KAAKW,IAAIoB,KAAKpB,IAAK,MAAM,EAc3D,EAEJ,CAED,IAAA,GAAeP"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./source-file-env-BDFTs5WJ.mjs";import{isSetString as t}from"@stryke/type-checks/is-set-string";import{isSetObject as n}from"@stryke/type-checks/is-set-object";import r from"defu";import{joinPaths as i}from"@stryke/path/join-paths";import{loadEnv as a,loadEnvFile as o}from"@stryke/env/load-env";import{kebabCase as s}from"@stryke/string-format/kebab-case";import{loadConfig as c}from"c12";async function l(t,n,i){let s=await a(i,n);if(t.additionalFiles&&t.additionalFiles?.length>0){let e=await Promise.all(t.additionalFiles.map(async e=>o(e,i)));for(let t of e)s=r(t,s)}return e(s)}async function u(e,t,n,a,o,s){let[u,d]=await Promise.all([l(e,n,t),c({cwd:t,name:`storm`,envName:n,defaults:{NAME:o.name?.replace(`@${s.namespace}/`,``),MODE:n,ORG:s.organization},globalRc:!0,packageJson:!0,dotenv:!0,jitiOptions:{fsCache:i(a,`jiti`),moduleCache:!0}})]);return r(u,d.config,s)}function d(e,i){return r({APP_NAME:s(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,``)),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${s(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:t(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode===`development`,STACKTRACE:e.workspaceConfig.mode===`development`,ENVIRONMENT:e.environment},n(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((e,t)=>(e[t.name]=i[t.name]??t.getDefaultValue(),e),{}):{})}async function f(e,t){let[n,i,a]=await Promise.all([u(t,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return r(d(e,process.env),n,i,a)}export{d as n,f as t};
2
+ //# sourceMappingURL=load-BZTlThWg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-BZTlThWg.mjs","names":["loadEnv","loadEnvBase","loadEnvFile","loadEnvFileBase","joinPaths","kebabCase","isSetObject","isSetString","loadConfig","defu","removeEnvPrefix","loadEnvFiles","options","mode","cwd","env","additionalFiles","length","additionalEnvFiles","Promise","all","map","additionalEnvFile","loadEnvDirectory","directory","cacheDir","packageJson","workspaceConfig","envResult","c12Result","name","envName","defaults","NAME","replace","namespace","MODE","ORG","organization","globalRc","dotenv","jitiOptions","fsCache","moduleCache","config","loadEnvFromContext","context","parsed","APP_NAME","APP_VERSION","version","BUILD_ID","meta","buildId","BUILD_TIMESTAMP","Date","timestamp","toISOString","BUILD_CHECKSUM","checksum","RELEASE_ID","releaseId","RELEASE_TAG","DEFAULT_LOCALE","locale","DEFAULT_TIMEZONE","timezone","LOG_LEVEL","logLevel","ERROR_URL","error","url","ORGANIZATION","PLATFORM","build","platform","DEBUG","STACKTRACE","ENVIRONMENT","environment","types","getProperties","reduce","ret","prop","getDefaultValue","project","workspace","projectRoot","cachePath","workspaceRoot","envPaths","process"],"sources":["../src/helpers/load.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines/types/config\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: workspaceConfig.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput\n) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL: context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION: isSetString(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization\n : context.workspaceConfig.organization?.name,\n PLATFORM: context.config.build.platform,\n MODE: context.workspaceConfig.mode,\n DEBUG: context.workspaceConfig.mode === \"development\",\n STACKTRACE: context.workspaceConfig.mode === \"development\",\n ENVIRONMENT: context.environment\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.projectRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":"yZAkCA,eAAeW,EACbC,EACAC,EACAC,EACe,CACf,IAAIC,EAAM,MAAMd,EAAYa,EAAKD,EAAK,CACtC,GAAID,EAAQI,iBAAmBJ,EAAQI,iBAAiBC,OAAS,EAAG,CAClE,IAAMC,EAAqB,MAAMC,QAAQC,IACvCR,EAAQI,gBAAgBK,IAAI,KAAMC,IAChCnB,EAAgBmB,EAAmBR,EACrC,CACF,CAAC,CAED,IAAK,IAAMQ,KAAqBJ,EAC9BH,EAAMN,EAAKa,EAAmBP,EAAI,CAItC,OAAOL,EAAgBK,EAAI,CAG7B,eAAeQ,EAGbX,EACAY,EACAX,EACAY,EACAC,EACAC,EACe,CACf,GAAM,CAACC,EAAWC,GAAa,MAAMV,QAAQC,IAAI,CAC/CT,EAAmBC,EAASC,EAAMW,EAAU,CAC5ChB,EAAW,CACTM,IAAKU,EACLM,KAAM,QACNC,QAASl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jE,IAAI,CACjC+B,EAAQ/B,IAAIiE,MAAMjE,KAAKkE,eAAe,CAACC,QACpCC,EAAKC,KACJD,EAAIC,EAAKtD,MAAQiB,EAAOqC,EAAKtD,OAASsD,EAAKC,iBAAiB,CACrDF,GAET,EACF,CAAC,CACD,EACN,CAAC,CAGH,eAAsBnF,EAEpB8C,EAA2BlC,EAA0C,CACrE,GAAM,CAAC0E,EAASC,EAAW3C,GAAU,MAAMzB,QAAQC,IAAI,CACrDG,EACEX,EACAkC,EAAQF,OAAO4C,YACf1C,EAAQF,OAAO/B,KACfiC,EAAQ2C,UACR3C,EAAQpB,YACRoB,EAAQnB,gBACT,CACDJ,EACEX,EACAkC,EAAQnB,gBAAgB+D,cACxB5C,EAAQF,OAAO/B,KACfiC,EAAQ2C,UACR3C,EAAQpB,YACRoB,EAAQnB,gBACT,CACDJ,EACEX,EACAkC,EAAQ6C,SAAS/C,OACjBE,EAAQF,OAAO/B,KACfiC,EAAQ2C,UACR3C,EAAQpB,YACRoB,EAAQnB,gBACT,CACF,CAAC,CAEF,OAAOlB,EACLoC,EAAmBC,EAAS8C,QAAQ7E,IAAI,CACxCuE,EACAC,EACA3C,EACD"}
@@ -0,0 +1,36 @@
1
+ import { n as EnvPluginOptions, t as EnvPluginContext } from "./plugin-Cl-yPswT.cjs";
2
+ import { u as EnvironmentResolvedConfig } from "./config-Dli3ofDp.cjs";
3
+ import { DotenvParseOutput } from "@stryke/env/types";
4
+
5
+ //#region src/helpers/load.d.ts
6
+
7
+ /**
8
+ * Retrieves various dotenv configuration parameters from the context.
9
+ *
10
+ * @param context - The context to retrieve the dotenv configuration from.
11
+ * @param parsed - The parsed dotenv configuration.
12
+ * @returns An object containing the dotenv configuration.
13
+ */
14
+ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
15
+ APP_NAME: string | undefined;
16
+ APP_VERSION: string | undefined;
17
+ BUILD_ID: string;
18
+ BUILD_TIMESTAMP: string;
19
+ BUILD_CHECKSUM: string;
20
+ RELEASE_ID: string;
21
+ RELEASE_TAG: string;
22
+ DEFAULT_LOCALE: string | undefined;
23
+ DEFAULT_TIMEZONE: string | undefined;
24
+ LOG_LEVEL: "error" | "warn" | "info" | "debug" | "trace" | null;
25
+ ERROR_URL: string | undefined;
26
+ ORGANIZATION: string | undefined;
27
+ PLATFORM: "node" | "browser" | "neutral" | undefined;
28
+ MODE: "test" | "development" | "production" | undefined;
29
+ DEBUG: boolean;
30
+ STACKTRACE: boolean;
31
+ ENVIRONMENT: EnvironmentResolvedConfig;
32
+ };
33
+ declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
34
+ //#endregion
35
+ export { loadEnvFromContext as n, loadEnv as t };
36
+ //# sourceMappingURL=load-CWOZ3u-s.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-CWOZ3u-s.d.cts","names":[],"sources":["../src/helpers/load.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAgGA;;;;iBAAgB,kBAAA,UACL,0BACD;EA0CY,QAAA,EAAO,MAAA,GAAA,SAAA;EACd,WAAA,EAAA,MAAA,GAAA,SAAA;EAAoB,QAAA,EAAA,MAAA;EACxB,eAAA,EAAA,MAAA;EAA2B,cAAA,EAAA,MAAA;EAA2B,UAAA,EAAA,MAAA;EAAR,WAAA,EAAA,MAAA;EAAO,cAAA,EAAA,MAAA,GAAA,SAAA;;;;;;;;;eA5CrC;;iBA0CL,qBACP,oBAAoB,4BACxB,2BAA2B,mBAAmB,QAAQ"}
@@ -0,0 +1,39 @@
1
+ import { n as EnvPluginOptions, t as EnvPluginContext } from "./plugin-VRahDLZZ.mjs";
2
+ import { u as EnvironmentResolvedConfig } from "./config-D2esSp2r.mjs";
3
+ import { DotenvParseOutput } from "@stryke/env/types";
4
+ import { MaybePromise } from "@stryke/types/base";
5
+ import { UnpluginOptions } from "unplugin";
6
+ import { ArrayValues } from "@stryke/types/array";
7
+
8
+ //#region src/helpers/load.d.ts
9
+
10
+ /**
11
+ * Retrieves various dotenv configuration parameters from the context.
12
+ *
13
+ * @param context - The context to retrieve the dotenv configuration from.
14
+ * @param parsed - The parsed dotenv configuration.
15
+ * @returns An object containing the dotenv configuration.
16
+ */
17
+ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
18
+ APP_NAME: string | undefined;
19
+ APP_VERSION: string | undefined;
20
+ BUILD_ID: string;
21
+ BUILD_TIMESTAMP: string;
22
+ BUILD_CHECKSUM: string;
23
+ RELEASE_ID: string;
24
+ RELEASE_TAG: string;
25
+ DEFAULT_LOCALE: string | undefined;
26
+ DEFAULT_TIMEZONE: string | undefined;
27
+ LOG_LEVEL: "error" | "warn" | "info" | "debug" | "trace" | null;
28
+ ERROR_URL: string | undefined;
29
+ ORGANIZATION: string | undefined;
30
+ PLATFORM: "node" | "browser" | "neutral" | undefined;
31
+ MODE: "test" | "development" | "production" | undefined;
32
+ DEBUG: boolean;
33
+ STACKTRACE: boolean;
34
+ ENVIRONMENT: EnvironmentResolvedConfig;
35
+ };
36
+ declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
37
+ //#endregion
38
+ export { loadEnvFromContext as n, loadEnv as t };
39
+ //# sourceMappingURL=load-Dzf30s_a.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-Dzf30s_a.d.mts","names":[],"sources":["../src/helpers/load.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AAgGA;AACW,iBADK,kBAAA,CACL,OAAA,EAAA,gBAAA,EAAA,MAAA,EACD,iBADC,CAAA,EAAA;EACD,QAAA,EAAA,MAAA,GAAA,SAAA;EAAiB,WAAA,EAAA,MAAA,GAAA,SAAA;;EA0CL,eAAO,EAAA,MAAA;EACd,cAAA,EAAA,MAAA;EAAoB,UAAA,EAAA,MAAA;EACxB,WAAA,EAAA,MAAA;EAA2B,cAAA,EAAA,MAAA,GAAA,SAAA;EAA2B,gBAAA,EAAA,MAAA,GAAA,SAAA;EAAR,SAAA,EAAA,OAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,IAAA;EAAO,SAAA,EAAA,MAAA,GAAA,SAAA;;;;;;eA5CrC;;iBA0CL,qBACP,oBAAoB,4BACxB,2BAA2B,mBAAmB,QAAQ"}
@@ -0,0 +1 @@
1
+ const e=require(`./chunk-DT2f8AgL.cjs`),t=require(`./source-file-env-C6uYyxww.cjs`);let n=require(`@stryke/type-checks/is-set-string`),r=require(`@stryke/type-checks/is-set-object`),i=require(`defu`);i=e.n(i);let a=require(`@stryke/path/join-paths`),o=require(`@stryke/env/load-env`),s=require(`@stryke/string-format/kebab-case`),c=require(`c12`);async function l(e,n,r){let a=await(0,o.loadEnv)(r,n);if(e.additionalFiles&&e.additionalFiles?.length>0){let t=await Promise.all(e.additionalFiles.map(async e=>(0,o.loadEnvFile)(e,r)));for(let e of t)a=(0,i.default)(e,a)}return t.n(a)}async function u(e,t,n,r,o,s){let[u,d]=await Promise.all([l(e,n,t),(0,c.loadConfig)({cwd:t,name:`storm`,envName:n,defaults:{NAME:o.name?.replace(`@${s.namespace}/`,``),MODE:n,ORG:s.organization},globalRc:!0,packageJson:!0,dotenv:!0,jitiOptions:{fsCache:(0,a.joinPaths)(r,`jiti`),moduleCache:!0}})]);return(0,i.default)(u,d.config,s)}function d(e,t){return(0,i.default)({APP_NAME:(0,s.kebabCase)(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,``)),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${(0,s.kebabCase)(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:(0,n.isSetString)(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode===`development`,STACKTRACE:e.workspaceConfig.mode===`development`,ENVIRONMENT:e.environment},(0,r.isSetObject)(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((e,n)=>(e[n.name]=t[n.name]??n.getDefaultValue(),e),{}):{})}async function f(e,t){let[n,r,a]=await Promise.all([u(t,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return(0,i.default)(d(e,process.env),n,r,a)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
@@ -1,33 +1,9 @@
1
- import { ReflectionClass } from '@deepkit/type';
2
- import { TypeDefinition } from '@stryke/types/configuration';
3
- import { U as UnresolvedContext, C as Context } from '../runtime-B75FziIk.js';
4
- import { EnvPluginResolvedConfig, EnvType, EnvPluginContext } from '../types/plugin.js';
5
- import '@stryke/env/get-env-paths';
6
- import '@stryke/http/fetch';
7
- import '@stryke/types/base';
8
- import '@stryke/types/package-json';
9
- import 'jiti';
10
- import 'magic-string';
11
- import 'oxc-parser';
12
- import 'semver';
13
- import 'ts-morph';
14
- import 'undici';
15
- import 'unplugin';
16
- import '@babel/core';
17
- import '@storm-software/build-tools/types';
18
- import '@storm-software/config-tools/types';
19
- import '@storm-software/config/types';
20
- import '@stryke/types/file';
21
- import 'vite';
22
- import '@babel/helper-plugin-utils';
23
- import '../fs-ECFlqnPg.js';
24
- import '@stryke/fs/resolve';
25
- import '@stryke/types/array';
26
- import '@stryke/types/tsconfig';
27
- import 'typescript';
28
- import '@alloy-js/core/jsx-runtime';
29
- import '@stryke/capnp';
30
- import '@stryke/env/types';
1
+ import { t as type_d_exports } from "./type-D6dRgWJT.cjs";
2
+ import { a as EnvType, r as EnvPluginResolvedConfig, t as EnvPluginContext } from "./plugin-Cl-yPswT.cjs";
3
+ import { i as Context, s as UnresolvedContext } from "./config-Dli3ofDp.cjs";
4
+ import { TypeDefinition } from "@stryke/types/configuration";
5
+
6
+ //#region src/helpers/persistence.d.ts
31
7
 
32
8
  /**
33
9
  * Resolves the runtime type definition file for the environment variables.
@@ -64,7 +40,7 @@ declare function getEnvTypeReflectionsPath(context: Context<EnvPluginResolvedCon
64
40
  * @param name - The name of the type reflections.
65
41
  * @returns The environment type reflection.
66
42
  */
67
- declare function readEnvTypeReflection(context: EnvPluginContext, name?: EnvType): Promise<ReflectionClass<any>>;
43
+ declare function readEnvTypeReflection(context: EnvPluginContext, name?: EnvType): Promise<type_d_exports.ReflectionClass<any>>;
68
44
  /**
69
45
  * Writes the environment type reflection to the file system.
70
46
  *
@@ -72,7 +48,7 @@ declare function readEnvTypeReflection(context: EnvPluginContext, name?: EnvType
72
48
  * @param reflection - The environment type reflection to write.
73
49
  * @param name - The name of the type reflections.
74
50
  */
75
- declare function writeEnvTypeReflection(context: EnvPluginContext, reflection: ReflectionClass<any>, name?: EnvType): Promise<void>;
51
+ declare function writeEnvTypeReflection(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): Promise<void>;
76
52
  declare function getEnvReflectionsPath(context: EnvPluginContext, name: EnvType): string;
77
53
  /**
78
54
  * Reads the environment reflection data from the file system.
@@ -80,14 +56,14 @@ declare function getEnvReflectionsPath(context: EnvPluginContext, name: EnvType)
80
56
  * @param context - The plugin context.
81
57
  * @returns The environment reflection data.
82
58
  */
83
- declare function readEnvReflection(context: EnvPluginContext): Promise<ReflectionClass<any>>;
59
+ declare function readEnvReflection(context: EnvPluginContext): Promise<type_d_exports.ReflectionClass<any>>;
84
60
  /**
85
61
  * Reads the secret environment reflection data from the file system.
86
62
  *
87
63
  * @param context - The plugin context.
88
64
  * @returns The environment reflection data.
89
65
  */
90
- declare function readSecretsReflection(context: EnvPluginContext): Promise<ReflectionClass<any>>;
66
+ declare function readSecretsReflection(context: EnvPluginContext): Promise<type_d_exports.ReflectionClass<any>>;
91
67
  /**
92
68
  * Writes the environment reflection data to the file system.
93
69
  *
@@ -95,7 +71,7 @@ declare function readSecretsReflection(context: EnvPluginContext): Promise<Refle
95
71
  * @param reflection - The reflection data to write.
96
72
  * @param name - The name of the reflection (either "env" or "secrets").
97
73
  */
98
- declare function writeEnvReflection(context: EnvPluginContext, reflection: ReflectionClass<any>, name?: EnvType): Promise<void>;
74
+ declare function writeEnvReflection(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): Promise<void>;
99
75
  /**
100
76
  * Writes the environment reflection data to the file system.
101
77
  *
@@ -103,6 +79,7 @@ declare function writeEnvReflection(context: EnvPluginContext, reflection: Refle
103
79
  * @param reflection - The reflection data to write.
104
80
  * @param name - The name of the reflection (either "env" or "secrets").
105
81
  */
106
- declare function writeEnvReflectionSync(context: EnvPluginContext, reflection: ReflectionClass<any>, name?: EnvType): void;
107
-
108
- export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
82
+ declare function writeEnvReflectionSync(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): void;
83
+ //#endregion
84
+ export { readEnvReflection as a, resolveRuntimeTypeFile as c, writeEnvTypeReflection as d, getSecretsDefaultTypeDefinition as i, writeEnvReflection as l, getEnvReflectionsPath as n, readEnvTypeReflection as o, getEnvTypeReflectionsPath as r, readSecretsReflection as s, getEnvDefaultTypeDefinition as t, writeEnvReflectionSync as u };
85
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