@powerlines/plugin-env 0.16.68 → 0.16.70
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.
- package/README.md +1 -1
- package/dist/components/docs.cjs +37 -27
- package/dist/components/docs.mjs +37 -27
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +404 -314
- package/dist/components/env-builtin.mjs +404 -314
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
|
@@ -2,10 +2,10 @@ import { loadEnvFromContext } from "../helpers/load.mjs";
|
|
|
2
2
|
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
3
3
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
4
4
|
import defu from "defu";
|
|
5
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
6
|
import { For, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
6
7
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
8
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
-
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
9
9
|
import { ClassDeclaration, ClassMethod, ElseIfClause, FunctionDeclaration, IfStatement, NewExpression, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
10
10
|
import { refkey } from "@powerlines/plugin-alloy/helpers/refkey";
|
|
11
11
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
@@ -20,28 +20,32 @@ import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns,
|
|
|
20
20
|
function EnvTypeDefinition(props) {
|
|
21
21
|
const [{ defaultValue, reflection }] = splitProps(props, ["defaultValue", "reflection"]);
|
|
22
22
|
const context = usePowerlines();
|
|
23
|
-
return
|
|
24
|
-
|
|
23
|
+
return [
|
|
24
|
+
createComponent(InterfaceDeclaration, {
|
|
25
25
|
name: " EnvBase",
|
|
26
26
|
defaultValue,
|
|
27
27
|
reflection,
|
|
28
|
-
export: true
|
|
28
|
+
"export": true
|
|
29
29
|
}),
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
createComponent(Spacing, {}),
|
|
31
|
+
createComponent(TSDoc, {
|
|
32
32
|
heading: "The environment configuration object with prefixed keys.",
|
|
33
|
-
children
|
|
33
|
+
get children() {
|
|
34
|
+
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.` });
|
|
35
|
+
}
|
|
34
36
|
}),
|
|
35
|
-
|
|
37
|
+
createComponent(TypeDeclaration, {
|
|
36
38
|
name: "Env",
|
|
37
|
-
export: true,
|
|
38
|
-
children
|
|
39
|
+
"export": true,
|
|
40
|
+
get children() {
|
|
41
|
+
return code` {
|
|
39
42
|
[Key in keyof EnvBase as Key ${context.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
42
46
|
}),
|
|
43
|
-
|
|
44
|
-
]
|
|
47
|
+
createComponent(Spacing, {})
|
|
48
|
+
];
|
|
45
49
|
}
|
|
46
50
|
function ConfigPropertyConditional(props) {
|
|
47
51
|
const [{ context, name }] = splitProps(props, ["context", "name"]);
|
|
@@ -53,39 +57,63 @@ function ConfigPropertyGet(props) {
|
|
|
53
57
|
"property",
|
|
54
58
|
"index"
|
|
55
59
|
]);
|
|
56
|
-
return
|
|
57
|
-
condition
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
60
|
+
return [index === 0 ? createComponent(IfStatement, {
|
|
61
|
+
get condition() {
|
|
62
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
63
|
+
get name() {
|
|
64
|
+
return property.getNameAsString();
|
|
65
|
+
},
|
|
66
|
+
context
|
|
67
|
+
}), createComponent(Show, {
|
|
68
|
+
get when() {
|
|
69
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
return [code` || `, createComponent(For, {
|
|
73
|
+
get each() {
|
|
74
|
+
return property.getAlias();
|
|
75
|
+
},
|
|
76
|
+
joiner: code` || `,
|
|
77
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
78
|
+
name: alias,
|
|
79
|
+
context
|
|
80
|
+
})
|
|
81
|
+
})];
|
|
82
|
+
}
|
|
83
|
+
})];
|
|
84
|
+
},
|
|
85
|
+
get children() {
|
|
86
|
+
return code`return target["${property.getNameAsString()}"];`;
|
|
87
|
+
}
|
|
88
|
+
}) : createComponent(ElseIfClause, {
|
|
89
|
+
get condition() {
|
|
90
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
91
|
+
get name() {
|
|
92
|
+
return property.getNameAsString();
|
|
93
|
+
},
|
|
94
|
+
context
|
|
95
|
+
}), createComponent(Show, {
|
|
96
|
+
get when() {
|
|
97
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
98
|
+
},
|
|
99
|
+
get children() {
|
|
100
|
+
return [code` || `, createComponent(For, {
|
|
101
|
+
get each() {
|
|
102
|
+
return property.getAlias();
|
|
103
|
+
},
|
|
104
|
+
joiner: code` || `,
|
|
105
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
106
|
+
name: alias,
|
|
107
|
+
context
|
|
108
|
+
})
|
|
109
|
+
})];
|
|
110
|
+
}
|
|
111
|
+
})];
|
|
112
|
+
},
|
|
113
|
+
get children() {
|
|
114
|
+
return code`return target["${property.getNameAsString()}"];`;
|
|
115
|
+
}
|
|
116
|
+
})];
|
|
89
117
|
}
|
|
90
118
|
function ConfigPropertySet(props) {
|
|
91
119
|
const [{ context, property, index }] = splitProps(props, [
|
|
@@ -93,45 +121,69 @@ function ConfigPropertySet(props) {
|
|
|
93
121
|
"property",
|
|
94
122
|
"index"
|
|
95
123
|
]);
|
|
96
|
-
return
|
|
97
|
-
condition
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
124
|
+
return [index === 0 ? createComponent(IfStatement, {
|
|
125
|
+
get condition() {
|
|
126
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
127
|
+
get name() {
|
|
128
|
+
return property.getNameAsString();
|
|
129
|
+
},
|
|
130
|
+
context
|
|
131
|
+
}), createComponent(Show, {
|
|
132
|
+
get when() {
|
|
133
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
134
|
+
},
|
|
135
|
+
get children() {
|
|
136
|
+
return [code` || `, createComponent(For, {
|
|
137
|
+
get each() {
|
|
138
|
+
return property.getAlias();
|
|
139
|
+
},
|
|
140
|
+
joiner: code` || `,
|
|
141
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
142
|
+
name: alias,
|
|
143
|
+
context
|
|
144
|
+
})
|
|
145
|
+
})];
|
|
146
|
+
}
|
|
147
|
+
})];
|
|
148
|
+
},
|
|
149
|
+
get children() {
|
|
150
|
+
return code`
|
|
112
151
|
target["${property.getNameAsString()}"] = newValue;
|
|
113
152
|
return true;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
}) : createComponent(ElseIfClause, {
|
|
156
|
+
get condition() {
|
|
157
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
158
|
+
get name() {
|
|
159
|
+
return property.getNameAsString();
|
|
160
|
+
},
|
|
161
|
+
context
|
|
162
|
+
}), createComponent(Show, {
|
|
163
|
+
get when() {
|
|
164
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
165
|
+
},
|
|
166
|
+
get children() {
|
|
167
|
+
return [code` || `, createComponent(For, {
|
|
168
|
+
get each() {
|
|
169
|
+
return property.getAlias();
|
|
170
|
+
},
|
|
171
|
+
joiner: code` || `,
|
|
172
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
173
|
+
name: alias,
|
|
174
|
+
context
|
|
175
|
+
})
|
|
176
|
+
})];
|
|
177
|
+
}
|
|
178
|
+
})];
|
|
179
|
+
},
|
|
180
|
+
get children() {
|
|
181
|
+
return code`
|
|
131
182
|
target["${property.getNameAsString()}"] = newValue;
|
|
132
183
|
return true;
|
|
133
|
-
|
|
134
|
-
|
|
184
|
+
`;
|
|
185
|
+
}
|
|
186
|
+
})];
|
|
135
187
|
}
|
|
136
188
|
const createEnvRefkey = refkey("createEnv");
|
|
137
189
|
const envRefkey = refkey("env");
|
|
@@ -156,62 +208,74 @@ function EnvBuiltin(props) {
|
|
|
156
208
|
});
|
|
157
209
|
const reflectionGetProperties = computed(() => reflection?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
158
210
|
const reflectionSetProperties = computed(() => reflection?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
159
|
-
return
|
|
211
|
+
return createComponent(BuiltinFile, mergeProps({
|
|
160
212
|
id: "env",
|
|
161
|
-
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
162
|
-
|
|
163
|
-
imports
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
reflection
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
214
|
+
}, rest, {
|
|
215
|
+
get imports() {
|
|
216
|
+
return defu({ "@powerlines/deepkit/vendor/type": [
|
|
217
|
+
"stringify",
|
|
218
|
+
"serializer",
|
|
219
|
+
"serializeFunction",
|
|
220
|
+
"deserializeFunction",
|
|
221
|
+
"ReflectionKind",
|
|
222
|
+
"Serializer",
|
|
223
|
+
"TemplateState",
|
|
224
|
+
"Type",
|
|
225
|
+
"TypeProperty",
|
|
226
|
+
"TypePropertySignature"
|
|
227
|
+
] }, rest.imports ?? {});
|
|
228
|
+
},
|
|
229
|
+
get children() {
|
|
230
|
+
return [
|
|
231
|
+
createComponent(Show, {
|
|
232
|
+
get when() {
|
|
233
|
+
return Boolean(reflection);
|
|
234
|
+
},
|
|
235
|
+
get children() {
|
|
236
|
+
return [
|
|
237
|
+
createComponent(EnvTypeDefinition, {
|
|
238
|
+
get defaultValue() {
|
|
239
|
+
return defaultValue.value;
|
|
240
|
+
},
|
|
241
|
+
reflection
|
|
242
|
+
}),
|
|
243
|
+
createIntrinsic("hbr", {}),
|
|
244
|
+
createIntrinsic("hbr", {})
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
createComponent(ObjectDeclaration, {
|
|
249
|
+
name: "initialEnv",
|
|
250
|
+
type: "Partial<EnvBase>",
|
|
251
|
+
defaultValue,
|
|
252
|
+
reflection: envInstance,
|
|
253
|
+
"export": true,
|
|
254
|
+
"const": true,
|
|
255
|
+
doc: "The initial environment configuration object values for the runtime."
|
|
256
|
+
}),
|
|
257
|
+
createComponent(Spacing, {}),
|
|
258
|
+
createComponent(TSDoc, {
|
|
259
|
+
heading: "The environment configuration serializer for the Powerlines application.",
|
|
260
|
+
get children() {
|
|
261
|
+
return [
|
|
262
|
+
createComponent(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
263
|
+
createComponent(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
264
|
+
createComponent(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
}),
|
|
268
|
+
createComponent(ClassDeclaration, {
|
|
269
|
+
refkey: envSerializerRefkey,
|
|
270
|
+
name: "EnvSerializer",
|
|
271
|
+
"extends": "Serializer",
|
|
272
|
+
"export": true,
|
|
273
|
+
get children() {
|
|
274
|
+
return createComponent(ClassMethod, {
|
|
275
|
+
name: "constructor",
|
|
276
|
+
"public": true,
|
|
277
|
+
doc: "Initializes a new instance of the `EnvSerializer` class.",
|
|
278
|
+
children: code`super("env");
|
|
215
279
|
|
|
216
280
|
this.deserializeRegistry.register(
|
|
217
281
|
ReflectionKind.boolean,
|
|
@@ -221,84 +285,99 @@ function EnvBuiltin(props) {
|
|
|
221
285
|
);
|
|
222
286
|
}
|
|
223
287
|
); `
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
291
|
+
createComponent(Spacing, {}),
|
|
292
|
+
createComponent(TSDoc, {
|
|
293
|
+
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
294
|
+
get children() {
|
|
295
|
+
return [
|
|
296
|
+
createComponent(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
297
|
+
createComponent(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
298
|
+
createComponent(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
}),
|
|
302
|
+
createComponent(VarDeclaration, {
|
|
303
|
+
name: "envSerializer",
|
|
304
|
+
"export": false,
|
|
305
|
+
"const": true,
|
|
306
|
+
get initializer() {
|
|
307
|
+
return createComponent(NewExpression, {
|
|
308
|
+
args: [],
|
|
309
|
+
target: "EnvSerializer"
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}),
|
|
313
|
+
createComponent(Spacing, {}),
|
|
314
|
+
createComponent(TSDoc, {
|
|
315
|
+
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
316
|
+
get children() {
|
|
317
|
+
return [
|
|
318
|
+
createComponent(TSDocRemarks, { children: `The resulting JSON object can be stringified using \`JSON.stringify()\`.` }),
|
|
319
|
+
createComponent(TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
320
|
+
createComponent(TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
321
|
+
];
|
|
322
|
+
}
|
|
323
|
+
}),
|
|
324
|
+
createComponent(VarDeclaration, {
|
|
325
|
+
name: "serializeEnv",
|
|
326
|
+
"export": true,
|
|
327
|
+
"const": true,
|
|
328
|
+
initializer: "serializeFunction<EnvBase>(envSerializer)"
|
|
329
|
+
}),
|
|
330
|
+
createComponent(Spacing, {}),
|
|
331
|
+
createComponent(TSDoc, {
|
|
332
|
+
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
333
|
+
get children() {
|
|
334
|
+
return [
|
|
335
|
+
createComponent(TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
336
|
+
createComponent(TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
337
|
+
createComponent(TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
}),
|
|
341
|
+
createComponent(VarDeclaration, {
|
|
342
|
+
name: "deserializeEnv",
|
|
343
|
+
"export": true,
|
|
344
|
+
"const": true,
|
|
345
|
+
initializer: "deserializeFunction<EnvBase>(envSerializer)"
|
|
346
|
+
}),
|
|
347
|
+
createComponent(Spacing, {}),
|
|
348
|
+
createComponent(TSDoc, {
|
|
349
|
+
heading: "Initializes the Powerlines environment configuration module.",
|
|
350
|
+
get children() {
|
|
351
|
+
return [
|
|
352
|
+
createComponent(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
353
|
+
createComponent(TSDocParam, {
|
|
354
|
+
name: "environmentConfig",
|
|
355
|
+
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
356
|
+
}),
|
|
357
|
+
createComponent(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
358
|
+
];
|
|
359
|
+
}
|
|
360
|
+
}),
|
|
361
|
+
createComponent(Show, {
|
|
362
|
+
get when() {
|
|
363
|
+
return Boolean(context?.entryPath);
|
|
364
|
+
},
|
|
365
|
+
get children() {
|
|
366
|
+
return createComponent(FunctionDeclaration, {
|
|
367
|
+
refkey: createEnvRefkey,
|
|
368
|
+
async: false,
|
|
369
|
+
"export": true,
|
|
370
|
+
name: "createEnv",
|
|
371
|
+
parameters: [{
|
|
372
|
+
name: "environmentConfig",
|
|
373
|
+
type: `Partial<Env>`,
|
|
374
|
+
optional: false,
|
|
375
|
+
default: "{}"
|
|
376
|
+
}],
|
|
377
|
+
returnType: "Env",
|
|
378
|
+
get children() {
|
|
379
|
+
return [
|
|
380
|
+
code`
|
|
302
381
|
return new Proxy<Env>(
|
|
303
382
|
deserializeEnv({
|
|
304
383
|
...initialEnv,
|
|
@@ -306,60 +385,66 @@ function EnvBuiltin(props) {
|
|
|
306
385
|
}) as Env,
|
|
307
386
|
{
|
|
308
387
|
get: (target: EnvBase, propertyName: string) => { `,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
388
|
+
createIntrinsic("hbr", {}),
|
|
389
|
+
createComponent(For, {
|
|
390
|
+
each: reflectionGetProperties,
|
|
391
|
+
children: (property, index) => createComponent(ConfigPropertyGet, {
|
|
392
|
+
index,
|
|
393
|
+
context,
|
|
394
|
+
property
|
|
395
|
+
})
|
|
396
|
+
}),
|
|
397
|
+
code`
|
|
319
398
|
return undefined;
|
|
320
399
|
}, `,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
400
|
+
createComponent(Spacing, {}),
|
|
401
|
+
code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,
|
|
402
|
+
createIntrinsic("hbr", {}),
|
|
403
|
+
createComponent(For, {
|
|
404
|
+
each: reflectionSetProperties,
|
|
405
|
+
ender: code` else `,
|
|
406
|
+
children: (property, index) => createComponent(ConfigPropertySet, {
|
|
407
|
+
index,
|
|
408
|
+
context,
|
|
409
|
+
property
|
|
410
|
+
})
|
|
411
|
+
}),
|
|
412
|
+
createIntrinsic("hbr", {}),
|
|
413
|
+
code`return false;
|
|
335
414
|
}
|
|
336
415
|
}
|
|
337
416
|
);
|
|
338
417
|
`
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
418
|
+
];
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}),
|
|
423
|
+
createComponent(Spacing, {}),
|
|
424
|
+
createIntrinsic("hbr", {}),
|
|
425
|
+
createComponent(TSDoc, {
|
|
426
|
+
heading: "The environment configuration object.",
|
|
427
|
+
get children() {
|
|
428
|
+
return createComponent(TSDocRemarks, { children: `This object provides access to the environment configuration parameters in the application runtime.` });
|
|
429
|
+
}
|
|
430
|
+
}),
|
|
431
|
+
createComponent(VarDeclaration, {
|
|
432
|
+
refkey: envRefkey,
|
|
433
|
+
name: "env",
|
|
434
|
+
type: "Env",
|
|
435
|
+
"export": true,
|
|
436
|
+
"const": true,
|
|
437
|
+
get initializer() {
|
|
438
|
+
return [code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
|
|
439
|
+
}
|
|
440
|
+
}),
|
|
441
|
+
createComponent(Spacing, {}),
|
|
442
|
+
createComponent(VarDeclaration, {
|
|
443
|
+
"export": true,
|
|
444
|
+
"const": true,
|
|
445
|
+
name: "isCI",
|
|
446
|
+
doc: "Detect if the application is running in a continuous integration (CI) environment.",
|
|
447
|
+
initializer: code`Boolean(
|
|
363
448
|
env.CI ||
|
|
364
449
|
env.RUN_ID ||
|
|
365
450
|
env.AGOLA_GIT_REF ||
|
|
@@ -413,61 +498,66 @@ function EnvBuiltin(props) {
|
|
|
413
498
|
env.XCS || false
|
|
414
499
|
);
|
|
415
500
|
`
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
501
|
+
}),
|
|
502
|
+
createComponent(Spacing, {}),
|
|
503
|
+
createComponent(TSDoc, {
|
|
504
|
+
heading: "Detect the \\`mode\\` of the current runtime environment.",
|
|
505
|
+
get children() {
|
|
506
|
+
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:
|
|
421
507
|
- \`production\`
|
|
422
508
|
- \`test\`
|
|
423
509
|
- \`development\`
|
|
424
|
-
` })
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
510
|
+
` });
|
|
511
|
+
}
|
|
512
|
+
}),
|
|
513
|
+
createComponent(VarDeclaration, {
|
|
514
|
+
"export": true,
|
|
515
|
+
"const": true,
|
|
516
|
+
name: "mode",
|
|
517
|
+
initializer: code`String(env.MODE) || "production"; `
|
|
518
|
+
}),
|
|
519
|
+
createComponent(Spacing, {}),
|
|
520
|
+
createComponent(VarDeclaration, {
|
|
521
|
+
"export": true,
|
|
522
|
+
"const": true,
|
|
523
|
+
name: "isProduction",
|
|
524
|
+
doc: "Detect if the application is running in `\"production\"` mode",
|
|
525
|
+
initializer: code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
|
|
526
|
+
}),
|
|
527
|
+
createComponent(Spacing, {}),
|
|
528
|
+
createComponent(VarDeclaration, {
|
|
529
|
+
"export": true,
|
|
530
|
+
"const": true,
|
|
531
|
+
name: "isTest",
|
|
532
|
+
doc: "Detect if the application is running in `\"test\"` mode",
|
|
533
|
+
initializer: code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
|
|
534
|
+
}),
|
|
535
|
+
createComponent(Spacing, {}),
|
|
536
|
+
createComponent(VarDeclaration, {
|
|
537
|
+
"export": true,
|
|
538
|
+
"const": true,
|
|
539
|
+
name: "isDevelopment",
|
|
540
|
+
doc: "Detect if the application is running in `\"development\"` mode",
|
|
541
|
+
initializer: code`["dev", "development"].includes(mode.toLowerCase()); `
|
|
542
|
+
}),
|
|
543
|
+
createComponent(Spacing, {}),
|
|
544
|
+
createComponent(VarDeclaration, {
|
|
545
|
+
"export": true,
|
|
546
|
+
"const": true,
|
|
547
|
+
name: "isDebug",
|
|
548
|
+
doc: "Detect if the application is currently being debugged",
|
|
549
|
+
initializer: code`Boolean(isDevelopment && env.DEBUG); `
|
|
550
|
+
}),
|
|
551
|
+
createComponent(Spacing, {}),
|
|
552
|
+
createComponent(Show, {
|
|
553
|
+
get when() {
|
|
554
|
+
return Boolean(children);
|
|
555
|
+
},
|
|
556
|
+
children
|
|
557
|
+
})
|
|
558
|
+
];
|
|
559
|
+
}
|
|
560
|
+
}));
|
|
471
561
|
}
|
|
472
562
|
|
|
473
563
|
//#endregion
|