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