@powerlines/plugin-env 0.16.260 → 0.16.262
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel/plugin.cjs +1 -1
- package/dist/babel/plugin.mjs +1 -1
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +2 -2
- package/dist/components/docs.mjs +2 -2
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +16 -7
- 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 +16 -7
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/schema.cjs +7 -13
- package/dist/helpers/schema.d.cts.map +1 -1
- package/dist/helpers/schema.d.mts.map +1 -1
- package/dist/helpers/schema.mjs +7 -13
- package/dist/helpers/schema.mjs.map +1 -1
- package/dist/types/plugin.d.cts +2 -2
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +2 -2
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs.map +1 -1
- package/package.json +9 -9
package/dist/babel/plugin.cjs
CHANGED
|
@@ -28,7 +28,7 @@ const envBabelPlugin = (_powerlines_plugin_babel_helpers_create_plugin.createBab
|
|
|
28
28
|
});
|
|
29
29
|
context.env.config.active.push(name);
|
|
30
30
|
if (!config[name].runtime && (context.config.env.inject && isInjectable || context.config.env.validate)) {
|
|
31
|
-
if (context.config.env.validate && !config[name].
|
|
31
|
+
if (context.config.env.validate && !config[name].required && (0, _stryke_type_checks_is_undefined.isUndefined)(config[name].default)) throw new Error(`Environment variable \`${name}\` is missing a default value, but is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}.\n\nPlease add a default value to the schema, or if this variable is optional, please mark it as optional in the type definition.`);
|
|
32
32
|
return (0, _powerlines_schema.stringifyValue)(config[name].default);
|
|
33
33
|
}
|
|
34
34
|
} else if (context.config.env.validate) throw new Error(`Environment variable \`${name}\` is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}, but is not defined in the \`config\` schema. Please check the \`env.config\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`);
|
package/dist/babel/plugin.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
|
|
|
27
27
|
});
|
|
28
28
|
context.env.config.active.push(name);
|
|
29
29
|
if (!config[name].runtime && (context.config.env.inject && isInjectable || context.config.env.validate)) {
|
|
30
|
-
if (context.config.env.validate && !config[name].
|
|
30
|
+
if (context.config.env.validate && !config[name].required && isUndefined(config[name].default)) throw new Error(`Environment variable \`${name}\` is missing a default value, but is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}.\n\nPlease add a default value to the schema, or if this variable is optional, please mark it as optional in the type definition.`);
|
|
31
31
|
return stringifyValue(config[name].default);
|
|
32
32
|
}
|
|
33
33
|
} else if (context.config.env.validate) throw new Error(`Environment variable \`${name}\` is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}, but is not defined in the \`config\` schema. Please check the \`env.config\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/babel/plugin.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 { NodePath } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { BabelPluginPass } from \"@powerlines/plugin-babel/types/config\";\nimport {\n getProperties,\n JsonSchemaProperty,\n stringifyValue\n} from \"@powerlines/schema\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/*\n * The Powerlines - Environment Configuration Babel Plugin\n *\n * @param babel - The Babel core module\n * @returns The Babel plugin object\n */\nexport const envBabelPlugin = createBabelPlugin<EnvPluginContext>(\n \"env\",\n ({ logger, context }) => {\n const config = getProperties(context.env.config);\n function extractEnv(\n node: t.Identifier,\n pass: BabelPluginPass,\n isInjectable = false\n ) {\n if (node.name) {\n const name = node.name.replace(\n new RegExp(`^(${context.config.env.prefix.join(\"|\")})_`),\n \"\"\n );\n\n logger.trace({\n meta: {\n category: \"env\"\n },\n message: `Environment variable ${name} found in ${\n pass.filename || \"unknown file\"\n }.`\n });\n\n if (\n name in config &&\n isSetObject(config[name]) &&\n !config[name]?.isIgnored\n ) {\n config[name] ??= {} as JsonSchemaProperty<Record<string, any>>;\n\n logger.debug({\n meta: {\n category: \"env\"\n },\n message: `The \"${name}\" environment variable is used in the source code file \"${\n pass.filename || \"unknown file\"\n }\" and will be added to the environment schema's active variables list.`\n });\n\n context.env.config.active.push(name);\n if (\n !config[name].runtime &&\n ((context.config.env.inject && isInjectable) ||\n context.config.env.validate)\n ) {\n if (\n context.config.env.validate &&\n !config[name].
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/babel/plugin.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 { NodePath } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { BabelPluginPass } from \"@powerlines/plugin-babel/types/config\";\nimport {\n getProperties,\n JsonSchemaProperty,\n stringifyValue\n} from \"@powerlines/schema\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/*\n * The Powerlines - Environment Configuration Babel Plugin\n *\n * @param babel - The Babel core module\n * @returns The Babel plugin object\n */\nexport const envBabelPlugin = createBabelPlugin<EnvPluginContext>(\n \"env\",\n ({ logger, context }) => {\n const config = getProperties(context.env.config);\n function extractEnv(\n node: t.Identifier,\n pass: BabelPluginPass,\n isInjectable = false\n ) {\n if (node.name) {\n const name = node.name.replace(\n new RegExp(`^(${context.config.env.prefix.join(\"|\")})_`),\n \"\"\n );\n\n logger.trace({\n meta: {\n category: \"env\"\n },\n message: `Environment variable ${name} found in ${\n pass.filename || \"unknown file\"\n }.`\n });\n\n if (\n name in config &&\n isSetObject(config[name]) &&\n !config[name]?.isIgnored\n ) {\n config[name] ??= {} as JsonSchemaProperty<Record<string, any>>;\n\n logger.debug({\n meta: {\n category: \"env\"\n },\n message: `The \"${name}\" environment variable is used in the source code file \"${\n pass.filename || \"unknown file\"\n }\" and will be added to the environment schema's active variables list.`\n });\n\n context.env.config.active.push(name);\n if (\n !config[name].runtime &&\n ((context.config.env.inject && isInjectable) ||\n context.config.env.validate)\n ) {\n if (\n context.config.env.validate &&\n !config[name].required &&\n isUndefined(config[name].default)\n ) {\n throw new Error(\n `Environment variable \\`${\n name\n }\\` is missing a default value, but is active in the source code${\n pass.filename ? ` file \\`${pass.filename}\\`` : \"\"\n }.\\n\\nPlease add a default value to the schema, or if this variable is optional, please mark it as optional in the type definition.`\n );\n }\n\n return stringifyValue(config[name].default);\n }\n } else if (context.config.env.validate) {\n throw new Error(\n `Environment variable \\`${name}\\` is active in the source code${\n pass.filename ? ` file \\`${pass.filename}\\`` : \"\"\n }, but is not defined in the \\`config\\` schema. Please check the \\`env.config\\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`\n );\n } else {\n logger.warn({\n meta: {\n category: \"env\"\n },\n message: `Environment variable \\`${name}\\` is active in the source code${\n pass.filename ? ` file \\`${pass.filename}\\`` : \"\"\n }, but is not defined in the \\`config\\` schema. If this is intentional, you can ignore this warning. Otherwise, please check the \\`env.config\\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`\n });\n }\n }\n\n return undefined;\n }\n\n return {\n visitor: {\n MemberExpression(\n path: NodePath<t.MemberExpression>,\n pass: BabelPluginPass\n ) {\n if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path\n .get(\"object\")\n ?.get(\"object\")\n ?.isIdentifier({ name: \"process\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // process.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework?.name || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path.get(\"object\")?.get(\"object\")?.isMetaProperty() &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // import.meta.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework?.name || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path.get(\"object\")?.isIdentifier({ name: \"env\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n }\n }\n }\n };\n }\n);\n"],"mappings":";;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;4HAaA,QACA,cACM;CACN,MAAQ,SAAC,cAAmB,QAAW,IAAA,MAAO;CAC9C,SAAS,WAAA,MAAkB,MAAO,eAAW,OAAO;EACpD,IAAO,KAAA,MAAA;GACL,MAAA,OAAa,KAAA,KAAA,QAAA,IAAA,OAAA,KAAA,QAAA,OAAA,IAAA,OAAA,KAAA,GAAA,EAAA,GAAA,GAAA,EAAA;GACb,OAAA,MAAA;IACA,MAAA,EACO,UAAW,MACZ;IACA,SAAC,wBAAgC,KAAC,YAAU,KAAU,YAAA,eAAA;GACxD,CAAC;;IAEN,OAAA,UAAA,CAAA;IACM,OAAA,MAAa;KACnB,MAAA,EACS,UAAY,MAClB;KACF,SAAA,QAAA,KAAA,0DAAA,KAAA,YAAA,eAAA;IACK,CAAA;IACA,QAAA,IAAA,OAAA,OAAA,KAAA,IAAA;IACF,IAAO,CAAC,OAAO,MAAM,YAAC,QAAA,OAAA,IAAA,UAAA,gBAAA,QAAA,OAAA,IAAA,WAAA;KACjB,IAAA,QAAS,OAAA,IAAc,YAAY,CAAA,OAAO,MAAA,YAAA,YAAA,OAAA,MAAA,OAAA,GACxC,MAAC,IAAA,MAAU,0BAAA,KAAA,iEAAA,KAAA,WAAA,WAAA,KAAA,SAAA,MAAA,GAAA,mIAAA;KAEb,OAAE,eAAe,OAAA,MAAA,OAAA;IACrB;GACA,OAA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IAAA,KAAA,IAAA,QAAA,GAAA,aAAA,EACL,MAAE;GAGF,MAAA,aAAA,KAAA,IAAA,UAAA,GAAA;GACA,IAAI,CAAC,WAAW,MAChB;GAEA,WAAS,YAAa,MAAO,KAAE;EACjC;CACF,GAAG;EAAC;EAAC;EAAA;EAAA;EAAA;CAAA,CAAA,EACP,EACF;AACF,GAAG;CAAC;CAAQ;CAAM;AAAA,CAAA,CAAA"}
|
package/dist/components/docs.cjs
CHANGED
|
@@ -70,9 +70,9 @@ function EnvDocsFile(props) {
|
|
|
70
70
|
return {
|
|
71
71
|
name: property.name?.trim(),
|
|
72
72
|
description: (property.description ?? "").trim(),
|
|
73
|
-
type: (
|
|
73
|
+
type: (0, _powerlines_schema.stringifyType)(property).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
|
|
74
74
|
defaultValue: property.default ? (0, _powerlines_schema.stringifyType)(property.default) : "",
|
|
75
|
-
required: property.
|
|
75
|
+
required: property.required ? "" : "✔"
|
|
76
76
|
};
|
|
77
77
|
}, [
|
|
78
78
|
"property",
|
package/dist/components/docs.mjs
CHANGED
|
@@ -69,9 +69,9 @@ function EnvDocsFile(props) {
|
|
|
69
69
|
return {
|
|
70
70
|
name: property.name?.trim(),
|
|
71
71
|
description: (property.description ?? "").trim(),
|
|
72
|
-
type:
|
|
72
|
+
type: stringifyType(property).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
|
|
73
73
|
defaultValue: property.default ? stringifyType(property.default) : "",
|
|
74
|
-
required: property.
|
|
74
|
+
required: property.required ? "" : "✔"
|
|
75
75
|
};
|
|
76
76
|
}, [
|
|
77
77
|
"property",
|
|
@@ -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 } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { Heading } from \"@powerlines/plugin-alloy/markdown/components/heading\";\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 { getPropertiesList, stringifyType } from \"@powerlines/schema\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\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\n/**\n * Generates the environment configuration markdown documentation for the Powerlines project.\n */\nexport function EnvDocsFile(props: EnvDocsFileProps) {\n const { levelOffset = 0, ...rest } = props;\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context.config.root), \"env.md\")}\n {...rest}>\n <Heading level={1 + levelOffset}>Environment</Heading>\n {code`The ${\n context.config.name\n } package uses various configuration parameters to control the behavior of the application. These parameters can be provided as environment variables when the application is run, or they can be defined in a \\`config.json\\` file in the application configuration directory.`}\n <Spacing />\n <Heading level={2 + levelOffset}>Configuration</Heading>\n <Spacing />\n {code`The below list of configuration parameters are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text locally.`}\n <Spacing />\n <MarkdownTable\n data={\n getPropertiesList(context.env.config)\n .filter(\n property =>\n getPropertiesList(context.env.config).some(\n p =>\n p.name === property.name &&\n context.env.config.active.includes(property.name)\n ) &&\n !property?.hidden &&\n !property?.ignore &&\n !property?.readOnly &&\n !property?.internal\n )\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a.name.localeCompare(b.name)\n )\n .map(property => {\n return {\n name: property.name?.trim(),\n description: (property.description ?? \"\").trim(),\n type: stringifyType
|
|
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 } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { Heading } from \"@powerlines/plugin-alloy/markdown/components/heading\";\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 { getPropertiesList, stringifyType } from \"@powerlines/schema\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\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\n/**\n * Generates the environment configuration markdown documentation for the Powerlines project.\n */\nexport function EnvDocsFile(props: EnvDocsFileProps) {\n const { levelOffset = 0, ...rest } = props;\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context.config.root), \"env.md\")}\n {...rest}>\n <Heading level={1 + levelOffset}>Environment</Heading>\n {code`The ${\n context.config.name\n } package uses various configuration parameters to control the behavior of the application. These parameters can be provided as environment variables when the application is run, or they can be defined in a \\`config.json\\` file in the application configuration directory.`}\n <Spacing />\n <Heading level={2 + levelOffset}>Configuration</Heading>\n <Spacing />\n {code`The below list of configuration parameters are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text locally.`}\n <Spacing />\n <MarkdownTable\n data={\n getPropertiesList(context.env.config)\n .filter(\n property =>\n getPropertiesList(context.env.config).some(\n p =>\n p.name === property.name &&\n context.env.config.active.includes(property.name)\n ) &&\n !property?.hidden &&\n !property?.ignore &&\n !property?.readOnly &&\n !property?.internal\n )\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a.name.localeCompare(b.name)\n )\n .map(property => {\n return {\n name: property.name?.trim(),\n description: (property.description ?? \"\").trim(),\n type: stringifyType(property)\n .trim()\n .replaceAll(/\\s*(?:\\||&)\\s*/g, \", or \"),\n defaultValue: property.default\n ? stringifyType(property.default)\n : \"\",\n required: property.required ? \"\" : \"✔\"\n };\n }) ?? []\n }\n />\n </MarkdownFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;AA2BA,MAAK,sBAAkB;OAAU;CAAa;CAAU;CAAA;CAAa;CAAA;AAAA;;;;AAKrE,SAAM,YAAa,OAAA;CACjB,MAAE,EACF,cAAc,GAChB,GAAA;CAEE,MAAA,WAAA,cAAA,IAAA,CAAA,OA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AA,WAAA,KAAA;KACK;IACF,GAAA;KAAA;KAAA;KAAkB;IAAW,CAAC,CAAA,KAAM,CAAA;GACtC,EACF,CAAC;EAAC;CACJ,EACF,CAAC,CAAC;AACJ;AACA,YAAY,SAAQ;OAAQ;CAAkB;CAAS;CAAa;CAAA;AAAA"}
|
|
@@ -73,7 +73,7 @@ function EnvTypeDefinition() {
|
|
|
73
73
|
get children() {
|
|
74
74
|
return __assignType((prefix) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
75
75
|
get each() {
|
|
76
|
-
return (0, _powerlines_schema.getPropertiesList)(context.env.config.schema).filter(__assignType((property) => !property
|
|
76
|
+
return (0, _powerlines_schema.getPropertiesList)(context.env.config.schema).filter(__assignType((property) => !property.ignore, [
|
|
77
77
|
"property",
|
|
78
78
|
"",
|
|
79
79
|
"P\"2!\"/\""
|
|
@@ -81,15 +81,24 @@ function EnvTypeDefinition() {
|
|
|
81
81
|
},
|
|
82
82
|
doubleHardline: true,
|
|
83
83
|
get children() {
|
|
84
|
-
return __assignType((property) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components.TSDocSchemaProperty, {
|
|
84
|
+
return __assignType((property) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components.TSDocSchemaProperty, {
|
|
85
|
+
schema: property,
|
|
86
|
+
get defaultValue() {
|
|
87
|
+
return property?.default;
|
|
88
|
+
}
|
|
89
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components.InterfaceMember, {
|
|
85
90
|
get name() {
|
|
86
|
-
return `${prefix}_${property
|
|
91
|
+
return `${prefix}_${property.name}`;
|
|
87
92
|
},
|
|
88
93
|
get type() {
|
|
89
|
-
return `UnprefixedEnv["${property
|
|
94
|
+
return `UnprefixedEnv["${property.name}"]`;
|
|
95
|
+
},
|
|
96
|
+
schema: property,
|
|
97
|
+
get required() {
|
|
98
|
+
return property.required;
|
|
90
99
|
},
|
|
91
100
|
get readOnly() {
|
|
92
|
-
return property
|
|
101
|
+
return property.readOnly;
|
|
93
102
|
}
|
|
94
103
|
})], [
|
|
95
104
|
"property",
|
|
@@ -322,7 +331,7 @@ function EnvBuiltin(props) {
|
|
|
322
331
|
const [{ defaultConfig, children }, rest] = (0, _alloy_js_core.splitProps)(props, ["defaultConfig", "children"]);
|
|
323
332
|
const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["EnvPluginContext", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
|
|
324
333
|
const defaultValue = (0, _alloy_js_core.computed)(() => context && require_helpers_load.loadEnvFromContext(context, process.env));
|
|
325
|
-
const schemaGetProperties = (0, _alloy_js_core.computed)(() => (0, _powerlines_schema.getPropertiesList)(context.env.config
|
|
334
|
+
const schemaGetProperties = (0, _alloy_js_core.computed)(() => (0, _powerlines_schema.getPropertiesList)(context.env.config).filter(__assignType((property) => !property?.ignore && !property?.writeOnly, [
|
|
326
335
|
"property",
|
|
327
336
|
"",
|
|
328
337
|
"P\"2!\"/\""
|
|
@@ -332,7 +341,7 @@ function EnvBuiltin(props) {
|
|
|
332
341
|
"",
|
|
333
342
|
"P\"2!\"2\"\"/#"
|
|
334
343
|
])) ?? []);
|
|
335
|
-
const schemaSetProperties = (0, _alloy_js_core.computed)(() => (0, _powerlines_schema.getPropertiesList)(context.env.config
|
|
344
|
+
const schemaSetProperties = (0, _alloy_js_core.computed)(() => (0, _powerlines_schema.getPropertiesList)(context.env.config).filter(__assignType((property) => !property?.ignore && !property?.readOnly, [
|
|
336
345
|
"property",
|
|
337
346
|
"",
|
|
338
347
|
"P\"2!\"/\""
|
|
@@ -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":";;;;;;AA+DA;iBAAgB,iBAAA,CAAA,GAAiB,QAAA;AAAA,UAwLhB,eAAA,SAAwB,IAAA,CAAK,gBAAA;EAC5C,aAAA,GAAgB,QAAA;AAAA;AADlB;;;AAAA,iBAUgB,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":";;;;;;AA+DA;iBAAgB,iBAAA,CAAA,GAAiB,QAAA;AAAA,UAwLhB,eAAA,SAAwB,IAAA,CAAK,gBAAA;EAC5C,aAAA,GAAgB,QAAA;AAAA;AADlB;;;AAAA,iBAUgB,UAAA,CAAW,KAAA,EAAO,eAAA,GAAe,QAAA"}
|
|
@@ -72,7 +72,7 @@ function EnvTypeDefinition() {
|
|
|
72
72
|
get children() {
|
|
73
73
|
return __assignType((prefix) => createComponent(For, {
|
|
74
74
|
get each() {
|
|
75
|
-
return getPropertiesList(context.env.config.schema).filter(__assignType((property) => !property
|
|
75
|
+
return getPropertiesList(context.env.config.schema).filter(__assignType((property) => !property.ignore, [
|
|
76
76
|
"property",
|
|
77
77
|
"",
|
|
78
78
|
"P\"2!\"/\""
|
|
@@ -80,15 +80,24 @@ function EnvTypeDefinition() {
|
|
|
80
80
|
},
|
|
81
81
|
doubleHardline: true,
|
|
82
82
|
get children() {
|
|
83
|
-
return __assignType((property) => [createComponent(TSDocSchemaProperty, {
|
|
83
|
+
return __assignType((property) => [createComponent(TSDocSchemaProperty, {
|
|
84
|
+
schema: property,
|
|
85
|
+
get defaultValue() {
|
|
86
|
+
return property?.default;
|
|
87
|
+
}
|
|
88
|
+
}), createComponent(InterfaceMember, {
|
|
84
89
|
get name() {
|
|
85
|
-
return `${prefix}_${property
|
|
90
|
+
return `${prefix}_${property.name}`;
|
|
86
91
|
},
|
|
87
92
|
get type() {
|
|
88
|
-
return `UnprefixedEnv["${property
|
|
93
|
+
return `UnprefixedEnv["${property.name}"]`;
|
|
94
|
+
},
|
|
95
|
+
schema: property,
|
|
96
|
+
get required() {
|
|
97
|
+
return property.required;
|
|
89
98
|
},
|
|
90
99
|
get readOnly() {
|
|
91
|
-
return property
|
|
100
|
+
return property.readOnly;
|
|
92
101
|
}
|
|
93
102
|
})], [
|
|
94
103
|
"property",
|
|
@@ -321,7 +330,7 @@ function EnvBuiltin(props) {
|
|
|
321
330
|
const [{ defaultConfig, children }, rest] = splitProps(props, ["defaultConfig", "children"]);
|
|
322
331
|
const context = (usePowerlines.Ω = [["EnvPluginContext", "\"w!"]], usePowerlines());
|
|
323
332
|
const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
|
|
324
|
-
const schemaGetProperties = computed(() => getPropertiesList(context.env.config
|
|
333
|
+
const schemaGetProperties = computed(() => getPropertiesList(context.env.config).filter(__assignType((property) => !property?.ignore && !property?.writeOnly, [
|
|
325
334
|
"property",
|
|
326
335
|
"",
|
|
327
336
|
"P\"2!\"/\""
|
|
@@ -331,7 +340,7 @@ function EnvBuiltin(props) {
|
|
|
331
340
|
"",
|
|
332
341
|
"P\"2!\"2\"\"/#"
|
|
333
342
|
])) ?? []);
|
|
334
|
-
const schemaSetProperties = computed(() => getPropertiesList(context.env.config
|
|
343
|
+
const schemaSetProperties = computed(() => getPropertiesList(context.env.config).filter(__assignType((property) => !property?.ignore && !property?.readOnly, [
|
|
335
344
|
"property",
|
|
336
345
|
"",
|
|
337
346
|
"P\"2!\"/\""
|
|
@@ -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 InterfaceDeclaration as BaseInterfaceDeclaration,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\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 type { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps,\n InterfaceDeclaration,\n InterfaceMember,\n ObjectDeclaration,\n TSDocSchemaProperty\n} from \"@powerlines/plugin-alloy/typescript/components\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport type { JsonSchemaProperty } from \"@powerlines/schema\";\nimport { getPropertiesList } from \"@powerlines/schema\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport type { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition() {\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\"UnprefixedEnv\"\n schema={context.env.config.schema}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`UnprefixedEnv\\` 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 <BaseInterfaceDeclaration name=\"Env\" export extends=\"UnprefixedEnv\">\n <For\n each={getUnique(context.config.env.prefix).map(prefix =>\n prefix.replace(/_$/, \"\")\n )}\n doubleHardline>\n {prefix => (\n <For\n each={\n getPropertiesList(context.env.config.schema).filter(\n property => !property?.isIgnored\n ) ?? []\n }\n doubleHardline>\n {property => (\n <>\n <TSDocSchemaProperty schema={property} />\n <InterfaceMember\n name={`${prefix}_${property?.name}`}\n type={`UnprefixedEnv[\"${property?.name}\"]`}\n readOnly={property?.readOnly}\n />\n </>\n )}\n </For>\n )}\n </For>\n </BaseInterfaceDeclaration>\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 name: string;\n property: JsonSchemaProperty;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const schemaGetProperties = computed(\n () =>\n getPropertiesList(context.env.config.schema)\n .filter(property => !property?.isIgnored && !property?.writeOnly)\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a?.name.localeCompare(b?.name)\n ) ?? []\n );\n const schemaSetProperties = computed(\n () =>\n getPropertiesList(context.env.config.schema)\n .filter(property => !property?.isIgnored && !property?.readOnly)\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a?.name.localeCompare(b?.name)\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 <Show when={Boolean(context.env.config.schema)}>\n <EnvTypeDefinition defaultValue={defaultValue} />\n <Spacing />\n </Show>\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<Env>\"\n schema={context.env.config.schema}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\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: UnprefixedEnv, propertyName: string) => { `}\n <hbr />\n <For each={schemaGetProperties.value}>\n {(property: JsonSchemaProperty, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n name={property.name}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `}\n <hbr />\n <For each={schemaSetProperties.value} ender={code` else `}>\n {(property: JsonSchemaProperty, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n name={property.name}\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 <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 <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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AAa,gBAAA;IACf,UAAM;IACN,SAAM;IACN,MAAM;IACN,aAAM,IAAW;GACnB,CAAC;GAAG,gBAAI,SAAkB,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACxB,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAM,IAAW;GACnB,CAAC;GAAG,gBAAe,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACjB,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAa,IAAC;GAChB,CAAC;GAAG,gBAAU,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACZ,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAI,IAAA;GACN,CAAC;GAAA,gBAAA,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACA,UAAS;;IAET,MAAM;IACL,KAAC;IACD,aAAa,IAAC;GAChB,CAAC;GAAG,gBAAe,SAAA,CAAA,CAAA;GAAA,gBAAA,MAAA;IACjB,IAAI,OAAO;KACT,OAAI,QAAW,QAAC;IAClB;IACE;GACJ,CAAC;EAAC;CACJ,EACF,CAAC,CAAC;AACJ;AACA,WAAQ,SAAU;OAAA;CAAA;CAAA;CAAA;CAAA;AAAA"}
|
|
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 InterfaceDeclaration as BaseInterfaceDeclaration,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\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 type { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps,\n InterfaceDeclaration,\n InterfaceMember,\n ObjectDeclaration,\n TSDocSchemaProperty\n} from \"@powerlines/plugin-alloy/typescript/components\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n getPropertiesList,\n GetPropertiesResult,\n JsonSchema\n} from \"@powerlines/schema\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport type { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition() {\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\"UnprefixedEnv\"\n schema={context.env.config.schema}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`UnprefixedEnv\\` 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 <BaseInterfaceDeclaration name=\"Env\" export extends=\"UnprefixedEnv\">\n <For\n each={getUnique(context.config.env.prefix).map(prefix =>\n prefix.replace(/_$/, \"\")\n )}\n doubleHardline>\n {prefix => (\n <For\n each={\n getPropertiesList(context.env.config.schema).filter(\n property => !property.ignore\n ) ?? []\n }\n doubleHardline>\n {property => (\n <>\n <TSDocSchemaProperty\n schema={property}\n defaultValue={property?.default}\n />\n <InterfaceMember\n name={`${prefix}_${property.name}`}\n type={`UnprefixedEnv[\"${property.name}\"]`}\n schema={property}\n required={property.required}\n readOnly={property.readOnly}\n />\n </>\n )}\n </For>\n )}\n </For>\n </BaseInterfaceDeclaration>\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 name: string;\n property: JsonSchema;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const schemaGetProperties = computed(\n () =>\n (getPropertiesList(context.env.config)\n .filter(property => !property?.ignore && !property?.writeOnly)\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a?.name.localeCompare(b?.name)\n ) ?? []) as GetPropertiesResult[]\n );\n const schemaSetProperties = computed(\n () =>\n (getPropertiesList(context.env.config)\n .filter(property => !property?.ignore && !property?.readOnly)\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a?.name.localeCompare(b?.name)\n ) ?? []) as GetPropertiesResult[]\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 <Show when={Boolean(context.env.config.schema)}>\n <EnvTypeDefinition defaultValue={defaultValue} />\n <Spacing />\n </Show>\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<Env>\"\n schema={context.env.config.schema}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\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: UnprefixedEnv, propertyName: string) => { `}\n <hbr />\n <For each={schemaGetProperties.value}>\n {(property: GetPropertiesResult, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n name={property.name}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `}\n <hbr />\n <For each={schemaSetProperties.value} ender={code` else `}>\n {(property: GetPropertiesResult, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n name={property.name}\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 <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 <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":";;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAU;CAAC;CAAI;CAAM;CAAQ;AAAG;;;;;;;AAEtC,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;;;;AA+BA,SAAa,oBAAA;CACX,MAAA,WAAgB,cAA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AAA;IACnB,UAAM;IACN,SAAM;IACN,MAAM;IACN,aAAM,IAAW;GACnB,CAAC;GAAG,gBAAiB,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACnB,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAM,IAAW;GACnB,CAAC;GAAG,gBAAe,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACjB,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAM,IAAA;GACR,CAAC;GAAG,gBAAY,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACd,UAAU;IACV,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAa,IAAA;GACf,CAAC;GAAG,gBAAE,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACL,UAAA;IACA,SAAS;;IAET,KAAM;IACL,aAAa,IAAA;GACf,CAAC;GAAG,gBAAkB,SAAI,CAAA,CAAA;GAAU,gBAAiB,MAAA;IACnD,IAAI,OAAE;KACJ,OAAI,QAAK,QAAA;IACX;IACG;GACL,CAAC;EAAC;CACJ,EACF,CAAC,CAAC;AACJ;AACA,WAAQ,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;AAAA"}
|
package/dist/helpers/schema.cjs
CHANGED
|
@@ -12,12 +12,6 @@ let defu = require("defu");
|
|
|
12
12
|
defu = require_runtime.__toESM(defu, 1);
|
|
13
13
|
|
|
14
14
|
//#region src/helpers/schema.ts
|
|
15
|
-
const __ΩRecord = [
|
|
16
|
-
"K",
|
|
17
|
-
"T",
|
|
18
|
-
"Record",
|
|
19
|
-
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
20
|
-
];
|
|
21
15
|
function __assignType(fn, args) {
|
|
22
16
|
fn.__type = args;
|
|
23
17
|
return fn;
|
|
@@ -100,7 +94,7 @@ getCacheFilePath.__type = [
|
|
|
100
94
|
"P\"2!P.\".#J2$&/%"
|
|
101
95
|
];
|
|
102
96
|
async function writeActive(context, variant, schema) {
|
|
103
|
-
if (!(
|
|
97
|
+
if (!(0, _powerlines_schema.isSchema)(schema)) throw new Error(`The provided input is not a valid env schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
|
|
104
98
|
await context.fs.write(getCacheFilePath(context, variant), JSON.stringify(schema.schema));
|
|
105
99
|
}
|
|
106
100
|
writeActive.__type = [
|
|
@@ -139,12 +133,12 @@ readActive.__type = [
|
|
|
139
133
|
async function extractEnv(context) {
|
|
140
134
|
const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
|
|
141
135
|
const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
|
|
142
|
-
const config = await (
|
|
136
|
+
const config = await (0, _powerlines_schema.extract)(context, context.config.env.config);
|
|
143
137
|
config.active = await readActive(context, "config");
|
|
144
|
-
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.config) && context.config.env.config !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.config) && (context.config.env.config.file !== defaultVarsTypeDefinition.file || context.config.env.config.name !== defaultVarsTypeDefinition.name)) config.schema = (
|
|
145
|
-
const secrets = await (
|
|
138
|
+
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.config) && context.config.env.config !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.config) && (context.config.env.config.file !== defaultVarsTypeDefinition.file || context.config.env.config.name !== defaultVarsTypeDefinition.name)) config.schema = (0, _powerlines_schema.mergeSchemas)(config, await (0, _powerlines_schema.extract)(context, defaultVarsTypeDefinition));
|
|
139
|
+
const secrets = await (0, _powerlines_schema.extract)(context, context.config.env.secrets);
|
|
146
140
|
secrets.active = await readActive(context, "secrets");
|
|
147
|
-
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = (
|
|
141
|
+
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = (0, _powerlines_schema.mergeSchemas)(secrets, await (0, _powerlines_schema.extract)(context, defaultSecretsTypeDefinition));
|
|
148
142
|
context.env = (0, defu.default)({
|
|
149
143
|
config,
|
|
150
144
|
secrets,
|
|
@@ -188,13 +182,13 @@ async function extractEnv(context) {
|
|
|
188
182
|
]), key);
|
|
189
183
|
if (properties[unprefixedKey]) {
|
|
190
184
|
if (!properties[unprefixedKey]?.runtime) {
|
|
191
|
-
const propertySchema = context.env.config.schema
|
|
185
|
+
const propertySchema = (0, _powerlines_schema.getProperties)(context.env.config.schema)?.[unprefixedKey];
|
|
192
186
|
if (propertySchema) propertySchema.default = value;
|
|
193
187
|
}
|
|
194
188
|
} else if (aliases[unprefixedKey]) {
|
|
195
189
|
if (!aliases[unprefixedKey]?.runtime) {
|
|
196
190
|
const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;
|
|
197
|
-
const aliasSchema = context.env.config.schema
|
|
191
|
+
const aliasSchema = (0, _powerlines_schema.getProperties)(context.env.config.schema)?.[alias];
|
|
198
192
|
if (aliasSchema) aliasSchema.default = value;
|
|
199
193
|
}
|
|
200
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AA6CA;;;;iBAAsB,sBAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA;;;;;;;iBAiBA,4BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;AAnBD;AAiB7B;;iBAcsB,+BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;;;;;iBAad,iBAAA,kBAAmC,gBAAA,CAAA,CACjD,OAAA,EAAS,QAAQ;AAAA,iBAKH,gBAAA,kBAAkC,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAQ,EACjB,OAAA;;;;;;AAnC0C;AAY5C;;;iBAsEsB,UAAA,kBAA4B,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAA,GACR,OAAA;;;;;;;iBAmKmB,QAAA,kBAA0B,gBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AA6CA;;;;iBAAsB,sBAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA;;;;;;;iBAiBA,4BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;AAnBD;AAiB7B;;iBAcsB,+BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;;;;;iBAad,iBAAA,kBAAmC,gBAAA,CAAA,CACjD,OAAA,EAAS,QAAQ;AAAA,iBAKH,gBAAA,kBAAkC,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAQ,EACjB,OAAA;;;;;;AAnC0C;AAY5C;;;iBAsEsB,UAAA,kBAA4B,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAA,GACR,OAAA;;;;;;;iBAmKmB,QAAA,kBAA0B,gBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,OAAA"}
|
package/dist/helpers/schema.mjs
CHANGED
|
@@ -9,12 +9,6 @@ import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
|
9
9
|
import defu from "defu";
|
|
10
10
|
|
|
11
11
|
//#region src/helpers/schema.ts
|
|
12
|
-
const __ΩRecord = [
|
|
13
|
-
"K",
|
|
14
|
-
"T",
|
|
15
|
-
"Record",
|
|
16
|
-
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
17
|
-
];
|
|
18
12
|
function __assignType(fn, args) {
|
|
19
13
|
fn.__type = args;
|
|
20
14
|
return fn;
|
|
@@ -97,7 +91,7 @@ getCacheFilePath.__type = [
|
|
|
97
91
|
"P\"2!P.\".#J2$&/%"
|
|
98
92
|
];
|
|
99
93
|
async function writeActive(context, variant, schema) {
|
|
100
|
-
if (!
|
|
94
|
+
if (!isSchema(schema)) throw new Error(`The provided input is not a valid env schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
|
|
101
95
|
await context.fs.write(getCacheFilePath(context, variant), JSON.stringify(schema.schema));
|
|
102
96
|
}
|
|
103
97
|
writeActive.__type = [
|
|
@@ -136,12 +130,12 @@ readActive.__type = [
|
|
|
136
130
|
async function extractEnv(context) {
|
|
137
131
|
const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
|
|
138
132
|
const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
|
|
139
|
-
const config = await
|
|
133
|
+
const config = await extract(context, context.config.env.config);
|
|
140
134
|
config.active = await readActive(context, "config");
|
|
141
|
-
if (isString(context.config.env.config) && context.config.env.config !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || isSetObject(context.config.env.config) && (context.config.env.config.file !== defaultVarsTypeDefinition.file || context.config.env.config.name !== defaultVarsTypeDefinition.name)) config.schema =
|
|
142
|
-
const secrets = await
|
|
135
|
+
if (isString(context.config.env.config) && context.config.env.config !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || isSetObject(context.config.env.config) && (context.config.env.config.file !== defaultVarsTypeDefinition.file || context.config.env.config.name !== defaultVarsTypeDefinition.name)) config.schema = mergeSchemas(config, await extract(context, defaultVarsTypeDefinition));
|
|
136
|
+
const secrets = await extract(context, context.config.env.secrets);
|
|
143
137
|
secrets.active = await readActive(context, "secrets");
|
|
144
|
-
if (isString(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || isSetObject(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema =
|
|
138
|
+
if (isString(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || isSetObject(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = mergeSchemas(secrets, await extract(context, defaultSecretsTypeDefinition));
|
|
145
139
|
context.env = defu({
|
|
146
140
|
config,
|
|
147
141
|
secrets,
|
|
@@ -185,13 +179,13 @@ async function extractEnv(context) {
|
|
|
185
179
|
]), key);
|
|
186
180
|
if (properties[unprefixedKey]) {
|
|
187
181
|
if (!properties[unprefixedKey]?.runtime) {
|
|
188
|
-
const propertySchema = context.env.config.schema
|
|
182
|
+
const propertySchema = getProperties(context.env.config.schema)?.[unprefixedKey];
|
|
189
183
|
if (propertySchema) propertySchema.default = value;
|
|
190
184
|
}
|
|
191
185
|
} else if (aliases[unprefixedKey]) {
|
|
192
186
|
if (!aliases[unprefixedKey]?.runtime) {
|
|
193
187
|
const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;
|
|
194
|
-
const aliasSchema = context.env.config.schema
|
|
188
|
+
const aliasSchema = getProperties(context.env.config.schema)?.[alias];
|
|
195
189
|
if (aliasSchema) aliasSchema.default = value;
|
|
196
190
|
}
|
|
197
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.mjs","names":[],"sources":["../../src/helpers/schema.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 {\n extract,\n getProperties,\n getPropertiesList,\n isSchema,\n mergeSchemas,\n Schema,\n writeSchema\n} from \"@powerlines/schema\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { UnresolvedContext } from \"powerlines\";\nimport { EnvPluginContext, EnvSchema } from \"../types/plugin\";\nimport { loadEnv } from \"./load\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<string> {\n const resolved = await context.fs.resolve(\"@powerlines/plugin-env/types/env\");\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getDefaultVarsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getDefaultSecretsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.\n *\n * @param context - The context object providing access to the cache path.\n * @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the \"schemas\" subdirectory.\n */\nexport function getCacheDirectory<TContext extends EnvPluginContext>(\n context: TContext\n): string {\n return joinPaths(context.cachePath, \"env\");\n}\n\nexport function getCacheFilePath<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): string {\n return joinPaths(getCacheDirectory(context), `${variant}.json`);\n}\n\nasync function writeActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\",\n schema: EnvSchema\n) {\n if (!isSchema<EnvSchema>(schema)) {\n throw new Error(\n `The provided input is not a valid env schema. A valid schema must have a \"variant\" property indicating the type of the input and a \"schema\" property containing the parsed JSON Schema object.`\n );\n }\n\n await context.fs.write(\n getCacheFilePath(context, variant),\n JSON.stringify(schema.schema)\n );\n}\n\nasync function readActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): Promise<string[]> {\n if (!context.fs.existsSync(getCacheFilePath(context, variant))) {\n return [];\n }\n\n const data = await context.fs.read(getCacheFilePath(context, variant));\n if (!data) {\n return [];\n }\n\n return JSON.parse(data);\n}\n\n/**\n * Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.\n *\n * @remarks\n * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void> {\n const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);\n const defaultSecretsTypeDefinition =\n await getDefaultSecretsTypeDefinition(context);\n\n const config = (await extract<Record<string, any>>(\n context,\n context.config.env.config\n )) as EnvSchema;\n config.active = await readActive(context, \"config\");\n\n if (\n (isString(context.config.env.config) &&\n context.config.env.config !==\n `${defaultVarsTypeDefinition.file}#${\n defaultVarsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.config) &&\n ((context.config.env.config as TypeDefinition).file !==\n defaultVarsTypeDefinition.file ||\n (context.config.env.config as TypeDefinition).name !==\n defaultVarsTypeDefinition.name))\n ) {\n config.schema = mergeSchemas<Record<string, any>>(\n config,\n await extract<Record<string, any>>(context, defaultVarsTypeDefinition)\n );\n }\n\n const secrets = (await extract<Record<string, any>>(\n context,\n context.config.env.secrets\n )) as EnvSchema;\n secrets.active = await readActive(context, \"secrets\");\n\n if (\n (isString(context.config.env.secrets) &&\n context.config.env.secrets !==\n `${defaultSecretsTypeDefinition.file}#${\n defaultSecretsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.secrets) &&\n ((context.config.env.secrets as TypeDefinition).file !==\n defaultSecretsTypeDefinition.file ||\n (context.config.env.secrets as TypeDefinition).name !==\n defaultSecretsTypeDefinition.name))\n ) {\n secrets.schema = mergeSchemas<Record<string, any>>(\n secrets,\n await extract<Record<string, any>>(context, defaultSecretsTypeDefinition)\n );\n }\n\n context.env = defu(\n {\n config,\n secrets,\n parsed: await loadEnv(context, context.config.env)\n },\n context.env ?? {},\n {\n active: [],\n parsed: {},\n injected: []\n }\n );\n\n const properties = getProperties(context.env.config);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.config ? \"\" : \"Defaulted \"\n }${\n context.env.config.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.config.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.config.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.config.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${context.config.env.config ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n context.config.env.secrets ? \"\" : \"Defaulted \"\n }${\n context.env.secrets.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.secrets.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.secrets.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.secrets.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${context.config.env.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? getPropertiesList(context.env.secrets).length\n : \"0\"\n } parameters\\nEnvironment variable Prefixes: ${context.config.env.prefix.join(\n \", \"\n )}\\nShould inject values: ${\n context.config.env.inject ? \"Yes\" : \"No\"\n }\\nShould validate configuration: ${\n context.config.env.validate ? \"Yes\" : \"No\"\n }`\n });\n\n const aliases = Object.fromEntries(\n Object.entries(properties).flatMap(\n ([key, prop]) =>\n (isSetArray(prop.alias)\n ? prop.alias?.map(alias => [\n alias,\n {\n ...prop,\n name: alias,\n alias: [...(prop.alias?.filter(a => a !== alias) ?? []), key]\n }\n ])\n : []) as [string, typeof prop][]\n )\n );\n\n for (const [key, value] of Object.entries(\n await loadEnv(context, context.config.env)\n )) {\n const unprefixedKey = context.config.env.prefix.reduce((ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n }, key);\n if (properties[unprefixedKey]) {\n if (!properties[unprefixedKey]?.runtime) {\n const propertySchema =\n context.env.config.schema.properties?.[unprefixedKey];\n if (propertySchema) {\n propertySchema.default = value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey]?.runtime) {\n const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;\n const aliasSchema = context.env.config.schema.properties?.[alias];\n if (aliasSchema) {\n aliasSchema.default = value;\n }\n }\n }\n }\n}\n\n/**\n * Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.\n *\n * @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.\n * @returns A promise that resolves when the schema has been successfully written to the cache directory.\n */\nexport async function writeEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void[]> {\n return Promise.all([\n writeSchema(context, omit(context.env.config, [\"active\"]) as Schema),\n writeSchema(context, omit(context.env.secrets, [\"active\"]) as Schema),\n writeActive(context, \"config\", context.env.config),\n writeActive(context, \"secrets\", context.env.secrets)\n ]);\n}\n"],"mappings":";;;;;;;;;;;AAAA,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;AAAwB;;CAI9D,GAAI,SAAS;CACb,OAAG;AACJ;;;;;;;AAgCA,eAAE,uBAAA,SAAA;CACA,MAAC,WAAa,MAAQ,QAAK,GAAA,QAAe,kCAA8B;CACzE,IAAA,CAAA,UACG,MAAM,IAAA,MAAU,yJAAkB;CAEpC,OAAA;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AAQ,IAAC,OAAQ,OAAA,cAAiB,KAAA,WAAA;GACjE,IAAQ,IAAC,QAAA,OAAA,EAAA,EAAA,WAAA,MAAA,GACR,OAAY,IAAE,QAAA,OAAA,EAAA,EAAA,MAAA,OAAA,MAAA;GAEf,OAAM;EACJ,GAAA;GAAA;GAAM;GAAA;GAAA;EAA+B,CAAC,GAAA,GAAA;iCAExC;OAAM,CAAA,WAAU,gBAAoB,SAAS;IAC3C,MAAO,iBAAA,QAAA,IAAA,OAAA,OAAA,aAAA;IACP,IAAQ,gBACJ,eAAS,UAAA;;SAGZ,IAAA,QAAA,gBACA;OAAA,CAAA,QAAS,gBAAmB,SAAS;IACpC,MAAQ,QAAO,QAAI,gBAAS,QAAA,MAAA;IAC1B,MAAG,cAAA,QAAyB,IAAC,OAAO,OAAA,aAAA;IACpC,IAAE,aACA,YAAG,UAAA;GAEP;;CAEJ;AACF;AACA,WAAI,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;AAOJ,eAAmB,SAAM,SAAe;CACtC,OAAE,QAAO,IAAA;EAAA,YAAA,SAAA,KAAA,QAAA,IAAA,QAAA,CAAA,QAAA,CAAA,CAAA;EAAA,YAAA,SAAA,KAAA,QAAA,IAAA,SAAA,CAAA,QAAA,CAAA,CAAA;EAAA,YAAA,SAAA,UAAA,QAAA,IAAA,MAAA;EAAA,YAAA,SAAA,WAAA,QAAA,IAAA,OAAA;CAAA,CAAA;AACX;AACA,SAAQ,SAAS;CAAA;CAAA;CAAA;CAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"schema.mjs","names":[],"sources":["../../src/helpers/schema.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 {\n extract,\n getProperties,\n getPropertiesList,\n isSchema,\n JsonSchemaObject,\n mergeSchemas,\n Schema,\n writeSchema\n} from \"@powerlines/schema\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { UnresolvedContext } from \"powerlines\";\nimport { EnvPluginContext, EnvSchema } from \"../types/plugin\";\nimport { loadEnv } from \"./load\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<string> {\n const resolved = await context.fs.resolve(\"@powerlines/plugin-env/types/env\");\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getDefaultVarsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getDefaultSecretsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.\n *\n * @param context - The context object providing access to the cache path.\n * @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the \"schemas\" subdirectory.\n */\nexport function getCacheDirectory<TContext extends EnvPluginContext>(\n context: TContext\n): string {\n return joinPaths(context.cachePath, \"env\");\n}\n\nexport function getCacheFilePath<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): string {\n return joinPaths(getCacheDirectory(context), `${variant}.json`);\n}\n\nasync function writeActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\",\n schema: EnvSchema\n) {\n if (!isSchema(schema)) {\n throw new Error(\n `The provided input is not a valid env schema. A valid schema must have a \"variant\" property indicating the type of the input and a \"schema\" property containing the parsed JSON Schema object.`\n );\n }\n\n await context.fs.write(\n getCacheFilePath(context, variant),\n JSON.stringify(schema.schema)\n );\n}\n\nasync function readActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): Promise<string[]> {\n if (!context.fs.existsSync(getCacheFilePath(context, variant))) {\n return [];\n }\n\n const data = await context.fs.read(getCacheFilePath(context, variant));\n if (!data) {\n return [];\n }\n\n return JSON.parse(data);\n}\n\n/**\n * Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.\n *\n * @remarks\n * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void> {\n const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);\n const defaultSecretsTypeDefinition =\n await getDefaultSecretsTypeDefinition(context);\n\n const config = (await extract(\n context,\n context.config.env.config\n )) as EnvSchema;\n config.active = await readActive(context, \"config\");\n\n if (\n (isString(context.config.env.config) &&\n context.config.env.config !==\n `${defaultVarsTypeDefinition.file}#${\n defaultVarsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.config) &&\n ((context.config.env.config as TypeDefinition).file !==\n defaultVarsTypeDefinition.file ||\n (context.config.env.config as TypeDefinition).name !==\n defaultVarsTypeDefinition.name))\n ) {\n config.schema = mergeSchemas(\n config,\n await extract(context, defaultVarsTypeDefinition)\n ) as JsonSchemaObject;\n }\n\n const secrets = (await extract(\n context,\n context.config.env.secrets\n )) as EnvSchema;\n secrets.active = await readActive(context, \"secrets\");\n\n if (\n (isString(context.config.env.secrets) &&\n context.config.env.secrets !==\n `${defaultSecretsTypeDefinition.file}#${\n defaultSecretsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.secrets) &&\n ((context.config.env.secrets as TypeDefinition).file !==\n defaultSecretsTypeDefinition.file ||\n (context.config.env.secrets as TypeDefinition).name !==\n defaultSecretsTypeDefinition.name))\n ) {\n secrets.schema = mergeSchemas(\n secrets,\n await extract(context, defaultSecretsTypeDefinition)\n ) as JsonSchemaObject;\n }\n\n context.env = defu(\n {\n config,\n secrets,\n parsed: await loadEnv(context, context.config.env)\n },\n context.env ?? {},\n {\n active: [],\n parsed: {},\n injected: []\n }\n );\n\n const properties = getProperties(context.env.config);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.config ? \"\" : \"Defaulted \"\n }${\n context.env.config.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.config.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.config.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.config.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${context.config.env.config ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n context.config.env.secrets ? \"\" : \"Defaulted \"\n }${\n context.env.secrets.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.secrets.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.secrets.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.secrets.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${context.config.env.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? getPropertiesList(context.env.secrets).length\n : \"0\"\n } parameters\\nEnvironment variable Prefixes: ${context.config.env.prefix.join(\n \", \"\n )}\\nShould inject values: ${\n context.config.env.inject ? \"Yes\" : \"No\"\n }\\nShould validate configuration: ${\n context.config.env.validate ? \"Yes\" : \"No\"\n }`\n });\n\n const aliases = Object.fromEntries(\n Object.entries(properties).flatMap(\n ([key, prop]) =>\n (isSetArray(prop.alias)\n ? prop.alias?.map(alias => [\n alias,\n {\n ...prop,\n name: alias,\n alias: [...(prop.alias?.filter(a => a !== alias) ?? []), key]\n }\n ])\n : []) as [string, typeof prop][]\n )\n );\n\n for (const [key, value] of Object.entries(\n await loadEnv(context, context.config.env)\n )) {\n const unprefixedKey = context.config.env.prefix.reduce((ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n }, key);\n if (properties[unprefixedKey]) {\n if (!properties[unprefixedKey]?.runtime) {\n const propertySchema = getProperties(context.env.config.schema)?.[\n unprefixedKey\n ];\n if (propertySchema) {\n propertySchema.default = value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey]?.runtime) {\n const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;\n const aliasSchema = getProperties(context.env.config.schema)?.[alias];\n if (aliasSchema) {\n aliasSchema.default = value;\n }\n }\n }\n }\n}\n\n/**\n * Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.\n *\n * @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.\n * @returns A promise that resolves when the schema has been successfully written to the cache directory.\n */\nexport async function writeEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void[]> {\n return Promise.all([\n writeSchema(context, omit(context.env.config, [\"active\"]) as Schema),\n writeSchema(context, omit(context.env.secrets, [\"active\"]) as Schema),\n writeActive(context, \"config\", context.env.config),\n writeActive(context, \"secrets\", context.env.secrets)\n ]);\n}\n"],"mappings":";;;;;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;;;;;;;AAgCA,eAAmB,uBAAa,SAAA;;CAE9B,IAAA,CAAA,UACC,MAAA,IAAS,MAAI,yJAA0D;CAExE,OAAO;AACT;AACA,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;AAOF,eAAiB,6BAAyB,SAAgB;CACxD,OAAG;EACH,MAAA,MAAA,uBAAA,OAAA;;CAEA;AACF;;;;;;;;;;;;AAOA,eAAE,gCAAA,SAAA;CACF,OAAO;EACL,MAAQ,MAAC,uBAAQ,OAAA;EACjB,MAAQ;CACR;AACF;AACA,gCAAuB,SAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;AAOvB,SAAgB,kBAAa,SAAc;CACzC,OAAA,UAAA,QAAA,WAAA,KAAA;AACF;AACA,kBAAkB,SAAC;CAAA;CAAA;CAAA;CAAA;AAAA;AACnB,SAAW,iBAAmB,SAAA,SAAgB;CAC5C,OAAO,UAAA,kBAAA,OAAA,GAAA,GAAA,QAAA,MAAA;AACT;AACA,iBAAW,SAAA;CAAgB;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAC3B,eAAG,YAAA,SAAA,SAAA,QAAA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eAAE,SAAA,SAAA;;;;;;;AAEF;AACA,SAAI,SAAO;CAAA;CAAA;CAAA;CAAA;AAAA"}
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
2
|
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
3
3
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
4
|
-
import { Schema, SchemaInput } from "@powerlines/schema";
|
|
4
|
+
import { JsonSchemaObject, Schema, SchemaInput } from "@powerlines/schema";
|
|
5
5
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
6
6
|
import { RequiredKeys } from "@stryke/types";
|
|
7
7
|
import { DotenvConfiguration } from "@stryke/types/configuration";
|
|
@@ -92,7 +92,7 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
|
92
92
|
* @remarks
|
|
93
93
|
* This schema is the result of parsing the type definitions provided in the {@link EnvPluginOptions.config} and {@link EnvPluginOptions.secrets} options, and is used to validate the loaded environment variables and secrets, as well as to determine which variables should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.
|
|
94
94
|
*/
|
|
95
|
-
type EnvSchema = Schema<
|
|
95
|
+
type EnvSchema = Schema<JsonSchemaObject> & {
|
|
96
96
|
/**
|
|
97
97
|
* The list of active environment variables or secrets that should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled. This list is determined by filtering the properties defined in the schema based on the provided prefix and any additional filtering criteria defined in the type definition, such as an `active` property.
|
|
98
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;KA+BY,OAAA;AAAA,KAEA,gBAAA,GAAmB,IAAA,CAAK,mBAAA;EAFxB;;;EAMV,MAAA,GAAS,WAAA;EANQ;AAEnB;;EASE,OAAA,GAA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;;;;;;;KAUM,SAAA,GAAY,MAAM,CAAC,gBAAA;EAYrB;;;;;;EALR,MAAA;AAAA;AAAA,UAGe,gBAAA,yBACS,uBAAA,GAA0B,uBAAA,UAC1C,kBAAA,CAAmB,eAAA;EAC3B,GAAA;IAOU;;;;;;IAAR,MAAA,EAAQ,SAAA;IAwBA;;;;;;IAhBR,OAAA,EAAS,SAAA;;;;;;;IAQT,MAAA,EAAQ,iBAAA;;;;;;;IAQR,QAAA;EAAA;AAAA"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
2
|
-
import { Schema, SchemaInput } from "@powerlines/schema";
|
|
2
|
+
import { JsonSchemaObject, Schema, SchemaInput } from "@powerlines/schema";
|
|
3
3
|
import { Children } from "@alloy-js/core";
|
|
4
4
|
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
5
5
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
@@ -92,7 +92,7 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
|
92
92
|
* @remarks
|
|
93
93
|
* This schema is the result of parsing the type definitions provided in the {@link EnvPluginOptions.config} and {@link EnvPluginOptions.secrets} options, and is used to validate the loaded environment variables and secrets, as well as to determine which variables should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.
|
|
94
94
|
*/
|
|
95
|
-
type EnvSchema = Schema<
|
|
95
|
+
type EnvSchema = Schema<JsonSchemaObject> & {
|
|
96
96
|
/**
|
|
97
97
|
* The list of active environment variables or secrets that should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled. This list is determined by filtering the properties defined in the schema based on the provided prefix and any additional filtering criteria defined in the type definition, such as an `active` property.
|
|
98
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/pl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,IAAA,CAAK,mBAAA,wBACjB,YAAA,CAAa,gBAAA;IAFqB;;;;;;IAShC,MAAA;IAAA;;;;AAgBM;AAUZ;IAlBM,QAAA;IAkByB;;;;;;IAVzB,MAAA;EAAA;AAAA;;;;;;;KAUM,SAAA,GAAY,MAAM,CAAC,gBAAA;EAYrB;;;;;;EALR,MAAA;AAAA;AAAA,UAGe,gBAAA,yBACS,uBAAA,GAA0B,uBAAA,UAC1C,kBAAA,CAAmB,eAAA;EAC3B,GAAA;IAOU;;;;;;IAAR,MAAA,EAAQ,SAAA;IAwBA;;;;;;IAhBR,OAAA,EAAS,SAAA;;;;;;;IAQT,MAAA,EAAQ,iBAAA;;;;;;;IAQR,QAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/types/plugin.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 { Children } from \"@alloy-js/core\";\nimport { AutoMDPluginOptions } from \"@powerlines/plugin-automd/types/plugin\";\nimport {\n BabelPluginContext,\n BabelPluginOptions,\n BabelPluginResolvedConfig,\n BabelPluginUserConfig\n} from \"@powerlines/plugin-babel/types\";\nimport type { Schema, SchemaInput } from \"@powerlines/schema\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { RequiredKeys } from \"@stryke/types\";\nimport { DotenvConfiguration } from \"@stryke/types/configuration\";\n\nexport type EnvType = \"env\" | \"secrets\";\n\nexport type EnvPluginOptions = Omit<DotenvConfiguration, \"types\"> & {\n /**\n * A path to the type definition for the expected env configuration parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `\":\"` or `\"#\"` character. For example: `\"./src/types/env.ts#ConfigConfiguration\"`.\n */\n config?: SchemaInput;\n\n /**\n * A path to the type definition for the expected env secret parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `\":\"` or `\"#\"` character. For example: `\"./src/types/env.ts#ConfigSecrets\"`.\n */\n secrets?: SchemaInput;\n\n /**\n * An additional prefix (or list of additional prefixes) to apply to the environment variables\n *\n * @remarks\n * By default, the plugin will use the `POWERLINES_` prefix. This option is useful for avoiding conflicts with other environment variables.\n */\n prefix?: string | string[];\n\n /**\n * Should the plugin inject the env variables in the source code with their values?\n *\n * @defaultValue false\n */\n inject?: boolean;\n\n /**\n * Should the plugin validate the loaded environment variables against the provided type definitions?\n *\n * @defaultValue false\n */\n validate?: boolean;\n\n /**\n * The default configuration to use when loading environment variables.\n *\n * @remarks\n * This configuration is used as the base configuration when loading environment variables, and will be overridden by any values found in the `.env` file or the process environment.\n */\n defaultConfig?: Children;\n\n /**\n * Babel configuration options to use when injecting environment variables into the source code.\n *\n * @remarks\n * This option allows you to customize the Babel transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Babel settings.\n */\n babel?: BabelPluginOptions;\n\n /**\n * AutoMD configuration options to allow injecting environment variables documentation into a markdown file such as a README.md.\n *\n * @remarks\n * The README.md file should contain the `<!-- automd:env --><!-- /automd -->` comment block where the documentation will be injected.\n */\n automd?: AutoMDPluginOptions;\n};\n\nexport type EnvPluginUserConfig = BabelPluginUserConfig & {\n env: EnvPluginOptions;\n};\n\nexport type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {\n env: Required<Pick<DotenvConfiguration, \"additionalFiles\">> &\n RequiredKeys<EnvPluginOptions, \"config\" | \"secrets\" | \"defaultConfig\"> & {\n /**\n * Should the plugin inject the env variables in the source code with their values?\n *\n * @remarks\n * This value is the result of reflecting the {@link EnvPluginOptions.inject} option.\n */\n inject: boolean;\n\n /**\n * Should the plugin validate the loaded environment variables against the provided type definitions?\n *\n * @remarks\n * This value is the result of reflecting the {@link EnvPluginOptions.validate} option.\n */\n validate: boolean;\n\n /**\n * The prefix used for environment variables\n *\n * @remarks\n * This value is used to filter environment variables that are loaded from the .env file and the process environment.\n */\n prefix: string[];\n };\n};\n\n/**\n * The schema for environment variables and secrets used by the plugin.\n *\n * @remarks\n * This schema is the result of parsing the type definitions provided in the {@link EnvPluginOptions.config} and {@link EnvPluginOptions.secrets} options, and is used to validate the loaded environment variables and secrets, as well as to determine which variables should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.\n */\nexport type EnvSchema = Schema<
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/types/plugin.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 { Children } from \"@alloy-js/core\";\nimport { AutoMDPluginOptions } from \"@powerlines/plugin-automd/types/plugin\";\nimport {\n BabelPluginContext,\n BabelPluginOptions,\n BabelPluginResolvedConfig,\n BabelPluginUserConfig\n} from \"@powerlines/plugin-babel/types\";\nimport type { JsonSchemaObject, Schema, SchemaInput } from \"@powerlines/schema\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { RequiredKeys } from \"@stryke/types\";\nimport { DotenvConfiguration } from \"@stryke/types/configuration\";\n\nexport type EnvType = \"env\" | \"secrets\";\n\nexport type EnvPluginOptions = Omit<DotenvConfiguration, \"types\"> & {\n /**\n * A path to the type definition for the expected env configuration parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `\":\"` or `\"#\"` character. For example: `\"./src/types/env.ts#ConfigConfiguration\"`.\n */\n config?: SchemaInput;\n\n /**\n * A path to the type definition for the expected env secret parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `\":\"` or `\"#\"` character. For example: `\"./src/types/env.ts#ConfigSecrets\"`.\n */\n secrets?: SchemaInput;\n\n /**\n * An additional prefix (or list of additional prefixes) to apply to the environment variables\n *\n * @remarks\n * By default, the plugin will use the `POWERLINES_` prefix. This option is useful for avoiding conflicts with other environment variables.\n */\n prefix?: string | string[];\n\n /**\n * Should the plugin inject the env variables in the source code with their values?\n *\n * @defaultValue false\n */\n inject?: boolean;\n\n /**\n * Should the plugin validate the loaded environment variables against the provided type definitions?\n *\n * @defaultValue false\n */\n validate?: boolean;\n\n /**\n * The default configuration to use when loading environment variables.\n *\n * @remarks\n * This configuration is used as the base configuration when loading environment variables, and will be overridden by any values found in the `.env` file or the process environment.\n */\n defaultConfig?: Children;\n\n /**\n * Babel configuration options to use when injecting environment variables into the source code.\n *\n * @remarks\n * This option allows you to customize the Babel transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Babel settings.\n */\n babel?: BabelPluginOptions;\n\n /**\n * AutoMD configuration options to allow injecting environment variables documentation into a markdown file such as a README.md.\n *\n * @remarks\n * The README.md file should contain the `<!-- automd:env --><!-- /automd -->` comment block where the documentation will be injected.\n */\n automd?: AutoMDPluginOptions;\n};\n\nexport type EnvPluginUserConfig = BabelPluginUserConfig & {\n env: EnvPluginOptions;\n};\n\nexport type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {\n env: Required<Pick<DotenvConfiguration, \"additionalFiles\">> &\n RequiredKeys<EnvPluginOptions, \"config\" | \"secrets\" | \"defaultConfig\"> & {\n /**\n * Should the plugin inject the env variables in the source code with their values?\n *\n * @remarks\n * This value is the result of reflecting the {@link EnvPluginOptions.inject} option.\n */\n inject: boolean;\n\n /**\n * Should the plugin validate the loaded environment variables against the provided type definitions?\n *\n * @remarks\n * This value is the result of reflecting the {@link EnvPluginOptions.validate} option.\n */\n validate: boolean;\n\n /**\n * The prefix used for environment variables\n *\n * @remarks\n * This value is used to filter environment variables that are loaded from the .env file and the process environment.\n */\n prefix: string[];\n };\n};\n\n/**\n * The schema for environment variables and secrets used by the plugin.\n *\n * @remarks\n * This schema is the result of parsing the type definitions provided in the {@link EnvPluginOptions.config} and {@link EnvPluginOptions.secrets} options, and is used to validate the loaded environment variables and secrets, as well as to determine which variables should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.\n */\nexport type EnvSchema = Schema<JsonSchemaObject> & {\n /**\n * The list of active environment variables or secrets that should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled. This list is determined by filtering the properties defined in the schema based on the provided prefix and any additional filtering criteria defined in the type definition, such as an `active` property.\n *\n * @remarks\n * If the type definition includes an `active` property for each environment variable or secret, this list will be determined by including only the variables or secrets that have `active` set to `true`. If the type definition does not include an `active` property, all variables or secrets defined in the schema that match the provided prefix will be included in this list.\n */\n active: string[];\n};\n\nexport interface EnvPluginContext<\n TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig\n> extends BabelPluginContext<TResolvedConfig> {\n env: {\n /**\n * The type definition for the expected env variable parameters\n *\n * @remarks\n * This value is parsed from the {@link EnvPluginOptions.config} option.\n */\n config: EnvSchema;\n\n /**\n * The type definition for the expected env secret parameters\n *\n * @remarks\n * This value is parsed from the {@link EnvPluginOptions.secrets} option.\n */\n secrets: EnvSchema;\n\n /**\n * The parsed .env configuration object\n *\n * @remarks\n * This value is the result of loading the .env configuration file found in the project root directory and merging it with the values provided at {@link EnvPluginOptions.values}\n */\n parsed: DotenvParseOutput;\n\n /**\n * The injected environment variables and secrets reflection\n *\n * @remarks\n * This reflection contains the structure of the injected environment variables and secrets that were injected into the source code during the build process.\n */\n injected: string[];\n };\n}\n"],"mappings":";AAAA,MAAM,UAAU;CAAC;CAAK;OAAW;OAAe;CAAY;CAAQ;AAAC;;;;;;AAErE,MAAM,UAAU;CAAC;CAAI;CAAM;CAAQ;AAAG;;;;;;;AAEtC,MAAM,aAAS;CAAA;CAAY;CAAW;CAAW;AAAU;AAE3D,MAAM,sBAAmB;OAAQ;CAAS;CAAK;CAAa;CAAO;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;AAInE,MAAC,6BAAkC;OAAO;OAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAE7D,MAAC,eAAoB;CAAC;CAAU;CAAqB;CAAA;AAAA;AAErD,MAAM,sBAAqB;OAAQ;CAAC;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-env",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.262",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Powerlines plugin for injecting static .env configuration values to the code so that they're accessible at runtime.",
|
|
6
6
|
"keywords": ["dotenv", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -107,12 +107,12 @@
|
|
|
107
107
|
"@alloy-js/typescript": "^0.23.0",
|
|
108
108
|
"@babel/core": "8.0.0-rc.5",
|
|
109
109
|
"@babel/types": "8.0.0-rc.5",
|
|
110
|
-
"@powerlines/core": "
|
|
111
|
-
"@powerlines/plugin-alloy": "0.26.
|
|
112
|
-
"@powerlines/plugin-automd": "
|
|
113
|
-
"@powerlines/plugin-babel": "
|
|
114
|
-
"@powerlines/plugin-plugin": "
|
|
115
|
-
"@powerlines/schema": "0.11.
|
|
110
|
+
"@powerlines/core": "0.48.8",
|
|
111
|
+
"@powerlines/plugin-alloy": "0.26.152",
|
|
112
|
+
"@powerlines/plugin-automd": "0.1.525",
|
|
113
|
+
"@powerlines/plugin-babel": "0.13.60",
|
|
114
|
+
"@powerlines/plugin-plugin": "0.12.476",
|
|
115
|
+
"@powerlines/schema": "0.11.47",
|
|
116
116
|
"@storm-software/config-tools": "^1.190.29",
|
|
117
117
|
"@stryke/capnp": "^0.12.102",
|
|
118
118
|
"@stryke/convert": "^0.7.7",
|
|
@@ -127,9 +127,9 @@
|
|
|
127
127
|
"automd": "^0.4.3",
|
|
128
128
|
"c12": "^3.3.4",
|
|
129
129
|
"defu": "^6.1.7",
|
|
130
|
-
"powerlines": "
|
|
130
|
+
"powerlines": "0.47.64"
|
|
131
131
|
},
|
|
132
132
|
"devDependencies": { "@types/node": "^25.9.1", "vite": "^8.0.14" },
|
|
133
133
|
"publishConfig": { "access": "public" },
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "366a6ca74840649eed94707526ec6fdb62db55c1"
|
|
135
135
|
}
|