@powerlines/plugin-env 0.16.115 → 0.16.117
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 +2 -5
- package/dist/babel/plugin.mjs +2 -5
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -1
- package/dist/components/docs.mjs +1 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +4 -3
- 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 +4 -3
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/automd-generator.cjs +1 -3
- package/dist/helpers/automd-generator.d.mts +1 -1
- package/dist/helpers/automd-generator.mjs +1 -3
- package/dist/helpers/automd-generator.mjs.map +1 -1
- package/dist/helpers/load.cjs +1 -3
- package/dist/helpers/load.d.cts +20 -1
- package/dist/helpers/load.d.cts.map +1 -1
- package/dist/helpers/load.d.mts +20 -1
- package/dist/helpers/load.d.mts.map +1 -1
- package/dist/helpers/load.mjs +1 -3
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +11 -26
- package/dist/helpers/persistence.mjs +12 -27
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/reflect.cjs +6 -15
- package/dist/helpers/reflect.mjs +6 -15
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/helpers/template-helpers.cjs +1 -3
- package/dist/helpers/template-helpers.mjs +1 -3
- package/dist/helpers/template-helpers.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.cjs +4 -26
- package/dist/types/plugin.d.mts +4 -4
- package/dist/types/plugin.mjs +4 -26
- package/dist/types/plugin.mjs.map +1 -1
- package/dist/types/runtime.d.cts +144 -0
- package/dist/types/runtime.d.cts.map +1 -1
- package/dist/types/runtime.d.mts +144 -0
- package/dist/types/runtime.d.mts.map +1 -1
- package/dist/types/runtime.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.cjs +0 -14
- package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs +0 -14
- package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs.map +0 -1
|
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
4
|
const require_helpers_persistence = require('./persistence.cjs');
|
|
5
|
-
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
6
5
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
7
6
|
|
|
8
7
|
//#region src/helpers/template-helpers.ts
|
|
@@ -61,10 +60,9 @@ createTemplateReflection.__type = [
|
|
|
61
60
|
"context",
|
|
62
61
|
() => require_types_plugin.__ΩEnvType,
|
|
63
62
|
"name",
|
|
64
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
65
63
|
"createTemplateReflection",
|
|
66
64
|
"Creates the reflection data used when generating runtime template files.",
|
|
67
|
-
"Pn!2\"n#2$
|
|
65
|
+
"Pn!2\"n#2$8!`/%?&"
|
|
68
66
|
];
|
|
69
67
|
|
|
70
68
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { __ΩEnvPluginContext, __ΩEnvType } from "../types/plugin.mjs";
|
|
2
2
|
import { readEnvTypeReflection } from "./persistence.mjs";
|
|
3
|
-
import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
|
|
4
3
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
5
4
|
|
|
6
5
|
//#region src/helpers/template-helpers.ts
|
|
@@ -59,10 +58,9 @@ createTemplateReflection.__type = [
|
|
|
59
58
|
"context",
|
|
60
59
|
() => __ΩEnvType,
|
|
61
60
|
"name",
|
|
62
|
-
() => ReflectionClass,
|
|
63
61
|
"createTemplateReflection",
|
|
64
62
|
"Creates the reflection data used when generating runtime template files.",
|
|
65
|
-
"Pn!2\"n#2$
|
|
63
|
+
"Pn!2\"n#2$8!`/%?&"
|
|
66
64
|
];
|
|
67
65
|
|
|
68
66
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-helpers.mjs","names":[],"sources":["../../src/helpers/template-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext, EnvType } from \"../types/plugin\";\nimport { readEnvTypeReflection } from \"./persistence\";\n\n/**\n * Creates the reflection data used when generating runtime template files.\n *\n * @param context - The context for the configuration plugin.\n * @param name - The name of the configuration template.\n * @returns The reflection for the specified configuration template.\n */\nexport async function createTemplateReflection(\n context: EnvPluginContext,\n name?: EnvType\n): Promise<ReflectionClass<any>> {\n const reflection = await readEnvTypeReflection(context, name);\n\n reflection.getProperties().forEach(prop => {\n const aliases = prop.getAlias();\n aliases.filter(Boolean).forEach(alias => {\n reflection.addProperty({\n name: alias,\n optional: prop.isOptional() ? true : undefined,\n readonly: prop.isReadonly() ? true : undefined,\n description: prop.getDescription(),\n visibility: prop.getVisibility(),\n type: prop.getType(),\n default: prop.getDefaultValue(),\n tags: {\n hidden: prop.isHidden(),\n ignore: prop.isIgnored(),\n internal: prop.isInternal(),\n alias: prop\n .getAlias()\n .filter(a => a !== alias)\n .concat(prop.name),\n title: prop.getTitle() || titleCase(prop.name),\n readonly: prop.isReadonly(),\n permission: prop.getPermission(),\n domain: prop.getDomain()\n }\n });\n });\n });\n\n return reflection;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"template-helpers.mjs","names":[],"sources":["../../src/helpers/template-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext, EnvType } from \"../types/plugin\";\nimport { readEnvTypeReflection } from \"./persistence\";\n\n/**\n * Creates the reflection data used when generating runtime template files.\n *\n * @param context - The context for the configuration plugin.\n * @param name - The name of the configuration template.\n * @returns The reflection for the specified configuration template.\n */\nexport async function createTemplateReflection(\n context: EnvPluginContext,\n name?: EnvType\n): Promise<ReflectionClass<any>> {\n const reflection = await readEnvTypeReflection(context, name);\n\n reflection.getProperties().forEach(prop => {\n const aliases = prop.getAlias();\n aliases.filter(Boolean).forEach(alias => {\n reflection.addProperty({\n name: alias,\n optional: prop.isOptional() ? true : undefined,\n readonly: prop.isReadonly() ? true : undefined,\n description: prop.getDescription(),\n visibility: prop.getVisibility(),\n type: prop.getType(),\n default: prop.getDefaultValue(),\n tags: {\n hidden: prop.isHidden(),\n ignore: prop.isIgnored(),\n internal: prop.isInternal(),\n alias: prop\n .getAlias()\n .filter(a => a !== alias)\n .concat(prop.name),\n title: prop.getTitle() || titleCase(prop.name),\n readonly: prop.isReadonly(),\n permission: prop.getPermission(),\n domain: prop.getDomain()\n }\n });\n });\n });\n\n return reflection;\n}\n"],"mappings":";;;;;AAIA,SAAM,aAAS,IAAW,MAAM;AAC5B,IAAA,SAAW;AACd,QAAS;;;;;;;;;;CAYV,MAAS,aAAA,MAAkB,sBAAkB,SAAe,KAAK;AACjE,YAAS,eAAmB,CAAA,QAAO,cAAc,SAAW;AAEpD,EADC,KAAkB,UAAU,CAC5B,OAAA,QAAsB,CAAC,QAAQ,cAAa,UAAA;;IAEnD,MAAA;IACa,UAAW,KAAK,YAAU,GAAA,OAAW;IACnD,UAAA,KAAA,YAAA,GAAA,OAAA;IACS,aAAc,KAAQ,gBAAQ;IACxB,YAAY,KAAK,eAAc;IAC/B,MAAA,KAAW,SAAQ;IACjC,SAAA,KAAA,iBAAA;IACW,MAAS;KACX,QAAgB,KAAA,UAAA;KAClB,QAAA,KAAA,WAAA;KACE,UAAmB,KAAG,YAAA;KACb,OAAO,gBAEd,OAAgB,cAAgB,MAAA,MAAA,OAAA;MAAA;MAAA;MAAA;MAAA,CAAA,CAAA,CACpB,OAAA,KAAU,KAAA;KAChB,OAAQ,KAAC,UAAc,IAAG,UAAA,KAAA,KAAA;KAC5B,UAAY,KAAA,YAAA;KACV,YAAA,KAAA,eAAA;KACD,QAAK,KAAU,WAAW;KAC3B;IACT,CAAA;KACA;GAAA;GAAY;GAAK;GAAA,CAAA,CAAA;IAClB;EAAC;EAAM;EAAK;EAAS,CAAA,CAAA;AACxB,QAAI;;AAER,yBAAuB,SAAU;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -8,13 +8,13 @@ const require_helpers_automd_generator = require('./helpers/automd-generator.cjs
|
|
|
8
8
|
const require_components_docs = require('./components/docs.cjs');
|
|
9
9
|
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
10
10
|
const require_babel_plugin = require('./babel/plugin.cjs');
|
|
11
|
-
const require_get_unique = require('./node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.cjs');
|
|
12
11
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
13
12
|
let _stryke_env_types = require("@stryke/env/types");
|
|
14
13
|
let defu = require("defu");
|
|
15
14
|
defu = require_runtime.__toESM(defu);
|
|
16
15
|
let _stryke_path_join = require("@stryke/path/join");
|
|
17
16
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
17
|
+
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
18
18
|
let _powerlines_plugin_alloy = require("@powerlines/plugin-alloy");
|
|
19
19
|
_powerlines_plugin_alloy = require_runtime.__toESM(_powerlines_plugin_alloy);
|
|
20
20
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
@@ -37,7 +37,7 @@ const plugin = (options = {}) => {
|
|
|
37
37
|
(0, _powerlines_plugin_alloy.default)(options.alloy),
|
|
38
38
|
(0, _powerlines_plugin_babel.default)(options.babel),
|
|
39
39
|
{
|
|
40
|
-
name: "env",
|
|
40
|
+
name: "env:core",
|
|
41
41
|
async config() {
|
|
42
42
|
this.debug("Providing default configuration for the Powerlines `env` build plugin.");
|
|
43
43
|
const config = {
|
|
@@ -77,7 +77,7 @@ const plugin = (options = {}) => {
|
|
|
77
77
|
"POWERLINES_",
|
|
78
78
|
this.config.framework && this.config.framework !== "powerlines" && `${(0, _stryke_string_format_constant_case.constantCase)(this.config.framework)}_`
|
|
79
79
|
].filter(Boolean));
|
|
80
|
-
config.env.prefix =
|
|
80
|
+
config.env.prefix = (0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(config.env.prefix).reduce((ret, prefix) => {
|
|
81
81
|
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
82
82
|
return ret;
|
|
83
83
|
}, []));
|
package/dist/index.mjs
CHANGED
|
@@ -6,12 +6,12 @@ import { env } from "./helpers/automd-generator.mjs";
|
|
|
6
6
|
import { EnvDocsFile } from "./components/docs.mjs";
|
|
7
7
|
import { EnvBuiltin } from "./components/env-builtin.mjs";
|
|
8
8
|
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
9
|
-
import { getUnique } from "./node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs";
|
|
10
9
|
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
11
10
|
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
12
11
|
import defu from "defu";
|
|
13
12
|
import { joinPaths } from "@stryke/path/join";
|
|
14
13
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
14
|
+
import { getUnique } from "@stryke/helpers/get-unique";
|
|
15
15
|
import alloy from "@powerlines/plugin-alloy";
|
|
16
16
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
17
17
|
import automd from "@powerlines/plugin-automd";
|
|
@@ -31,7 +31,7 @@ const plugin = (options = {}) => {
|
|
|
31
31
|
alloy(options.alloy),
|
|
32
32
|
babel(options.babel),
|
|
33
33
|
{
|
|
34
|
-
name: "env",
|
|
34
|
+
name: "env:core",
|
|
35
35
|
async config() {
|
|
36
36
|
this.debug("Providing default configuration for the Powerlines `env` build plugin.");
|
|
37
37
|
const config = {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n ReflectionClass,\n ReflectionKind\n} from \"@powerlines/deepkit/vendor/type\";\nimport alloy from \"@powerlines/plugin-alloy\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env-builtin\";\nimport { env } from \"./helpers/automd-generator\";\nimport { getDocsOutputPath } from \"./helpers/docs-helper\";\nimport { loadEnv } from \"./helpers/load\";\nimport {\n getEnvDefaultTypeDefinition,\n getEnvReflectionsPath,\n getEnvTypeReflectionsPath,\n getSecretsDefaultTypeDefinition,\n readEnvReflection,\n readEnvTypeReflection,\n readSecretsReflection,\n writeEnvReflection,\n writeEnvTypeReflection\n} from \"./helpers/persistence\";\nimport { reflectEnv, reflectSecrets } from \"./helpers/reflect\";\nimport { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n env?: EnvPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n alloy(options.alloy),\n babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n plugins: [envBabelPlugin]\n }\n };\n\n if (\n isSetString(config.env.types) ||\n (config.env.types && isSetString(config.env.types.file))\n ) {\n config.env.types = parseTypeDefinition(\n config.env.types\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.types.file);\n if (file) {\n config.env.types.file = file;\n }\n } else {\n this.warn(\n \"The `env.types` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n const envDefaultTypeDefinition =\n await getEnvDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(envDefaultTypeDefinition.file);\n if (file) {\n config.env.types = parseTypeDefinition(\n `${file}#${envDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n if (\n isSetString(config.env.secrets) ||\n (config.env.secrets && isSetString(config.env.secrets.file))\n ) {\n config.env.secrets = parseTypeDefinition(\n config.env.secrets\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.secrets.file);\n if (file) {\n config.env.secrets.file = file;\n }\n } else {\n const secretsDefaultTypeDefinition =\n await getSecretsDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);\n if (file) {\n config.env.secrets = parseTypeDefinition(\n `${file}#${secretsDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n config.env.prefix = toArray(\n (config.env.prefix ?? []) as string[]\n ).reduce(\n (ret: string[], prefix: string) => {\n const formattedPrefix = constantCase(prefix);\n if (!ret.includes(formattedPrefix)) {\n ret.push(formattedPrefix);\n }\n\n return ret;\n },\n [\n ...ENV_PREFIXES,\n \"POWERLINES_\",\n this.config.framework &&\n this.config.framework !== \"powerlines\" &&\n `${constantCase(this.config.framework)}_`\n ].filter(Boolean) as string[]\n );\n\n config.env.prefix = getUnique(\n toArray(config.env.prefix).reduce((ret, prefix) => {\n if (!ret.includes(prefix.replace(/_$/g, \"\"))) {\n ret.push(prefix.replace(/_$/g, \"\"));\n }\n return ret;\n }, [] as string[])\n );\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n this.env = defu(\n {\n parsed: await loadEnv(this, this.config.env)\n },\n this.env ?? {},\n {\n types: {\n env: {}\n },\n used: {\n env: {},\n secrets: {}\n },\n parsed: {},\n injected: {}\n }\n ) as EnvPluginContext[\"env\"];\n\n if (\n this.config.command !== \"prepare\" &&\n !this.config.skipCache &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n existsSync(getEnvTypeReflectionsPath(this, \"env\"))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n this.env.types.env = await readEnvTypeReflection(this, \"env\");\n\n if (existsSync(getEnvReflectionsPath(this, \"env\"))) {\n this.env.used.env = await readEnvReflection(this);\n }\n\n if (existsSync(getEnvTypeReflectionsPath(this, \"secrets\"))) {\n this.env.types.secrets = await readEnvTypeReflection(\n this,\n \"secrets\"\n );\n }\n\n if (existsSync(getEnvReflectionsPath(this, \"secrets\"))) {\n this.env.used.secrets = await readSecretsReflection(this);\n }\n } else {\n this.debug(\n `Starting environment configuration reflection initialization.`\n );\n\n this.env.types.env = await reflectEnv(\n this,\n this.config.env.types?.file,\n this.config.env.types?.name\n );\n if (!this.env.types.env) {\n throw new Error(\n \"Failed to find the environment configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.env, \"env\");\n\n this.env.types.secrets = await reflectSecrets(\n this,\n this.config.env.secrets?.file,\n this.config.env.secrets?.name\n );\n if (!this.env.types.secrets) {\n throw new Error(\n \"Failed to find the secrets configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.secrets, \"secrets\");\n\n this.debug(\n `Resolved ${\n this.env.types.env.getProperties().length ?? 0\n } environment configuration parameters and ${\n this.env.types.secrets?.getProperties().length ?? 0\n } secret configuration parameters`\n );\n\n const envWithAlias = this.env.types.env\n .getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n Object.entries(await loadEnv(this, this.config.env)).forEach(\n ([key, value]) => {\n const unprefixedKey = this.config.env.prefix.reduce(\n (ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n },\n key\n );\n\n const aliasKey = envWithAlias.find(prop =>\n prop?.getAlias().reverse().includes(unprefixedKey)\n );\n if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) {\n this.env.types.env\n .getProperty(unprefixedKey)\n .setDefaultValue(value);\n }\n }\n );\n\n this.env.used.env = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.env\n );\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n\n if (this.env.types.secrets) {\n await writeEnvTypeReflection(\n this,\n this.env.types.secrets,\n \"secrets\"\n );\n\n this.env.used.secrets = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.secrets\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async prepare() {\n this.debug(\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvBuiltin\n defaultConfig={this.config.env.defaultConfig}\n reflection={result}\n />\n );\n },\n transform: {\n order: \"post\",\n async handler() {\n if (this.env.used.env.getProperties().length > 0) {\n this.trace(\n `Persisting used environment configuration reflections to ${getEnvReflectionsPath(\n this,\n \"env\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n\n if (this.env.used.secrets.getProperties().length > 0) {\n this.trace(\n `Persisting used secret configuration reflections to ${getEnvReflectionsPath(\n this,\n \"secrets\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async docs() {\n this.debug(\n `Documenting environment variables configuration values in \"${joinPaths(\n getDocsOutputPath(this),\n \"env.md\"\n )}\"`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvDocsFile levelOffset={0} reflection={result} />\n );\n },\n async buildEnd() {\n const reflectionPath = getEnvReflectionsPath(this, \"env\");\n\n this.debug(`Writing env reflection types to ${reflectionPath}.`);\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n },\n {\n name: \"env:automd-generator\",\n config() {\n return {\n automd: defu(options.automd ?? {}, {\n generators: {\n env: env(this)\n }\n })\n };\n }\n },\n {\n name: \"env:vite\",\n vite: {\n configResolved(this: TContext) {\n return {\n envPrefix: this.config?.env?.prefix\n } as ViteUserConfig;\n }\n }\n },\n automd(options.automd)\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAE,UAAkB,UAAA,EAAA,KAAA;AAClB,QAAA;EAAA,MAAA,QAAA,MAAA;EAAA,MAAA,QAAA,MAAA;EAAA;GACA,MAAQ;GACV,MAAS,SAAU;AACb,SAAG,MAAA,yEAA0D;;KAE5D,KAAM,KAAK,SAAS;;MAEnB,UAAQ;MACd,QAAgB;MACR,QAAA,EAAA;MACR,CAAA;KACF,OAAA,6BAEE;KACG;AACH,QAAA,YAAA,OAAA,IAAA,MAAA,IAAA,OAAA,IAAA,SAAA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2C;IACjD,MAAK,SAAA,MAAA,sBAAA,MAAA,MAAA;AACL,WAAI,OAAU,MAAI,gBAAA,YAAA;KAChB,IAAE,gBAAA;AACA,aAAO,OAAE,OAAA,IAAA;;KAEX,YAAK;KACN,CAAC,CAAC;;GAEL,WAAU;IACR,OAAO;IACP,MAAM,UAAU;AACd,SAAI,KAAA,IAAS,KAAE,IAAA,eAAA,CAAA,SAAA,GAAA;AACb,WAAA,MAAA,4DAAA,sBAAA,MAAA,MAAA,CAAA,GAAA;AACA,YAAG,mBAAsB,MAAC,KAAA,IAAA,KAAA,KAAA,MAAA;;AAE5B,SAAG,KAAA,IAAA,KAAA,QAAA,eAAA,CAAA,SAAA,GAAA;AACD,WAAK,MAAM,uDAAwB,sBAAA,MAAA,UAAA,CAAA,GAAA;AACnC,YAAM,mBAAkB,MAAA,KAAA,IAAA,KAAA,SAAA,UAAA;;;IAG7B;GACD,MAAM,OAAK;AACT,SAAK,MAAE,8DAAgE,UAAQ,kBAAA,KAAA,EAAA,SAAA,CAAA,GAAA;IAC/E,MAAK,SAAA,MAAA,sBAAA,MAAA,MAAA;;KAEH,aAAW;;KAEZ,CAAC,CAAC;;GAEL,MAAM,WAAA;;AAEJ,SAAI,MAAI,mCAAqC,eAAgB,GAAG;AAChE,UAAM,mBAAe,MAAU,KAAK,IAAC,KAAA,KAAA,MAAA;;GAExC;EAAE;GACD,MAAM;GACN,SAAM;aAEF,QAAM,KAAA,QAAW,UAAA,EAAA,EAAA,EACf,YAAW,EACX,KAAA,IAAA,KAAA,EACA,EACD,CAAC,EACH;;;;GAGH,MAAM;GACN,MAAM,EACJ,iBAA6B;AAC3B,WAAI,EACF,WAAC,KAAA,QAAA,KAAA,QACF;MAEJ;GACF;EAAE,OAAO,QAAC,OAAA;EAAA"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n ReflectionClass,\n ReflectionKind\n} from \"@powerlines/deepkit/vendor/type\";\nimport alloy from \"@powerlines/plugin-alloy\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env-builtin\";\nimport { env } from \"./helpers/automd-generator\";\nimport { getDocsOutputPath } from \"./helpers/docs-helper\";\nimport { loadEnv } from \"./helpers/load\";\nimport {\n getEnvDefaultTypeDefinition,\n getEnvReflectionsPath,\n getEnvTypeReflectionsPath,\n getSecretsDefaultTypeDefinition,\n readEnvReflection,\n readEnvTypeReflection,\n readSecretsReflection,\n writeEnvReflection,\n writeEnvTypeReflection\n} from \"./helpers/persistence\";\nimport { reflectEnv, reflectSecrets } from \"./helpers/reflect\";\nimport { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n env?: EnvPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n alloy(options.alloy),\n babel(options.babel),\n {\n name: \"env:core\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n plugins: [envBabelPlugin]\n }\n };\n\n if (\n isSetString(config.env.types) ||\n (config.env.types && isSetString(config.env.types.file))\n ) {\n config.env.types = parseTypeDefinition(\n config.env.types\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.types.file);\n if (file) {\n config.env.types.file = file;\n }\n } else {\n this.warn(\n \"The `env.types` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n const envDefaultTypeDefinition =\n await getEnvDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(envDefaultTypeDefinition.file);\n if (file) {\n config.env.types = parseTypeDefinition(\n `${file}#${envDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n if (\n isSetString(config.env.secrets) ||\n (config.env.secrets && isSetString(config.env.secrets.file))\n ) {\n config.env.secrets = parseTypeDefinition(\n config.env.secrets\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(config.env.secrets.file);\n if (file) {\n config.env.secrets.file = file;\n }\n } else {\n const secretsDefaultTypeDefinition =\n await getSecretsDefaultTypeDefinition(this);\n\n const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);\n if (file) {\n config.env.secrets = parseTypeDefinition(\n `${file}#${secretsDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n }\n\n config.env.prefix = toArray(\n (config.env.prefix ?? []) as string[]\n ).reduce(\n (ret: string[], prefix: string) => {\n const formattedPrefix = constantCase(prefix);\n if (!ret.includes(formattedPrefix)) {\n ret.push(formattedPrefix);\n }\n\n return ret;\n },\n [\n ...ENV_PREFIXES,\n \"POWERLINES_\",\n this.config.framework &&\n this.config.framework !== \"powerlines\" &&\n `${constantCase(this.config.framework)}_`\n ].filter(Boolean) as string[]\n );\n\n config.env.prefix = getUnique(\n toArray(config.env.prefix).reduce((ret, prefix) => {\n if (!ret.includes(prefix.replace(/_$/g, \"\"))) {\n ret.push(prefix.replace(/_$/g, \"\"));\n }\n return ret;\n }, [] as string[])\n );\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n this.env = defu(\n {\n parsed: await loadEnv(this, this.config.env)\n },\n this.env ?? {},\n {\n types: {\n env: {}\n },\n used: {\n env: {},\n secrets: {}\n },\n parsed: {},\n injected: {}\n }\n ) as EnvPluginContext[\"env\"];\n\n if (\n this.config.command !== \"prepare\" &&\n !this.config.skipCache &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n existsSync(getEnvTypeReflectionsPath(this, \"env\"))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n this.env.types.env = await readEnvTypeReflection(this, \"env\");\n\n if (existsSync(getEnvReflectionsPath(this, \"env\"))) {\n this.env.used.env = await readEnvReflection(this);\n }\n\n if (existsSync(getEnvTypeReflectionsPath(this, \"secrets\"))) {\n this.env.types.secrets = await readEnvTypeReflection(\n this,\n \"secrets\"\n );\n }\n\n if (existsSync(getEnvReflectionsPath(this, \"secrets\"))) {\n this.env.used.secrets = await readSecretsReflection(this);\n }\n } else {\n this.debug(\n `Starting environment configuration reflection initialization.`\n );\n\n this.env.types.env = await reflectEnv(\n this,\n this.config.env.types?.file,\n this.config.env.types?.name\n );\n if (!this.env.types.env) {\n throw new Error(\n \"Failed to find the environment configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.env, \"env\");\n\n this.env.types.secrets = await reflectSecrets(\n this,\n this.config.env.secrets?.file,\n this.config.env.secrets?.name\n );\n if (!this.env.types.secrets) {\n throw new Error(\n \"Failed to find the secrets configuration type reflection in the context.\"\n );\n }\n\n await writeEnvTypeReflection(this, this.env.types.secrets, \"secrets\");\n\n this.debug(\n `Resolved ${\n this.env.types.env.getProperties().length ?? 0\n } environment configuration parameters and ${\n this.env.types.secrets?.getProperties().length ?? 0\n } secret configuration parameters`\n );\n\n const envWithAlias = this.env.types.env\n .getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n Object.entries(await loadEnv(this, this.config.env)).forEach(\n ([key, value]) => {\n const unprefixedKey = this.config.env.prefix.reduce(\n (ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n },\n key\n );\n\n const aliasKey = envWithAlias.find(prop =>\n prop?.getAlias().reverse().includes(unprefixedKey)\n );\n if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) {\n this.env.types.env\n .getProperty(unprefixedKey)\n .setDefaultValue(value);\n }\n }\n );\n\n this.env.used.env = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.env\n );\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n\n if (this.env.types.secrets) {\n await writeEnvTypeReflection(\n this,\n this.env.types.secrets,\n \"secrets\"\n );\n\n this.env.used.secrets = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters used by the ${\n this.config.name\n ? `${this.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n this.env.types.secrets\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async prepare() {\n this.debug(\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvBuiltin\n defaultConfig={this.config.env.defaultConfig}\n reflection={result}\n />\n );\n },\n transform: {\n order: \"post\",\n async handler() {\n if (this.env.used.env.getProperties().length > 0) {\n this.trace(\n `Persisting used environment configuration reflections to ${getEnvReflectionsPath(\n this,\n \"env\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n\n if (this.env.used.secrets.getProperties().length > 0) {\n this.trace(\n `Persisting used secret configuration reflections to ${getEnvReflectionsPath(\n this,\n \"secrets\"\n )}.`\n );\n await writeEnvReflection(this, this.env.used.secrets, \"secrets\");\n }\n }\n },\n async docs() {\n this.debug(\n `Documenting environment variables configuration values in \"${joinPaths(\n getDocsOutputPath(this),\n \"env.md\"\n )}\"`\n );\n\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <EnvDocsFile levelOffset={0} reflection={result} />\n );\n },\n async buildEnd() {\n const reflectionPath = getEnvReflectionsPath(this, \"env\");\n\n this.debug(`Writing env reflection types to ${reflectionPath}.`);\n\n await writeEnvReflection(this, this.env.used.env, \"env\");\n }\n },\n {\n name: \"env:automd-generator\",\n config() {\n return {\n automd: defu(options.automd ?? {}, {\n generators: {\n env: env(this)\n }\n })\n };\n }\n },\n {\n name: \"env:vite\",\n vite: {\n configResolved(this: TContext) {\n return {\n envPrefix: this.config?.env?.prefix\n } as ViteUserConfig;\n }\n }\n },\n automd(options.automd)\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAE,UAAkB,UAAA,EAAA,KAAA;AAClB,QAAA;EAAA,MAAA,QAAA,MAAA;EAAA,MAAA,QAAA,MAAA;EAAA;GACA,MAAQ;GACV,MAAS,SAAU;AACb,SAAG,MAAA,yEAA0D;;KAE5D,KAAM,KAAK,SAAS;;MAEnB,UAAQ;MACd,QAAgB;MACR,QAAA,EAAA;MACR,CAAA;KACF,OAAA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
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_types_runtime = require('./runtime.cjs');
|
|
4
|
-
let _powerlines_plugin_babel_types = require("@powerlines/plugin-babel/types");
|
|
5
|
-
let _powerlines_plugin_automd_types_plugin = require("@powerlines/plugin-automd/types/plugin");
|
|
6
|
-
let _powerlines_plugin_alloy_types = require("@powerlines/plugin-alloy/types");
|
|
7
|
-
let _powerlines_deepkit_types = require("@powerlines/deepkit/types");
|
|
8
2
|
|
|
9
3
|
//#region src/types/plugin.ts
|
|
10
4
|
const __ΩOmit = [
|
|
@@ -55,29 +49,22 @@ const __ΩEnvPluginOptions = [
|
|
|
55
49
|
"Children",
|
|
56
50
|
"defaultConfig",
|
|
57
51
|
"The default configuration to use when loading environment variables.",
|
|
58
|
-
() => _powerlines_plugin_babel_types.__ΩBabelPluginOptions,
|
|
59
52
|
"babel",
|
|
60
53
|
"Babel configuration options to use when injecting environment variables into the source code.",
|
|
61
|
-
() => _powerlines_plugin_automd_types_plugin.__ΩAutoMDPluginOptions,
|
|
62
54
|
"automd",
|
|
63
55
|
"AutoMD configuration options to allow injecting environment variables documentation into a markdown file such as a README.md.",
|
|
64
|
-
() => _powerlines_plugin_alloy_types.__ΩAlloyPluginOptions,
|
|
65
56
|
"alloy",
|
|
66
57
|
"Alloy configuration options to use when injecting environment variables into the source code.",
|
|
67
58
|
"EnvPluginOptions",
|
|
68
|
-
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?
|
|
59
|
+
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?0!418?2!438?4!458?6MKw7y"
|
|
69
60
|
];
|
|
70
61
|
const __ΩEnvPluginUserConfig = [
|
|
71
|
-
() => _powerlines_plugin_babel_types.__ΩBabelPluginUserConfig,
|
|
72
|
-
() => _powerlines_plugin_alloy_types.__ΩAlloyPluginUserConfig,
|
|
73
62
|
() => __ΩEnvPluginOptions,
|
|
74
63
|
"env",
|
|
75
64
|
"EnvPluginUserConfig",
|
|
76
|
-
"Pn!
|
|
65
|
+
"P!!Pn!4\"MKw#y"
|
|
77
66
|
];
|
|
78
67
|
const __ΩEnvPluginResolvedConfig = [
|
|
79
|
-
() => _powerlines_plugin_babel_types.__ΩBabelPluginResolvedConfig,
|
|
80
|
-
() => _powerlines_plugin_alloy_types.__ΩAlloyPluginResolvedConfig,
|
|
81
68
|
() => __ΩRequired,
|
|
82
69
|
() => __ΩPick,
|
|
83
70
|
"additionalFiles",
|
|
@@ -97,36 +84,27 @@ const __ΩEnvPluginResolvedConfig = [
|
|
|
97
84
|
"The prefix used for environment variables",
|
|
98
85
|
"env",
|
|
99
86
|
"EnvPluginResolvedConfig",
|
|
100
|
-
"
|
|
87
|
+
"P!!PP!.#o\"#o!\"n&.'o%#o$\"P!4(?)!4*?+)4,?-)4.?/&F40?1MK42MKw3y"
|
|
101
88
|
];
|
|
102
89
|
const __ΩEnvPluginContext = [
|
|
103
90
|
() => __ΩEnvPluginResolvedConfig,
|
|
104
91
|
"TResolvedConfig",
|
|
105
|
-
() => _powerlines_plugin_babel_types.__ΩBabelPluginContext,
|
|
106
|
-
() => _powerlines_plugin_alloy_types.__ΩAlloyPluginContext,
|
|
107
|
-
() => _powerlines_deepkit_types.__ΩReflection,
|
|
108
92
|
"env",
|
|
109
93
|
"The type definitions for the expected env variables",
|
|
110
|
-
() => _powerlines_deepkit_types.__ΩReflection,
|
|
111
94
|
"secrets",
|
|
112
95
|
"The type definitions for the expected env secrets",
|
|
113
96
|
"The type definitions reflection for the env variables and secrets",
|
|
114
97
|
"types",
|
|
115
|
-
() => _powerlines_deepkit_types.__ΩReflection,
|
|
116
|
-
() => require_types_runtime.__ΩEnvInterface,
|
|
117
98
|
"The current env variables reflection",
|
|
118
|
-
() => _powerlines_deepkit_types.__ΩReflection,
|
|
119
|
-
() => require_types_runtime.__ΩSecretsInterface,
|
|
120
99
|
"The current env secrets reflection",
|
|
121
100
|
"The current **used** environment variables and secrets reflection",
|
|
122
101
|
"used",
|
|
123
102
|
"parsed",
|
|
124
103
|
"The parsed .env configuration object",
|
|
125
|
-
() => _powerlines_deepkit_types.__ΩReflection,
|
|
126
104
|
"injected",
|
|
127
105
|
"The injected environment variables and secrets reflection",
|
|
128
106
|
"EnvPluginContext",
|
|
129
|
-
"n!c\"
|
|
107
|
+
"n!c\"P!!PP!4#?$!4%?&M?'4(?'P!4#?)!4%?*M?+4,?+!4-?.!4/?0M4#Mw1y"
|
|
130
108
|
];
|
|
131
109
|
|
|
132
110
|
//#endregion
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EnvInterface, SecretsInterface } from "./runtime.mjs";
|
|
2
|
-
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
3
|
-
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
4
|
-
import { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
|
|
5
|
-
import { Reflection } from "@powerlines/deepkit/types";
|
|
6
2
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
7
3
|
import { Children } from "@alloy-js/core";
|
|
4
|
+
import { Reflection } from "@powerlines/deepkit/types";
|
|
5
|
+
import { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
|
|
6
|
+
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
7
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
8
8
|
import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
9
9
|
|
|
10
10
|
//#region src/types/plugin.d.ts
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { __ΩEnvInterface, __ΩSecretsInterface } from "./runtime.mjs";
|
|
2
|
-
import { __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
3
|
-
import { __ΩAutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
4
|
-
import { __ΩAlloyPluginContext, __ΩAlloyPluginOptions, __ΩAlloyPluginResolvedConfig, __ΩAlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
|
|
5
|
-
import { __ΩReflection } from "@powerlines/deepkit/types";
|
|
6
|
-
|
|
7
1
|
//#region src/types/plugin.ts
|
|
8
2
|
const __ΩOmit = [
|
|
9
3
|
"T",
|
|
@@ -53,29 +47,22 @@ const __ΩEnvPluginOptions = [
|
|
|
53
47
|
"Children",
|
|
54
48
|
"defaultConfig",
|
|
55
49
|
"The default configuration to use when loading environment variables.",
|
|
56
|
-
() => __ΩBabelPluginOptions,
|
|
57
50
|
"babel",
|
|
58
51
|
"Babel configuration options to use when injecting environment variables into the source code.",
|
|
59
|
-
() => __ΩAutoMDPluginOptions,
|
|
60
52
|
"automd",
|
|
61
53
|
"AutoMD configuration options to allow injecting environment variables documentation into a markdown file such as a README.md.",
|
|
62
|
-
() => __ΩAlloyPluginOptions,
|
|
63
54
|
"alloy",
|
|
64
55
|
"Alloy configuration options to use when injecting environment variables into the source code.",
|
|
65
56
|
"EnvPluginOptions",
|
|
66
|
-
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?
|
|
57
|
+
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?0!418?2!438?4!458?6MKw7y"
|
|
67
58
|
];
|
|
68
59
|
const __ΩEnvPluginUserConfig = [
|
|
69
|
-
() => __ΩBabelPluginUserConfig,
|
|
70
|
-
() => __ΩAlloyPluginUserConfig,
|
|
71
60
|
() => __ΩEnvPluginOptions,
|
|
72
61
|
"env",
|
|
73
62
|
"EnvPluginUserConfig",
|
|
74
|
-
"Pn!
|
|
63
|
+
"P!!Pn!4\"MKw#y"
|
|
75
64
|
];
|
|
76
65
|
const __ΩEnvPluginResolvedConfig = [
|
|
77
|
-
() => __ΩBabelPluginResolvedConfig,
|
|
78
|
-
() => __ΩAlloyPluginResolvedConfig,
|
|
79
66
|
() => __ΩRequired,
|
|
80
67
|
() => __ΩPick,
|
|
81
68
|
"additionalFiles",
|
|
@@ -95,36 +82,27 @@ const __ΩEnvPluginResolvedConfig = [
|
|
|
95
82
|
"The prefix used for environment variables",
|
|
96
83
|
"env",
|
|
97
84
|
"EnvPluginResolvedConfig",
|
|
98
|
-
"
|
|
85
|
+
"P!!PP!.#o\"#o!\"n&.'o%#o$\"P!4(?)!4*?+)4,?-)4.?/&F40?1MK42MKw3y"
|
|
99
86
|
];
|
|
100
87
|
const __ΩEnvPluginContext = [
|
|
101
88
|
() => __ΩEnvPluginResolvedConfig,
|
|
102
89
|
"TResolvedConfig",
|
|
103
|
-
() => __ΩBabelPluginContext,
|
|
104
|
-
() => __ΩAlloyPluginContext,
|
|
105
|
-
() => __ΩReflection,
|
|
106
90
|
"env",
|
|
107
91
|
"The type definitions for the expected env variables",
|
|
108
|
-
() => __ΩReflection,
|
|
109
92
|
"secrets",
|
|
110
93
|
"The type definitions for the expected env secrets",
|
|
111
94
|
"The type definitions reflection for the env variables and secrets",
|
|
112
95
|
"types",
|
|
113
|
-
() => __ΩReflection,
|
|
114
|
-
() => __ΩEnvInterface,
|
|
115
96
|
"The current env variables reflection",
|
|
116
|
-
() => __ΩReflection,
|
|
117
|
-
() => __ΩSecretsInterface,
|
|
118
97
|
"The current env secrets reflection",
|
|
119
98
|
"The current **used** environment variables and secrets reflection",
|
|
120
99
|
"used",
|
|
121
100
|
"parsed",
|
|
122
101
|
"The parsed .env configuration object",
|
|
123
|
-
() => __ΩReflection,
|
|
124
102
|
"injected",
|
|
125
103
|
"The injected environment variables and secrets reflection",
|
|
126
104
|
"EnvPluginContext",
|
|
127
|
-
"n!c\"
|
|
105
|
+
"n!c\"P!!PP!4#?$!4%?&M?'4(?'P!4#?)!4%?*M?+4,?+!4-?.!4/?0M4#Mw1y"
|
|
128
106
|
];
|
|
129
107
|
|
|
130
108
|
//#endregion
|
|
@@ -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 { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n AlloyPluginContext,\n AlloyPluginOptions,\n AlloyPluginResolvedConfig,\n AlloyPluginUserConfig\n} from \"@powerlines/plugin-alloy/types\";\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 { DotenvParseOutput } from \"@stryke/env/types\";\nimport {\n DotenvConfiguration,\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { EnvInterface, SecretsInterface } from \"./runtime\";\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 types?: TypeDefinitionParameter;\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?: TypeDefinitionParameter;\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 /**\n * Alloy configuration options to use when injecting environment variables into the source code.\n *\n * @remarks\n * This option allows you to customize the Alloy transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Alloy settings.\n */\n alloy?: AlloyPluginOptions;\n};\n\nexport type EnvPluginUserConfig = BabelPluginUserConfig &\n AlloyPluginUserConfig & {\n env: EnvPluginOptions;\n };\n\nexport type EnvPluginResolvedConfig = BabelPluginResolvedConfig &\n AlloyPluginResolvedConfig & {\n env: Required<Pick<DotenvConfiguration, \"additionalFiles\">> &\n Required<Pick<EnvPluginOptions, \"defaultConfig\">> & {\n /**\n * The type definition for the expected env variable parameters\n *\n * @remarks\n * This value is parsed from the {@link EnvPluginOptions.types} option.\n */\n types: TypeDefinition;\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: TypeDefinition;\n\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\nexport interface EnvPluginContext<\n TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig\n>\n extends\n BabelPluginContext<TResolvedConfig>,\n AlloyPluginContext<TResolvedConfig> {\n env: {\n /**\n * The type definitions reflection for the env variables and secrets\n *\n * @remarks\n * These reflections contains the structure of the expected environment variables and secrets as defined by the type definitions provided in the plugin configuration.\n */\n types: {\n /**\n * The type definitions for the expected env variables\n */\n env: Reflection;\n\n /**\n * The type definitions for the expected env secrets\n */\n secrets: Reflection;\n };\n\n /**\n * The current **used** environment variables and secrets reflection\n *\n * @remarks\n * This reflection contains the structure of the current environment variables and secrets as defined during the plugin initialization by extracting the values from the source code.\n */\n used: {\n /**\n * The current env variables reflection\n */\n env: Reflection<EnvInterface>;\n\n /**\n * The current env secrets reflection\n */\n secrets: Reflection<SecretsInterface>;\n };\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: Reflection;\n };\n}\n"],"mappings":"
|
|
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 { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n AlloyPluginContext,\n AlloyPluginOptions,\n AlloyPluginResolvedConfig,\n AlloyPluginUserConfig\n} from \"@powerlines/plugin-alloy/types\";\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 { DotenvParseOutput } from \"@stryke/env/types\";\nimport {\n DotenvConfiguration,\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { EnvInterface, SecretsInterface } from \"./runtime\";\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 types?: TypeDefinitionParameter;\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?: TypeDefinitionParameter;\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 /**\n * Alloy configuration options to use when injecting environment variables into the source code.\n *\n * @remarks\n * This option allows you to customize the Alloy transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Alloy settings.\n */\n alloy?: AlloyPluginOptions;\n};\n\nexport type EnvPluginUserConfig = BabelPluginUserConfig &\n AlloyPluginUserConfig & {\n env: EnvPluginOptions;\n };\n\nexport type EnvPluginResolvedConfig = BabelPluginResolvedConfig &\n AlloyPluginResolvedConfig & {\n env: Required<Pick<DotenvConfiguration, \"additionalFiles\">> &\n Required<Pick<EnvPluginOptions, \"defaultConfig\">> & {\n /**\n * The type definition for the expected env variable parameters\n *\n * @remarks\n * This value is parsed from the {@link EnvPluginOptions.types} option.\n */\n types: TypeDefinition;\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: TypeDefinition;\n\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\nexport interface EnvPluginContext<\n TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig\n>\n extends\n BabelPluginContext<TResolvedConfig>,\n AlloyPluginContext<TResolvedConfig> {\n env: {\n /**\n * The type definitions reflection for the env variables and secrets\n *\n * @remarks\n * These reflections contains the structure of the expected environment variables and secrets as defined by the type definitions provided in the plugin configuration.\n */\n types: {\n /**\n * The type definitions for the expected env variables\n */\n env: Reflection;\n\n /**\n * The type definitions for the expected env secrets\n */\n secrets: Reflection;\n };\n\n /**\n * The current **used** environment variables and secrets reflection\n *\n * @remarks\n * This reflection contains the structure of the current environment variables and secrets as defined during the plugin initialization by extracting the values from the source code.\n */\n used: {\n /**\n * The current env variables reflection\n */\n env: Reflection<EnvInterface>;\n\n /**\n * The current env secrets reflection\n */\n secrets: Reflection<SecretsInterface>;\n };\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: Reflection;\n };\n}\n"],"mappings":";AAAA,MAAM,UAAU;CAAC;CAAK;OAAW;OAAe;CAAY;CAAQ;CAAC;;;;;;AAErE,MAAM,UAAU;CAAC;CAAI;CAAM;CAAQ;CAAG;;;;;;;AAEtC,MAAM,aAAS;CAAA;CAAY;CAAW;CAAW;CAAU;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;CAAA;CAAA;CAAA;;;;;;;AAInE,MAAC,6BAAkC;OAAO;OAAmB;CAAA;OAAA;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAE7D,MAAC,sBAA0B;OAAQ;CAAkB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|