@powerlines/plugin-env 0.16.115 → 0.16.116
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/components/docs.cjs +1 -1
- package/dist/components/docs.mjs +1 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +3 -2
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts.map +1 -1
- package/dist/components/env-builtin.mjs +3 -2
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/load.d.cts +20 -1
- package/dist/helpers/load.d.cts.map +1 -1
- package/dist/helpers/load.d.mts +20 -1
- package/dist/helpers/load.d.mts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/runtime.d.cts +141 -0
- package/dist/types/runtime.d.cts.map +1 -1
- package/dist/types/runtime.d.mts +141 -0
- package/dist/types/runtime.d.mts.map +1 -1
- package/dist/types/runtime.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.cjs +0 -14
- package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs +0 -14
- package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs.map +0 -1
package/dist/components/docs.cjs
CHANGED
|
@@ -52,7 +52,7 @@ function EnvDocsFile(props) {
|
|
|
52
52
|
_alloy_js_core.code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`,
|
|
53
53
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
54
54
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
|
|
55
|
-
return reflection?.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
55
|
+
return reflection?.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__" && !property.isHidden()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
56
56
|
return {
|
|
57
57
|
name: reflectionProperty.getNameAsString().trim(),
|
|
58
58
|
description: (reflectionProperty.getDescription() ?? "").trim(),
|
package/dist/components/docs.mjs
CHANGED
|
@@ -50,7 +50,7 @@ function EnvDocsFile(props) {
|
|
|
50
50
|
code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`,
|
|
51
51
|
createComponent(Spacing, {}),
|
|
52
52
|
createComponent(MarkdownTable, { get data() {
|
|
53
|
-
return reflection?.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
53
|
+
return reflection?.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__" && !property.isHidden()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
54
54
|
return {
|
|
55
55
|
name: reflectionProperty.getNameAsString().trim(),
|
|
56
56
|
description: (reflectionProperty.getDescription() ?? "").trim(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.mjs","names":[],"sources":["../../src/components/docs.tsx"],"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 { code, Show } from \"@alloy-js/core\";\nimport { Heading, Link } from \"@alloy-js/markdown\";\nimport {\n ReflectionClass,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n MarkdownFile,\n MarkdownFileProps\n} from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownTable } from \"@powerlines/plugin-alloy/markdown/components/markdown-table\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { getDocsOutputPath } from \"../helpers/docs-helper\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\nexport interface EnvDocsFileProps extends Partial<MarkdownFileProps> {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n reflection: ReflectionClass<any>;\n}\n\n/**\n * Generates the environment configuration markdown documentation for the Powerlines project.\n */\nexport function EnvDocsFile(props: EnvDocsFileProps) {\n const { levelOffset = 0, reflection, ...rest } = props;\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context), \"env.md\")}\n {...rest}>\n <Heading level={1 + levelOffset}>Environment Configuration</Heading>\n {code`Below is a list of environment variables used by the`}\n <Show when={!!context.packageJson.name}>\n <Link\n href={`https://www.npmjs.com/package/${context.packageJson.name}`}\n title={context.packageJson.name!}\n />\n </Show>\n {code`package. These values can be updated in the \\`.env\\` file in the root of the project.`}\n <Spacing />\n <Heading level={2 + levelOffset}>Environment Variables</Heading>\n <Spacing />\n {code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`}\n <Spacing />\n <MarkdownTable\n data={\n reflection\n ?.getProperties()\n .filter(\n property =>\n property.getNameAsString() !== \"__POWERLINES_INJECTED__\"\n )\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n )\n .map(reflectionProperty => {\n return {\n name: reflectionProperty.getNameAsString().trim(),\n description: (reflectionProperty.getDescription() ?? \"\").trim(),\n type: stringifyType(reflectionProperty.getType())\n .trim()\n .replaceAll(\" | \", \", or \"),\n defaultValue: reflectionProperty.hasDefault()\n ? String(reflectionProperty.getDefaultValue())?.includes('\"')\n ? reflectionProperty.getDefaultValue()\n : `\\`${reflectionProperty.getDefaultValue()}\\``\n : \"\",\n required: reflectionProperty.isValueRequired() ? \"\" : \"✔\"\n };\n }) ?? []\n }\n />\n </MarkdownFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;CA8CE,MAAA,EACF,cAAA,eAEE,GAAA,SACC;CACD,MAAA,UAAA,eAAA;AACF,QAAO,gBAAoB,cAAQ,WAAkB,EACnD,IAAM,OAAE;;cAIR,IAAM,WAAC;AACJ,SAAA;GAAA,gBAAA,SAAA;IACC,OAAM,IAAA;IACJ,UAAO;IACR,CAAA;GAAA,IAAO;GAAoD,gBAAO,MAAA;IAClE,IAAK,OAAM;AACX,YAAU,CAAC,CAAC,QAAQ,YAAY;;IAE/B,IAAE,WAAa;AACb,YAAO,gBAAQ,MAAgB;MAChC,IAAA,OAAA;AACG,cAAA,iCAAA,QAAA,YAAA;;MAEL,IAAS,QAAA;AACF,cAAO,QAAK,YAAa;;MAE5B,CAAC;;IAEL,CAAA;GAAA,IAAA;GAAA,gBAAA,SAAA,EAAA,CAAA;GAAA,gBAAA,SAAA;IACC,OAAK,IAAA;IACL,UAAE;IACH,CAAC;GAAE,gBAAkB,SAAA,EAAA,CAAA;GAAA,IAAA;GAAA,gBAAA,SAAA,EAAA,CAAA;GAAA,gBAAA,eAAA,EACpB,IAAI,OAAO;AACT,WAAI,YAAU,eAAA,CAAA,QAAA,aAAA,SAAA,iBAAA,KAAA,
|
|
1
|
+
{"version":3,"file":"docs.mjs","names":[],"sources":["../../src/components/docs.tsx"],"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 { code, Show } from \"@alloy-js/core\";\nimport { Heading, Link } from \"@alloy-js/markdown\";\nimport {\n ReflectionClass,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n MarkdownFile,\n MarkdownFileProps\n} from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownTable } from \"@powerlines/plugin-alloy/markdown/components/markdown-table\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { getDocsOutputPath } from \"../helpers/docs-helper\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\nexport interface EnvDocsFileProps extends Partial<MarkdownFileProps> {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n reflection: ReflectionClass<any>;\n}\n\n/**\n * Generates the environment configuration markdown documentation for the Powerlines project.\n */\nexport function EnvDocsFile(props: EnvDocsFileProps) {\n const { levelOffset = 0, reflection, ...rest } = props;\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context), \"env.md\")}\n {...rest}>\n <Heading level={1 + levelOffset}>Environment Configuration</Heading>\n {code`Below is a list of environment variables used by the`}\n <Show when={!!context.packageJson.name}>\n <Link\n href={`https://www.npmjs.com/package/${context.packageJson.name}`}\n title={context.packageJson.name!}\n />\n </Show>\n {code`package. These values can be updated in the \\`.env\\` file in the root of the project.`}\n <Spacing />\n <Heading level={2 + levelOffset}>Environment Variables</Heading>\n <Spacing />\n {code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`}\n <Spacing />\n <MarkdownTable\n data={\n reflection\n ?.getProperties()\n .filter(\n property =>\n property.getNameAsString() !== \"__POWERLINES_INJECTED__\" &&\n !property.isHidden()\n )\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n )\n .map(reflectionProperty => {\n return {\n name: reflectionProperty.getNameAsString().trim(),\n description: (reflectionProperty.getDescription() ?? \"\").trim(),\n type: stringifyType(reflectionProperty.getType())\n .trim()\n .replaceAll(\" | \", \", or \"),\n defaultValue: reflectionProperty.hasDefault()\n ? String(reflectionProperty.getDefaultValue())?.includes('\"')\n ? reflectionProperty.getDefaultValue()\n : `\\`${reflectionProperty.getDefaultValue()}\\``\n : \"\",\n required: reflectionProperty.isValueRequired() ? \"\" : \"✔\"\n };\n }) ?? []\n }\n />\n </MarkdownFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;CA8CE,MAAA,EACF,cAAA,eAEE,GAAA,SACC;CACD,MAAA,UAAA,eAAA;AACF,QAAO,gBAAoB,cAAQ,WAAkB,EACnD,IAAM,OAAE;;cAIR,IAAM,WAAC;AACJ,SAAA;GAAA,gBAAA,SAAA;IACC,OAAM,IAAA;IACJ,UAAO;IACR,CAAA;GAAA,IAAO;GAAoD,gBAAO,MAAA;IAClE,IAAK,OAAM;AACX,YAAU,CAAC,CAAC,QAAQ,YAAY;;IAE/B,IAAE,WAAa;AACb,YAAO,gBAAQ,MAAgB;MAChC,IAAA,OAAA;AACG,cAAA,iCAAA,QAAA,YAAA;;MAEL,IAAS,QAAA;AACF,cAAO,QAAK,YAAa;;MAE5B,CAAC;;IAEL,CAAA;GAAA,IAAA;GAAA,gBAAA,SAAA,EAAA,CAAA;GAAA,gBAAA,SAAA;IACC,OAAK,IAAA;IACL,UAAE;IACH,CAAC;GAAE,gBAAkB,SAAA,EAAA,CAAA;GAAA,IAAA;GAAA,gBAAA,SAAA,EAAA,CAAA;GAAA,gBAAA,eAAA,EACpB,IAAI,OAAO;AACT,WAAI,YAAU,eAAA,CAAA,QAAA,aAAA,SAAA,iBAAA,KAAA,6BAAA,CAAA,SAAA,UAAA,CAAA,CAAA,MAAA,GAAA,MAAA,EAAA,iBAAA,CAAA,cAAA,EAAA,iBAAA,CAAA,CAAA,CAAA,KAAA,uBAAA;AACZ,YAAI;MACF,MAAG,mBAAkB,iBAAA,CAAA,MAAA;MACvB,cAAA,mBAAA,gBAAA,IAAA,IAAA,MAAA;MACC,MAAO,cAAM,mBAAA,SAAA,CAAA,CAAA,MAAA,CAAA,WAAA,OAAA,QAAA;MACZ,cAAE,mBAA+B,YAAG,GAAA,OAAiB,mBAAA,iBAAA,CAAA,EAAA,SAAA,KAAA,GAAA,mBAAA,iBAAA,GAAA,KAAA,mBAAA,iBAAA,CAAA,MAAA;MACvD,UAAA,mBAAA,iBAAA,GAAA,KAAA;MACC;MACD,IAAE,EAAA;MAEP,CAAC;GAAC;IAEN,CAAC,CAAC"}
|
|
@@ -15,6 +15,7 @@ let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powe
|
|
|
15
15
|
let _powerlines_plugin_alloy_typescript_components_interface_declaration = require("@powerlines/plugin-alloy/typescript/components/interface-declaration");
|
|
16
16
|
let _powerlines_plugin_alloy_typescript_components_object_declaration = require("@powerlines/plugin-alloy/typescript/components/object-declaration");
|
|
17
17
|
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
18
|
+
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
18
19
|
|
|
19
20
|
//#region src/components/env-builtin.tsx
|
|
20
21
|
/**
|
|
@@ -42,7 +43,7 @@ function EnvTypeDefinition(props) {
|
|
|
42
43
|
"export": true,
|
|
43
44
|
get children() {
|
|
44
45
|
return _alloy_js_core.code` {
|
|
45
|
-
[Key in keyof EnvBase as Key ${context.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
46
|
+
[Key in keyof EnvBase as Key ${(0, _stryke_helpers_get_unique.getUnique)(context.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``)).join(" ")}]: EnvBase[Key];
|
|
46
47
|
}
|
|
47
48
|
`;
|
|
48
49
|
}
|
|
@@ -52,7 +53,7 @@ function EnvTypeDefinition(props) {
|
|
|
52
53
|
}
|
|
53
54
|
function ConfigPropertyConditional(props) {
|
|
54
55
|
const [{ context, name }] = (0, _alloy_js_core.splitProps)(props, ["context", "name"]);
|
|
55
|
-
return _alloy_js_core.code`propertyName === "${name}" || propertyName.replace(/^(${context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
|
|
56
|
+
return _alloy_js_core.code`propertyName === "${name}" || propertyName.replace(/^(${(0, _stryke_helpers_get_unique.getUnique)(context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`)).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
|
|
56
57
|
}
|
|
57
58
|
function ConfigPropertyGet(props) {
|
|
58
59
|
const [{ context, property, index }] = (0, _alloy_js_core.splitProps)(props, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-builtin.d.cts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"env-builtin.d.cts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;;;;;AAsEA;iBAAgB,iBAAA,CACd,KAAA,EAAO,IAAA,CAAK,yBAAA,YAAkC,QAAA;AAAA,UAqL/B,eAAA,SAAwB,IAAA,CAAK,gBAAA;EAC5C,aAAA,GAAgB,QAAA;EAChB,UAAA,EAAY,eAAA;AAAA;;;;iBAUE,UAAA,CAAW,KAAA,EAAO,eAAA,GAAe,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-builtin.d.mts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"env-builtin.d.mts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;;;;;AAsEA;iBAAgB,iBAAA,CACd,KAAA,EAAO,IAAA,CAAK,yBAAA,YAAkC,QAAA;AAAA,UAqL/B,eAAA,SAAwB,IAAA,CAAK,gBAAA;EAC5C,aAAA,GAAgB,QAAA;EAChB,UAAA,EAAY,eAAA;AAAA;;;;iBAUE,UAAA,CAAW,KAAA,EAAO,eAAA,GAAe,QAAA"}
|
|
@@ -12,6 +12,7 @@ import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/buil
|
|
|
12
12
|
import { InterfaceDeclaration } from "@powerlines/plugin-alloy/typescript/components/interface-declaration";
|
|
13
13
|
import { ObjectDeclaration } from "@powerlines/plugin-alloy/typescript/components/object-declaration";
|
|
14
14
|
import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
15
|
+
import { getUnique } from "@stryke/helpers/get-unique";
|
|
15
16
|
|
|
16
17
|
//#region src/components/env-builtin.tsx
|
|
17
18
|
/**
|
|
@@ -39,7 +40,7 @@ function EnvTypeDefinition(props) {
|
|
|
39
40
|
"export": true,
|
|
40
41
|
get children() {
|
|
41
42
|
return code` {
|
|
42
|
-
[Key in keyof EnvBase as Key ${context.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
43
|
+
[Key in keyof EnvBase as Key ${getUnique(context.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``)).join(" ")}]: EnvBase[Key];
|
|
43
44
|
}
|
|
44
45
|
`;
|
|
45
46
|
}
|
|
@@ -49,7 +50,7 @@ function EnvTypeDefinition(props) {
|
|
|
49
50
|
}
|
|
50
51
|
function ConfigPropertyConditional(props) {
|
|
51
52
|
const [{ context, name }] = splitProps(props, ["context", "name"]);
|
|
52
|
-
return code`propertyName === "${name}" || propertyName.replace(/^(${context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
|
|
53
|
+
return code`propertyName === "${name}" || propertyName.replace(/^(${getUnique(context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`)).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
|
|
53
54
|
}
|
|
54
55
|
function ConfigPropertyGet(props) {
|
|
55
56
|
const [{ context, property, index }] = splitProps(props, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-builtin.mjs","names":[],"sources":["../../src/components/env-builtin.tsx"],"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 {\n Children,\n code,\n computed,\n For,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n ClassDeclaration,\n ClassMethod,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n NewExpression,\n TypeDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport {\n ReflectionClass,\n ReflectionKind,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { InterfaceDeclarationProps } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { InterfaceDeclaration } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { ObjectDeclaration } from \"@powerlines/plugin-alloy/typescript/components/object-declaration\";\nimport {\n TSDoc,\n TSDocExample,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns,\n TSDocThrows\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport defu from \"defu\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition(\n props: Omit<InterfaceDeclarationProps, \"name\">\n) {\n const [{ defaultValue, reflection }] = splitProps(props, [\n \"defaultValue\",\n \"reflection\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\" EnvBase\"\n defaultValue={defaultValue}\n reflection={reflection}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`EnvBase\\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.`}\n </TSDocRemarks>\n </TSDoc>\n <TypeDeclaration name=\"Env\" export>\n {code` {\n [Key in keyof EnvBase as Key ${context.config.env.prefix\n .map(prefix => `| \\`${prefix.replace(/_$/g, \"\")}_\\${Key}\\``)\n .join(\" \")}]: EnvBase[Key];\n}\n`}\n </TypeDeclaration>\n <Spacing />\n </>\n );\n}\n\ninterface ConfigPropertyConditionalProps extends ComponentProps {\n context: EnvPluginContext;\n name: string;\n}\n\nfunction ConfigPropertyConditional(props: ConfigPropertyConditionalProps) {\n const [{ context, name }] = splitProps(props, [\"context\", \"name\"]);\n\n return code`propertyName === \"${name}\" || propertyName.replace(/^(${context.config.env.prefix\n .sort((a, b) =>\n a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)\n )\n .map(prefix => `${prefix.replace(/_$/, \"\")}_`)\n .join(\"|\")})/g, \"\").toLowerCase().replace(/[\\\\s\\\\-_]+/g, \"\") === \"${name\n .toLowerCase()\n .replace(/[\\s\\-_]+/g, \"\")}\"`;\n}\n\ninterface ConfigPropertyProps extends ComponentProps {\n index: number;\n context: EnvPluginContext;\n property: ReflectionProperty;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n reflection: ReflectionClass<any>;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\nconst envSerializerRefkey = refkey(\"EnvSerializer\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, reflection, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"reflection\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const envInstance = computed(() => {\n const result = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n description: `The initial environment configuration state for the ${titleCase(\n context?.config?.name\n )} project.`,\n types: []\n },\n reflection\n );\n\n result\n .getProperties()\n .filter(\n property => property.isRuntime() || property.getTags().runtime === true\n )\n .forEach(property => {\n result.removeProperty(property.getNameAsString());\n });\n\n return result;\n });\n\n const reflectionGetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n const reflectionSetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored() && !property.isReadonly())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n\n return (\n <BuiltinFile\n id=\"env\"\n description=\"The environment configuration module provides an interface to define environment configuration parameters.\"\n {...rest}\n imports={defu(\n {\n \"@powerlines/deepkit/vendor/type\": [\n \"serializeFunction\",\n \"deserializeFunction\",\n \"ReflectionKind\",\n \"Serializer\",\n \"TemplateState\",\n \"Type\",\n \"TypeProperty\",\n \"TypePropertySignature\"\n ]\n },\n rest.imports ?? {}\n )}>\n <Show when={Boolean(reflection)}>\n <EnvTypeDefinition\n defaultValue={defaultValue}\n reflection={reflection}\n />\n <hbr />\n <hbr />\n </Show>\n\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<EnvBase>\"\n defaultValue={defaultValue}\n reflection={envInstance}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\n\n <TSDoc heading=\"The environment configuration serializer for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <ClassDeclaration\n refkey={envSerializerRefkey}\n name=\"EnvSerializer\"\n extends=\"Serializer\"\n export>\n <ClassMethod\n name=\"constructor\"\n public\n doc=\"Initializes a new instance of the `EnvSerializer` class.\">\n {code`super(\"env\");\n\n this.deserializeRegistry.register(\n ReflectionKind.boolean,\n (type: Type, state: TemplateState) => {\n state.addSetter(\n \\`typeof \\${state.accessor.toString()} !== \"boolean\" ? \\${state.accessor.toString()} === 1 || \\${state.accessor.toString()} === \"1\" || \\${state.accessor.toString()}.toLowerCase() === \"t\" || \\${state.accessor.toString()}.toLowerCase() === \"true\" || \\${state.accessor.toString()}.toLowerCase() === \"y\" || \\${state.accessor.toString()}.toLowerCase() === \"yes\" : \\${state.accessor.toString()}\\`\n );\n }\n ); `}\n </ClassMethod>\n </ClassDeclaration>\n <Spacing />\n\n <TSDoc heading=\"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n name=\"envSerializer\"\n export={false}\n const\n initializer={<NewExpression args={[]} target=\"EnvSerializer\" />}\n />\n <Spacing />\n\n <TSDoc heading=\"Serialize a environment configuration object to JSON data objects (not a JSON string).\">\n <TSDocRemarks>\n {`The resulting JSON object can be stringified using \\`JSON.stringify()\\`.`}\n </TSDocRemarks>\n <TSDocExample>{`const json = serializeEnv(env);`}</TSDocExample>\n <TSDocThrows>\n {`ValidationError when serialization or validation fails.`}\n </TSDocThrows>\n </TSDoc>\n <VarDeclaration\n name=\"serializeEnv\"\n export\n const\n initializer={\"serializeFunction<EnvBase>(envSerializer)\"}\n />\n <Spacing />\n\n <TSDoc heading=\"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.\">\n <TSDocRemarks>\n {`Types that are already correct will be used as-is.`}\n </TSDocRemarks>\n <TSDocExample>{`const env = deserializeEnv(json);`}</TSDocExample>\n <TSDocThrows>\n {`ValidationError when deserialization fails.`}\n </TSDocThrows>\n </TSDoc>\n <VarDeclaration\n name=\"deserializeEnv\"\n export\n const\n initializer=\"deserializeFunction<EnvBase>(envSerializer)\"\n />\n <Spacing />\n\n <TSDoc heading=\"Initializes the Powerlines environment configuration module.\">\n <TSDocRemarks>\n {`This function initializes the Powerlines environment configuration object.`}\n </TSDocRemarks>\n <TSDocParam name=\"environmentConfig\">\n {`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}\n </TSDocParam>\n <TSDocReturns>\n {`The initialized Powerlines configuration object.`}\n </TSDocReturns>\n </TSDoc>\n <Show when={Boolean(context?.entryPath)}>\n <FunctionDeclaration\n refkey={createEnvRefkey}\n async={false}\n export\n name=\"createEnv\"\n parameters={[\n {\n name: \"environmentConfig\",\n type: `Partial<Env>`,\n optional: false,\n default: \"{}\"\n }\n ]}\n returnType=\"Env\">\n {code`\n return new Proxy<Env>(\n deserializeEnv({\n ...initialEnv,\n ...environmentConfig\n }) as Env,\n {\n get: (target: EnvBase, propertyName: string) => { `}\n <hbr />\n\n <For each={reflectionGetProperties}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: EnvBase, propertyName: string, newValue: any) => { `}\n <hbr />\n\n <For each={reflectionSetProperties} ender={code` else `}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n\n <hbr />\n {code`return false;\n }\n }\n );\n`}\n </FunctionDeclaration>\n </Show>\n <Spacing />\n <hbr />\n\n <TSDoc heading=\"The environment configuration object.\">\n <TSDocRemarks>\n {`This object provides access to the environment configuration parameters in the application runtime.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n refkey={envRefkey}\n name=\"env\"\n type=\"Env\"\n export\n const\n initializer={\n <>{code`createEnv(${defaultConfig || \"{}\"} as Partial<Env>);`}</>\n }\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isCI\"\n doc=\"Detect if the application is running in a continuous integration (CI) environment.\"\n initializer={code`Boolean(\n env.CI ||\n env.RUN_ID ||\n env.AGOLA_GIT_REF ||\n env.AC_APPCIRCLE ||\n env.APPVEYOR ||\n env.CODEBUILD ||\n env.TF_BUILD ||\n env.bamboo_planKey ||\n env.BITBUCKET_COMMIT ||\n env.BITRISE_IO ||\n env.BUDDY_WORKSPACE_ID ||\n env.BUILDKITE ||\n env.CIRCLECI ||\n env.CIRRUS_CI ||\n env.CF_BUILD_ID ||\n env.CM_BUILD_ID ||\n env.CI_NAME ||\n env.DRONE ||\n env.DSARI ||\n env.EARTHLY_CI ||\n env.EAS_BUILD ||\n env.GERRIT_PROJECT ||\n env.GITEA_ACTIONS ||\n env.GITHUB_ACTIONS ||\n env.GITLAB_CI ||\n env.GOCD ||\n env.BUILDER_OUTPUT ||\n env.HARNESS_BUILD_ID ||\n env.JENKINS_URL ||\n env.LAYERCI ||\n env.MAGNUM ||\n env.NETLIFY ||\n env.NEVERCODE ||\n env.PROW_JOB_ID ||\n env.RELEASE_BUILD_ID ||\n env.RENDER ||\n env.SAILCI ||\n env.HUDSON ||\n env.SCREWDRIVER ||\n env.SEMAPHORE ||\n env.SOURCEHUT ||\n env.STRIDER ||\n env.TASK_ID ||\n env.RUN_ID ||\n env.TEAMCITY_VERSION ||\n env.TRAVIS ||\n env.VELA ||\n env.NOW_BUILDER ||\n env.APPCENTER_BUILD_ID ||\n env.CI_XCODE_PROJECT ||\n env.XCS || false\n );\n `}\n />\n <Spacing />\n\n <TSDoc heading=\"Detect the \\`mode\\` of the current runtime environment.\">\n <TSDocRemarks>\n {code`The \\`mode\\` is determined by the \\`MODE\\` environment variable, or falls back to the \\`NEXT_PUBLIC_VERCEL_ENV\\`, \\`NODE_ENV\\`, or defaults to \\`production\\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:\n - \\`production\\`\n - \\`test\\`\n - \\`development\\`\n `}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n export\n const\n name=\"mode\"\n initializer={code`String(env.MODE) || \"production\"; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isProduction\"\n doc='Detect if the application is running in `\"production\"` mode'\n initializer={code`[\"prd\", \"prod\", \"production\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isTest\"\n doc='Detect if the application is running in `\"test\"` mode'\n initializer={code`[\"tst\", \"test\", \"testing\", \"stg\", \"stage\", \"staging\"].includes(mode.toLowerCase()) || env.TEST; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDevelopment\"\n doc='Detect if the application is running in `\"development\"` mode'\n initializer={code`[\"dev\", \"development\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDebug\"\n doc=\"Detect if the application is currently being debugged\"\n initializer={code`Boolean(isDevelopment && env.DEBUG); `}\n />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,SAAE,kBAAA,OAAA;CACA,M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MAAE;KACF,KAAC;KACD,aAAQ,IAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDjB,CAAC;IAAE,gBAAK,SAAA,EAAA,CAAA;IAAA,gBAAA,OAAA;KACP,SAAK;KACL,IAAI,WAAG;6CAEJ,UAAK,IAAA;;;;aAKf,CAAA;;KAEM,CAAC;IAAA,gBAAI,gBAAA;KACL,UAAS;KACT,SAAK;;KAEL,aAAc,IAAI;KAClB,CAAC;IAAC,gBAAY,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACb,UAAS;KACT,SAAE;KACF,MAAK;KACN,KAAA;KACC,aAAQ,IAAS;KAClB,CAAC;IAAA,gBAAS,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACT,UAAS;KACT,SAAA;KACA,MAAA;KACA,KAAA;KACA,aAAU,IAAA;KACX,CAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACD,UAAA;KACA,SAAS;;KAET,KAAA;KACC,aAAA,IAAA;KACD,CAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACA,UAAU;KACV,SAAK;KACL,MAAA;KACA,KAAK;KACL,aAAa,IAAC;KACf,CAAC;IAAE,gBAAkB,SAAC,EAAA,CAAA;IAAA,gBAAA,MAAA;KACrB,IAAE,OAAI;AACJ,aAAI,QAAU,SAAA;;KAEV;KACP,CAAC;IAAC;;EAEN,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"env-builtin.mjs","names":[],"sources":["../../src/components/env-builtin.tsx"],"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 {\n Children,\n code,\n computed,\n For,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n ClassDeclaration,\n ClassMethod,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n NewExpression,\n TypeDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport {\n ReflectionClass,\n ReflectionKind,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { InterfaceDeclarationProps } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { InterfaceDeclaration } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { ObjectDeclaration } from \"@powerlines/plugin-alloy/typescript/components/object-declaration\";\nimport {\n TSDoc,\n TSDocExample,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns,\n TSDocThrows\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport defu from \"defu\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition(\n props: Omit<InterfaceDeclarationProps, \"name\">\n) {\n const [{ defaultValue, reflection }] = splitProps(props, [\n \"defaultValue\",\n \"reflection\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\" EnvBase\"\n defaultValue={defaultValue}\n reflection={reflection}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`EnvBase\\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.`}\n </TSDocRemarks>\n </TSDoc>\n <TypeDeclaration name=\"Env\" export>\n {code` {\n [Key in keyof EnvBase as Key ${getUnique(\n context.config.env.prefix.map(\n prefix => `| \\`${prefix.replace(/_$/g, \"\")}_\\${Key}\\``\n )\n ).join(\" \")}]: EnvBase[Key];\n}\n`}\n </TypeDeclaration>\n <Spacing />\n </>\n );\n}\n\ninterface ConfigPropertyConditionalProps extends ComponentProps {\n context: EnvPluginContext;\n name: string;\n}\n\nfunction ConfigPropertyConditional(props: ConfigPropertyConditionalProps) {\n const [{ context, name }] = splitProps(props, [\"context\", \"name\"]);\n\n return code`propertyName === \"${name}\" || propertyName.replace(/^(${getUnique(\n context.config.env.prefix\n .sort((a, b) =>\n a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)\n )\n .map(prefix => `${prefix.replace(/_$/, \"\")}_`)\n ).join(\"|\")})/g, \"\").toLowerCase().replace(/[\\\\s\\\\-_]+/g, \"\") === \"${name\n .toLowerCase()\n .replace(/[\\s\\-_]+/g, \"\")}\"`;\n}\n\ninterface ConfigPropertyProps extends ComponentProps {\n index: number;\n context: EnvPluginContext;\n property: ReflectionProperty;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n reflection: ReflectionClass<any>;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\nconst envSerializerRefkey = refkey(\"EnvSerializer\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, reflection, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"reflection\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const envInstance = computed(() => {\n const result = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n description: `The initial environment configuration state for the ${titleCase(\n context?.config?.name\n )} project.`,\n types: []\n },\n reflection\n );\n\n result\n .getProperties()\n .filter(\n property => property.isRuntime() || property.getTags().runtime === true\n )\n .forEach(property => {\n result.removeProperty(property.getNameAsString());\n });\n\n return result;\n });\n\n const reflectionGetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n const reflectionSetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored() && !property.isReadonly())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n\n return (\n <BuiltinFile\n id=\"env\"\n description=\"The environment configuration module provides an interface to define environment configuration parameters.\"\n {...rest}\n imports={defu(\n {\n \"@powerlines/deepkit/vendor/type\": [\n \"serializeFunction\",\n \"deserializeFunction\",\n \"ReflectionKind\",\n \"Serializer\",\n \"TemplateState\",\n \"Type\",\n \"TypeProperty\",\n \"TypePropertySignature\"\n ]\n },\n rest.imports ?? {}\n )}>\n <Show when={Boolean(reflection)}>\n <EnvTypeDefinition\n defaultValue={defaultValue}\n reflection={reflection}\n />\n <hbr />\n <hbr />\n </Show>\n\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<EnvBase>\"\n defaultValue={defaultValue}\n reflection={envInstance}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\n\n <TSDoc heading=\"The environment configuration serializer for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <ClassDeclaration\n refkey={envSerializerRefkey}\n name=\"EnvSerializer\"\n extends=\"Serializer\"\n export>\n <ClassMethod\n name=\"constructor\"\n public\n doc=\"Initializes a new instance of the `EnvSerializer` class.\">\n {code`super(\"env\");\n\n this.deserializeRegistry.register(\n ReflectionKind.boolean,\n (type: Type, state: TemplateState) => {\n state.addSetter(\n \\`typeof \\${state.accessor.toString()} !== \"boolean\" ? \\${state.accessor.toString()} === 1 || \\${state.accessor.toString()} === \"1\" || \\${state.accessor.toString()}.toLowerCase() === \"t\" || \\${state.accessor.toString()}.toLowerCase() === \"true\" || \\${state.accessor.toString()}.toLowerCase() === \"y\" || \\${state.accessor.toString()}.toLowerCase() === \"yes\" : \\${state.accessor.toString()}\\`\n );\n }\n ); `}\n </ClassMethod>\n </ClassDeclaration>\n <Spacing />\n\n <TSDoc heading=\"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n name=\"envSerializer\"\n export={false}\n const\n initializer={<NewExpression args={[]} target=\"EnvSerializer\" />}\n />\n <Spacing />\n\n <TSDoc heading=\"Serialize a environment configuration object to JSON data objects (not a JSON string).\">\n <TSDocRemarks>\n {`The resulting JSON object can be stringified using \\`JSON.stringify()\\`.`}\n </TSDocRemarks>\n <TSDocExample>{`const json = serializeEnv(env);`}</TSDocExample>\n <TSDocThrows>\n {`ValidationError when serialization or validation fails.`}\n </TSDocThrows>\n </TSDoc>\n <VarDeclaration\n name=\"serializeEnv\"\n export\n const\n initializer={\"serializeFunction<EnvBase>(envSerializer)\"}\n />\n <Spacing />\n\n <TSDoc heading=\"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.\">\n <TSDocRemarks>\n {`Types that are already correct will be used as-is.`}\n </TSDocRemarks>\n <TSDocExample>{`const env = deserializeEnv(json);`}</TSDocExample>\n <TSDocThrows>\n {`ValidationError when deserialization fails.`}\n </TSDocThrows>\n </TSDoc>\n <VarDeclaration\n name=\"deserializeEnv\"\n export\n const\n initializer=\"deserializeFunction<EnvBase>(envSerializer)\"\n />\n <Spacing />\n\n <TSDoc heading=\"Initializes the Powerlines environment configuration module.\">\n <TSDocRemarks>\n {`This function initializes the Powerlines environment configuration object.`}\n </TSDocRemarks>\n <TSDocParam name=\"environmentConfig\">\n {`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}\n </TSDocParam>\n <TSDocReturns>\n {`The initialized Powerlines configuration object.`}\n </TSDocReturns>\n </TSDoc>\n <Show when={Boolean(context?.entryPath)}>\n <FunctionDeclaration\n refkey={createEnvRefkey}\n async={false}\n export\n name=\"createEnv\"\n parameters={[\n {\n name: \"environmentConfig\",\n type: `Partial<Env>`,\n optional: false,\n default: \"{}\"\n }\n ]}\n returnType=\"Env\">\n {code`\n return new Proxy<Env>(\n deserializeEnv({\n ...initialEnv,\n ...environmentConfig\n }) as Env,\n {\n get: (target: EnvBase, propertyName: string) => { `}\n <hbr />\n\n <For each={reflectionGetProperties}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: EnvBase, propertyName: string, newValue: any) => { `}\n <hbr />\n\n <For each={reflectionSetProperties} ender={code` else `}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n\n <hbr />\n {code`return false;\n }\n }\n );\n`}\n </FunctionDeclaration>\n </Show>\n <Spacing />\n <hbr />\n\n <TSDoc heading=\"The environment configuration object.\">\n <TSDocRemarks>\n {`This object provides access to the environment configuration parameters in the application runtime.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n refkey={envRefkey}\n name=\"env\"\n type=\"Env\"\n export\n const\n initializer={\n <>{code`createEnv(${defaultConfig || \"{}\"} as Partial<Env>);`}</>\n }\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isCI\"\n doc=\"Detect if the application is running in a continuous integration (CI) environment.\"\n initializer={code`Boolean(\n env.CI ||\n env.RUN_ID ||\n env.AGOLA_GIT_REF ||\n env.AC_APPCIRCLE ||\n env.APPVEYOR ||\n env.CODEBUILD ||\n env.TF_BUILD ||\n env.bamboo_planKey ||\n env.BITBUCKET_COMMIT ||\n env.BITRISE_IO ||\n env.BUDDY_WORKSPACE_ID ||\n env.BUILDKITE ||\n env.CIRCLECI ||\n env.CIRRUS_CI ||\n env.CF_BUILD_ID ||\n env.CM_BUILD_ID ||\n env.CI_NAME ||\n env.DRONE ||\n env.DSARI ||\n env.EARTHLY_CI ||\n env.EAS_BUILD ||\n env.GERRIT_PROJECT ||\n env.GITEA_ACTIONS ||\n env.GITHUB_ACTIONS ||\n env.GITLAB_CI ||\n env.GOCD ||\n env.BUILDER_OUTPUT ||\n env.HARNESS_BUILD_ID ||\n env.JENKINS_URL ||\n env.LAYERCI ||\n env.MAGNUM ||\n env.NETLIFY ||\n env.NEVERCODE ||\n env.PROW_JOB_ID ||\n env.RELEASE_BUILD_ID ||\n env.RENDER ||\n env.SAILCI ||\n env.HUDSON ||\n env.SCREWDRIVER ||\n env.SEMAPHORE ||\n env.SOURCEHUT ||\n env.STRIDER ||\n env.TASK_ID ||\n env.RUN_ID ||\n env.TEAMCITY_VERSION ||\n env.TRAVIS ||\n env.VELA ||\n env.NOW_BUILDER ||\n env.APPCENTER_BUILD_ID ||\n env.CI_XCODE_PROJECT ||\n env.XCS || false\n );\n `}\n />\n <Spacing />\n\n <TSDoc heading=\"Detect the \\`mode\\` of the current runtime environment.\">\n <TSDocRemarks>\n {code`The \\`mode\\` is determined by the \\`MODE\\` environment variable, or falls back to the \\`NEXT_PUBLIC_VERCEL_ENV\\`, \\`NODE_ENV\\`, or defaults to \\`production\\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:\n - \\`production\\`\n - \\`test\\`\n - \\`development\\`\n `}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n export\n const\n name=\"mode\"\n initializer={code`String(env.MODE) || \"production\"; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isProduction\"\n doc='Detect if the application is running in `\"production\"` mode'\n initializer={code`[\"prd\", \"prod\", \"production\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isTest\"\n doc='Detect if the application is running in `\"test\"` mode'\n initializer={code`[\"tst\", \"test\", \"testing\", \"stg\", \"stage\", \"staging\"].includes(mode.toLowerCase()) || env.TEST; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDevelopment\"\n doc='Detect if the application is running in `\"development\"` mode'\n initializer={code`[\"dev\", \"development\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDebug\"\n doc=\"Detect if the application is currently being debugged\"\n initializer={code`Boolean(isDevelopment && env.DEBUG); `}\n />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,SAAS,kBAAyB,OAAM;CACxC,MAAQ,CAAC,EACT,cACA,gBACO,WAAE,OAAgB,CAAC,gBAAO,aAAkB,CAAK;CACxD,MAAO,UAAA,eAAA;AACL,QAAA;EAAA,gBAAW,sBAAA;GACX,MAAA;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AA,OAAA;KACpB,SAAQ;KACR,IAAI,WAAI;AACN,aAAK,gBAAA,cAAA,EACH,UAAC,IAAA;;;;aAKP,CAAA;;KAEH,CAAA;IAAA,gBAAA,gBAAA;KACF,UAAA;KACO,SAAE;KACF,MAAI;KACL,aAAS,IAAA;KACT,CAAA;IAAG,gBAAE,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;;KAEL,SAAM;KACL,MAAC;KACD,KAAI;KACJ,aAAE,IAAY;KACf,CAAC;IAAA,gBAAK,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACN,UAAA;KACC,SAAQ;KACR,MAAM;KACN,KAAK;KACL,aAAA,IAAA;KACD,CAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACA,UAAA;KACA,SAAS;KACT,MAAA;KACD,KAAA;KACA,aAAS,IAAA;;;;KAET,UAAA;KACC,SAAA;KACA,MAAA;KACA,KAAK;KACL,aAAY,IAAG;KAChB,CAAC;IAAA,gBAAkB,SAAO,EAAA,CAAA;IAAA,gBAAA,MAAA;KACzB,IAAE,OAAQ;AACR,aAAI,QAAQ,SAAA;;KAER;KACP,CAAC;IAAC;;EAEN,CAAC,CAAC"}
|
package/dist/helpers/load.d.cts
CHANGED
|
@@ -9,7 +9,26 @@ import { DotenvParseOutput } from "@stryke/env/types";
|
|
|
9
9
|
* @param parsed - The parsed dotenv configuration.
|
|
10
10
|
* @returns An object containing the dotenv configuration.
|
|
11
11
|
*/
|
|
12
|
-
declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput):
|
|
12
|
+
declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
|
|
13
|
+
APP_NAME: string | undefined;
|
|
14
|
+
APP_VERSION: string | undefined;
|
|
15
|
+
BUILD_ID: string;
|
|
16
|
+
BUILD_TIMESTAMP: string;
|
|
17
|
+
BUILD_CHECKSUM: string;
|
|
18
|
+
RELEASE_ID: string;
|
|
19
|
+
RELEASE_TAG: string;
|
|
20
|
+
DEFAULT_LOCALE: string | undefined;
|
|
21
|
+
DEFAULT_TIMEZONE: string | undefined;
|
|
22
|
+
LOG_LEVEL: "error" | "warn" | "info" | "debug" | null;
|
|
23
|
+
ERROR_URL: string | undefined;
|
|
24
|
+
ORGANIZATION: string | undefined;
|
|
25
|
+
PLATFORM: "node" | "browser" | "neutral";
|
|
26
|
+
MODE: "test" | "development" | "production";
|
|
27
|
+
TEST: boolean;
|
|
28
|
+
DEBUG: boolean;
|
|
29
|
+
STACKTRACE: boolean;
|
|
30
|
+
ENVIRONMENT: string;
|
|
31
|
+
};
|
|
13
32
|
declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
|
|
14
33
|
//#endregion
|
|
15
34
|
export { loadEnv, loadEnvFromContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.cts","names":[],"sources":["../../src/helpers/load.ts"],"mappings":";;;;;;AAgGA;;;;;iBAAgB,kBAAA,CACd,OAAA,EAAS,gBAAA,EACT,MAAA,EAAQ,iBAAA
|
|
1
|
+
{"version":3,"file":"load.d.cts","names":[],"sources":["../../src/helpers/load.ts"],"mappings":";;;;;;AAgGA;;;;;iBAAgB,kBAAA,CACd,OAAA,EAAS,gBAAA,EACT,MAAA,EAAQ,iBAAA;;;;;;;;;;;;;;;;;;;;iBAkDY,OAAA,cACP,iBAAA,GAAoB,iBAAA,CAAA,CACjC,OAAA,EAAS,gBAAA,EAAkB,OAAA,EAAS,gBAAA,GAAmB,OAAA,CAAQ,IAAA"}
|
package/dist/helpers/load.d.mts
CHANGED
|
@@ -9,7 +9,26 @@ import { DotenvParseOutput } from "@stryke/env/types";
|
|
|
9
9
|
* @param parsed - The parsed dotenv configuration.
|
|
10
10
|
* @returns An object containing the dotenv configuration.
|
|
11
11
|
*/
|
|
12
|
-
declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput):
|
|
12
|
+
declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
|
|
13
|
+
APP_NAME: string | undefined;
|
|
14
|
+
APP_VERSION: string | undefined;
|
|
15
|
+
BUILD_ID: string;
|
|
16
|
+
BUILD_TIMESTAMP: string;
|
|
17
|
+
BUILD_CHECKSUM: string;
|
|
18
|
+
RELEASE_ID: string;
|
|
19
|
+
RELEASE_TAG: string;
|
|
20
|
+
DEFAULT_LOCALE: string | undefined;
|
|
21
|
+
DEFAULT_TIMEZONE: string | undefined;
|
|
22
|
+
LOG_LEVEL: "error" | "warn" | "info" | "debug" | null;
|
|
23
|
+
ERROR_URL: string | undefined;
|
|
24
|
+
ORGANIZATION: string | undefined;
|
|
25
|
+
PLATFORM: "node" | "browser" | "neutral";
|
|
26
|
+
MODE: "test" | "development" | "production";
|
|
27
|
+
TEST: boolean;
|
|
28
|
+
DEBUG: boolean;
|
|
29
|
+
STACKTRACE: boolean;
|
|
30
|
+
ENVIRONMENT: string;
|
|
31
|
+
};
|
|
13
32
|
declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
|
|
14
33
|
//#endregion
|
|
15
34
|
export { loadEnv, loadEnvFromContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.mts","names":[],"sources":["../../src/helpers/load.ts"],"mappings":";;;;;;AAgGA;;;;;iBAAgB,kBAAA,CACd,OAAA,EAAS,gBAAA,EACT,MAAA,EAAQ,iBAAA
|
|
1
|
+
{"version":3,"file":"load.d.mts","names":[],"sources":["../../src/helpers/load.ts"],"mappings":";;;;;;AAgGA;;;;;iBAAgB,kBAAA,CACd,OAAA,EAAS,gBAAA,EACT,MAAA,EAAQ,iBAAA;;;;;;;;;;;;;;;;;;;;iBAkDY,OAAA,cACP,iBAAA,GAAoB,iBAAA,CAAA,CACjC,OAAA,EAAS,gBAAA,EAAkB,OAAA,EAAS,gBAAA,GAAmB,OAAA,CAAQ,IAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -8,13 +8,13 @@ const require_helpers_automd_generator = require('./helpers/automd-generator.cjs
|
|
|
8
8
|
const require_components_docs = require('./components/docs.cjs');
|
|
9
9
|
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
10
10
|
const require_babel_plugin = require('./babel/plugin.cjs');
|
|
11
|
-
const require_get_unique = require('./node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.cjs');
|
|
12
11
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
13
12
|
let _stryke_env_types = require("@stryke/env/types");
|
|
14
13
|
let defu = require("defu");
|
|
15
14
|
defu = require_runtime.__toESM(defu);
|
|
16
15
|
let _stryke_path_join = require("@stryke/path/join");
|
|
17
16
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
17
|
+
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
18
18
|
let _powerlines_plugin_alloy = require("@powerlines/plugin-alloy");
|
|
19
19
|
_powerlines_plugin_alloy = require_runtime.__toESM(_powerlines_plugin_alloy);
|
|
20
20
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
@@ -37,7 +37,7 @@ const plugin = (options = {}) => {
|
|
|
37
37
|
(0, _powerlines_plugin_alloy.default)(options.alloy),
|
|
38
38
|
(0, _powerlines_plugin_babel.default)(options.babel),
|
|
39
39
|
{
|
|
40
|
-
name: "env",
|
|
40
|
+
name: "env:core",
|
|
41
41
|
async config() {
|
|
42
42
|
this.debug("Providing default configuration for the Powerlines `env` build plugin.");
|
|
43
43
|
const config = {
|
|
@@ -77,7 +77,7 @@ const plugin = (options = {}) => {
|
|
|
77
77
|
"POWERLINES_",
|
|
78
78
|
this.config.framework && this.config.framework !== "powerlines" && `${(0, _stryke_string_format_constant_case.constantCase)(this.config.framework)}_`
|
|
79
79
|
].filter(Boolean));
|
|
80
|
-
config.env.prefix =
|
|
80
|
+
config.env.prefix = (0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(config.env.prefix).reduce((ret, prefix) => {
|
|
81
81
|
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
82
82
|
return ret;
|
|
83
83
|
}, []));
|
package/dist/index.mjs
CHANGED
|
@@ -6,12 +6,12 @@ import { env } from "./helpers/automd-generator.mjs";
|
|
|
6
6
|
import { EnvDocsFile } from "./components/docs.mjs";
|
|
7
7
|
import { EnvBuiltin } from "./components/env-builtin.mjs";
|
|
8
8
|
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
9
|
-
import { getUnique } from "./node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs";
|
|
10
9
|
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
11
10
|
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
12
11
|
import defu from "defu";
|
|
13
12
|
import { joinPaths } from "@stryke/path/join";
|
|
14
13
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
14
|
+
import { getUnique } from "@stryke/helpers/get-unique";
|
|
15
15
|
import alloy from "@powerlines/plugin-alloy";
|
|
16
16
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
17
17
|
import automd from "@powerlines/plugin-automd";
|
|
@@ -31,7 +31,7 @@ const plugin = (options = {}) => {
|
|
|
31
31
|
alloy(options.alloy),
|
|
32
32
|
babel(options.babel),
|
|
33
33
|
{
|
|
34
|
-
name: "env",
|
|
34
|
+
name: "env:core",
|
|
35
35
|
async config() {
|
|
36
36
|
this.debug("Providing default configuration for the Powerlines `env` build plugin.");
|
|
37
37
|
const config = {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"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 {\n ReflectionClass,\n ReflectionKind\n} from \"@powerlines/deepkit/vendor/type\";\nimport alloy from \"@powerlines/plugin-alloy\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env-builtin\";\nimport { env } from \"./helpers/automd-generator\";\nimport { getDocsOutputPath } from \"./helpers/docs-helper\";\nimport { loadEnv } from \"./helpers/load\";\nimport {\n getEnvDefaultTypeDefinition,\n getEnvReflectionsPath,\n getEnvTypeReflectionsPath,\n getSecretsDefaultTypeDefinition,\n readEnvReflection,\n readEnvTypeReflection,\n readSecretsReflection,\n writeEnvReflection,\n writeEnvTypeReflection\n} from \"./helpers/persistence\";\nimport { reflectEnv, reflectSecrets } from \"./helpers/reflect\";\nimport { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n env?: EnvPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n alloy(options.alloy),\n babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n plugins: [envBabelPlugin]\n }\n };\n\n if (\n isSetString(config.env.types) ||\n (config.env.types && isSetString(config.env.types.file))\n ) {\n config.env.types = parseTypeDefinition(\n config.env.types\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.types.file);\n if (file) {\n config.env.types.file = file;\n }\n } else {\n this.warn(\n \"The `env.types` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n const envDefaultTypeDefinition =\n await getEnvDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(envDefaultTypeDefinition.file);\n if (file) {\n config.env.types = parseTypeDefinition(\n `${file}#${envDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n if (\n isSetString(config.env.secrets) ||\n (config.env.secrets && isSetString(config.env.secrets.file))\n ) {\n config.env.secrets = parseTypeDefinition(\n config.env.secrets\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.secrets.file);\n if (file) {\n config.env.secrets.file = file;\n }\n } else {\n const secretsDefaultTypeDefinition =\n await getSecretsDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);\n if (file) {\n config.env.secrets = parseTypeDefinition(\n `${file}#${secretsDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n config.env.prefix = toArray(\n (config.env.prefix ?? []) as string[]\n ).reduce(\n (ret: string[], prefix: string) => {\n const formattedPrefix = constantCase(prefix);\n if (!ret.includes(formattedPrefix)) {\n ret.push(formattedPrefix);\n }\n\n return ret;\n },\n [\n ...ENV_PREFIXES,\n \"POWERLINES_\",\n this.config.framework &&\n this.config.framework !== \"powerlines\" &&\n `${constantCase(this.config.framework)}_`\n ].filter(Boolean) as string[]\n );\n\n config.env.prefix = getUnique(\n toArray(config.env.prefix).reduce((ret, prefix) => {\n if (!ret.includes(prefix.replace(/_$/g, \"\"))) {\n ret.push(prefix.replace(/_$/g, \"\"));\n }\n return ret;\n }, [] as string[])\n );\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n this.env = defu(\n {\n parsed: await loadEnv(this, this.config.env)\n },\n this.env ?? {},\n {\n types: {\n env: {}\n },\n used: {\n env: {},\n secrets: {}\n },\n parsed: {},\n injected: {}\n }\n ) as EnvPluginContext[\"env\"];\n\n if (\n this.config.command !== \"prepare\" &&\n !this.config.skipCache &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n existsSync(getEnvTypeReflectionsPath(this, \"env\"))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n this.env.types.env = await readEnvTypeReflection(this, \"env\");\n\n if (existsSync(getEnvReflectionsPath(this, \"env\"))) {\n this.env.used.env = await readEnvReflection(this);\n }\n\n if (existsSync(getEnvTypeReflectionsPath(this, \"secrets\"))) {\n this.env.types.secrets = await readEnvTypeReflection(\n this,\n \"secrets\"\n );\n }\n\n if (existsSync(getEnvReflectionsPath(this, \"secrets\"))) {\n this.env.used.secrets = await readSecretsReflection(this);\n }\n } else {\n this.debug(\n `Starting environment configuration reflection initialization.`\n );\n\n this.env.types.env = await reflectEnv(\n this,\n this.config.env.types?.file,\n this.config.env.types?.name\n );\n if (!this.env.types.env) {\n throw new Error(\n \"Failed to find the environment configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.env, \"env\");\n\n this.env.types.secrets = await reflectSecrets(\n this,\n this.config.env.secrets?.file,\n this.config.env.secrets?.name\n );\n if (!this.env.types.secrets) {\n throw new Error(\n \"Failed to find the secrets configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.secrets, \"secrets\");\n\n this.debug(\n `Resolved ${\n this.env.types.env.getProperties().length ?? 0\n } environment configuration parameters and ${\n this.env.types.secrets?.getProperties().length ?? 0\n } secret configuration parameters`\n );\n\n const envWithAlias = this.env.types.env\n .getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n Object.entries(await loadEnv(this, this.config.env)).forEach(\n ([key, value]) => {\n const unprefixedKey = this.config.env.prefix.reduce(\n (ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n },\n key\n );\n\n const aliasKey = envWithAlias.find(prop =>\n prop?.getAlias().reverse().includes(unprefixedKey)\n );\n if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) {\n this.env.types.env\n .getProperty(unprefixedKey)\n .setDefaultValue(value);\n }\n }\n );\n\n this.env.used.env = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.env\n );\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n\n if (this.env.types.secrets) {\n await writeEnvTypeReflection(\n this,\n this.env.types.secrets,\n \"secrets\"\n );\n\n this.env.used.secrets = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.secrets\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async prepare() {\n this.debug(\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvBuiltin\n defaultConfig={this.config.env.defaultConfig}\n reflection={result}\n />\n );\n },\n transform: {\n order: \"post\",\n async handler() {\n if (this.env.used.env.getProperties().length > 0) {\n this.trace(\n `Persisting used environment configuration reflections to ${getEnvReflectionsPath(\n this,\n \"env\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n\n if (this.env.used.secrets.getProperties().length > 0) {\n this.trace(\n `Persisting used secret configuration reflections to ${getEnvReflectionsPath(\n this,\n \"secrets\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async docs() {\n this.debug(\n `Documenting environment variables configuration values in \"${joinPaths(\n getDocsOutputPath(this),\n \"env.md\"\n )}\"`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvDocsFile levelOffset={0} reflection={result} />\n );\n },\n async buildEnd() {\n const reflectionPath = getEnvReflectionsPath(this, \"env\");\n\n this.debug(`Writing env reflection types to ${reflectionPath}.`);\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n },\n {\n name: \"env:automd-generator\",\n config() {\n return {\n automd: defu(options.automd ?? {}, {\n generators: {\n env: env(this)\n }\n })\n };\n }\n },\n {\n name: \"env:vite\",\n vite: {\n configResolved(this: TContext) {\n return {\n envPrefix: this.config?.env?.prefix\n } as ViteUserConfig;\n }\n }\n },\n automd(options.automd)\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAE,UAAkB,UAAA,EAAA,KAAA;AAClB,QAAA;EAAA,MAAA,QAAA,MAAA;EAAA,MAAA,QAAA,MAAA;EAAA;GACA,MAAQ;GACV,MAAS,SAAU;AACb,SAAG,MAAA,yEAA0D;;KAE5D,KAAM,KAAK,SAAS;;MAEnB,UAAQ;MACd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"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"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 {\n ReflectionClass,\n ReflectionKind\n} from \"@powerlines/deepkit/vendor/type\";\nimport alloy from \"@powerlines/plugin-alloy\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env-builtin\";\nimport { env } from \"./helpers/automd-generator\";\nimport { getDocsOutputPath } from \"./helpers/docs-helper\";\nimport { loadEnv } from \"./helpers/load\";\nimport {\n getEnvDefaultTypeDefinition,\n getEnvReflectionsPath,\n getEnvTypeReflectionsPath,\n getSecretsDefaultTypeDefinition,\n readEnvReflection,\n readEnvTypeReflection,\n readSecretsReflection,\n writeEnvReflection,\n writeEnvTypeReflection\n} from \"./helpers/persistence\";\nimport { reflectEnv, reflectSecrets } from \"./helpers/reflect\";\nimport { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n env?: EnvPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n alloy(options.alloy),\n babel(options.babel),\n {\n name: \"env:core\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n plugins: [envBabelPlugin]\n }\n };\n\n if (\n isSetString(config.env.types) ||\n (config.env.types && isSetString(config.env.types.file))\n ) {\n config.env.types = parseTypeDefinition(\n config.env.types\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.types.file);\n if (file) {\n config.env.types.file = file;\n }\n } else {\n this.warn(\n \"The `env.types` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n const envDefaultTypeDefinition =\n await getEnvDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(envDefaultTypeDefinition.file);\n if (file) {\n config.env.types = parseTypeDefinition(\n `${file}#${envDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n if (\n isSetString(config.env.secrets) ||\n (config.env.secrets && isSetString(config.env.secrets.file))\n ) {\n config.env.secrets = parseTypeDefinition(\n config.env.secrets\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.secrets.file);\n if (file) {\n config.env.secrets.file = file;\n }\n } else {\n const secretsDefaultTypeDefinition =\n await getSecretsDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);\n if (file) {\n config.env.secrets = parseTypeDefinition(\n `${file}#${secretsDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n config.env.prefix = toArray(\n (config.env.prefix ?? []) as string[]\n ).reduce(\n (ret: string[], prefix: string) => {\n const formattedPrefix = constantCase(prefix);\n if (!ret.includes(formattedPrefix)) {\n ret.push(formattedPrefix);\n }\n\n return ret;\n },\n [\n ...ENV_PREFIXES,\n \"POWERLINES_\",\n this.config.framework &&\n this.config.framework !== \"powerlines\" &&\n `${constantCase(this.config.framework)}_`\n ].filter(Boolean) as string[]\n );\n\n config.env.prefix = getUnique(\n toArray(config.env.prefix).reduce((ret, prefix) => {\n if (!ret.includes(prefix.replace(/_$/g, \"\"))) {\n ret.push(prefix.replace(/_$/g, \"\"));\n }\n return ret;\n }, [] as string[])\n );\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n this.env = defu(\n {\n parsed: await loadEnv(this, this.config.env)\n },\n this.env ?? {},\n {\n types: {\n env: {}\n },\n used: {\n env: {},\n secrets: {}\n },\n parsed: {},\n injected: {}\n }\n ) as EnvPluginContext[\"env\"];\n\n if (\n this.config.command !== \"prepare\" &&\n !this.config.skipCache &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n existsSync(getEnvTypeReflectionsPath(this, \"env\"))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n this.env.types.env = await readEnvTypeReflection(this, \"env\");\n\n if (existsSync(getEnvReflectionsPath(this, \"env\"))) {\n this.env.used.env = await readEnvReflection(this);\n }\n\n if (existsSync(getEnvTypeReflectionsPath(this, \"secrets\"))) {\n this.env.types.secrets = await readEnvTypeReflection(\n this,\n \"secrets\"\n );\n }\n\n if (existsSync(getEnvReflectionsPath(this, \"secrets\"))) {\n this.env.used.secrets = await readSecretsReflection(this);\n }\n } else {\n this.debug(\n `Starting environment configuration reflection initialization.`\n );\n\n this.env.types.env = await reflectEnv(\n this,\n this.config.env.types?.file,\n this.config.env.types?.name\n );\n if (!this.env.types.env) {\n throw new Error(\n \"Failed to find the environment configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.env, \"env\");\n\n this.env.types.secrets = await reflectSecrets(\n this,\n this.config.env.secrets?.file,\n this.config.env.secrets?.name\n );\n if (!this.env.types.secrets) {\n throw new Error(\n \"Failed to find the secrets configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.secrets, \"secrets\");\n\n this.debug(\n `Resolved ${\n this.env.types.env.getProperties().length ?? 0\n } environment configuration parameters and ${\n this.env.types.secrets?.getProperties().length ?? 0\n } secret configuration parameters`\n );\n\n const envWithAlias = this.env.types.env\n .getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n Object.entries(await loadEnv(this, this.config.env)).forEach(\n ([key, value]) => {\n const unprefixedKey = this.config.env.prefix.reduce(\n (ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n },\n key\n );\n\n const aliasKey = envWithAlias.find(prop =>\n prop?.getAlias().reverse().includes(unprefixedKey)\n );\n if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) {\n this.env.types.env\n .getProperty(unprefixedKey)\n .setDefaultValue(value);\n }\n }\n );\n\n this.env.used.env = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.env\n );\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n\n if (this.env.types.secrets) {\n await writeEnvTypeReflection(\n this,\n this.env.types.secrets,\n \"secrets\"\n );\n\n this.env.used.secrets = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.secrets\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async prepare() {\n this.debug(\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvBuiltin\n defaultConfig={this.config.env.defaultConfig}\n reflection={result}\n />\n );\n },\n transform: {\n order: \"post\",\n async handler() {\n if (this.env.used.env.getProperties().length > 0) {\n this.trace(\n `Persisting used environment configuration reflections to ${getEnvReflectionsPath(\n this,\n \"env\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n\n if (this.env.used.secrets.getProperties().length > 0) {\n this.trace(\n `Persisting used secret configuration reflections to ${getEnvReflectionsPath(\n this,\n \"secrets\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async docs() {\n this.debug(\n `Documenting environment variables configuration values in \"${joinPaths(\n getDocsOutputPath(this),\n \"env.md\"\n )}\"`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvDocsFile levelOffset={0} reflection={result} />\n );\n },\n async buildEnd() {\n const reflectionPath = getEnvReflectionsPath(this, \"env\");\n\n this.debug(`Writing env reflection types to ${reflectionPath}.`);\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n },\n {\n name: \"env:automd-generator\",\n config() {\n return {\n automd: defu(options.automd ?? {}, {\n generators: {\n env: env(this)\n }\n })\n };\n }\n },\n {\n name: \"env:vite\",\n vite: {\n configResolved(this: TContext) {\n return {\n envPrefix: this.config?.env?.prefix\n } as ViteUserConfig;\n }\n }\n },\n automd(options.automd)\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAE,UAAkB,UAAA,EAAA,KAAA;AAClB,QAAA;EAAA,MAAA,QAAA,MAAA;EAAA,MAAA,QAAA,MAAA;EAAA;GACA,MAAQ;GACV,MAAS,SAAU;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