@powerlines/plugin-env 0.16.82 → 0.16.84
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/package.json +9 -9
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/_virtual/_rolldown/runtime.mjs +0 -3
- package/dist/babel/index.cjs +0 -4
- package/dist/babel/index.d.cts +0 -2
- package/dist/babel/index.d.mts +0 -2
- package/dist/babel/index.mjs +0 -3
- package/dist/babel/plugin.cjs +0 -144
- package/dist/babel/plugin.d.cts +0 -8
- package/dist/babel/plugin.d.cts.map +0 -1
- package/dist/babel/plugin.d.mts +0 -8
- package/dist/babel/plugin.d.mts.map +0 -1
- package/dist/babel/plugin.mjs +0 -143
- package/dist/babel/plugin.mjs.map +0 -1
- package/dist/components/docs.cjs +0 -70
- package/dist/components/docs.d.cts +0 -25
- package/dist/components/docs.d.cts.map +0 -1
- package/dist/components/docs.d.mts +0 -25
- package/dist/components/docs.d.mts.map +0 -1
- package/dist/components/docs.mjs +0 -69
- package/dist/components/docs.mjs.map +0 -1
- package/dist/components/env-builtin.cjs +0 -568
- package/dist/components/env-builtin.d.cts +0 -22
- package/dist/components/env-builtin.d.cts.map +0 -1
- package/dist/components/env-builtin.d.mts +0 -22
- package/dist/components/env-builtin.d.mts.map +0 -1
- package/dist/components/env-builtin.mjs +0 -565
- package/dist/components/env-builtin.mjs.map +0 -1
- package/dist/components/index.cjs +0 -7
- package/dist/components/index.d.cts +0 -3
- package/dist/components/index.d.mts +0 -3
- package/dist/components/index.mjs +0 -4
- package/dist/helpers/automd-generator.cjs +0 -33
- package/dist/helpers/automd-generator.d.cts +0 -14
- package/dist/helpers/automd-generator.d.cts.map +0 -1
- package/dist/helpers/automd-generator.d.mts +0 -14
- package/dist/helpers/automd-generator.d.mts.map +0 -1
- package/dist/helpers/automd-generator.mjs +0 -32
- package/dist/helpers/automd-generator.mjs.map +0 -1
- package/dist/helpers/create-reflection-resource.cjs +0 -23
- package/dist/helpers/create-reflection-resource.d.cts +0 -13
- package/dist/helpers/create-reflection-resource.d.cts.map +0 -1
- package/dist/helpers/create-reflection-resource.d.mts +0 -13
- package/dist/helpers/create-reflection-resource.d.mts.map +0 -1
- package/dist/helpers/create-reflection-resource.mjs +0 -23
- package/dist/helpers/create-reflection-resource.mjs.map +0 -1
- package/dist/helpers/docs-helper.cjs +0 -25
- package/dist/helpers/docs-helper.d.cts +0 -13
- package/dist/helpers/docs-helper.d.cts.map +0 -1
- package/dist/helpers/docs-helper.d.mts +0 -13
- package/dist/helpers/docs-helper.d.mts.map +0 -1
- package/dist/helpers/docs-helper.mjs +0 -24
- package/dist/helpers/docs-helper.mjs.map +0 -1
- package/dist/helpers/index.cjs +0 -34
- package/dist/helpers/index.d.cts +0 -7
- package/dist/helpers/index.d.mts +0 -7
- package/dist/helpers/index.mjs +0 -8
- package/dist/helpers/load.cjs +0 -136
- package/dist/helpers/load.d.cts +0 -35
- package/dist/helpers/load.d.cts.map +0 -1
- package/dist/helpers/load.d.mts +0 -35
- package/dist/helpers/load.d.mts.map +0 -1
- package/dist/helpers/load.mjs +0 -133
- package/dist/helpers/load.mjs.map +0 -1
- package/dist/helpers/persistence.cjs +0 -323
- package/dist/helpers/persistence.d.cts +0 -84
- package/dist/helpers/persistence.d.cts.map +0 -1
- package/dist/helpers/persistence.d.mts +0 -84
- package/dist/helpers/persistence.d.mts.map +0 -1
- package/dist/helpers/persistence.mjs +0 -311
- package/dist/helpers/persistence.mjs.map +0 -1
- package/dist/helpers/reflect.cjs +0 -299
- package/dist/helpers/reflect.d.cts +0 -69
- package/dist/helpers/reflect.d.cts.map +0 -1
- package/dist/helpers/reflect.d.mts +0 -69
- package/dist/helpers/reflect.d.mts.map +0 -1
- package/dist/helpers/reflect.mjs +0 -290
- package/dist/helpers/reflect.mjs.map +0 -1
- package/dist/helpers/source-file-env.cjs +0 -59
- package/dist/helpers/source-file-env.d.cts +0 -9
- package/dist/helpers/source-file-env.d.cts.map +0 -1
- package/dist/helpers/source-file-env.d.mts +0 -9
- package/dist/helpers/source-file-env.d.mts.map +0 -1
- package/dist/helpers/source-file-env.mjs +0 -57
- package/dist/helpers/source-file-env.mjs.map +0 -1
- package/dist/helpers/template-helpers.cjs +0 -71
- package/dist/helpers/template-helpers.d.cts +0 -15
- package/dist/helpers/template-helpers.d.cts.map +0 -1
- package/dist/helpers/template-helpers.d.mts +0 -15
- package/dist/helpers/template-helpers.d.mts.map +0 -1
- package/dist/helpers/template-helpers.mjs +0 -70
- package/dist/helpers/template-helpers.mjs.map +0 -1
- package/dist/index.cjs +0 -195
- package/dist/index.d.cts +0 -17
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -17
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -189
- package/dist/index.mjs.map +0 -1
- package/dist/types/index.cjs +0 -11
- package/dist/types/index.d.cts +0 -3
- package/dist/types/index.d.mts +0 -3
- package/dist/types/index.mjs +0 -4
- package/dist/types/plugin.cjs +0 -137
- package/dist/types/plugin.d.cts +0 -168
- package/dist/types/plugin.d.cts.map +0 -1
- package/dist/types/plugin.d.mts +0 -168
- package/dist/types/plugin.d.mts.map +0 -1
- package/dist/types/plugin.mjs +0 -132
- package/dist/types/plugin.mjs.map +0 -1
- package/dist/types/runtime.cjs +0 -244
- package/dist/types/runtime.d.cts +0 -792
- package/dist/types/runtime.d.cts.map +0 -1
- package/dist/types/runtime.d.mts +0 -792
- package/dist/types/runtime.d.mts.map +0 -1
- package/dist/types/runtime.mjs +0 -242
- package/dist/types/runtime.mjs.map +0 -1
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
|
-
const require_helpers_persistence = require('./persistence.cjs');
|
|
5
|
-
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
6
|
-
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
7
|
-
|
|
8
|
-
//#region src/helpers/template-helpers.ts
|
|
9
|
-
function __assignType(fn, args) {
|
|
10
|
-
fn.__type = args;
|
|
11
|
-
return fn;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Creates the reflection data used when generating runtime template files.
|
|
15
|
-
*
|
|
16
|
-
* @param context - The context for the configuration plugin.
|
|
17
|
-
* @param name - The name of the configuration template.
|
|
18
|
-
* @returns The reflection for the specified configuration template.
|
|
19
|
-
*/
|
|
20
|
-
async function createTemplateReflection(context, name) {
|
|
21
|
-
const reflection = await require_helpers_persistence.readEnvTypeReflection(context, name);
|
|
22
|
-
reflection.getProperties().forEach(__assignType((prop) => {
|
|
23
|
-
prop.getAlias().filter(Boolean).forEach(__assignType((alias) => {
|
|
24
|
-
reflection.addProperty({
|
|
25
|
-
name: alias,
|
|
26
|
-
optional: prop.isOptional() ? true : void 0,
|
|
27
|
-
readonly: prop.isReadonly() ? true : void 0,
|
|
28
|
-
description: prop.getDescription(),
|
|
29
|
-
visibility: prop.getVisibility(),
|
|
30
|
-
type: prop.getType(),
|
|
31
|
-
default: prop.getDefaultValue(),
|
|
32
|
-
tags: {
|
|
33
|
-
hidden: prop.isHidden(),
|
|
34
|
-
ignore: prop.isIgnored(),
|
|
35
|
-
internal: prop.isInternal(),
|
|
36
|
-
alias: prop.getAlias().filter(__assignType((a) => a !== alias, [
|
|
37
|
-
"a",
|
|
38
|
-
"",
|
|
39
|
-
"P\"2!\"/\""
|
|
40
|
-
])).concat(prop.name),
|
|
41
|
-
title: prop.getTitle() || (0, _stryke_string_format_title_case.titleCase)(prop.name),
|
|
42
|
-
readonly: prop.isReadonly(),
|
|
43
|
-
permission: prop.getPermission(),
|
|
44
|
-
domain: prop.getDomain()
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}, [
|
|
48
|
-
"alias",
|
|
49
|
-
"",
|
|
50
|
-
"P\"2!\"/\""
|
|
51
|
-
]));
|
|
52
|
-
}, [
|
|
53
|
-
"prop",
|
|
54
|
-
"",
|
|
55
|
-
"P\"2!\"/\""
|
|
56
|
-
]));
|
|
57
|
-
return reflection;
|
|
58
|
-
}
|
|
59
|
-
createTemplateReflection.__type = [
|
|
60
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
61
|
-
"context",
|
|
62
|
-
() => require_types_plugin.__ΩEnvType,
|
|
63
|
-
"name",
|
|
64
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
65
|
-
"createTemplateReflection",
|
|
66
|
-
"Creates the reflection data used when generating runtime template files.",
|
|
67
|
-
"Pn!2\"n#2$8P\"7%`/&?'"
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
//#endregion
|
|
71
|
-
exports.createTemplateReflection = createTemplateReflection;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EnvPluginContext, EnvType } from "../types/plugin.cjs";
|
|
2
|
-
import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/template-helpers.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Creates the reflection data used when generating runtime template files.
|
|
7
|
-
*
|
|
8
|
-
* @param context - The context for the configuration plugin.
|
|
9
|
-
* @param name - The name of the configuration template.
|
|
10
|
-
* @returns The reflection for the specified configuration template.
|
|
11
|
-
*/
|
|
12
|
-
declare function createTemplateReflection(context: EnvPluginContext, name?: EnvType): Promise<ReflectionClass<any>>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { createTemplateReflection };
|
|
15
|
-
//# sourceMappingURL=template-helpers.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-helpers.d.cts","names":[],"sources":["../../src/helpers/template-helpers.ts"],"mappings":";;;;;;AA8BA;;;;;iBAAsB,wBAAA,CACpB,OAAA,EAAS,gBAAA,EACT,IAAA,GAAO,OAAA,GACN,OAAA,CAAQ,eAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EnvPluginContext, EnvType } from "../types/plugin.mjs";
|
|
2
|
-
import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/template-helpers.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Creates the reflection data used when generating runtime template files.
|
|
7
|
-
*
|
|
8
|
-
* @param context - The context for the configuration plugin.
|
|
9
|
-
* @param name - The name of the configuration template.
|
|
10
|
-
* @returns The reflection for the specified configuration template.
|
|
11
|
-
*/
|
|
12
|
-
declare function createTemplateReflection(context: EnvPluginContext, name?: EnvType): Promise<ReflectionClass<any>>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { createTemplateReflection };
|
|
15
|
-
//# sourceMappingURL=template-helpers.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-helpers.d.mts","names":[],"sources":["../../src/helpers/template-helpers.ts"],"mappings":";;;;;;AA8BA;;;;;iBAAsB,wBAAA,CACpB,OAAA,EAAS,gBAAA,EACT,IAAA,GAAO,OAAA,GACN,OAAA,CAAQ,eAAA"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { __ΩEnvPluginContext, __ΩEnvType } from "../types/plugin.mjs";
|
|
2
|
-
import { readEnvTypeReflection } from "./persistence.mjs";
|
|
3
|
-
import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
|
|
4
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/template-helpers.ts
|
|
7
|
-
function __assignType(fn, args) {
|
|
8
|
-
fn.__type = args;
|
|
9
|
-
return fn;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Creates the reflection data used when generating runtime template files.
|
|
13
|
-
*
|
|
14
|
-
* @param context - The context for the configuration plugin.
|
|
15
|
-
* @param name - The name of the configuration template.
|
|
16
|
-
* @returns The reflection for the specified configuration template.
|
|
17
|
-
*/
|
|
18
|
-
async function createTemplateReflection(context, name) {
|
|
19
|
-
const reflection = await readEnvTypeReflection(context, name);
|
|
20
|
-
reflection.getProperties().forEach(__assignType((prop) => {
|
|
21
|
-
prop.getAlias().filter(Boolean).forEach(__assignType((alias) => {
|
|
22
|
-
reflection.addProperty({
|
|
23
|
-
name: alias,
|
|
24
|
-
optional: prop.isOptional() ? true : void 0,
|
|
25
|
-
readonly: prop.isReadonly() ? true : void 0,
|
|
26
|
-
description: prop.getDescription(),
|
|
27
|
-
visibility: prop.getVisibility(),
|
|
28
|
-
type: prop.getType(),
|
|
29
|
-
default: prop.getDefaultValue(),
|
|
30
|
-
tags: {
|
|
31
|
-
hidden: prop.isHidden(),
|
|
32
|
-
ignore: prop.isIgnored(),
|
|
33
|
-
internal: prop.isInternal(),
|
|
34
|
-
alias: prop.getAlias().filter(__assignType((a) => a !== alias, [
|
|
35
|
-
"a",
|
|
36
|
-
"",
|
|
37
|
-
"P\"2!\"/\""
|
|
38
|
-
])).concat(prop.name),
|
|
39
|
-
title: prop.getTitle() || titleCase(prop.name),
|
|
40
|
-
readonly: prop.isReadonly(),
|
|
41
|
-
permission: prop.getPermission(),
|
|
42
|
-
domain: prop.getDomain()
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}, [
|
|
46
|
-
"alias",
|
|
47
|
-
"",
|
|
48
|
-
"P\"2!\"/\""
|
|
49
|
-
]));
|
|
50
|
-
}, [
|
|
51
|
-
"prop",
|
|
52
|
-
"",
|
|
53
|
-
"P\"2!\"/\""
|
|
54
|
-
]));
|
|
55
|
-
return reflection;
|
|
56
|
-
}
|
|
57
|
-
createTemplateReflection.__type = [
|
|
58
|
-
() => __ΩEnvPluginContext,
|
|
59
|
-
"context",
|
|
60
|
-
() => __ΩEnvType,
|
|
61
|
-
"name",
|
|
62
|
-
() => ReflectionClass,
|
|
63
|
-
"createTemplateReflection",
|
|
64
|
-
"Creates the reflection data used when generating runtime template files.",
|
|
65
|
-
"Pn!2\"n#2$8P\"7%`/&?'"
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { createTemplateReflection };
|
|
70
|
-
//# sourceMappingURL=template-helpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-helpers.mjs","names":[],"sources":["../../src/helpers/template-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext, EnvType } from \"../types/plugin\";\nimport { readEnvTypeReflection } from \"./persistence\";\n\n/**\n * Creates the reflection data used when generating runtime template files.\n *\n * @param context - The context for the configuration plugin.\n * @param name - The name of the configuration template.\n * @returns The reflection for the specified configuration template.\n */\nexport async function createTemplateReflection(\n context: EnvPluginContext,\n name?: EnvType\n): Promise<ReflectionClass<any>> {\n const reflection = await readEnvTypeReflection(context, name);\n\n reflection.getProperties().forEach(prop => {\n const aliases = prop.getAlias();\n aliases.filter(Boolean).forEach(alias => {\n reflection.addProperty({\n name: alias,\n optional: prop.isOptional() ? true : undefined,\n readonly: prop.isReadonly() ? true : undefined,\n description: prop.getDescription(),\n visibility: prop.getVisibility(),\n type: prop.getType(),\n default: prop.getDefaultValue(),\n tags: {\n hidden: prop.isHidden(),\n ignore: prop.isIgnored(),\n internal: prop.isInternal(),\n alias: prop\n .getAlias()\n .filter(a => a !== alias)\n .concat(prop.name),\n title: prop.getTitle() || titleCase(prop.name),\n readonly: prop.isReadonly(),\n permission: prop.getPermission(),\n domain: prop.getDomain()\n }\n });\n });\n });\n\n return reflection;\n}\n"],"mappings":";;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;AAC5B,IAAA,SAAW;AACd,QAAS;;;;;;;;;;CA8BR,MAAA,aAAW,MAAgB,sBAAgB,SAAA,KAAA;AACzC,YAAM,eAAe,CAAA,QAAU,cAAA,SAAA;AAE7B,EADa,KAAS,UAAQ,CACpB,OAAC,QAAY,CAAA,QAAA,cAAA,UAAA;AACjB,cAAO,YAAA;IACH,MAAM;IACN,UAAO,KAAA,YAAoB,GAAE,OAAA;IACrC,UAAkB,KAAA,YAAgB,GAAA,OAAA;IAClC,aAAiB,KAAA,gBAAe;IAC1B,YAAc,KAAA,eAAA;IACZ,MAAM,KAAA,SAAA;IACR,SAAA,KAAA,iBAAA;IACE,MAAM;KACJ,QAAK,KAAU,UAAC;KACd,QAAK,KAAA,WAAY;KACpB,UAAA,KAAA,YAAA;KACJ,OAAS,KACG,UAAM,CACN,OAAK,cAAA,MAAA,MAAA,OAAA;MAAA;MAAA;MAAA;MAAA,CAAA,CAAA,CACR,OAAU,KAAI,KAAA;KAChB,OAAK,KAAA,UAAY,IAAA,UAAA,KAAA,KAAA;KACjB,UAAO,KAAA,YAAe;KACxB,YAAc,KAAC,eAAA;KACzB,QAAA,KAAA,WAAA;KACA;IACF,CAAA;KACF;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;;;;AAEF,QAAO"}
|
package/dist/index.cjs
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_helpers_reflect = require('./helpers/reflect.cjs');
|
|
4
|
-
const require_helpers_persistence = require('./helpers/persistence.cjs');
|
|
5
|
-
const require_helpers_load = require('./helpers/load.cjs');
|
|
6
|
-
const require_helpers_docs_helper = require('./helpers/docs-helper.cjs');
|
|
7
|
-
const require_helpers_automd_generator = require('./helpers/automd-generator.cjs');
|
|
8
|
-
const require_components_docs = require('./components/docs.cjs');
|
|
9
|
-
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
10
|
-
const require_babel_plugin = require('./babel/plugin.cjs');
|
|
11
|
-
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
12
|
-
let _stryke_env_types = require("@stryke/env/types");
|
|
13
|
-
let defu = require("defu");
|
|
14
|
-
defu = require_runtime.__toESM(defu);
|
|
15
|
-
let _stryke_path_join = require("@stryke/path/join");
|
|
16
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
17
|
-
let _powerlines_plugin_alloy = require("@powerlines/plugin-alloy");
|
|
18
|
-
_powerlines_plugin_alloy = require_runtime.__toESM(_powerlines_plugin_alloy);
|
|
19
|
-
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
20
|
-
let _powerlines_plugin_automd = require("@powerlines/plugin-automd");
|
|
21
|
-
_powerlines_plugin_automd = require_runtime.__toESM(_powerlines_plugin_automd);
|
|
22
|
-
let _powerlines_plugin_babel = require("@powerlines/plugin-babel");
|
|
23
|
-
_powerlines_plugin_babel = require_runtime.__toESM(_powerlines_plugin_babel);
|
|
24
|
-
let _stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
|
|
25
|
-
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
26
|
-
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
27
|
-
let _stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
28
|
-
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
29
|
-
|
|
30
|
-
//#region src/index.tsx
|
|
31
|
-
/**
|
|
32
|
-
* A Powerlines plugin to inject environment variables into the source code.
|
|
33
|
-
*/
|
|
34
|
-
const plugin = (options = {}) => {
|
|
35
|
-
return [
|
|
36
|
-
(0, _powerlines_plugin_alloy.default)(options.alloy),
|
|
37
|
-
(0, _powerlines_plugin_babel.default)(options.babel),
|
|
38
|
-
{
|
|
39
|
-
name: "env",
|
|
40
|
-
async config() {
|
|
41
|
-
this.debug("Providing default configuration for the Powerlines `env` build plugin.");
|
|
42
|
-
const config = {
|
|
43
|
-
env: (0, defu.default)(options, {
|
|
44
|
-
types: {},
|
|
45
|
-
validate: false,
|
|
46
|
-
inject: false,
|
|
47
|
-
prefix: []
|
|
48
|
-
}),
|
|
49
|
-
transform: { babel: { plugins: [require_babel_plugin.envBabelPlugin] } }
|
|
50
|
-
};
|
|
51
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(config.env.types) || config.env.types && (0, _stryke_type_checks_is_set_string.isSetString)(config.env.types.file)) {
|
|
52
|
-
config.env.types = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.types);
|
|
53
|
-
const file = await this.fs.resolve(config.env.types.file);
|
|
54
|
-
if (file) config.env.types.file = file;
|
|
55
|
-
} else {
|
|
56
|
-
this.warn("The `env.types` configuration parameter was not provided. Please ensure this is expected.");
|
|
57
|
-
const envDefaultTypeDefinition = await require_helpers_persistence.getEnvDefaultTypeDefinition(this);
|
|
58
|
-
const file = await this.fs.resolve(envDefaultTypeDefinition.file);
|
|
59
|
-
if (file) config.env.types = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(`${file}#${envDefaultTypeDefinition.name}`);
|
|
60
|
-
}
|
|
61
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(config.env.secrets) || config.env.secrets && (0, _stryke_type_checks_is_set_string.isSetString)(config.env.secrets.file)) {
|
|
62
|
-
config.env.secrets = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.secrets);
|
|
63
|
-
const file = await this.fs.resolve(config.env.secrets.file);
|
|
64
|
-
if (file) config.env.secrets.file = file;
|
|
65
|
-
} else {
|
|
66
|
-
const secretsDefaultTypeDefinition = await require_helpers_persistence.getSecretsDefaultTypeDefinition(this);
|
|
67
|
-
const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);
|
|
68
|
-
if (file) config.env.secrets = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(`${file}#${secretsDefaultTypeDefinition.name}`);
|
|
69
|
-
}
|
|
70
|
-
config.env.prefix = (0, _stryke_convert_to_array.toArray)(config.env.prefix ?? []).reduce((ret, prefix) => {
|
|
71
|
-
const formattedPrefix = (0, _stryke_string_format_constant_case.constantCase)(prefix);
|
|
72
|
-
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
73
|
-
return ret;
|
|
74
|
-
}, [
|
|
75
|
-
..._stryke_env_types.ENV_PREFIXES,
|
|
76
|
-
"POWERLINES_",
|
|
77
|
-
this.config.framework && this.config.framework !== "powerlines" && `${(0, _stryke_string_format_constant_case.constantCase)(this.config.framework)}_`
|
|
78
|
-
].filter(Boolean));
|
|
79
|
-
config.env.prefix = (0, _stryke_convert_to_array.toArray)(config.env.prefix).reduce((ret, prefix) => {
|
|
80
|
-
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
81
|
-
return ret;
|
|
82
|
-
}, []);
|
|
83
|
-
return config;
|
|
84
|
-
},
|
|
85
|
-
async configResolved() {
|
|
86
|
-
this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
|
|
87
|
-
this.env = (0, defu.default)({ parsed: await require_helpers_load.loadEnv(this, this.config.env) }, this.env ?? {}, {
|
|
88
|
-
types: { env: {} },
|
|
89
|
-
used: {
|
|
90
|
-
env: {},
|
|
91
|
-
secrets: {}
|
|
92
|
-
},
|
|
93
|
-
parsed: {},
|
|
94
|
-
injected: {}
|
|
95
|
-
});
|
|
96
|
-
if (this.config.command !== "prepare" && !this.config.skipCache && this.persistedMeta?.checksum === this.meta.checksum && (0, _stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvTypeReflectionsPath(this, "env"))) {
|
|
97
|
-
this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
|
|
98
|
-
this.env.types.env = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
99
|
-
if ((0, _stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvReflectionsPath(this, "env"))) this.env.used.env = await require_helpers_persistence.readEnvReflection(this);
|
|
100
|
-
if ((0, _stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await require_helpers_persistence.readEnvTypeReflection(this, "secrets");
|
|
101
|
-
if ((0, _stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await require_helpers_persistence.readSecretsReflection(this);
|
|
102
|
-
} else {
|
|
103
|
-
this.debug(`Starting environment configuration reflection initialization.`);
|
|
104
|
-
this.env.types.env = await require_helpers_reflect.reflectEnv(this, this.config.env.types?.file, this.config.env.types?.name);
|
|
105
|
-
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
106
|
-
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
107
|
-
this.env.types.secrets = await require_helpers_reflect.reflectSecrets(this, this.config.env.secrets?.file, this.config.env.secrets?.name);
|
|
108
|
-
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
109
|
-
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
110
|
-
this.debug(`Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
111
|
-
const envWithAlias = this.env.types.env.getProperties().filter((prop) => prop.getAlias().length > 0);
|
|
112
|
-
Object.entries(await require_helpers_load.loadEnv(this, this.config.env)).forEach(([key, value]) => {
|
|
113
|
-
const unprefixedKey = this.config.env.prefix.reduce((ret, prefix) => {
|
|
114
|
-
if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
|
|
115
|
-
return ret;
|
|
116
|
-
}, key);
|
|
117
|
-
const aliasKey = envWithAlias.find((prop) => prop?.getAlias().reverse().includes(unprefixedKey));
|
|
118
|
-
if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
|
|
119
|
-
});
|
|
120
|
-
this.env.used.env = new _powerlines_deepkit_vendor_type.ReflectionClass({
|
|
121
|
-
kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
122
|
-
typeName: "Env",
|
|
123
|
-
description: `An object containing the environment configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
124
|
-
types: []
|
|
125
|
-
}, this.env.types.env);
|
|
126
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
127
|
-
if (this.env.types.secrets) {
|
|
128
|
-
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
129
|
-
this.env.used.secrets = new _powerlines_deepkit_vendor_type.ReflectionClass({
|
|
130
|
-
kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
131
|
-
typeName: "Secrets",
|
|
132
|
-
description: `An object containing the secret configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
133
|
-
types: []
|
|
134
|
-
}, this.env.types.secrets);
|
|
135
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
async prepare() {
|
|
140
|
-
const _self$ = this;
|
|
141
|
-
this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);
|
|
142
|
-
const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
143
|
-
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_env_builtin.EnvBuiltin, {
|
|
144
|
-
get defaultConfig() {
|
|
145
|
-
return _self$.config.env.defaultConfig;
|
|
146
|
-
},
|
|
147
|
-
reflection: result
|
|
148
|
-
}));
|
|
149
|
-
},
|
|
150
|
-
transform: {
|
|
151
|
-
order: "post",
|
|
152
|
-
async handler() {
|
|
153
|
-
if (this.env.used.env.getProperties().length > 0) {
|
|
154
|
-
this.trace(`Persisting used environment configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "env")}.`);
|
|
155
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
156
|
-
}
|
|
157
|
-
if (this.env.used.secrets.getProperties().length > 0) {
|
|
158
|
-
this.trace(`Persisting used secret configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "secrets")}.`);
|
|
159
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
async docs() {
|
|
164
|
-
this.debug(`Documenting environment variables configuration values in "${(0, _stryke_path_join.joinPaths)(require_helpers_docs_helper.getDocsOutputPath(this), "env.md")}"`);
|
|
165
|
-
const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
166
|
-
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_docs.EnvDocsFile, {
|
|
167
|
-
levelOffset: 0,
|
|
168
|
-
reflection: result
|
|
169
|
-
}));
|
|
170
|
-
},
|
|
171
|
-
async buildEnd() {
|
|
172
|
-
const reflectionPath = require_helpers_persistence.getEnvReflectionsPath(this, "env");
|
|
173
|
-
this.debug(`Writing env reflection types to ${reflectionPath}.`);
|
|
174
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: "env:automd-generator",
|
|
179
|
-
config() {
|
|
180
|
-
return { automd: (0, defu.default)(options.automd ?? {}, { generators: { env: require_helpers_automd_generator.env(this) } }) };
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "env:vite",
|
|
185
|
-
vite: { configResolved() {
|
|
186
|
-
return { envPrefix: this.config?.env?.prefix };
|
|
187
|
-
} }
|
|
188
|
-
},
|
|
189
|
-
(0, _powerlines_plugin_automd.default)(options.automd)
|
|
190
|
-
];
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
//#endregion
|
|
194
|
-
exports.default = plugin;
|
|
195
|
-
exports.plugin = plugin;
|
package/dist/index.d.cts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.cjs";
|
|
2
|
-
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.cjs";
|
|
3
|
-
import { Plugin } from "powerlines";
|
|
4
|
-
|
|
5
|
-
//#region src/index.d.ts
|
|
6
|
-
declare module "powerlines" {
|
|
7
|
-
interface Config {
|
|
8
|
-
env?: EnvPluginOptions;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A Powerlines plugin to inject environment variables into the source code.
|
|
13
|
-
*/
|
|
14
|
-
declare const plugin: <TContext extends EnvPluginContext = EnvPluginContext>(options?: EnvPluginOptions) => Plugin<TContext>[];
|
|
15
|
-
//#endregion
|
|
16
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface, plugin as default, plugin };
|
|
17
|
-
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;YA+DY,MAAA;IACR,GAAA,GAAM,gBAAA;EAAA;AAAA;;;;cAOG,MAAA,oBAA2B,gBAAA,GAAmB,gBAAA,EACzD,OAAA,GAAS,gBAAA,KA2VJ,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.mjs";
|
|
2
|
-
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
|
|
3
|
-
import { Plugin } from "powerlines";
|
|
4
|
-
|
|
5
|
-
//#region src/index.d.ts
|
|
6
|
-
declare module "powerlines" {
|
|
7
|
-
interface Config {
|
|
8
|
-
env?: EnvPluginOptions;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A Powerlines plugin to inject environment variables into the source code.
|
|
13
|
-
*/
|
|
14
|
-
declare const plugin: <TContext extends EnvPluginContext = EnvPluginContext>(options?: EnvPluginOptions) => Plugin<TContext>[];
|
|
15
|
-
//#endregion
|
|
16
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface, plugin as default, plugin };
|
|
17
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;YA+DY,MAAA;IACR,GAAA,GAAM,gBAAA;EAAA;AAAA;;;;cAOG,MAAA,oBAA2B,gBAAA,GAAmB,gBAAA,EACzD,OAAA,GAAS,gBAAA,KA2VJ,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
|
|
2
|
-
import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, writeEnvReflection, writeEnvTypeReflection } from "./helpers/persistence.mjs";
|
|
3
|
-
import { loadEnv } from "./helpers/load.mjs";
|
|
4
|
-
import { getDocsOutputPath } from "./helpers/docs-helper.mjs";
|
|
5
|
-
import { env } from "./helpers/automd-generator.mjs";
|
|
6
|
-
import { EnvDocsFile } from "./components/docs.mjs";
|
|
7
|
-
import { EnvBuiltin } from "./components/env-builtin.mjs";
|
|
8
|
-
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
9
|
-
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
10
|
-
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
11
|
-
import defu from "defu";
|
|
12
|
-
import { joinPaths } from "@stryke/path/join";
|
|
13
|
-
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
14
|
-
import alloy from "@powerlines/plugin-alloy";
|
|
15
|
-
import { render } from "@powerlines/plugin-alloy/render";
|
|
16
|
-
import automd from "@powerlines/plugin-automd";
|
|
17
|
-
import babel from "@powerlines/plugin-babel";
|
|
18
|
-
import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
|
|
19
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
20
|
-
import { existsSync } from "@stryke/fs/exists";
|
|
21
|
-
import { constantCase } from "@stryke/string-format/constant-case";
|
|
22
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
23
|
-
|
|
24
|
-
//#region src/index.tsx
|
|
25
|
-
/**
|
|
26
|
-
* A Powerlines plugin to inject environment variables into the source code.
|
|
27
|
-
*/
|
|
28
|
-
const plugin = (options = {}) => {
|
|
29
|
-
return [
|
|
30
|
-
alloy(options.alloy),
|
|
31
|
-
babel(options.babel),
|
|
32
|
-
{
|
|
33
|
-
name: "env",
|
|
34
|
-
async config() {
|
|
35
|
-
this.debug("Providing default configuration for the Powerlines `env` build plugin.");
|
|
36
|
-
const config = {
|
|
37
|
-
env: defu(options, {
|
|
38
|
-
types: {},
|
|
39
|
-
validate: false,
|
|
40
|
-
inject: false,
|
|
41
|
-
prefix: []
|
|
42
|
-
}),
|
|
43
|
-
transform: { babel: { plugins: [envBabelPlugin] } }
|
|
44
|
-
};
|
|
45
|
-
if (isSetString(config.env.types) || config.env.types && isSetString(config.env.types.file)) {
|
|
46
|
-
config.env.types = parseTypeDefinition(config.env.types);
|
|
47
|
-
const file = await this.fs.resolve(config.env.types.file);
|
|
48
|
-
if (file) config.env.types.file = file;
|
|
49
|
-
} else {
|
|
50
|
-
this.warn("The `env.types` configuration parameter was not provided. Please ensure this is expected.");
|
|
51
|
-
const envDefaultTypeDefinition = await getEnvDefaultTypeDefinition(this);
|
|
52
|
-
const file = await this.fs.resolve(envDefaultTypeDefinition.file);
|
|
53
|
-
if (file) config.env.types = parseTypeDefinition(`${file}#${envDefaultTypeDefinition.name}`);
|
|
54
|
-
}
|
|
55
|
-
if (isSetString(config.env.secrets) || config.env.secrets && isSetString(config.env.secrets.file)) {
|
|
56
|
-
config.env.secrets = parseTypeDefinition(config.env.secrets);
|
|
57
|
-
const file = await this.fs.resolve(config.env.secrets.file);
|
|
58
|
-
if (file) config.env.secrets.file = file;
|
|
59
|
-
} else {
|
|
60
|
-
const secretsDefaultTypeDefinition = await getSecretsDefaultTypeDefinition(this);
|
|
61
|
-
const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);
|
|
62
|
-
if (file) config.env.secrets = parseTypeDefinition(`${file}#${secretsDefaultTypeDefinition.name}`);
|
|
63
|
-
}
|
|
64
|
-
config.env.prefix = toArray(config.env.prefix ?? []).reduce((ret, prefix) => {
|
|
65
|
-
const formattedPrefix = constantCase(prefix);
|
|
66
|
-
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
67
|
-
return ret;
|
|
68
|
-
}, [
|
|
69
|
-
...ENV_PREFIXES,
|
|
70
|
-
"POWERLINES_",
|
|
71
|
-
this.config.framework && this.config.framework !== "powerlines" && `${constantCase(this.config.framework)}_`
|
|
72
|
-
].filter(Boolean));
|
|
73
|
-
config.env.prefix = toArray(config.env.prefix).reduce((ret, prefix) => {
|
|
74
|
-
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
75
|
-
return ret;
|
|
76
|
-
}, []);
|
|
77
|
-
return config;
|
|
78
|
-
},
|
|
79
|
-
async configResolved() {
|
|
80
|
-
this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
|
|
81
|
-
this.env = defu({ parsed: await loadEnv(this, this.config.env) }, this.env ?? {}, {
|
|
82
|
-
types: { env: {} },
|
|
83
|
-
used: {
|
|
84
|
-
env: {},
|
|
85
|
-
secrets: {}
|
|
86
|
-
},
|
|
87
|
-
parsed: {},
|
|
88
|
-
injected: {}
|
|
89
|
-
});
|
|
90
|
-
if (this.config.command !== "prepare" && !this.config.skipCache && this.persistedMeta?.checksum === this.meta.checksum && existsSync(getEnvTypeReflectionsPath(this, "env"))) {
|
|
91
|
-
this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
|
|
92
|
-
this.env.types.env = await readEnvTypeReflection(this, "env");
|
|
93
|
-
if (existsSync(getEnvReflectionsPath(this, "env"))) this.env.used.env = await readEnvReflection(this);
|
|
94
|
-
if (existsSync(getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await readEnvTypeReflection(this, "secrets");
|
|
95
|
-
if (existsSync(getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await readSecretsReflection(this);
|
|
96
|
-
} else {
|
|
97
|
-
this.debug(`Starting environment configuration reflection initialization.`);
|
|
98
|
-
this.env.types.env = await reflectEnv(this, this.config.env.types?.file, this.config.env.types?.name);
|
|
99
|
-
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
100
|
-
await writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
101
|
-
this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file, this.config.env.secrets?.name);
|
|
102
|
-
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
103
|
-
await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
104
|
-
this.debug(`Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
105
|
-
const envWithAlias = this.env.types.env.getProperties().filter((prop) => prop.getAlias().length > 0);
|
|
106
|
-
Object.entries(await loadEnv(this, this.config.env)).forEach(([key, value]) => {
|
|
107
|
-
const unprefixedKey = this.config.env.prefix.reduce((ret, prefix) => {
|
|
108
|
-
if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
|
|
109
|
-
return ret;
|
|
110
|
-
}, key);
|
|
111
|
-
const aliasKey = envWithAlias.find((prop) => prop?.getAlias().reverse().includes(unprefixedKey));
|
|
112
|
-
if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
|
|
113
|
-
});
|
|
114
|
-
this.env.used.env = new ReflectionClass({
|
|
115
|
-
kind: ReflectionKind.objectLiteral,
|
|
116
|
-
typeName: "Env",
|
|
117
|
-
description: `An object containing the environment configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
118
|
-
types: []
|
|
119
|
-
}, this.env.types.env);
|
|
120
|
-
await writeEnvReflection(this, this.env.used.env, "env");
|
|
121
|
-
if (this.env.types.secrets) {
|
|
122
|
-
await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
123
|
-
this.env.used.secrets = new ReflectionClass({
|
|
124
|
-
kind: ReflectionKind.objectLiteral,
|
|
125
|
-
typeName: "Secrets",
|
|
126
|
-
description: `An object containing the secret configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
127
|
-
types: []
|
|
128
|
-
}, this.env.types.secrets);
|
|
129
|
-
await writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
async prepare() {
|
|
134
|
-
const _self$ = this;
|
|
135
|
-
this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);
|
|
136
|
-
const result = await readEnvTypeReflection(this, "env");
|
|
137
|
-
return render(this, createComponent(EnvBuiltin, {
|
|
138
|
-
get defaultConfig() {
|
|
139
|
-
return _self$.config.env.defaultConfig;
|
|
140
|
-
},
|
|
141
|
-
reflection: result
|
|
142
|
-
}));
|
|
143
|
-
},
|
|
144
|
-
transform: {
|
|
145
|
-
order: "post",
|
|
146
|
-
async handler() {
|
|
147
|
-
if (this.env.used.env.getProperties().length > 0) {
|
|
148
|
-
this.trace(`Persisting used environment configuration reflections to ${getEnvReflectionsPath(this, "env")}.`);
|
|
149
|
-
await writeEnvReflection(this, this.env.used.env, "env");
|
|
150
|
-
}
|
|
151
|
-
if (this.env.used.secrets.getProperties().length > 0) {
|
|
152
|
-
this.trace(`Persisting used secret configuration reflections to ${getEnvReflectionsPath(this, "secrets")}.`);
|
|
153
|
-
await writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
async docs() {
|
|
158
|
-
this.debug(`Documenting environment variables configuration values in "${joinPaths(getDocsOutputPath(this), "env.md")}"`);
|
|
159
|
-
const result = await readEnvTypeReflection(this, "env");
|
|
160
|
-
return render(this, createComponent(EnvDocsFile, {
|
|
161
|
-
levelOffset: 0,
|
|
162
|
-
reflection: result
|
|
163
|
-
}));
|
|
164
|
-
},
|
|
165
|
-
async buildEnd() {
|
|
166
|
-
const reflectionPath = getEnvReflectionsPath(this, "env");
|
|
167
|
-
this.debug(`Writing env reflection types to ${reflectionPath}.`);
|
|
168
|
-
await writeEnvReflection(this, this.env.used.env, "env");
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: "env:automd-generator",
|
|
173
|
-
config() {
|
|
174
|
-
return { automd: defu(options.automd ?? {}, { generators: { env: env(this) } }) };
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: "env:vite",
|
|
179
|
-
vite: { configResolved() {
|
|
180
|
-
return { envPrefix: this.config?.env?.prefix };
|
|
181
|
-
} }
|
|
182
|
-
},
|
|
183
|
-
automd(options.automd)
|
|
184
|
-
];
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
//#endregion
|
|
188
|
-
export { plugin as default, plugin };
|
|
189
|
-
//# sourceMappingURL=index.mjs.map
|