@powerlines/plugin-nodejs 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/components/env.cjs +188 -2
  3. package/dist/components/env.d.cts +9 -2
  4. package/dist/components/env.d.mts +9 -2
  5. package/dist/components/env.mjs +185 -1
  6. package/dist/components/index.cjs +2 -3
  7. package/dist/components/index.d.cts +1 -3
  8. package/dist/components/index.d.mts +1 -3
  9. package/dist/components/index.mjs +1 -2
  10. package/dist/deepkit/schemas/reflection.cjs +3940 -0
  11. package/dist/{plugin-D7kBf19k.d.cts → deepkit/schemas/reflection.d.cts} +1 -1078
  12. package/dist/{plugin-JL1BtFku.d.mts → deepkit/schemas/reflection.d.mts} +59 -1136
  13. package/dist/deepkit/schemas/reflection.mjs +3938 -0
  14. package/dist/deepkit/schemas/reflection2.cjs +4112 -0
  15. package/dist/deepkit/schemas/reflection2.mjs +4110 -0
  16. package/dist/deepkit/src/capnp.cjs +913 -0
  17. package/dist/deepkit/src/capnp.mjs +911 -0
  18. package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
  19. package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
  20. package/dist/deepkit/src/reflect-type.cjs +22 -0
  21. package/dist/deepkit/src/reflect-type.mjs +20 -0
  22. package/dist/deepkit/src/resolve-reflections.cjs +16 -0
  23. package/dist/deepkit/src/resolve-reflections.mjs +15 -0
  24. package/dist/deepkit/src/transformer.cjs +52 -0
  25. package/dist/deepkit/src/transformer.mjs +49 -0
  26. package/dist/deepkit/src/transpile.cjs +29 -0
  27. package/dist/deepkit/src/transpile.mjs +27 -0
  28. package/dist/deepkit/src/types.d.cts +10 -0
  29. package/dist/deepkit/src/types.d.mts +10 -0
  30. package/dist/deepkit/src/utilities.cjs +66 -0
  31. package/dist/deepkit/src/utilities.mjs +65 -0
  32. package/dist/index.cjs +14 -813
  33. package/dist/index.d.cts +5 -5
  34. package/dist/index.d.mts +5 -5
  35. package/dist/index.mjs +11 -803
  36. package/dist/plugin-alloy/src/core/components/output.cjs +45 -0
  37. package/dist/plugin-alloy/src/core/components/output.mjs +44 -0
  38. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
  39. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
  40. package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
  41. package/dist/plugin-alloy/src/core/components/source-file.d.cts +23 -0
  42. package/dist/plugin-alloy/src/core/components/source-file.d.mts +23 -0
  43. package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
  44. package/dist/plugin-alloy/src/core/contexts/context.cjs +60 -0
  45. package/dist/plugin-alloy/src/core/contexts/context.mjs +54 -0
  46. package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
  47. package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
  48. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
  49. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
  50. package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
  51. package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
  52. package/dist/plugin-alloy/src/index.cjs +93 -0
  53. package/dist/plugin-alloy/src/index.mjs +91 -0
  54. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
  55. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
  56. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
  57. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
  58. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
  59. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
  60. package/dist/plugin-alloy/src/types/components.d.cts +22 -0
  61. package/dist/plugin-alloy/src/types/components.d.mts +24 -0
  62. package/dist/plugin-alloy/src/types/index.d.mts +2 -0
  63. package/dist/plugin-alloy/src/types/plugin.d.cts +37 -0
  64. package/dist/plugin-alloy/src/types/plugin.d.mts +37 -0
  65. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +57 -0
  66. package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +25 -0
  67. package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +26 -0
  68. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +56 -0
  69. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +126 -0
  70. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +124 -0
  71. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +442 -0
  72. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +27 -0
  73. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +28 -0
  74. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +433 -0
  75. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +194 -0
  76. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +14 -0
  77. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +15 -0
  78. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +191 -0
  79. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +68 -0
  80. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +1 -0
  81. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +4 -0
  82. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +67 -0
  83. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
  84. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
  85. package/dist/plugin-automd/src/index.cjs +101 -0
  86. package/dist/plugin-automd/src/index.mjs +98 -0
  87. package/dist/plugin-automd/src/types/plugin.d.cts +38 -0
  88. package/dist/plugin-automd/src/types/plugin.d.mts +40 -0
  89. package/dist/plugin-automd/src/types/toc.d.cts +33 -0
  90. package/dist/plugin-automd/src/types/toc.d.mts +33 -0
  91. package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
  92. package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
  93. package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
  94. package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
  95. package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
  96. package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
  97. package/dist/plugin-babel/src/helpers/index.cjs +5 -0
  98. package/dist/plugin-babel/src/helpers/index.mjs +7 -0
  99. package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
  100. package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
  101. package/dist/plugin-babel/src/helpers/options.cjs +50 -0
  102. package/dist/plugin-babel/src/helpers/options.mjs +47 -0
  103. package/dist/plugin-babel/src/index.cjs +91 -0
  104. package/dist/plugin-babel/src/index.mjs +89 -0
  105. package/dist/plugin-babel/src/types/index.d.mts +1 -0
  106. package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
  107. package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
  108. package/dist/plugin-env/src/babel/index.cjs +1 -0
  109. package/dist/plugin-env/src/babel/index.mjs +3 -0
  110. package/dist/plugin-env/src/babel/plugin.cjs +121 -0
  111. package/dist/plugin-env/src/babel/plugin.mjs +119 -0
  112. package/dist/plugin-env/src/components/docs.cjs +9 -0
  113. package/dist/plugin-env/src/components/docs.mjs +11 -0
  114. package/dist/plugin-env/src/components/env.cjs +575 -0
  115. package/dist/plugin-env/src/components/env.d.cts +11 -0
  116. package/dist/plugin-env/src/components/env.d.mts +11 -0
  117. package/dist/plugin-env/src/components/env.mjs +572 -0
  118. package/dist/plugin-env/src/components/index.cjs +2 -0
  119. package/dist/plugin-env/src/components/index.mjs +4 -0
  120. package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
  121. package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
  122. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
  123. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
  124. package/dist/plugin-env/src/helpers/index.cjs +6 -0
  125. package/dist/plugin-env/src/helpers/index.mjs +8 -0
  126. package/dist/plugin-env/src/helpers/load.cjs +83 -0
  127. package/dist/plugin-env/src/helpers/load.mjs +80 -0
  128. package/dist/plugin-env/src/helpers/persistence.cjs +199 -0
  129. package/dist/plugin-env/src/helpers/persistence.mjs +188 -0
  130. package/dist/plugin-env/src/helpers/reflect.cjs +111 -0
  131. package/dist/plugin-env/src/helpers/reflect.mjs +103 -0
  132. package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
  133. package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
  134. package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
  135. package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
  136. package/dist/plugin-env/src/index.cjs +175 -0
  137. package/dist/plugin-env/src/index.mjs +173 -0
  138. package/dist/plugin-env/src/types/plugin.d.cts +151 -0
  139. package/dist/plugin-env/src/types/plugin.d.mts +153 -0
  140. package/dist/plugin-env/src/types/runtime.d.cts +792 -0
  141. package/dist/plugin-env/src/types/runtime.d.mts +792 -0
  142. package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
  143. package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
  144. package/dist/powerlines/src/lib/entry.cjs +12 -0
  145. package/dist/powerlines/src/lib/entry.mjs +14 -0
  146. package/dist/powerlines/src/lib/logger.cjs +41 -0
  147. package/dist/powerlines/src/lib/logger.mjs +39 -0
  148. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -0
  149. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -0
  150. package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
  151. package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
  152. package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
  153. package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
  154. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
  155. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
  156. package/dist/powerlines/src/types/babel.d.cts +22 -0
  157. package/dist/powerlines/src/types/babel.d.mts +22 -0
  158. package/dist/powerlines/src/types/build.d.cts +145 -0
  159. package/dist/powerlines/src/types/build.d.mts +145 -0
  160. package/dist/powerlines/src/types/commands.d.cts +8 -0
  161. package/dist/powerlines/src/types/commands.d.mts +9 -0
  162. package/dist/powerlines/src/types/config.d.cts +387 -0
  163. package/dist/powerlines/src/types/config.d.mts +388 -0
  164. package/dist/powerlines/src/types/context.d.cts +414 -0
  165. package/dist/powerlines/src/types/context.d.mts +416 -0
  166. package/dist/powerlines/src/types/fs.d.cts +486 -0
  167. package/dist/powerlines/src/types/fs.d.mts +486 -0
  168. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  169. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  170. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  171. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  172. package/dist/powerlines/src/types/resolved.d.mts +82 -0
  173. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  174. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  175. package/dist/types/index.cjs +0 -2
  176. package/dist/types/index.d.cts +1 -3
  177. package/dist/types/index.d.mts +1 -3
  178. package/dist/types/index.mjs +0 -3
  179. package/dist/types/plugin.cjs +0 -1
  180. package/dist/types/plugin.d.cts +22 -2
  181. package/dist/types/plugin.d.mts +22 -2
  182. package/dist/types/plugin.mjs +0 -2
  183. package/package.json +6 -6
  184. package/dist/components-BWLXb7a2.cjs +0 -0
  185. package/dist/components-CXZYcH4q.d.mts +0 -1816
  186. package/dist/components-kh0CpIG2.mjs +0 -1
  187. package/dist/env-CAhIy_H3.cjs +0 -11713
  188. package/dist/env-CUyFiniR.d.cts +0 -107
  189. package/dist/env-IF4XhMjG.mjs +0 -11570
  190. package/dist/env-sRb-Y8mJ.d.mts +0 -89
  191. package/dist/index-CUbWeWHc.d.mts +0 -1
  192. package/dist/index-D6CnpA_r.d.cts +0 -1
  193. package/dist/index-DL0uimUT.d.mts +0 -1
  194. package/dist/index-DWPDThxu.d.cts +0 -1
  195. package/dist/plugin-ifZVa20V.mjs +0 -1
  196. package/dist/plugin-pBKbb5K9.cjs +0 -0
  197. package/dist/resolved-zsx09G03.d.cts +0 -1795
  198. package/dist/types-U3zd8PTP.mjs +0 -1
  199. package/dist/types-o3zWarRp.cjs +0 -0
@@ -0,0 +1,572 @@
1
+ import { usePowerlines } from "../../../plugin-alloy/src/core/contexts/context.mjs";
2
+ import { refkey as refkey$1 } from "../../../plugin-alloy/src/helpers/refkey.mjs";
3
+ import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows } from "../../../plugin-alloy/src/typescript/components/tsdoc.mjs";
4
+ import { BuiltinFile } from "../../../plugin-alloy/src/typescript/components/builtin-file.mjs";
5
+ import { TypeScriptInterface } from "../../../plugin-alloy/src/typescript/components/typescript-interface.mjs";
6
+ import { TypescriptObject } from "../../../plugin-alloy/src/typescript/components/typescript-object.mjs";
7
+ import { loadEnvFromContext } from "../helpers/load.mjs";
8
+ import { createReflectionResource } from "../helpers/create-reflection-resource.mjs";
9
+ import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
10
+ import defu from "defu";
11
+ import { titleCase } from "@stryke/string-format/title-case";
12
+ import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
13
+ import { For, Show, code, computed, splitProps } from "@alloy-js/core";
14
+ import { isNull } from "@stryke/type-checks/is-null";
15
+ import { ClassDeclaration, ClassMethod, ElseIfClause, FunctionDeclaration, IfStatement, NewExpression, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
16
+
17
+ //#region ../plugin-env/src/components/env.tsx
18
+ /**
19
+ * Generates the environment configuration typescript definition for the Powerlines project.
20
+ */
21
+ function EnvTypeDefinition(props) {
22
+ const [{ defaultValue, reflection }] = splitProps(props, ["defaultValue", "reflection"]);
23
+ const context = usePowerlines();
24
+ return [
25
+ createComponent(TypeScriptInterface, {
26
+ name: " EnvBase",
27
+ "extends": ["EnvInterface"],
28
+ defaultValue,
29
+ reflection,
30
+ "export": true
31
+ }),
32
+ createIntrinsic("hbr", {}),
33
+ createIntrinsic("hbr", {}),
34
+ createComponent(TypeDeclaration, {
35
+ name: "Env",
36
+ "export": true,
37
+ get children() {
38
+ return code` {
39
+ [Key in keyof EnvBase as Key ${context?.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
40
+ }
41
+ `;
42
+ }
43
+ })
44
+ ];
45
+ }
46
+ function ConfigPropertyConditional(props) {
47
+ const [{ context, name }] = splitProps(props, ["context", "name"]);
48
+ if (!context) return null;
49
+ return code`propertyName === "${name}" || propertyName.replace(/^(${context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
50
+ }
51
+ function ConfigPropertyGet(props) {
52
+ const [{ context, property, index }] = splitProps(props, [
53
+ "context",
54
+ "property",
55
+ "index"
56
+ ]);
57
+ if (!context) return null;
58
+ return [index === 0 ? createComponent(IfStatement, {
59
+ get condition() {
60
+ return [createComponent(ConfigPropertyConditional, {
61
+ get name() {
62
+ return property.getNameAsString();
63
+ },
64
+ context
65
+ }), createComponent(Show, {
66
+ get when() {
67
+ return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
68
+ },
69
+ get children() {
70
+ return [code` || `, createComponent(For, {
71
+ get each() {
72
+ return property.getAlias();
73
+ },
74
+ joiner: code` || `,
75
+ children: (alias) => createComponent(ConfigPropertyConditional, {
76
+ name: alias,
77
+ context
78
+ })
79
+ })];
80
+ }
81
+ })];
82
+ },
83
+ get children() {
84
+ return code`return target["${property.getNameAsString()}"];`;
85
+ }
86
+ }) : createComponent(ElseIfClause, {
87
+ get condition() {
88
+ return [createComponent(ConfigPropertyConditional, {
89
+ get name() {
90
+ return property.getNameAsString();
91
+ },
92
+ context
93
+ }), createComponent(Show, {
94
+ get when() {
95
+ return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
96
+ },
97
+ get children() {
98
+ return [code` || `, createComponent(For, {
99
+ get each() {
100
+ return property.getAlias();
101
+ },
102
+ joiner: code` || `,
103
+ children: (alias) => createComponent(ConfigPropertyConditional, {
104
+ name: alias,
105
+ context
106
+ })
107
+ })];
108
+ }
109
+ })];
110
+ },
111
+ get children() {
112
+ return code`return target["${property.getNameAsString()}"];`;
113
+ }
114
+ })];
115
+ }
116
+ function ConfigPropertySet(props) {
117
+ const [{ context, property, index }] = splitProps(props, [
118
+ "context",
119
+ "property",
120
+ "index"
121
+ ]);
122
+ if (!context) return null;
123
+ return [index === 0 ? createComponent(IfStatement, {
124
+ get condition() {
125
+ return [createComponent(ConfigPropertyConditional, {
126
+ get name() {
127
+ return property.getNameAsString();
128
+ },
129
+ context
130
+ }), createComponent(Show, {
131
+ get when() {
132
+ return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
133
+ },
134
+ get children() {
135
+ return [code` || `, createComponent(For, {
136
+ get each() {
137
+ return property.getAlias();
138
+ },
139
+ joiner: code` || `,
140
+ children: (alias) => createComponent(ConfigPropertyConditional, {
141
+ name: alias,
142
+ context
143
+ })
144
+ })];
145
+ }
146
+ })];
147
+ },
148
+ get children() {
149
+ return code`
150
+ target["${property.getNameAsString()}"] = newValue;
151
+ return true;
152
+ `;
153
+ }
154
+ }) : createComponent(ElseIfClause, {
155
+ get condition() {
156
+ return [createComponent(ConfigPropertyConditional, {
157
+ get name() {
158
+ return property.getNameAsString();
159
+ },
160
+ context
161
+ }), createComponent(Show, {
162
+ get when() {
163
+ return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
164
+ },
165
+ get children() {
166
+ return [code` || `, createComponent(For, {
167
+ get each() {
168
+ return property.getAlias();
169
+ },
170
+ joiner: code` || `,
171
+ children: (alias) => createComponent(ConfigPropertyConditional, {
172
+ name: alias,
173
+ context
174
+ })
175
+ })];
176
+ }
177
+ })];
178
+ },
179
+ get children() {
180
+ return code`
181
+ target["${property.getNameAsString()}"] = newValue;
182
+ return true;
183
+ `;
184
+ }
185
+ })];
186
+ }
187
+ const createEnvRefkey = refkey$1("createEnv");
188
+ const envRefkey = refkey$1("env");
189
+ const envSerializerRefkey = refkey$1("EnvSerializer");
190
+ /**
191
+ * Generates the environment configuration module for the Powerlines project.
192
+ */
193
+ function EnvBuiltin(props) {
194
+ const [{ defaultConfig, children }, rest] = splitProps(props, ["defaultConfig", "children"]);
195
+ const context = usePowerlines();
196
+ const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
197
+ const reflection = createReflectionResource(context);
198
+ const envInstance = computed(() => {
199
+ return new ReflectionClass({
200
+ kind: ReflectionKind.objectLiteral,
201
+ description: `The initial environment configuration state for the ${titleCase(context?.config?.name)} project.`,
202
+ types: []
203
+ }, reflection.data ?? void 0);
204
+ });
205
+ const reflectionGetProperties = computed(() => reflection.data?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
206
+ const reflectionSetProperties = computed(() => reflection.data?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
207
+ return createComponent(BuiltinFile, mergeProps({
208
+ id: "env",
209
+ description: "The Powerlines environment configuration module provides an interface to define environment configuration parameters."
210
+ }, rest, {
211
+ get imports() {
212
+ return defu({
213
+ "@powerlines/deepkit/vendor/type": [
214
+ "Type",
215
+ "stringify",
216
+ "serializer",
217
+ "serializeFunction",
218
+ "deserializeFunction",
219
+ "ReflectionKind",
220
+ "TemplateState",
221
+ "Serializer",
222
+ "TypeProperty",
223
+ "TypePropertySignature"
224
+ ],
225
+ "@powerlines/plugin-env/types/runtime": [{ name: "EnvInterface" }]
226
+ }, rest.imports ?? {});
227
+ },
228
+ get children() {
229
+ return [
230
+ createComponent(Show, {
231
+ get when() {
232
+ return !isNull(reflection.data);
233
+ },
234
+ get children() {
235
+ return [
236
+ createComponent(EnvTypeDefinition, {
237
+ get defaultValue() {
238
+ return defaultValue.value;
239
+ },
240
+ get reflection() {
241
+ return reflection.data;
242
+ }
243
+ }),
244
+ createIntrinsic("hbr", {}),
245
+ createIntrinsic("hbr", {})
246
+ ];
247
+ }
248
+ }),
249
+ createComponent(TypescriptObject, {
250
+ name: "initialEnv",
251
+ type: "Partial<EnvBase>",
252
+ defaultValue,
253
+ reflection: envInstance,
254
+ "export": true,
255
+ "const": true
256
+ }),
257
+ createIntrinsic("hbr", {}),
258
+ createIntrinsic("hbr", {}),
259
+ createComponent(TSDoc, {
260
+ heading: "The environment configuration serializer for the Powerlines application.",
261
+ get children() {
262
+ return [
263
+ createComponent(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
264
+ createComponent(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
265
+ createComponent(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
266
+ ];
267
+ }
268
+ }),
269
+ createComponent(ClassDeclaration, {
270
+ refkey: envSerializerRefkey,
271
+ name: "EnvSerializer",
272
+ "extends": "Serializer",
273
+ "export": true,
274
+ get children() {
275
+ return createComponent(ClassMethod, {
276
+ name: "constructor",
277
+ "public": true,
278
+ children: code`
279
+ super("env");
280
+
281
+ this.deserializeRegistry.register(
282
+ ReflectionKind.boolean,
283
+ (type: Type, state: TemplateState) => {
284
+ state.addSetter(
285
+ \`typeof \${state.accessor.toString()} !== "boolean" ? \${state.accessor.toString()} === 1 || \${state.accessor.toString()} === "1" || \${state.accessor.toString()}.toLowerCase() === "t" || \${state.accessor.toString()}.toLowerCase() === "true" || \${state.accessor.toString()}.toLowerCase() === "y" || \${state.accessor.toString()}.toLowerCase() === "yes" : \${state.accessor.toString()}\`
286
+ );
287
+ }
288
+ );
289
+ `
290
+ });
291
+ }
292
+ }),
293
+ createIntrinsic("hbr", {}),
294
+ createIntrinsic("hbr", {}),
295
+ createComponent(TSDoc, {
296
+ heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
297
+ get children() {
298
+ return [
299
+ createComponent(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
300
+ createComponent(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
301
+ createComponent(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
302
+ ];
303
+ }
304
+ }),
305
+ createComponent(VarDeclaration, {
306
+ name: "envSerializer",
307
+ "export": false,
308
+ "const": true,
309
+ get initializer() {
310
+ return createComponent(NewExpression, {
311
+ args: [],
312
+ target: "EnvSerializer"
313
+ });
314
+ }
315
+ }),
316
+ createIntrinsic("hbr", {}),
317
+ createIntrinsic("hbr", {}),
318
+ createComponent(TSDoc, {
319
+ heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
320
+ get children() {
321
+ return [
322
+ createComponent(TSDocRemarks, { children: `The resulting JSON object can be stringified using JSON.stringify().` }),
323
+ createComponent(TSDocExample, { children: `const json = serializeEnv(env);` }),
324
+ createComponent(TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
325
+ ];
326
+ }
327
+ }),
328
+ createComponent(VarDeclaration, {
329
+ name: "serializeEnv",
330
+ "export": true,
331
+ "const": true,
332
+ initializer: "serializeFunction<EnvBase>(envSerializer)"
333
+ }),
334
+ createIntrinsic("hbr", {}),
335
+ createIntrinsic("hbr", {}),
336
+ createComponent(TSDoc, {
337
+ heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
338
+ get children() {
339
+ return [
340
+ createComponent(TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
341
+ createComponent(TSDocExample, { children: `const env = deserializeEnv(json);` }),
342
+ createComponent(TSDocThrows, { children: `ValidationError when deserialization fails.` })
343
+ ];
344
+ }
345
+ }),
346
+ createComponent(VarDeclaration, {
347
+ name: "deserializeEnv",
348
+ "export": true,
349
+ "const": true,
350
+ initializer: "deserializeFunction<EnvBase>(envSerializer)"
351
+ }),
352
+ createIntrinsic("hbr", {}),
353
+ createIntrinsic("hbr", {}),
354
+ createComponent(TSDoc, {
355
+ heading: "Initializes the Powerlines environment configuration module.",
356
+ get children() {
357
+ return [
358
+ createComponent(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
359
+ createComponent(TSDocParam, {
360
+ name: "environmentConfig",
361
+ children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
362
+ }),
363
+ createComponent(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
364
+ ];
365
+ }
366
+ }),
367
+ createComponent(Show, {
368
+ get when() {
369
+ return Boolean(context?.entryPath);
370
+ },
371
+ get children() {
372
+ return createComponent(FunctionDeclaration, {
373
+ refkey: createEnvRefkey,
374
+ async: false,
375
+ "export": true,
376
+ name: "createEnv",
377
+ parameters: [{
378
+ name: "environmentConfig",
379
+ type: `Partial<Env>`,
380
+ optional: false,
381
+ default: "{}"
382
+ }],
383
+ returnType: "Env",
384
+ get children() {
385
+ return [
386
+ code`
387
+ return new Proxy<Env>(
388
+ deserializeEnv({
389
+ ...initialEnv,
390
+ ...environmentConfig
391
+ }) as Env,
392
+ {
393
+ get: (target: EnvBase, propertyName: string) => { `,
394
+ createIntrinsic("hbr", {}),
395
+ createComponent(For, {
396
+ each: reflectionGetProperties,
397
+ children: (property, index) => createComponent(ConfigPropertyGet, {
398
+ index,
399
+ context,
400
+ property
401
+ })
402
+ }),
403
+ code`
404
+ return undefined;
405
+ }, `,
406
+ createIntrinsic("hbr", {}),
407
+ createIntrinsic("hbr", {}),
408
+ code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,
409
+ createIntrinsic("hbr", {}),
410
+ createComponent(For, {
411
+ each: reflectionSetProperties,
412
+ ender: code` else `,
413
+ children: (property, index) => createComponent(ConfigPropertySet, {
414
+ index,
415
+ context,
416
+ property
417
+ })
418
+ }),
419
+ createIntrinsic("hbr", {}),
420
+ code`return false;
421
+ }
422
+ }
423
+ );
424
+ `
425
+ ];
426
+ }
427
+ });
428
+ }
429
+ }),
430
+ createIntrinsic("hbr", {}),
431
+ createIntrinsic("hbr", {}),
432
+ createIntrinsic("hbr", {}),
433
+ createComponent(VarDeclaration, {
434
+ refkey: envRefkey,
435
+ name: "env",
436
+ type: "Env",
437
+ "export": true,
438
+ "const": true,
439
+ get initializer() {
440
+ return [code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
441
+ }
442
+ }),
443
+ createIntrinsic("hbr", {}),
444
+ createIntrinsic("hbr", {}),
445
+ createComponent(VarDeclaration, {
446
+ "export": true,
447
+ "const": true,
448
+ name: "isCI",
449
+ doc: "Detect if the application is running in a CI environment.",
450
+ initializer: code`Boolean(
451
+ env.CI ||
452
+ env.RUN_ID ||
453
+ env.AGOLA_GIT_REF ||
454
+ env.AC_APPCIRCLE ||
455
+ env.APPVEYOR ||
456
+ env.CODEBUILD ||
457
+ env.TF_BUILD ||
458
+ env.bamboo_planKey ||
459
+ env.BITBUCKET_COMMIT ||
460
+ env.BITRISE_IO ||
461
+ env.BUDDY_WORKSPACE_ID ||
462
+ env.BUILDKITE ||
463
+ env.CIRCLECI ||
464
+ env.CIRRUS_CI ||
465
+ env.CF_BUILD_ID ||
466
+ env.CM_BUILD_ID ||
467
+ env.CI_NAME ||
468
+ env.DRONE ||
469
+ env.DSARI ||
470
+ env.EARTHLY_CI ||
471
+ env.EAS_BUILD ||
472
+ env.GERRIT_PROJECT ||
473
+ env.GITEA_ACTIONS ||
474
+ env.GITHUB_ACTIONS ||
475
+ env.GITLAB_CI ||
476
+ env.GOCD ||
477
+ env.BUILDER_OUTPUT ||
478
+ env.HARNESS_BUILD_ID ||
479
+ env.JENKINS_URL ||
480
+ env.LAYERCI ||
481
+ env.MAGNUM ||
482
+ env.NETLIFY ||
483
+ env.NEVERCODE ||
484
+ env.PROW_JOB_ID ||
485
+ env.RELEASE_BUILD_ID ||
486
+ env.RENDER ||
487
+ env.SAILCI ||
488
+ env.HUDSON ||
489
+ env.SCREWDRIVER ||
490
+ env.SEMAPHORE ||
491
+ env.SOURCEHUT ||
492
+ env.STRIDER ||
493
+ env.TASK_ID ||
494
+ env.RUN_ID ||
495
+ env.TEAMCITY_VERSION ||
496
+ env.TRAVIS ||
497
+ env.VELA ||
498
+ env.NOW_BUILDER ||
499
+ env.APPCENTER_BUILD_ID ||
500
+ env.CI_XCODE_PROJECT ||
501
+ env.XCS || false
502
+ );
503
+ `
504
+ }),
505
+ createIntrinsic("hbr", {}),
506
+ createIntrinsic("hbr", {}),
507
+ createComponent(TSDoc, {
508
+ heading: "Detect the \\`mode\\` of the current runtime environment.",
509
+ get children() {
510
+ return createComponent(TSDocRemarks, { children: code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, Storm Software generally only allows a value in the following list:
511
+ - \`production\`
512
+ - \`test\`
513
+ - \`development\`` });
514
+ }
515
+ }),
516
+ createComponent(VarDeclaration, {
517
+ "export": true,
518
+ "const": true,
519
+ name: "mode",
520
+ initializer: code`String(env.MODE) || "production"; `
521
+ }),
522
+ createIntrinsic("hbr", {}),
523
+ createIntrinsic("hbr", {}),
524
+ createComponent(VarDeclaration, {
525
+ "export": true,
526
+ "const": true,
527
+ name: "isProduction",
528
+ doc: "Detect if the application is running in \\\"production\\\\\" mode",
529
+ initializer: code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
530
+ }),
531
+ createIntrinsic("hbr", {}),
532
+ createIntrinsic("hbr", {}),
533
+ createComponent(VarDeclaration, {
534
+ "export": true,
535
+ "const": true,
536
+ name: "isTest",
537
+ doc: "Detect if the application is running in \"test\" mode",
538
+ initializer: code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
539
+ }),
540
+ createIntrinsic("hbr", {}),
541
+ createIntrinsic("hbr", {}),
542
+ createComponent(VarDeclaration, {
543
+ "export": true,
544
+ "const": true,
545
+ name: "isDevelopment",
546
+ doc: "Detect if the application is running in \"development\" mode",
547
+ initializer: code`["dev", "development"].includes(mode.toLowerCase()); `
548
+ }),
549
+ createIntrinsic("hbr", {}),
550
+ createIntrinsic("hbr", {}),
551
+ createComponent(VarDeclaration, {
552
+ "export": true,
553
+ "const": true,
554
+ name: "isDebug",
555
+ doc: "Detect if the application is running in \"debug\" mode",
556
+ initializer: code`Boolean(isDevelopment && env.DEBUG); `
557
+ }),
558
+ createIntrinsic("hbr", {}),
559
+ createIntrinsic("hbr", {}),
560
+ createComponent(Show, {
561
+ get when() {
562
+ return Boolean(children);
563
+ },
564
+ children
565
+ })
566
+ ];
567
+ }
568
+ }));
569
+ }
570
+
571
+ //#endregion
572
+ export { EnvBuiltin, EnvTypeDefinition };
@@ -0,0 +1,2 @@
1
+ const require_env = require('./env.cjs');
2
+ require('./docs.cjs');
@@ -0,0 +1,4 @@
1
+ import { EnvBuiltin, EnvTypeDefinition } from "./env.mjs";
2
+ import "./docs.mjs";
3
+
4
+ export { };
@@ -0,0 +1,22 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
3
+ let automd = require("automd");
4
+
5
+ //#region ../plugin-env/src/helpers/automd-generator.ts
6
+ /**
7
+ * AutoMD generator to generate environment variable documentation
8
+ *
9
+ * @param context - The generator context.
10
+ * @returns The generated documentation content.
11
+ */
12
+ const env = (context) => (0, automd.defineGenerator)({
13
+ name: "env",
14
+ async generate() {
15
+ const envDocFile = (0, __stryke_path_join_paths.joinPaths)(context.config.projectRoot, "docs", "generated", "env.md");
16
+ if (!context.fs.existsSync(envDocFile)) return { contents: "" };
17
+ return { contents: await context.fs.read(envDocFile) || "" };
18
+ }
19
+ });
20
+
21
+ //#endregion
22
+ exports.env = env;
@@ -0,0 +1,21 @@
1
+ import { joinPaths } from "@stryke/path/join-paths";
2
+ import { defineGenerator } from "automd";
3
+
4
+ //#region ../plugin-env/src/helpers/automd-generator.ts
5
+ /**
6
+ * AutoMD generator to generate environment variable documentation
7
+ *
8
+ * @param context - The generator context.
9
+ * @returns The generated documentation content.
10
+ */
11
+ const env = (context) => defineGenerator({
12
+ name: "env",
13
+ async generate() {
14
+ const envDocFile = joinPaths(context.config.projectRoot, "docs", "generated", "env.md");
15
+ if (!context.fs.existsSync(envDocFile)) return { contents: "" };
16
+ return { contents: await context.fs.read(envDocFile) || "" };
17
+ }
18
+ });
19
+
20
+ //#endregion
21
+ export { env };
@@ -0,0 +1,55 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_persistence = require('./persistence.cjs');
3
+ const require_load = require('./load.cjs');
4
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
5
+ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
+ let __alloy_js_core = require("@alloy-js/core");
7
+
8
+ //#region ../plugin-env/src/helpers/create-reflection-resource.ts
9
+ /**
10
+ * Creates a reflection resource for the environment configuration.
11
+ *
12
+ * @param context - The environment plugin context.
13
+ * @returns A resource that provides the reflection of the environment configuration.
14
+ */
15
+ function createReflectionResource(context) {
16
+ const defaultValue = (0, __alloy_js_core.computed)(() => context && require_load.loadEnvFromContext(context, process.env));
17
+ return (0, __alloy_js_core.createResource)(async () => {
18
+ if (!context) return new __powerlines_deepkit_vendor_type.ReflectionClass({
19
+ kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
20
+ description: `The initial environment configuration state for the Powerlines project.`,
21
+ types: []
22
+ });
23
+ const result = await require_persistence.readEnvTypeReflection(context, "env");
24
+ result.getProperties().forEach((prop) => {
25
+ prop.getAlias().filter(Boolean).forEach((alias) => {
26
+ result.addProperty({
27
+ name: alias,
28
+ optional: prop.isOptional() ? true : void 0,
29
+ readonly: prop.isReadonly() ? true : void 0,
30
+ description: prop.getDescription(),
31
+ visibility: prop.getVisibility(),
32
+ type: prop.getType(),
33
+ default: prop.getDefaultValue(),
34
+ tags: {
35
+ hidden: prop.isHidden(),
36
+ ignore: prop.isIgnored(),
37
+ internal: prop.isInternal(),
38
+ alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
39
+ title: prop.getTitle() || (0, __stryke_string_format_title_case.titleCase)(prop.name),
40
+ readonly: prop.isReadonly(),
41
+ permission: prop.getPermission(),
42
+ domain: prop.getDomain()
43
+ }
44
+ });
45
+ });
46
+ });
47
+ result.getProperties().forEach((prop) => {
48
+ prop.setDefaultValue(defaultValue.value?.[prop.getNameAsString()] ?? prop.getAlias().reduce((ret, alias) => ret ?? defaultValue.value?.[alias], void 0) ?? prop.getDefaultValue());
49
+ });
50
+ return result;
51
+ });
52
+ }
53
+
54
+ //#endregion
55
+ exports.createReflectionResource = createReflectionResource;