@powerlines/plugin-env 0.16.155 → 0.16.157
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/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/babel/index.cjs +1 -4
- package/dist/babel/index.mjs +1 -3
- package/dist/babel/plugin.cjs +4 -129
- package/dist/babel/plugin.mjs +4 -127
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -111
- package/dist/components/docs.mjs +1 -108
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +13 -730
- package/dist/components/env-builtin.mjs +11 -726
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/components/index.cjs +1 -9
- package/dist/components/index.mjs +1 -4
- package/dist/helpers/automd-generator.cjs +1 -32
- package/dist/helpers/automd-generator.mjs +1 -30
- package/dist/helpers/automd-generator.mjs.map +1 -1
- package/dist/helpers/create-reflection-resource.cjs +1 -23
- package/dist/helpers/create-reflection-resource.mjs +1 -22
- package/dist/helpers/create-reflection-resource.mjs.map +1 -1
- package/dist/helpers/index.cjs +1 -34
- package/dist/helpers/index.mjs +1 -8
- package/dist/helpers/load.cjs +1 -139
- package/dist/helpers/load.mjs +1 -135
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +1 -308
- package/dist/helpers/persistence.mjs +1 -295
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/reflect.cjs +1 -290
- package/dist/helpers/reflect.mjs +1 -280
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/helpers/source-file-env.cjs +1 -59
- package/dist/helpers/source-file-env.mjs +1 -56
- package/dist/helpers/source-file-env.mjs.map +1 -1
- package/dist/helpers/template-helpers.cjs +1 -70
- package/dist/helpers/template-helpers.mjs +1 -68
- package/dist/helpers/template-helpers.mjs.map +1 -1
- package/dist/index.cjs +1 -241
- package/dist/index.mjs +1 -234
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -11
- package/dist/types/index.mjs +1 -4
- package/dist/types/plugin.cjs +1 -115
- package/dist/types/plugin.mjs +1 -109
- package/dist/types/plugin.mjs.map +1 -1
- package/dist/types/runtime.cjs +1 -535
- package/dist/types/runtime.mjs +1 -532
- package/dist/types/runtime.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -1,59 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _stryke_env_types = require("@stryke/env/types");
|
|
4
|
-
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
5
|
-
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
6
|
-
|
|
7
|
-
//#region src/helpers/source-file-env.ts
|
|
8
|
-
function __assignType(fn, args) {
|
|
9
|
-
fn.__type = args;
|
|
10
|
-
return fn;
|
|
11
|
-
}
|
|
12
|
-
const __ΩTReturned = [
|
|
13
|
-
"TEnv",
|
|
14
|
-
"TReturned",
|
|
15
|
-
"l2&R!RPe#!&qk#%QRb!Pde\"!p'w\"y"
|
|
16
|
-
];
|
|
17
|
-
function removeEnvPrefix(env) {
|
|
18
|
-
if ((0, _stryke_type_checks_is_string.isString)(env)) {
|
|
19
|
-
let name = _stryke_env_types.ENV_PREFIXES.reduce(__assignType((ret, prefix) => {
|
|
20
|
-
if (ret.startsWith(prefix)) ret = ret.slice(prefix.length);
|
|
21
|
-
return ret;
|
|
22
|
-
}, [
|
|
23
|
-
"ret",
|
|
24
|
-
"prefix",
|
|
25
|
-
"",
|
|
26
|
-
"P\"2!\"2\"\"/#"
|
|
27
|
-
]), env.toUpperCase());
|
|
28
|
-
while (name.startsWith("_")) name = name.slice(1);
|
|
29
|
-
return name;
|
|
30
|
-
}
|
|
31
|
-
return Object.keys(env).reduce(__assignType((ret, key) => {
|
|
32
|
-
const name = removeEnvPrefix(key);
|
|
33
|
-
if (name) ret[name] = env[key];
|
|
34
|
-
return ret;
|
|
35
|
-
}, [
|
|
36
|
-
"ret",
|
|
37
|
-
"key",
|
|
38
|
-
"",
|
|
39
|
-
"P\"2!\"2\"\"/#"
|
|
40
|
-
]), {});
|
|
41
|
-
}
|
|
42
|
-
removeEnvPrefix.__type = [
|
|
43
|
-
"env",
|
|
44
|
-
() => __ΩTReturned,
|
|
45
|
-
"removeEnvPrefix",
|
|
46
|
-
"P\"2!\"o\"\"/#"
|
|
47
|
-
];
|
|
48
|
-
function formatEnvField(key) {
|
|
49
|
-
return (0, _stryke_string_format_camel_case.camelCase)(removeEnvPrefix(key));
|
|
50
|
-
}
|
|
51
|
-
formatEnvField.__type = [
|
|
52
|
-
"key",
|
|
53
|
-
"formatEnvField",
|
|
54
|
-
"P&2!&/\""
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
exports.formatEnvField = formatEnvField;
|
|
59
|
-
exports.removeEnvPrefix = removeEnvPrefix;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@stryke/env/types`),t=require(`@stryke/string-format/camel-case`),n=require(`@stryke/type-checks/is-string`);function r(e,t){return e.__type=t,e}const i=[`TEnv`,`TReturned`,`l2&R!RPe#!&qk#%QRb!Pde"!p'w"y`];function a(t){if((0,n.isString)(t)){let n=e.ENV_PREFIXES.reduce(r((e,t)=>(e.startsWith(t)&&(e=e.slice(t.length)),e),[`ret`,`prefix`,``,`P"2!"2""/#`]),t.toUpperCase());for(;n.startsWith(`_`);)n=n.slice(1);return n}return Object.keys(t).reduce(r((e,n)=>{let r=a(n);return r&&(e[r]=t[n]),e},[`ret`,`key`,``,`P"2!"2""/#`]),{})}a.__type=[`env`,()=>i,`removeEnvPrefix`,`P"2!"o""/#`];function o(e){return(0,t.camelCase)(a(e))}o.__type=[`key`,`formatEnvField`,`P&2!&/"`],exports.formatEnvField=o,exports.removeEnvPrefix=a;
|
|
@@ -1,57 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { camelCase } from "@stryke/string-format/camel-case";
|
|
3
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/source-file-env.ts
|
|
6
|
-
function __assignType(fn, args) {
|
|
7
|
-
fn.__type = args;
|
|
8
|
-
return fn;
|
|
9
|
-
}
|
|
10
|
-
const __ΩTReturned = [
|
|
11
|
-
"TEnv",
|
|
12
|
-
"TReturned",
|
|
13
|
-
"l2&R!RPe#!&qk#%QRb!Pde\"!p'w\"y"
|
|
14
|
-
];
|
|
15
|
-
function removeEnvPrefix(env) {
|
|
16
|
-
if (isString(env)) {
|
|
17
|
-
let name = ENV_PREFIXES.reduce(__assignType((ret, prefix) => {
|
|
18
|
-
if (ret.startsWith(prefix)) ret = ret.slice(prefix.length);
|
|
19
|
-
return ret;
|
|
20
|
-
}, [
|
|
21
|
-
"ret",
|
|
22
|
-
"prefix",
|
|
23
|
-
"",
|
|
24
|
-
"P\"2!\"2\"\"/#"
|
|
25
|
-
]), env.toUpperCase());
|
|
26
|
-
while (name.startsWith("_")) name = name.slice(1);
|
|
27
|
-
return name;
|
|
28
|
-
}
|
|
29
|
-
return Object.keys(env).reduce(__assignType((ret, key) => {
|
|
30
|
-
const name = removeEnvPrefix(key);
|
|
31
|
-
if (name) ret[name] = env[key];
|
|
32
|
-
return ret;
|
|
33
|
-
}, [
|
|
34
|
-
"ret",
|
|
35
|
-
"key",
|
|
36
|
-
"",
|
|
37
|
-
"P\"2!\"2\"\"/#"
|
|
38
|
-
]), {});
|
|
39
|
-
}
|
|
40
|
-
removeEnvPrefix.__type = [
|
|
41
|
-
"env",
|
|
42
|
-
() => __ΩTReturned,
|
|
43
|
-
"removeEnvPrefix",
|
|
44
|
-
"P\"2!\"o\"\"/#"
|
|
45
|
-
];
|
|
46
|
-
function formatEnvField(key) {
|
|
47
|
-
return camelCase(removeEnvPrefix(key));
|
|
48
|
-
}
|
|
49
|
-
formatEnvField.__type = [
|
|
50
|
-
"key",
|
|
51
|
-
"formatEnvField",
|
|
52
|
-
"P&2!&/\""
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { formatEnvField, removeEnvPrefix };
|
|
1
|
+
import{ENV_PREFIXES as e}from"@stryke/env/types";import{camelCase as t}from"@stryke/string-format/camel-case";import{isString as n}from"@stryke/type-checks/is-string";function r(e,t){return e.__type=t,e}const i=[`TEnv`,`TReturned`,`l2&R!RPe#!&qk#%QRb!Pde"!p'w"y`];function a(t){if(n(t)){let n=e.reduce(r((e,t)=>(e.startsWith(t)&&(e=e.slice(t.length)),e),[`ret`,`prefix`,``,`P"2!"2""/#`]),t.toUpperCase());for(;n.startsWith(`_`);)n=n.slice(1);return n}return Object.keys(t).reduce(r((e,n)=>{let r=a(n);return r&&(e[r]=t[n]),e},[`ret`,`key`,``,`P"2!"2""/#`]),{})}a.__type=[`env`,()=>i,`removeEnvPrefix`,`P"2!"o""/#`];function o(e){return t(a(e))}o.__type=[`key`,`formatEnvField`,`P&2!&/"`];export{o as formatEnvField,a as removeEnvPrefix};
|
|
57
2
|
//# sourceMappingURL=source-file-env.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file-env.mjs","names":[],"sources":["../../src/helpers/source-file-env.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 type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\ntype TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;\n\nexport function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(\n env: TEnv\n): TReturned<TEnv> {\n if (isString(env)) {\n let name: string = ENV_PREFIXES.reduce((ret, prefix) => {\n if (ret.startsWith(prefix)) {\n ret = ret.slice(prefix.length);\n }\n\n return ret;\n }, env.toUpperCase());\n\n while (name.startsWith(\"_\")) {\n name = name.slice(1);\n }\n\n return name as TReturned<TEnv>;\n }\n\n return Object.keys(env).reduce((ret, key) => {\n const name = removeEnvPrefix(key);\n if (name) {\n (ret as DotenvParseOutput)[name] = env[key];\n }\n\n return ret;\n }, {} as TReturned<TEnv>);\n}\n\nexport function formatEnvField(key: string): string {\n return camelCase(removeEnvPrefix(key));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"source-file-env.mjs","names":[],"sources":["../../src/helpers/source-file-env.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 type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\ntype TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;\n\nexport function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(\n env: TEnv\n): TReturned<TEnv> {\n if (isString(env)) {\n let name: string = ENV_PREFIXES.reduce((ret, prefix) => {\n if (ret.startsWith(prefix)) {\n ret = ret.slice(prefix.length);\n }\n\n return ret;\n }, env.toUpperCase());\n\n while (name.startsWith(\"_\")) {\n name = name.slice(1);\n }\n\n return name as TReturned<TEnv>;\n }\n\n return Object.keys(env).reduce((ret, key) => {\n const name = removeEnvPrefix(key);\n if (name) {\n (ret as DotenvParseOutput)[name] = env[key];\n }\n\n return ret;\n }, {} as TReturned<TEnv>);\n}\n\nexport function formatEnvField(key: string): string {\n return camelCase(removeEnvPrefix(key));\n}\n"],"mappings":"uKAAA,SAAS,EAAa,EAAI,EAAM,CAE9B,kBAAO,EAKT,MAAK,EAAe,CAAE,OAAQ,YAAC,gCAAoC,eAElE,GAAA,EAAc,EAAI,CAAE,CACpB,IAAA,EAAc,EAAY,OAAQ,GAAW,EAAM,KACnD,EAAa,WAAW,EAAO,GACxB,EAAM,EAAI,MAAM,EAAG,OAAQ,EAEtB,sDAET,KAAO,EAAK,WAAW,IAAI,EAAA,EAAA,EAAA,MAAA,EAAA,CAG/B,OAAS,EAET,OAAS,OAAA,KAAW,EAAK,CAAC,OAAO,GAAa,EAAG,IAAO,YAKtD,OAHG,IAAA,EAAA,GAAA,EAAA,IAGE,GACJ,CAAA,MAAU,MAAM,GAAA,aAAA,CAAA,CAAA,EAAA,CAAA,CAEnB,EAAc,OAAS,CAAA,UAAa,EAAa,kBAAW,aAAA,CAC5D,SAAc,EAAiB,EAAG,CAChC,OAAM,EAAU,EAAa,EAAO,CAAA"}
|
|
@@ -1,70 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
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 _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
6
|
-
|
|
7
|
-
//#region src/helpers/template-helpers.ts
|
|
8
|
-
function __assignType(fn, args) {
|
|
9
|
-
fn.__type = args;
|
|
10
|
-
return fn;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Creates the reflection data used when generating runtime template files.
|
|
14
|
-
*
|
|
15
|
-
* @param context - The context for the configuration plugin.
|
|
16
|
-
* @param name - The name of the configuration template.
|
|
17
|
-
* @returns The reflection for the specified configuration template.
|
|
18
|
-
*/
|
|
19
|
-
async function createTemplateReflection(context, name) {
|
|
20
|
-
const reflection = await require_helpers_persistence.readEnvTypeReflection(context, name);
|
|
21
|
-
reflection.getProperties().forEach(__assignType((prop) => {
|
|
22
|
-
prop.getAlias().filter(Boolean).forEach(__assignType((alias) => {
|
|
23
|
-
reflection.addProperty({
|
|
24
|
-
name: alias,
|
|
25
|
-
optional: prop.isOptional() ? true : void 0,
|
|
26
|
-
readonly: prop.isReadonly() ? true : void 0,
|
|
27
|
-
description: prop.getDescription(),
|
|
28
|
-
visibility: prop.getVisibility(),
|
|
29
|
-
type: prop.getType(),
|
|
30
|
-
default: prop.getDefaultValue(),
|
|
31
|
-
tags: {
|
|
32
|
-
hidden: prop.isHidden(),
|
|
33
|
-
ignore: prop.isIgnored(),
|
|
34
|
-
internal: prop.isInternal(),
|
|
35
|
-
runtime: prop.isRuntime(),
|
|
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
|
-
"createTemplateReflection",
|
|
65
|
-
"Creates the reflection data used when generating runtime template files.",
|
|
66
|
-
"Pn!2\"n#2$8!`/%?&"
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
exports.createTemplateReflection = createTemplateReflection;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../types/plugin.cjs`),t=require(`./persistence.cjs`);let n=require(`@stryke/string-format/title-case`);function r(e,t){return e.__type=t,e}async function i(e,i){let a=await t.readEnvTypeReflection(e,i);return a.getProperties().forEach(r(e=>{e.getAlias().filter(Boolean).forEach(r(t=>{a.addProperty({name:t,optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,description:e.getDescription(),visibility:e.getVisibility(),type:e.getType(),default:e.getDefaultValue(),tags:{hidden:e.isHidden(),ignore:e.isIgnored(),internal:e.isInternal(),runtime:e.isRuntime(),alias:e.getAlias().filter(r(e=>e!==t,[`a`,``,`P"2!"/"`])).concat(e.name),title:e.getTitle()||(0,n.titleCase)(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})},[`alias`,``,`P"2!"/"`]))},[`prop`,``,`P"2!"/"`])),a}i.__type=[()=>e.__ΩEnvPluginContext,`context`,()=>e.__ΩEnvType,`name`,`createTemplateReflection`,`Creates the reflection data used when generating runtime template files.`,'Pn!2"n#2$8!`/%?&'],exports.createTemplateReflection=i;
|
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { readEnvTypeReflection } from "./persistence.mjs";
|
|
3
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/template-helpers.ts
|
|
6
|
-
function __assignType(fn, args) {
|
|
7
|
-
fn.__type = args;
|
|
8
|
-
return fn;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Creates the reflection data used when generating runtime template files.
|
|
12
|
-
*
|
|
13
|
-
* @param context - The context for the configuration plugin.
|
|
14
|
-
* @param name - The name of the configuration template.
|
|
15
|
-
* @returns The reflection for the specified configuration template.
|
|
16
|
-
*/
|
|
17
|
-
async function createTemplateReflection(context, name) {
|
|
18
|
-
const reflection = await readEnvTypeReflection(context, name);
|
|
19
|
-
reflection.getProperties().forEach(__assignType((prop) => {
|
|
20
|
-
prop.getAlias().filter(Boolean).forEach(__assignType((alias) => {
|
|
21
|
-
reflection.addProperty({
|
|
22
|
-
name: alias,
|
|
23
|
-
optional: prop.isOptional() ? true : void 0,
|
|
24
|
-
readonly: prop.isReadonly() ? true : void 0,
|
|
25
|
-
description: prop.getDescription(),
|
|
26
|
-
visibility: prop.getVisibility(),
|
|
27
|
-
type: prop.getType(),
|
|
28
|
-
default: prop.getDefaultValue(),
|
|
29
|
-
tags: {
|
|
30
|
-
hidden: prop.isHidden(),
|
|
31
|
-
ignore: prop.isIgnored(),
|
|
32
|
-
internal: prop.isInternal(),
|
|
33
|
-
runtime: prop.isRuntime(),
|
|
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
|
-
"createTemplateReflection",
|
|
63
|
-
"Creates the reflection data used when generating runtime template files.",
|
|
64
|
-
"Pn!2\"n#2$8!`/%?&"
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
export { createTemplateReflection };
|
|
1
|
+
import{__ΩEnvPluginContext as e,__ΩEnvType as t}from"../types/plugin.mjs";import{readEnvTypeReflection as n}from"./persistence.mjs";import{titleCase as r}from"@stryke/string-format/title-case";function i(e,t){return e.__type=t,e}async function a(e,t){let a=await n(e,t);return a.getProperties().forEach(i(e=>{e.getAlias().filter(Boolean).forEach(i(t=>{a.addProperty({name:t,optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,description:e.getDescription(),visibility:e.getVisibility(),type:e.getType(),default:e.getDefaultValue(),tags:{hidden:e.isHidden(),ignore:e.isIgnored(),internal:e.isInternal(),runtime:e.isRuntime(),alias:e.getAlias().filter(i(e=>e!==t,[`a`,``,`P"2!"/"`])).concat(e.name),title:e.getTitle()||r(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})},[`alias`,``,`P"2!"/"`]))},[`prop`,``,`P"2!"/"`])),a}a.__type=[()=>e,`context`,()=>t,`name`,`createTemplateReflection`,`Creates the reflection data used when generating runtime template files.`,'Pn!2"n#2$8!`/%?&'];export{a as createTemplateReflection};
|
|
69
2
|
//# sourceMappingURL=template-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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 runtime: prop.isRuntime(),\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":"
|
|
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 runtime: prop.isRuntime(),\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":"iMAIA,SAAM,EAAS,EAAW,EAAM,CAE/B,MADA,GAAG,OAAU,EACL,wBAYT,IAAQ,EAAC,MAAkB,EAAkB,EAAQ,EAAO,CA0B1D,OAzBF,EAAS,eAAmB,CAAA,QAAO,EAAc,GAAM,CAC9C,EAAgB,UAChB,CAAA,OAAA,QAAA,CAAA,QAAwB,EAAQ,GAAY,gBAEnD,KAAA,EACC,SAAY,EAAA,YAAoB,CAAC,GAAK,IAAA,GACxC,SAAA,EAAA,YAAA,CAAA,GAAA,IAAA,GACG,YAAgB,EAAI,gBAAgB,CACpC,WAAgB,EAAK,eAAQ,CAC7B,KAAQ,EAAI,SAAW,CACzB,QAAA,EAAA,iBAAA,CACK,KAAM,CACH,OAAC,EAAA,UAAgB,CAClB,OAAA,EAAA,WAAA,CACC,SAAC,EAAA,YAAsB,CACzB,QAAW,EAAE,WAAM,0EAEzB,MAAW,EAAA,UAAgB,EAAO,EAAS,EAAA,KAAA,CACnC,SAAU,EAAK,YAAU,CAC/B,WAAe,EAAQ,eAAe,CACpC,OAAW,EAAA,WAAY,CACrB,CACD,CAAC,EACD,CAAC,QAAS,GAAC,UAAK,CAAA,CAAU,EAC5B,CAAC,OAAE,GAAA,UAAkB,CAAA,CAAA,CAClB,EAER,EAAsB,OAAA,KAAiB,EAAA,cAAA,EAAA,OAAA,2BAAA,2EAAA,mBAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,241 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_types_plugin = require('./types/plugin.cjs');
|
|
4
|
-
const require_helpers_reflect = require('./helpers/reflect.cjs');
|
|
5
|
-
const require_helpers_persistence = require('./helpers/persistence.cjs');
|
|
6
|
-
const require_helpers_load = require('./helpers/load.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 defu = require("defu");
|
|
13
|
-
defu = require_runtime.__toESM(defu);
|
|
14
|
-
let powerlines_constants = require("powerlines/constants");
|
|
15
|
-
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
16
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
17
|
-
let _stryke_path_join = require("@stryke/path/join");
|
|
18
|
-
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
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 _powerlines_plugin_deepkit = require("@powerlines/plugin-deepkit");
|
|
25
|
-
_powerlines_plugin_deepkit = require_runtime.__toESM(_powerlines_plugin_deepkit);
|
|
26
|
-
let _stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
|
|
27
|
-
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
28
|
-
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
29
|
-
let _stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
30
|
-
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
31
|
-
|
|
32
|
-
//#region src/index.tsx
|
|
33
|
-
function __assignType(fn, args) {
|
|
34
|
-
fn.__type = args;
|
|
35
|
-
return fn;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A Powerlines plugin to inject environment variables into the source code.
|
|
39
|
-
*/
|
|
40
|
-
const plugin = __assignType((options = {}) => {
|
|
41
|
-
return [
|
|
42
|
-
(0, _powerlines_plugin_deepkit.default)(options.deepkit),
|
|
43
|
-
(0, _powerlines_plugin_babel.default)(options.babel),
|
|
44
|
-
{
|
|
45
|
-
name: "env:core",
|
|
46
|
-
async config() {
|
|
47
|
-
this.debug("Providing default configuration for the Powerlines `env` build plugin.");
|
|
48
|
-
const config = {
|
|
49
|
-
env: (0, defu.default)(options, {
|
|
50
|
-
types: {},
|
|
51
|
-
validate: false,
|
|
52
|
-
inject: false,
|
|
53
|
-
prefix: []
|
|
54
|
-
}),
|
|
55
|
-
babel: { plugins: [require_babel_plugin.envBabelPlugin] },
|
|
56
|
-
deepkit: {
|
|
57
|
-
reflection: "default",
|
|
58
|
-
level: "all"
|
|
59
|
-
},
|
|
60
|
-
tsc: {}
|
|
61
|
-
};
|
|
62
|
-
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)) {
|
|
63
|
-
config.env.types = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.types);
|
|
64
|
-
const file = await this.fs.resolve(config.env.types.file);
|
|
65
|
-
if (file) config.env.types.file = file;
|
|
66
|
-
} else {
|
|
67
|
-
this.warn("The `env.types` configuration parameter was not provided. Please ensure this is expected.");
|
|
68
|
-
const envDefaultTypeDefinition = await require_helpers_persistence.getEnvDefaultTypeDefinition(this);
|
|
69
|
-
const file = await this.fs.resolve(envDefaultTypeDefinition.file);
|
|
70
|
-
if (file) config.env.types = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(`${file}#${envDefaultTypeDefinition.name}`);
|
|
71
|
-
}
|
|
72
|
-
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)) {
|
|
73
|
-
config.env.secrets = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.secrets);
|
|
74
|
-
const file = await this.fs.resolve(config.env.secrets.file);
|
|
75
|
-
if (file) config.env.secrets.file = file;
|
|
76
|
-
} else {
|
|
77
|
-
const secretsDefaultTypeDefinition = await require_helpers_persistence.getSecretsDefaultTypeDefinition(this);
|
|
78
|
-
const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);
|
|
79
|
-
if (file) config.env.secrets = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(`${file}#${secretsDefaultTypeDefinition.name}`);
|
|
80
|
-
}
|
|
81
|
-
if (config.env.types || config.env.secrets) config.tsc.filter = { id: [new RegExp(`^(${powerlines_constants.VIRTUAL_MODULE_PREFIX})?${(0, _stryke_path_join.joinPaths)(this.builtinsPath, "env.ts").replace(/\\/g, "\\\\").replace(/\//g, "\\/").replace(/\./g, "\\.").replace(/\$/g, "\\$")}$`)] };
|
|
82
|
-
config.env.prefix = (0, _stryke_convert_to_array.toArray)(config.env.prefix ?? []).reduce(__assignType((ret, prefix) => {
|
|
83
|
-
const formattedPrefix = (0, _stryke_string_format_constant_case.constantCase)(prefix);
|
|
84
|
-
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
85
|
-
return ret;
|
|
86
|
-
}, [
|
|
87
|
-
"ret",
|
|
88
|
-
"prefix",
|
|
89
|
-
"",
|
|
90
|
-
"P&F2!&2\"\"/#"
|
|
91
|
-
]), ["POWERLINES_", this.config.framework && this.config.framework !== "powerlines" && `${(0, _stryke_string_format_constant_case.constantCase)(this.config.framework)}_`].filter(Boolean));
|
|
92
|
-
config.env.prefix = (0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(config.env.prefix).reduce(__assignType((ret, prefix) => {
|
|
93
|
-
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
94
|
-
return ret;
|
|
95
|
-
}, [
|
|
96
|
-
"ret",
|
|
97
|
-
"prefix",
|
|
98
|
-
"",
|
|
99
|
-
"P\"2!\"2\"\"/#"
|
|
100
|
-
]), []));
|
|
101
|
-
return config;
|
|
102
|
-
},
|
|
103
|
-
async configResolved() {
|
|
104
|
-
this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
|
|
105
|
-
this.env = (0, defu.default)({ parsed: await require_helpers_load.loadEnv(this, this.config.env) }, this.env ?? {}, {
|
|
106
|
-
types: { env: {} },
|
|
107
|
-
used: {
|
|
108
|
-
env: {},
|
|
109
|
-
secrets: {}
|
|
110
|
-
},
|
|
111
|
-
parsed: {},
|
|
112
|
-
injected: {}
|
|
113
|
-
});
|
|
114
|
-
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"))) {
|
|
115
|
-
this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
|
|
116
|
-
this.env.types.env = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
117
|
-
if ((0, _stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvReflectionsPath(this, "env"))) this.env.used.env = await require_helpers_persistence.readEnvReflection(this);
|
|
118
|
-
if ((0, _stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await require_helpers_persistence.readEnvTypeReflection(this, "secrets");
|
|
119
|
-
if ((0, _stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await require_helpers_persistence.readSecretsReflection(this);
|
|
120
|
-
} else {
|
|
121
|
-
this.debug(`Starting environment configuration reflection initialization.`);
|
|
122
|
-
this.env.types.env = await require_helpers_reflect.reflectEnv(this, this.config.env.types?.file, this.config.env.types?.name);
|
|
123
|
-
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
124
|
-
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
125
|
-
this.env.types.secrets = await require_helpers_reflect.reflectSecrets(this, this.config.env.secrets?.file, this.config.env.secrets?.name);
|
|
126
|
-
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
127
|
-
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
128
|
-
this.debug(`Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
129
|
-
const envWithAlias = this.env.types.env.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
|
|
130
|
-
"prop",
|
|
131
|
-
"",
|
|
132
|
-
"P\"2!\"/\""
|
|
133
|
-
]));
|
|
134
|
-
Object.entries(await require_helpers_load.loadEnv(this, this.config.env)).forEach(__assignType(([key, value]) => {
|
|
135
|
-
const unprefixedKey = this.config.env.prefix.reduce(__assignType((ret, prefix) => {
|
|
136
|
-
if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
|
|
137
|
-
return ret;
|
|
138
|
-
}, [
|
|
139
|
-
"ret",
|
|
140
|
-
"prefix",
|
|
141
|
-
"",
|
|
142
|
-
"P\"2!\"2\"\"/#"
|
|
143
|
-
]), key);
|
|
144
|
-
const aliasKey = envWithAlias.find(__assignType((prop) => prop?.getAlias().reverse().includes(unprefixedKey), [
|
|
145
|
-
"prop",
|
|
146
|
-
"",
|
|
147
|
-
"P\"2!\"/\""
|
|
148
|
-
]));
|
|
149
|
-
if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
|
|
150
|
-
}, [
|
|
151
|
-
"param0",
|
|
152
|
-
"",
|
|
153
|
-
"P\"2!\"/\""
|
|
154
|
-
]));
|
|
155
|
-
this.env.used.env = new _powerlines_deepkit_vendor_type.ReflectionClass({
|
|
156
|
-
kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
157
|
-
typeName: "Env",
|
|
158
|
-
description: `An object containing the environment configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
159
|
-
types: []
|
|
160
|
-
}, this.env.types.env);
|
|
161
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
162
|
-
if (this.env.types.secrets) {
|
|
163
|
-
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
164
|
-
this.env.used.secrets = new _powerlines_deepkit_vendor_type.ReflectionClass({
|
|
165
|
-
kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
166
|
-
typeName: "Secrets",
|
|
167
|
-
description: `An object containing the secret configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
168
|
-
types: []
|
|
169
|
-
}, this.env.types.secrets);
|
|
170
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
prepare: __assignType(async function prepare() {
|
|
175
|
-
const _self$ = this;
|
|
176
|
-
this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);
|
|
177
|
-
const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
178
|
-
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_env_builtin.EnvBuiltin, {
|
|
179
|
-
get defaultConfig() {
|
|
180
|
-
return _self$.config.env.defaultConfig;
|
|
181
|
-
},
|
|
182
|
-
reflection: result
|
|
183
|
-
}));
|
|
184
|
-
}, ["prepare", "P\"/!"]),
|
|
185
|
-
transform: {
|
|
186
|
-
order: "post",
|
|
187
|
-
handler: __assignType(async function handler() {
|
|
188
|
-
if (this.env.used.env.getProperties().length > 0) {
|
|
189
|
-
this.trace(`Persisting used environment configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "env")}.`);
|
|
190
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
191
|
-
}
|
|
192
|
-
if (this.env.used.secrets.getProperties().length > 0) {
|
|
193
|
-
this.trace(`Persisting used secret configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "secrets")}.`);
|
|
194
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
195
|
-
}
|
|
196
|
-
}, ["handler", "P\"/!"])
|
|
197
|
-
},
|
|
198
|
-
docs: __assignType(async function docs() {
|
|
199
|
-
this.debug(`Documenting environment variables configuration values in "${(0, _stryke_path_join.joinPaths)((0, powerlines_plugin_utils.getDocsOutputPath)(this.config.root), "env.md")}"`);
|
|
200
|
-
const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
201
|
-
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_docs.EnvDocsFile, {
|
|
202
|
-
levelOffset: 0,
|
|
203
|
-
reflection: result
|
|
204
|
-
}));
|
|
205
|
-
}, ["docs", "P\"/!"]),
|
|
206
|
-
buildEnd: __assignType(async function buildEnd() {
|
|
207
|
-
const reflectionPath = require_helpers_persistence.getEnvReflectionsPath(this, "env");
|
|
208
|
-
this.debug(`Writing env reflection types to ${reflectionPath}.`);
|
|
209
|
-
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
210
|
-
}, ["buildEnd", "P\"/!"])
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: "env:automd-generator",
|
|
214
|
-
config: __assignType(function config() {
|
|
215
|
-
return { automd: (0, defu.default)(options.automd ?? {}, { generators: { env: require_helpers_automd_generator.env(this) } }) };
|
|
216
|
-
}, ["config", "P\"/!"])
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: "env:vite",
|
|
220
|
-
vite: { configResolved: __assignType(function configResolved() {
|
|
221
|
-
return { envPrefix: this.config?.env?.prefix };
|
|
222
|
-
}, [
|
|
223
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
224
|
-
"this",
|
|
225
|
-
"configResolved",
|
|
226
|
-
"Pn!2\"\"/#"
|
|
227
|
-
]) }
|
|
228
|
-
},
|
|
229
|
-
(0, _powerlines_plugin_automd.default)(options.automd)
|
|
230
|
-
];
|
|
231
|
-
}, [
|
|
232
|
-
() => require_types_plugin.__ΩEnvPluginOptions,
|
|
233
|
-
"options",
|
|
234
|
-
() => ({}),
|
|
235
|
-
"",
|
|
236
|
-
"Pn!2\">#\"/$"
|
|
237
|
-
]);
|
|
238
|
-
|
|
239
|
-
//#endregion
|
|
240
|
-
exports.default = plugin;
|
|
241
|
-
exports.plugin = plugin;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./types/plugin.cjs`),n=require(`./helpers/reflect.cjs`),r=require(`./helpers/persistence.cjs`),i=require(`./helpers/load.cjs`),a=require(`./helpers/automd-generator.cjs`),o=require(`./components/docs.cjs`),s=require(`./components/env-builtin.cjs`),c=require(`./babel/plugin.cjs`);let l=require(`@powerlines/deepkit/vendor/type`),u=require(`defu`);u=e.__toESM(u);let d=require(`powerlines/constants`),f=require(`powerlines/plugin-utils`),p=require(`@alloy-js/core/jsx-runtime`),m=require(`@stryke/path/join`),h=require(`@stryke/helpers/get-unique`),g=require(`@powerlines/plugin-alloy/render`),_=require(`@powerlines/plugin-automd`);_=e.__toESM(_);let v=require(`@powerlines/plugin-babel`);v=e.__toESM(v);let y=require(`@powerlines/plugin-deepkit`);y=e.__toESM(y);let b=require(`@stryke/convert/parse-type-definition`),x=require(`@stryke/convert/to-array`),S=require(`@stryke/fs/exists`),C=require(`@stryke/string-format/constant-case`),w=require(`@stryke/type-checks/is-set-string`);function T(e,t){return e.__type=t,e}const E=T((e={})=>[(0,y.default)(e.deepkit),(0,v.default)(e.babel),{name:`env:core`,async config(){this.debug("Providing default configuration for the Powerlines `env` build plugin.");let t={env:(0,u.default)(e,{types:{},validate:!1,inject:!1,prefix:[]}),babel:{plugins:[c.envBabelPlugin]},deepkit:{reflection:`default`,level:`all`},tsc:{}};if((0,w.isSetString)(t.env.types)||t.env.types&&(0,w.isSetString)(t.env.types.file)){t.env.types=(0,b.parseTypeDefinition)(t.env.types);let e=await this.fs.resolve(t.env.types.file);e&&(t.env.types.file=e)}else{this.warn("The `env.types` configuration parameter was not provided. Please ensure this is expected.");let e=await r.getEnvDefaultTypeDefinition(this),n=await this.fs.resolve(e.file);n&&(t.env.types=(0,b.parseTypeDefinition)(`${n}#${e.name}`))}if((0,w.isSetString)(t.env.secrets)||t.env.secrets&&(0,w.isSetString)(t.env.secrets.file)){t.env.secrets=(0,b.parseTypeDefinition)(t.env.secrets);let e=await this.fs.resolve(t.env.secrets.file);e&&(t.env.secrets.file=e)}else{let e=await r.getSecretsDefaultTypeDefinition(this),n=await this.fs.resolve(e.file);n&&(t.env.secrets=(0,b.parseTypeDefinition)(`${n}#${e.name}`))}return(t.env.types||t.env.secrets)&&(t.tsc.filter={id:[RegExp(`^(${d.VIRTUAL_MODULE_PREFIX})?${(0,m.joinPaths)(this.builtinsPath,`env.ts`).replace(/\\/g,`\\\\`).replace(/\//g,`\\/`).replace(/\./g,`\\.`).replace(/\$/g,`\\$`)}$`)]}),t.env.prefix=(0,x.toArray)(t.env.prefix??[]).reduce(T((e,t)=>{let n=(0,C.constantCase)(t);return e.includes(n)||e.push(n),e},[`ret`,`prefix`,``,`P&F2!&2""/#`]),[`POWERLINES_`,this.config.framework&&this.config.framework!==`powerlines`&&`${(0,C.constantCase)(this.config.framework)}_`].filter(Boolean)),t.env.prefix=(0,h.getUnique)((0,x.toArray)(t.env.prefix).reduce(T((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[`ret`,`prefix`,``,`P"2!"2""/#`]),[])),t},async configResolved(){if(this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`),this.env=(0,u.default)({parsed:await i.loadEnv(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&!this.config.skipCache&&this.persistedMeta?.checksum===this.meta.checksum&&(0,S.existsSync)(r.getEnvTypeReflectionsPath(this,`env`)))this.debug(`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await r.readEnvTypeReflection(this,`env`),(0,S.existsSync)(r.getEnvReflectionsPath(this,`env`))&&(this.env.used.env=await r.readEnvReflection(this)),(0,S.existsSync)(r.getEnvTypeReflectionsPath(this,`secrets`))&&(this.env.types.secrets=await r.readEnvTypeReflection(this,`secrets`)),(0,S.existsSync)(r.getEnvReflectionsPath(this,`secrets`))&&(this.env.used.secrets=await r.readSecretsReflection(this));else{if(this.debug(`Starting environment configuration reflection initialization.`),this.env.types.env=await n.reflectEnv(this,this.config.env.types?.file,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await r.writeEnvTypeReflection(this,this.env.types.env,`env`),this.env.types.secrets=await n.reflectSecrets(this,this.config.env.secrets?.file,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await r.writeEnvTypeReflection(this,this.env.types.secrets,`secrets`),this.debug(`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let e=this.env.types.env.getProperties().filter(T(e=>e.getAlias().length>0,[`prop`,``,`P"2!"/"`]));Object.entries(await i.loadEnv(this,this.config.env)).forEach(T(([t,n])=>{let r=this.config.env.prefix.reduce(T((e,n)=>t.replace(/_$/g,``).startsWith(n)?t.replace(/_$/g,``).slice(n.length):e,[`ret`,`prefix`,``,`P"2!"2""/#`]),t),i=e.find(T(e=>e?.getAlias().reverse().includes(r),[`prop`,``,`P"2!"/"`]));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(n)},[`param0`,``,`P"2!"/"`])),this.env.used.env=new l.ReflectionClass({kind:l.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await r.writeEnvReflection(this,this.env.used.env,`env`),this.env.types.secrets&&(await r.writeEnvTypeReflection(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new l.ReflectionClass({kind:l.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await r.writeEnvReflection(this,this.env.used.secrets,`secrets`))}},prepare:T(async function(){let e=this;this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);let t=await r.readEnvTypeReflection(this,`env`);return(0,g.render)(this,(0,p.createComponent)(s.EnvBuiltin,{get defaultConfig(){return e.config.env.defaultConfig},reflection:t}))},[`prepare`,`P"/!`]),transform:{order:`post`,handler:T(async function(){this.env.used.env.getProperties().length>0&&(this.trace(`Persisting used environment configuration reflections to ${r.getEnvReflectionsPath(this,`env`)}.`),await r.writeEnvReflection(this,this.env.used.env,`env`)),this.env.used.secrets.getProperties().length>0&&(this.trace(`Persisting used secret configuration reflections to ${r.getEnvReflectionsPath(this,`secrets`)}.`),await r.writeEnvReflection(this,this.env.used.secrets,`secrets`))},[`handler`,`P"/!`])},docs:T(async function(){this.debug(`Documenting environment variables configuration values in "${(0,m.joinPaths)((0,f.getDocsOutputPath)(this.config.root),`env.md`)}"`);let e=await r.readEnvTypeReflection(this,`env`);return(0,g.render)(this,(0,p.createComponent)(o.EnvDocsFile,{levelOffset:0,reflection:e}))},[`docs`,`P"/!`]),buildEnd:T(async function(){let e=r.getEnvReflectionsPath(this,`env`);this.debug(`Writing env reflection types to ${e}.`),await r.writeEnvReflection(this,this.env.used.env,`env`)},[`buildEnd`,`P"/!`])},{name:`env:automd-generator`,config:T(function(){return{automd:(0,u.default)(e.automd??{},{generators:{env:a.env(this)}})}},[`config`,`P"/!`])},{name:`env:vite`,vite:{configResolved:T(function(){return{envPrefix:this.config?.env?.prefix}},[()=>t.__ΩEnvPluginContext,`this`,`configResolved`,`Pn!2""/#`])}},(0,_.default)(e.automd)],[()=>t.__ΩEnvPluginOptions,`options`,()=>({}),``,`Pn!2">#"/$`]);exports.default=E,exports.plugin=E;
|