@powerlines/plugin-nodejs 0.1.8 → 0.1.10

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 (129) hide show
  1. package/dist/components/env.cjs +14 -14
  2. package/dist/components/env.mjs +6 -6
  3. package/dist/index.cjs +8 -6
  4. package/dist/index.mjs +5 -5
  5. package/dist/plugin-alloy/src/types/components.d.mts +1 -2
  6. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +1 -1
  7. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +2 -2
  8. package/dist/plugin-automd/src/types/plugin.d.mts +1 -3
  9. package/dist/plugin-env/src/types/plugin.d.mts +1 -2
  10. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -2
  11. package/dist/powerlines/src/types/build.d.mts +6 -6
  12. package/dist/powerlines/src/types/commands.d.mts +0 -1
  13. package/dist/powerlines/src/types/config.d.mts +2 -3
  14. package/dist/powerlines/src/types/context.d.cts +1 -1
  15. package/dist/powerlines/src/types/context.d.mts +1 -1
  16. package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
  17. package/dist/powerlines/src/types/unplugin.d.mts +0 -1
  18. package/package.json +11 -9
  19. package/dist/deepkit/schemas/reflection.cjs +0 -3940
  20. package/dist/deepkit/schemas/reflection.mjs +0 -3938
  21. package/dist/deepkit/schemas/reflection2.cjs +0 -4112
  22. package/dist/deepkit/schemas/reflection2.mjs +0 -4110
  23. package/dist/deepkit/src/capnp.cjs +0 -913
  24. package/dist/deepkit/src/capnp.mjs +0 -911
  25. package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
  26. package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
  27. package/dist/deepkit/src/reflect-type.cjs +0 -22
  28. package/dist/deepkit/src/reflect-type.mjs +0 -20
  29. package/dist/deepkit/src/resolve-reflections.cjs +0 -16
  30. package/dist/deepkit/src/resolve-reflections.mjs +0 -15
  31. package/dist/deepkit/src/transformer.cjs +0 -52
  32. package/dist/deepkit/src/transformer.mjs +0 -49
  33. package/dist/deepkit/src/transpile.cjs +0 -29
  34. package/dist/deepkit/src/transpile.mjs +0 -27
  35. package/dist/deepkit/src/utilities.cjs +0 -66
  36. package/dist/deepkit/src/utilities.mjs +0 -65
  37. package/dist/plugin-alloy/src/core/components/output.cjs +0 -45
  38. package/dist/plugin-alloy/src/core/components/output.mjs +0 -44
  39. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -22
  40. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -21
  41. package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -64
  42. package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -62
  43. package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
  44. package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
  45. package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
  46. package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
  47. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
  48. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
  49. package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
  50. package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
  51. package/dist/plugin-alloy/src/index.cjs +0 -106
  52. package/dist/plugin-alloy/src/index.mjs +0 -104
  53. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -7
  54. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -9
  55. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -5
  56. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -7
  57. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -17
  58. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
  59. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -57
  60. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -56
  61. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -126
  62. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -124
  63. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -442
  64. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -433
  65. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -212
  66. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -209
  67. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -68
  68. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -67
  69. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -124
  70. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -123
  71. package/dist/plugin-automd/src/index.cjs +0 -101
  72. package/dist/plugin-automd/src/index.mjs +0 -98
  73. package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
  74. package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
  75. package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
  76. package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
  77. package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
  78. package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
  79. package/dist/plugin-babel/src/helpers/index.cjs +0 -5
  80. package/dist/plugin-babel/src/helpers/index.mjs +0 -7
  81. package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
  82. package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
  83. package/dist/plugin-babel/src/helpers/options.cjs +0 -50
  84. package/dist/plugin-babel/src/helpers/options.mjs +0 -47
  85. package/dist/plugin-babel/src/index.cjs +0 -91
  86. package/dist/plugin-babel/src/index.mjs +0 -89
  87. package/dist/plugin-babel/src/types/index.d.mts +0 -1
  88. package/dist/plugin-env/src/babel/index.cjs +0 -1
  89. package/dist/plugin-env/src/babel/index.mjs +0 -3
  90. package/dist/plugin-env/src/babel/plugin.cjs +0 -121
  91. package/dist/plugin-env/src/babel/plugin.mjs +0 -119
  92. package/dist/plugin-env/src/components/docs.cjs +0 -9
  93. package/dist/plugin-env/src/components/docs.mjs +0 -11
  94. package/dist/plugin-env/src/components/env.cjs +0 -575
  95. package/dist/plugin-env/src/components/env.mjs +0 -572
  96. package/dist/plugin-env/src/components/index.cjs +0 -2
  97. package/dist/plugin-env/src/components/index.mjs +0 -4
  98. package/dist/plugin-env/src/helpers/automd-generator.cjs +0 -22
  99. package/dist/plugin-env/src/helpers/automd-generator.mjs +0 -21
  100. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +0 -55
  101. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +0 -54
  102. package/dist/plugin-env/src/helpers/index.cjs +0 -6
  103. package/dist/plugin-env/src/helpers/index.mjs +0 -8
  104. package/dist/plugin-env/src/helpers/load.cjs +0 -83
  105. package/dist/plugin-env/src/helpers/load.mjs +0 -80
  106. package/dist/plugin-env/src/helpers/persistence.cjs +0 -201
  107. package/dist/plugin-env/src/helpers/persistence.mjs +0 -190
  108. package/dist/plugin-env/src/helpers/reflect.cjs +0 -111
  109. package/dist/plugin-env/src/helpers/reflect.mjs +0 -103
  110. package/dist/plugin-env/src/helpers/source-file-env.cjs +0 -24
  111. package/dist/plugin-env/src/helpers/source-file-env.mjs +0 -23
  112. package/dist/plugin-env/src/helpers/template-helpers.cjs +0 -2
  113. package/dist/plugin-env/src/helpers/template-helpers.mjs +0 -4
  114. package/dist/plugin-env/src/index.cjs +0 -175
  115. package/dist/plugin-env/src/index.mjs +0 -173
  116. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
  117. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
  118. package/dist/powerlines/src/lib/entry.cjs +0 -12
  119. package/dist/powerlines/src/lib/entry.mjs +0 -14
  120. package/dist/powerlines/src/lib/logger.cjs +0 -41
  121. package/dist/powerlines/src/lib/logger.mjs +0 -39
  122. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -38
  123. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -35
  124. package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
  125. package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
  126. package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
  127. package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
  128. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
  129. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
@@ -1,572 +0,0 @@
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 };
@@ -1,2 +0,0 @@
1
- const require_env = require('./env.cjs');
2
- require('./docs.cjs');
@@ -1,4 +0,0 @@
1
- import { EnvBuiltin, EnvTypeDefinition } from "./env.mjs";
2
- import "./docs.mjs";
3
-
4
- export { };
@@ -1,22 +0,0 @@
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;
@@ -1,21 +0,0 @@
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 };
@@ -1,55 +0,0 @@
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;