@powerlines/plugin-nodejs 0.1.115 → 0.1.117

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