@powerlines/plugin-env 0.16.237 → 0.16.238
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/components/docs.cjs +2 -2
- package/dist/components/docs.mjs +3 -3
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +14 -18
- package/dist/components/env-builtin.d.cts +1 -1
- package/dist/components/env-builtin.d.mts +1 -1
- package/dist/components/env-builtin.mjs +12 -16
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/index.cjs +3 -1
- package/dist/helpers/index.d.cts +2 -2
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/schema.cjs +45 -1
- package/dist/helpers/schema.d.cts +15 -1
- package/dist/helpers/schema.d.cts.map +1 -1
- package/dist/helpers/schema.d.mts +15 -1
- package/dist/helpers/schema.d.mts.map +1 -1
- package/dist/helpers/schema.mjs +46 -4
- package/dist/helpers/schema.mjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/dist/types/plugin.cjs +15 -5
- package/dist/types/plugin.d.cts +7 -4
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +8 -5
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +15 -5
- package/dist/types/plugin.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -34,6 +34,20 @@ declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedCont
|
|
|
34
34
|
* @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
|
|
35
35
|
*/
|
|
36
36
|
declare function extractEnvSchema<TContext extends EnvPluginContext>(context: TContext, options?: EnvPluginOptions): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
|
|
39
|
+
*
|
|
40
|
+
* @param context - The plugin context
|
|
41
|
+
* @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
|
|
42
|
+
*/
|
|
43
|
+
declare function readActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
|
|
46
|
+
*
|
|
47
|
+
* @param context - The plugin context
|
|
48
|
+
* @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
|
|
49
|
+
*/
|
|
50
|
+
declare function writeActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void[]>;
|
|
37
51
|
//#endregion
|
|
38
|
-
export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
|
|
52
|
+
export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, readActiveEnv, resolveRuntimeTypeFile, writeActiveEnv };
|
|
39
53
|
//# sourceMappingURL=schema.d.mts.map
|
|
@@ -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":";;;;;;;AAqCA;;;;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;;;;;;;;;;;iBAiBR,gBAAA,kBAAkC,gBAAA,CAAA,CACtD,OAAA,EAAS,QAAA,EACT,OAAA,GAAS,gBAAA,GACR,OAAA;;;AAlCyC;AAY5C;;;iBA8LsB,aAAA,kBAA+B,gBAAA,CAAA,CACnD,OAAA,EAAS,QAAA,GAAQ,OAAA;;;;;;;iBAqCG,cAAA,kBAAgC,gBAAA,CAAA,CACpD,OAAA,EAAS,QAAA,GAAQ,OAAA"}
|
package/dist/helpers/schema.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { __ΩEnvPluginOptions } from "../types/plugin.mjs";
|
|
2
2
|
import { loadEnv } from "./load.mjs";
|
|
3
3
|
import { isString } from "@stryke/type-checks/is-string";
|
|
4
|
+
import { getCacheDirectory } from "@powerlines/schema";
|
|
4
5
|
import { extract } from "@powerlines/schema/extract";
|
|
5
|
-
import { getProperties, mergeSchemas } from "@powerlines/schema/helpers";
|
|
6
|
+
import { getProperties as getProperties$1, mergeSchemas } from "@powerlines/schema/helpers";
|
|
7
|
+
import { joinPaths } from "@stryke/path/join";
|
|
6
8
|
import { isSetArray } from "@stryke/type-checks/is-set-array";
|
|
7
9
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
10
|
import defu from "defu";
|
|
@@ -88,10 +90,11 @@ async function extractEnvSchema(context, options = {}) {
|
|
|
88
90
|
parsed: {},
|
|
89
91
|
injected: []
|
|
90
92
|
});
|
|
91
|
-
|
|
93
|
+
await readActiveEnv(context);
|
|
94
|
+
const properties = getProperties$1(context.env.vars);
|
|
92
95
|
context.info({
|
|
93
96
|
meta: { category: "env" },
|
|
94
|
-
message: `Environment Variables configuration: ${options.vars ? "" : "Defaulted "}${context.env.vars.variant === "reflection" ? "Deepkit type definition" : context.env.vars.variant === "json-schema" ? "JSON Schema" : context.env.vars.variant === "standard-schema" ? "Standard Schema" : context.env.vars.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.vars ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${options.secrets ? "" : "Defaulted "}${context.env.secrets.variant === "reflection" ? "Deepkit type definition" : context.env.secrets.variant === "json-schema" ? "JSON Schema" : context.env.secrets.variant === "standard-schema" ? "Standard Schema" : context.env.secrets.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? Object.keys(getProperties(context.env.secrets)).length : "0"} parameters\nEnvironment variable Prefixes: ${context.config.env.prefix.join(", ")}\nShould inject values: ${context.config.env.inject ? "Yes" : "No"}\nShould validate configuration: ${context.config.env.validate ? "Yes" : "No"}`
|
|
97
|
+
message: `Environment Variables configuration: ${options.vars ? "" : "Defaulted "}${context.env.vars.variant === "reflection" ? "Deepkit type definition" : context.env.vars.variant === "json-schema" ? "JSON Schema" : context.env.vars.variant === "standard-schema" ? "Standard Schema" : context.env.vars.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.vars ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${options.secrets ? "" : "Defaulted "}${context.env.secrets.variant === "reflection" ? "Deepkit type definition" : context.env.secrets.variant === "json-schema" ? "JSON Schema" : context.env.secrets.variant === "standard-schema" ? "Standard Schema" : context.env.secrets.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? Object.keys(getProperties$1(context.env.secrets)).length : "0"} parameters\nEnvironment variable Prefixes: ${context.config.env.prefix.join(", ")}\nShould inject values: ${context.config.env.inject ? "Yes" : "No"}\nShould validate configuration: ${context.config.env.validate ? "Yes" : "No"}`
|
|
95
98
|
});
|
|
96
99
|
const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => isSetArray(prop.metadata?.alias) ? prop.metadata?.alias?.map(__assignType((alias) => [alias, {
|
|
97
100
|
...prop,
|
|
@@ -151,7 +154,46 @@ extractEnvSchema.__type = [
|
|
|
151
154
|
"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.",
|
|
152
155
|
"P\"2!n\"2#>$$`/%?&"
|
|
153
156
|
];
|
|
157
|
+
/**
|
|
158
|
+
* Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
|
|
159
|
+
*
|
|
160
|
+
* @param context - The plugin context
|
|
161
|
+
* @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
|
|
162
|
+
*/
|
|
163
|
+
async function readActiveEnv(context) {
|
|
164
|
+
context.env.vars.active ??= [];
|
|
165
|
+
if (context.fs.existsSync(joinPaths(getCacheDirectory(context), "env", "vars.json"))) {
|
|
166
|
+
const content = await context.fs.read(joinPaths(getCacheDirectory(context), "env", "vars.json"));
|
|
167
|
+
if (content) context.env.vars.active = JSON.parse(content)?.elements ?? [];
|
|
168
|
+
}
|
|
169
|
+
context.env.secrets.active ??= [];
|
|
170
|
+
if (context.fs.existsSync(joinPaths(getCacheDirectory(context), "env", "secrets.json"))) {
|
|
171
|
+
const content = await context.fs.read(joinPaths(getCacheDirectory(context), "env", "secrets.json"));
|
|
172
|
+
if (content) context.env.secrets.active = JSON.parse(content)?.elements ?? [];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
readActiveEnv.__type = [
|
|
176
|
+
"context",
|
|
177
|
+
"readActiveEnv",
|
|
178
|
+
"Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.",
|
|
179
|
+
"P\"2!\"/\"?#"
|
|
180
|
+
];
|
|
181
|
+
/**
|
|
182
|
+
* Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
|
|
183
|
+
*
|
|
184
|
+
* @param context - The plugin context
|
|
185
|
+
* @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
|
|
186
|
+
*/
|
|
187
|
+
async function writeActiveEnv(context) {
|
|
188
|
+
return Promise.all([isSetArray(context.env.vars.active) ? context.fs.write(joinPaths(getCacheDirectory(context), "env", "vars.json"), JSON.stringify({ elements: context.env.vars.active })) : void 0, isSetArray(context.env.secrets.active) ? context.fs.write(joinPaths(getCacheDirectory(context), "env", "secrets.json"), JSON.stringify({ elements: context.env.secrets.active })) : void 0].filter(Boolean));
|
|
189
|
+
}
|
|
190
|
+
writeActiveEnv.__type = [
|
|
191
|
+
"context",
|
|
192
|
+
"writeActiveEnv",
|
|
193
|
+
"Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.",
|
|
194
|
+
"P\"2!\"/\"?#"
|
|
195
|
+
];
|
|
154
196
|
|
|
155
197
|
//#endregion
|
|
156
|
-
export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
|
|
198
|
+
export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, readActiveEnv, resolveRuntimeTypeFile, writeActiveEnv };
|
|
157
199
|
//# sourceMappingURL=schema.mjs.map
|
|
@@ -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 { ObjectSchema } from \"@powerlines/schema\";\nimport { extract } from \"@powerlines/schema/extract\";\nimport { getProperties, mergeSchemas } from \"@powerlines/schema/helpers\";\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 {\n EnvPluginContext,\n EnvPluginOptions,\n EnvSchemaMetadata\n} 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 * 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 * @param options - The plugin options containing the environment variables and secrets type definitions to extract the schema from. If not provided, the default type definitions will be used.\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnvSchema<TContext extends EnvPluginContext>(\n context: TContext,\n options: EnvPluginOptions = {}\n): Promise<void> {\n const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);\n const defaultSecretsTypeDefinition =\n await getDefaultSecretsTypeDefinition(context);\n\n const vars = (await extract(\n context,\n context.config.env.vars\n )) as ObjectSchema<EnvSchemaMetadata>;\n if (\n (isString(context.config.env.vars) &&\n context.config.env.vars !==\n `${defaultVarsTypeDefinition.file}#${\n defaultVarsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.vars) &&\n ((context.config.env.vars as TypeDefinition).file !==\n defaultVarsTypeDefinition.file ||\n (context.config.env.vars as TypeDefinition).name !==\n defaultVarsTypeDefinition.name))\n ) {\n vars.schema = mergeSchemas(\n vars,\n (await extract(\n context,\n defaultVarsTypeDefinition\n )) as ObjectSchema<EnvSchemaMetadata>\n );\n }\n\n const secrets = (await extract(\n context,\n context.config.env.secrets\n )) as ObjectSchema<EnvSchemaMetadata>;\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(\n context,\n defaultSecretsTypeDefinition\n )) as ObjectSchema<EnvSchemaMetadata>\n );\n }\n\n context.env = defu(\n {\n vars,\n secrets,\n parsed: await loadEnv(context, context.config.env)\n },\n context.env ?? {},\n {\n parsed: {},\n injected: []\n }\n );\n\n const properties = getProperties(context.env.vars);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n options.vars ? \"\" : \"Defaulted \"\n }${\n context.env.vars.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.vars.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.vars.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.vars.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${options.vars ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n options.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 }${options.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? Object.keys(getProperties(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.metadata?.alias)\n ? prop.metadata?.alias?.map(alias => [\n alias,\n { ...prop, metadata: { ...prop.metadata, alias: [key] } }\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].metadata?.isRuntime) {\n if (\n properties[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[unprefixedKey]\n ) {\n context.env.vars.schema.optionalProperties[unprefixedKey].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.optionalProperties[\n unprefixedKey\n ].metadata.default = value;\n } else if (context.env.vars.schema.properties?.[unprefixedKey]) {\n context.env.vars.schema.properties[unprefixedKey].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.properties[unprefixedKey].metadata.default =\n value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey].metadata?.isRuntime) {\n const alias =\n aliases[unprefixedKey].metadata?.alias?.[0] ?? unprefixedKey;\n if (\n aliases[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[alias]\n ) {\n context.env.vars.schema.optionalProperties[alias].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.optionalProperties[alias].metadata.default =\n value;\n } else if (context.env.vars.schema.properties?.[alias]) {\n context.env.vars.schema.properties[alias].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.properties[alias].metadata.default = value;\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;;;;;;;AAcA,eAAmB,uBAAyB,SAAQ;CACpD,MAAQ,WAAC,MAAe,QAAA,GAAY,QAAQ,kCAA4B;CACxE,IAAM,CAAC,UACP,MAAS,IAAA,MAAW,yJAA2C;CAE/D,OAAO;AACP;AACA,uBAAS,SAAoB;CAAI;CAAE;CAAW;CAAA;AAAA;;;;;;;;CAQ5C,OAAA;EACC,MAAA,MAAa,uBAAuB,OAAM;EAC5C,MAAA;CACC;AACF;AACA,6BAAE,SAAA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AAA,OAAA,EAAA,EAAA,MAAgC,OAAQ,MAAA;GAEhD,OAAW;EACT,GAAA;GAAA;GAAO;GAAA;GAAA;EAAA,CAAA,GAAA,GAAA;EACP,IAAA,WAAe,gBACd;OAAG,CAAA,WAAa,eAAA,UAAkB,WAClC;QAAA,WAAA,eAAA,YAAA,QAAA,IAAA,KAAA,OAAA,qBAAA,gBAAA;KACA,QAAS,IAAQ,KAAA,OAAW,mBAAO,eAAA,aAAA,CAAA;KAClC,QAAQ,IAAO,KAAI,OAAO,mBAAA,eAAA,SAAA,UAAA;IACxB,OAAG,IAAA,QAAA,IAAA,KAAyB,OAAO,aAAC,gBAAA;KAClC,QAAA,IAAA,KAAA,OAAA,WAA0B,eAAA,aAAA,CAAA;KAC1B,QAAG,IAAA,KAAA,OAAA,WAAA,eAAA,SAAA,UAAA;IACR;;EACC,OACE,IAAA,QAAA,gBACF;OAAG,CAAA,QAAQ,eAAgB,UAAG,WAAgB;IAC5C,MAAE,QAAA,QAAA,eAA+B,UAAA,QAAA,MAAA;IACrC,IAAA,QAAA,eAAA,YAAA,QAAA,IAAA,KAAA,OAAA,qBAAA,QAAA;KACK,QAAS,IAAA,KAAA,OAAY,mBAAA,OAAA,aAAA,CAAA;KACpB,QAAA,IAAA,KAAA,OAAA,mBAAA,OAAA,SAAA,UAAA;IACH,OAAM,IAAA,QAAO,IAAA,KAAA,OAAA,aAAA,QAAA;KACZ,QAAO,IAAA,KAAA,OAAA,WAAA,OAAA,aAAA,CAAA;KACP,QAAA,IAAA,KAAA,OAAA,WAAA,OAAA,SAAA,UAAA;IACA;GACH;;;AAGL;AACA,iBAAW,SAAA;CAAA;OAAA;CAAA;QAAA,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 { getCacheDirectory } from \"@powerlines/schema\";\nimport { extract } from \"@powerlines/schema/extract\";\nimport { getProperties, mergeSchemas } from \"@powerlines/schema/helpers\";\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, EnvPluginOptions, 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 * 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 * @param options - The plugin options containing the environment variables and secrets type definitions to extract the schema from. If not provided, the default type definitions will be used.\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnvSchema<TContext extends EnvPluginContext>(\n context: TContext,\n options: EnvPluginOptions = {}\n): Promise<void> {\n const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);\n const defaultSecretsTypeDefinition =\n await getDefaultSecretsTypeDefinition(context);\n\n const vars = (await extract(context, context.config.env.vars)) as EnvSchema;\n if (\n (isString(context.config.env.vars) &&\n context.config.env.vars !==\n `${defaultVarsTypeDefinition.file}#${\n defaultVarsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.vars) &&\n ((context.config.env.vars as TypeDefinition).file !==\n defaultVarsTypeDefinition.file ||\n (context.config.env.vars as TypeDefinition).name !==\n defaultVarsTypeDefinition.name))\n ) {\n vars.schema = mergeSchemas(\n vars,\n (await extract(context, defaultVarsTypeDefinition)) as EnvSchema\n );\n }\n\n const secrets = (await extract(\n context,\n context.config.env.secrets\n )) as EnvSchema;\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)) as EnvSchema\n );\n }\n\n context.env = defu(\n {\n vars,\n secrets,\n parsed: await loadEnv(context, context.config.env)\n },\n context.env ?? {},\n {\n parsed: {},\n injected: []\n }\n );\n await readActiveEnv(context);\n\n const properties = getProperties(context.env.vars);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n options.vars ? \"\" : \"Defaulted \"\n }${\n context.env.vars.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.vars.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.vars.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.vars.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${options.vars ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n options.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 }${options.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? Object.keys(getProperties(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.metadata?.alias)\n ? prop.metadata?.alias?.map(alias => [\n alias,\n { ...prop, metadata: { ...prop.metadata, alias: [key] } }\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].metadata?.isRuntime) {\n if (\n properties[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[unprefixedKey]\n ) {\n context.env.vars.schema.optionalProperties[unprefixedKey].metadata ??=\n {};\n context.env.vars.schema.optionalProperties[\n unprefixedKey\n ].metadata.default = value;\n } else if (context.env.vars.schema.properties?.[unprefixedKey]) {\n context.env.vars.schema.properties[unprefixedKey].metadata ??= {};\n context.env.vars.schema.properties[unprefixedKey].metadata.default =\n value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey].metadata?.isRuntime) {\n const alias =\n aliases[unprefixedKey].metadata?.alias?.[0] ?? unprefixedKey;\n if (\n aliases[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[alias]\n ) {\n context.env.vars.schema.optionalProperties[alias].metadata ??= {};\n context.env.vars.schema.optionalProperties[alias].metadata.default =\n value;\n } else if (context.env.vars.schema.properties?.[alias]) {\n context.env.vars.schema.properties[alias].metadata ??= {};\n context.env.vars.schema.properties[alias].metadata.default = value;\n }\n }\n }\n }\n}\n\n/**\n * Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.\n */\nexport async function readActiveEnv<TContext extends EnvPluginContext>(\n context: TContext\n) {\n context.env.vars.active ??= [];\n if (\n context.fs.existsSync(\n joinPaths(getCacheDirectory(context), \"env\", \"vars.json\")\n )\n ) {\n const content = await context.fs.read(\n joinPaths(getCacheDirectory(context), \"env\", \"vars.json\")\n );\n if (content) {\n context.env.vars.active = JSON.parse(content)?.elements ?? [];\n }\n }\n\n context.env.secrets.active ??= [];\n if (\n context.fs.existsSync(\n joinPaths(getCacheDirectory(context), \"env\", \"secrets.json\")\n )\n ) {\n const content = await context.fs.read(\n joinPaths(getCacheDirectory(context), \"env\", \"secrets.json\")\n );\n if (content) {\n context.env.secrets.active = JSON.parse(content)?.elements ?? [];\n }\n }\n}\n\n/**\n * Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.\n */\nexport async function writeActiveEnv<TContext extends EnvPluginContext>(\n context: TContext\n) {\n return Promise.all(\n [\n isSetArray(context.env.vars.active)\n ? context.fs.write(\n joinPaths(getCacheDirectory(context), \"env\", \"vars.json\"),\n JSON.stringify({\n elements: context.env.vars.active\n })\n )\n : undefined,\n isSetArray(context.env.secrets.active)\n ? context.fs.write(\n joinPaths(getCacheDirectory(context), \"env\", \"secrets.json\"),\n JSON.stringify({\n elements: context.env.secrets.active\n })\n )\n : undefined\n ].filter(Boolean) as Promise<void>[]\n );\n}\n"],"mappings":";;;;;;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;;;;;;;AAiCA,eAAmB,uBAAA,SAAA;CACjB,MAAA,WAAiB,MAAG,QAAQ,GAAM,QAAE,kCAAA;CACpC,IAAA,CAAK,UACH,MAAG,IAAA,MAAU,yJAAA;CAEf,OAAK;AACP;AACA,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;AAOF,eAAC,6BAAA,SAAA;CACC,OAAO;EACL,MAAA,MAAY,uBAAuB,OAAK;EAC1C,MAAA;CACF;AACA;AACA,6BAA6B,SAAC;CAAA;CAAgB;CAAA;CAAA;AAAA;;;;;;;CAO5C,OAAO;EACR,MAAA,MAAA,uBAAA,OAAA;EACG,MAAM;CACR;AACF;AACA,gCAAsB,SA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AU;CAChC,IAAI,QAAI,GAAO,WAAU,UAAW,kBAAa,OAAA,GAAA,OAAA,cAAA,CAAA,GAAA;EAC/C,MAAM,UAAQ,MAAM,QAAA,GAAA,KAAA,UAAA,kBAAA,OAAA,GAAA,OAAA,cAAA,CAAA;EACpB,IAAI,SACF,QAAQ,IAAC,QAAS,SAAM,KAAA,MAAA,OAAA,GAAA,YAAA,CAAA;CAE5B;AACF;AACA,cAAc,SAAS;CAAC;CAAW;CAAgB;CAAU;AAAA;;;;;;;AAO7D,eAAsB,eAAe,SAAM;CACzC,OAAO,QAAQ,IAAC,CAAA,WAAM,QAAA,IAAA,KAAA,MAAA,IAAA,QAAA,GAAA,MAAA,UAAA,kBAAA,OAAA,GAAA,OAAA,WAAA,GAAA,KAAA,UAAA,EACpB,UAAQ,QAAQ,IAAI,KAAO,OAC7B,CAAC,CAAC,IAAI,QAAO,WAAe,QAAA,IAAA,QAAA,MAAA,IAAA,QAAA,GAAA,MAAA,UAAA,kBAAA,OAAA,GAAA,OAAA,cAAA,GAAA,KAAA,UAAA,EAC1B,UAAU,QAAQ,IAAI,QAAQ,OAChC,CAAC,CAAC,IAAI,MAAS,EAAA,OAAO,OAAM,CAAA;AAC9B;AACA,eAAe,SAAS;CAAC;CAAO;CAAsB;CAAU;AAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -7,11 +7,11 @@ const require_helpers_automd_generator = require('./helpers/automd-generator.cjs
|
|
|
7
7
|
const require_components_docs = require('./components/docs.cjs');
|
|
8
8
|
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
9
9
|
const require_babel_plugin = require('./babel/plugin.cjs');
|
|
10
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
10
11
|
let defu = require("defu");
|
|
11
12
|
defu = require_runtime.__toESM(defu);
|
|
12
13
|
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
13
14
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
14
|
-
let _stryke_path_join = require("@stryke/path/join");
|
|
15
15
|
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
16
16
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
17
17
|
let _powerlines_plugin_automd = require("@powerlines/plugin-automd");
|
|
@@ -128,7 +128,7 @@ exports.__ΩEnvPluginContext = require_types_plugin.__ΩEnvPluginContext;
|
|
|
128
128
|
exports.__ΩEnvPluginOptions = require_types_plugin.__ΩEnvPluginOptions;
|
|
129
129
|
exports.__ΩEnvPluginResolvedConfig = require_types_plugin.__ΩEnvPluginResolvedConfig;
|
|
130
130
|
exports.__ΩEnvPluginUserConfig = require_types_plugin.__ΩEnvPluginUserConfig;
|
|
131
|
-
exports.__Ω
|
|
131
|
+
exports.__ΩEnvSchema = require_types_plugin.__ΩEnvSchema;
|
|
132
132
|
exports.__ΩEnvType = require_types_plugin.__ΩEnvType;
|
|
133
133
|
exports.__ΩSecretsInterface = require_types_env.__ΩSecretsInterface;
|
|
134
134
|
exports.default = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
1
|
+
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./types/plugin.cjs";
|
|
2
2
|
import { EnvInterface, SecretsInterface } from "./types/env.cjs";
|
|
3
3
|
import { Plugin } from "powerlines";
|
|
4
4
|
|
|
@@ -13,5 +13,5 @@ declare module "powerlines" {
|
|
|
13
13
|
*/
|
|
14
14
|
declare const plugin: <TContext extends EnvPluginContext = EnvPluginContext>(options?: EnvPluginOptions) => Plugin<TContext>[];
|
|
15
15
|
//#endregion
|
|
16
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
16
|
+
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface, plugin as default, plugin };
|
|
17
17
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
1
|
+
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./types/plugin.mjs";
|
|
2
2
|
import { EnvInterface, SecretsInterface } from "./types/env.mjs";
|
|
3
3
|
import { Plugin } from "powerlines";
|
|
4
4
|
|
|
@@ -13,5 +13,5 @@ declare module "powerlines" {
|
|
|
13
13
|
*/
|
|
14
14
|
declare const plugin: <TContext extends EnvPluginContext = EnvPluginContext>(options?: EnvPluginOptions) => Plugin<TContext>[];
|
|
15
15
|
//#endregion
|
|
16
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
16
|
+
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface, plugin as default, plugin };
|
|
17
17
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __Ω
|
|
1
|
+
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType } from "./types/plugin.mjs";
|
|
2
2
|
import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/env.mjs";
|
|
3
3
|
import { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition } from "./helpers/schema.mjs";
|
|
4
4
|
import { env } from "./helpers/automd-generator.mjs";
|
|
5
5
|
import { EnvDocsFile } from "./components/docs.mjs";
|
|
6
6
|
import { EnvBuiltin } from "./components/env-builtin.mjs";
|
|
7
7
|
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
8
|
+
import { joinPaths } from "@stryke/path/join";
|
|
8
9
|
import defu from "defu";
|
|
9
10
|
import { getDocsOutputPath } from "powerlines/plugin-utils";
|
|
10
11
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
11
|
-
import { joinPaths } from "@stryke/path/join";
|
|
12
12
|
import { getUnique } from "@stryke/helpers/get-unique";
|
|
13
13
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
14
14
|
import automd from "@powerlines/plugin-automd";
|
|
@@ -118,5 +118,5 @@ const plugin = __assignType((options = {}) => {
|
|
|
118
118
|
]);
|
|
119
119
|
|
|
120
120
|
//#endregion
|
|
121
|
-
export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __Ω
|
|
121
|
+
export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType, __ΩSecretsInterface, plugin as default, plugin };
|
|
122
122
|
//# sourceMappingURL=index.mjs.map
|
package/dist/types/index.cjs
CHANGED
|
@@ -7,6 +7,6 @@ exports.__ΩEnvPluginContext = require_types_plugin.__ΩEnvPluginContext;
|
|
|
7
7
|
exports.__ΩEnvPluginOptions = require_types_plugin.__ΩEnvPluginOptions;
|
|
8
8
|
exports.__ΩEnvPluginResolvedConfig = require_types_plugin.__ΩEnvPluginResolvedConfig;
|
|
9
9
|
exports.__ΩEnvPluginUserConfig = require_types_plugin.__ΩEnvPluginUserConfig;
|
|
10
|
-
exports.__Ω
|
|
10
|
+
exports.__ΩEnvSchema = require_types_plugin.__ΩEnvSchema;
|
|
11
11
|
exports.__ΩEnvType = require_types_plugin.__ΩEnvType;
|
|
12
12
|
exports.__ΩSecretsInterface = require_types_env.__ΩSecretsInterface;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
1
|
+
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./plugin.cjs";
|
|
2
2
|
import { EnvInterface, SecretsInterface } from "./env.cjs";
|
|
3
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
3
|
+
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
1
|
+
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./plugin.mjs";
|
|
2
2
|
import { EnvInterface, SecretsInterface } from "./env.mjs";
|
|
3
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
3
|
+
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface };
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __Ω
|
|
1
|
+
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType } from "./plugin.mjs";
|
|
2
2
|
import { __ΩEnvInterface, __ΩSecretsInterface } from "./env.mjs";
|
|
3
3
|
|
|
4
|
-
export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __Ω
|
|
4
|
+
export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType, __ΩSecretsInterface };
|
package/dist/types/plugin.cjs
CHANGED
|
@@ -20,6 +20,11 @@ const __ΩPick = [
|
|
|
20
20
|
"Pick",
|
|
21
21
|
"l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
|
|
22
22
|
];
|
|
23
|
+
const __ΩPartial = [
|
|
24
|
+
"T",
|
|
25
|
+
"Partial",
|
|
26
|
+
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
27
|
+
];
|
|
23
28
|
const __ΩExclude = [
|
|
24
29
|
"T",
|
|
25
30
|
"U",
|
|
@@ -76,17 +81,22 @@ const __ΩEnvPluginResolvedConfig = [
|
|
|
76
81
|
"EnvPluginResolvedConfig",
|
|
77
82
|
"P!PP!.#o\"#o!\"!P)4$?%)4&?'&F4(?)MK4*MKw+y"
|
|
78
83
|
];
|
|
79
|
-
const __Ω
|
|
84
|
+
const __ΩEnvSchema = [
|
|
85
|
+
() => __ΩPartial,
|
|
86
|
+
"TMetadata",
|
|
80
87
|
"active",
|
|
81
88
|
"The active environment variables or secrets that are used by the project and are expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true).",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
89
|
+
"The schema for the environment variables or secrets used by the project and expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true). This schema extends the base {@link ObjectSchema} with additional metadata specific to environment variables, including an `active` property that lists the environment variables or secrets that are currently active and should be injected during the build process.",
|
|
90
|
+
"EnvSchema",
|
|
91
|
+
"!o!\"c\"P!&F4#?$M?%w&y"
|
|
84
92
|
];
|
|
85
93
|
const __ΩEnvPluginContext = [
|
|
86
94
|
() => __ΩEnvPluginResolvedConfig,
|
|
87
95
|
"TResolvedConfig",
|
|
96
|
+
() => __ΩEnvSchema,
|
|
88
97
|
"vars",
|
|
89
98
|
"The type definition for the expected env variable parameters",
|
|
99
|
+
() => __ΩEnvSchema,
|
|
90
100
|
"secrets",
|
|
91
101
|
"The type definition for the expected env secret parameters",
|
|
92
102
|
"parsed",
|
|
@@ -95,7 +105,7 @@ const __ΩEnvPluginContext = [
|
|
|
95
105
|
"The injected environment variables and secrets reflection",
|
|
96
106
|
"env",
|
|
97
107
|
"EnvPluginContext",
|
|
98
|
-
"n!c\"P!
|
|
108
|
+
"n!c\"P!Pn#4$?%n&4'?(!4)?*&F4+?,M4-Mw.y"
|
|
99
109
|
];
|
|
100
110
|
|
|
101
111
|
//#endregion
|
|
@@ -103,5 +113,5 @@ exports.__ΩEnvPluginContext = __ΩEnvPluginContext;
|
|
|
103
113
|
exports.__ΩEnvPluginOptions = __ΩEnvPluginOptions;
|
|
104
114
|
exports.__ΩEnvPluginResolvedConfig = __ΩEnvPluginResolvedConfig;
|
|
105
115
|
exports.__ΩEnvPluginUserConfig = __ΩEnvPluginUserConfig;
|
|
106
|
-
exports.__Ω
|
|
116
|
+
exports.__ΩEnvSchema = __ΩEnvSchema;
|
|
107
117
|
exports.__ΩEnvType = __ΩEnvType;
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -86,7 +86,10 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
|
86
86
|
prefix: string[];
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
|
+
* The schema for the environment variables or secrets used by the project and expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true). This schema extends the base {@link ObjectSchema} with additional metadata specific to environment variables, including an `active` property that lists the environment variables or secrets that are currently active and should be injected during the build process.
|
|
91
|
+
*/
|
|
92
|
+
interface EnvSchema<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>> extends ObjectSchema<TMetadata> {
|
|
90
93
|
/**
|
|
91
94
|
* The active environment variables or secrets that are used by the project and are expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true).
|
|
92
95
|
*/
|
|
@@ -100,14 +103,14 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
|
|
|
100
103
|
* @remarks
|
|
101
104
|
* This value is parsed from the {@link EnvPluginOptions.vars} option.
|
|
102
105
|
*/
|
|
103
|
-
vars:
|
|
106
|
+
vars: EnvSchema;
|
|
104
107
|
/**
|
|
105
108
|
* The type definition for the expected env secret parameters
|
|
106
109
|
*
|
|
107
110
|
* @remarks
|
|
108
111
|
* This value is parsed from the {@link EnvPluginOptions.secrets} option.
|
|
109
112
|
*/
|
|
110
|
-
secrets:
|
|
113
|
+
secrets: EnvSchema;
|
|
111
114
|
/**
|
|
112
115
|
* The parsed .env configuration object
|
|
113
116
|
*
|
|
@@ -125,5 +128,5 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
|
|
|
125
128
|
};
|
|
126
129
|
}
|
|
127
130
|
//#endregion
|
|
128
|
-
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
131
|
+
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType };
|
|
129
132
|
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;KAmCY,OAAA;AAAA,KAEA,gBAAA,GAAmB,IAAA,CAAK,mBAAA;EAFxB;;;EAMV,IAAA,GAAO,WAAA;EANU;AAEnB;;EASE,OAAA,GAAU,WAAA;EATwB;;;;;;EAiBlC,MAAA;EAsC4B;;;;;EA/B5B,MAAA;EAfA;;;;;EAsBA,QAAA;EAQgB;;;;;;EA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3B,GAAA;IAH+B;;;;;;IAU7B,IAAA,EAAM,SAAA;IAgBE;;;;;;IARR,OAAA,EAAS,SAAA;IAhBH;;;;;;IAwBN,MAAA,EAAQ,iBAAA;IAAR;;;;AAQQ;;IAAR,QAAA;EAAA;AAAA"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
2
|
-
import { Children } from "@alloy-js/core";
|
|
3
2
|
import { ObjectSchema, SchemaInput, SchemaMetadata } from "@powerlines/schema";
|
|
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";
|
|
6
6
|
import { RequiredKeys } from "@stryke/types";
|
|
@@ -86,7 +86,10 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
|
86
86
|
prefix: string[];
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
|
+
* The schema for the environment variables or secrets used by the project and expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true). This schema extends the base {@link ObjectSchema} with additional metadata specific to environment variables, including an `active` property that lists the environment variables or secrets that are currently active and should be injected during the build process.
|
|
91
|
+
*/
|
|
92
|
+
interface EnvSchema<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>> extends ObjectSchema<TMetadata> {
|
|
90
93
|
/**
|
|
91
94
|
* The active environment variables or secrets that are used by the project and are expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true).
|
|
92
95
|
*/
|
|
@@ -100,14 +103,14 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
|
|
|
100
103
|
* @remarks
|
|
101
104
|
* This value is parsed from the {@link EnvPluginOptions.vars} option.
|
|
102
105
|
*/
|
|
103
|
-
vars:
|
|
106
|
+
vars: EnvSchema;
|
|
104
107
|
/**
|
|
105
108
|
* The type definition for the expected env secret parameters
|
|
106
109
|
*
|
|
107
110
|
* @remarks
|
|
108
111
|
* This value is parsed from the {@link EnvPluginOptions.secrets} option.
|
|
109
112
|
*/
|
|
110
|
-
secrets:
|
|
113
|
+
secrets: EnvSchema;
|
|
111
114
|
/**
|
|
112
115
|
* The parsed .env configuration object
|
|
113
116
|
*
|
|
@@ -125,5 +128,5 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
|
|
|
125
128
|
};
|
|
126
129
|
}
|
|
127
130
|
//#endregion
|
|
128
|
-
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig,
|
|
131
|
+
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType };
|
|
129
132
|
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;KAmCY,OAAA;AAAA,KAEA,gBAAA,GAAmB,IAAA,CAAK,mBAAA;EAFxB;;;EAMV,IAAA,GAAO,WAAA;EANU;AAEnB;;EASE,OAAA,GAAU,WAAA;EATwB;;;;;;EAiBlC,MAAA;EAsC4B;;;;;EA/B5B,MAAA;EAfA;;;;;EAsBA,QAAA;EAQgB;;;;;;EAAhB,aAAA,GAAgB,QAAA;EAmBN;;;;;;EAXV,KAAA,GAAQ,kBAAA;EAYa;AAAA;AAGvB;;;;EAPE,MAAA,GAAS,mBAAA;AAAA;AAAA,KAGC,mBAAA,GAAsB,qBAAA;EAChC,GAAA,EAAK,gBAAgB;AAAA;AAAA,KAGX,uBAAA,GAA0B,yBAAA;EACpC,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,mBAAA,wBACjB,YAAA,CAAa,gBAAA;IAFqB;;;;;;IAShC,MAAA;I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|
21
|
+
const __ΩPartial = [
|
|
22
|
+
"T",
|
|
23
|
+
"Partial",
|
|
24
|
+
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
25
|
+
];
|
|
21
26
|
const __ΩExclude = [
|
|
22
27
|
"T",
|
|
23
28
|
"U",
|
|
@@ -74,17 +79,22 @@ const __ΩEnvPluginResolvedConfig = [
|
|
|
74
79
|
"EnvPluginResolvedConfig",
|
|
75
80
|
"P!PP!.#o\"#o!\"!P)4$?%)4&?'&F4(?)MK4*MKw+y"
|
|
76
81
|
];
|
|
77
|
-
const __Ω
|
|
82
|
+
const __ΩEnvSchema = [
|
|
83
|
+
() => __ΩPartial,
|
|
84
|
+
"TMetadata",
|
|
78
85
|
"active",
|
|
79
86
|
"The active environment variables or secrets that are used by the project and are expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true).",
|
|
80
|
-
"
|
|
81
|
-
"
|
|
87
|
+
"The schema for the environment variables or secrets used by the project and expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true). This schema extends the base {@link ObjectSchema} with additional metadata specific to environment variables, including an `active` property that lists the environment variables or secrets that are currently active and should be injected during the build process.",
|
|
88
|
+
"EnvSchema",
|
|
89
|
+
"!o!\"c\"P!&F4#?$M?%w&y"
|
|
82
90
|
];
|
|
83
91
|
const __ΩEnvPluginContext = [
|
|
84
92
|
() => __ΩEnvPluginResolvedConfig,
|
|
85
93
|
"TResolvedConfig",
|
|
94
|
+
() => __ΩEnvSchema,
|
|
86
95
|
"vars",
|
|
87
96
|
"The type definition for the expected env variable parameters",
|
|
97
|
+
() => __ΩEnvSchema,
|
|
88
98
|
"secrets",
|
|
89
99
|
"The type definition for the expected env secret parameters",
|
|
90
100
|
"parsed",
|
|
@@ -93,9 +103,9 @@ const __ΩEnvPluginContext = [
|
|
|
93
103
|
"The injected environment variables and secrets reflection",
|
|
94
104
|
"env",
|
|
95
105
|
"EnvPluginContext",
|
|
96
|
-
"n!c\"P!
|
|
106
|
+
"n!c\"P!Pn#4$?%n&4'?(!4)?*&F4+?,M4-Mw.y"
|
|
97
107
|
];
|
|
98
108
|
|
|
99
109
|
//#endregion
|
|
100
|
-
export { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __Ω
|
|
110
|
+
export { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType };
|
|
101
111
|
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -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 {\n ObjectSchema,\n SchemaInput,\n SchemaMetadata\n} 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 vars?: 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, \"vars\" | \"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\nexport interface
|
|
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 {\n ObjectSchema,\n SchemaInput,\n SchemaMetadata\n} 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 vars?: 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, \"vars\" | \"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 the environment variables or secrets used by the project and expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true). This schema extends the base {@link ObjectSchema} with additional metadata specific to environment variables, including an `active` property that lists the environment variables or secrets that are currently active and should be injected during the build process.\n */\nexport interface EnvSchema<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n> extends ObjectSchema<TMetadata> {\n /**\n * The active environment variables or secrets that are used by the project and are expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true).\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.vars} option.\n */\n vars: 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;CAAS;CAAG;CAAY;AAAoB;AAC3D,MAAI,aAAc;CAAA;CAAM;CAAc;CAAW;AAAK;AAEtD,MAAK,sBAAuB;OAAG;CAAa;CAAK;CAAS;CAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAE7E,MAAC,yBAA0B;OAAQ;CAAc;CAAA;CAAA;AAAA;AAEjD,MAAC,6BAAkC;OAAK;OAAkB;CAAS;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.238",
|
|
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"],
|
|
@@ -108,11 +108,11 @@
|
|
|
108
108
|
"@babel/core": "8.0.0-rc.5",
|
|
109
109
|
"@babel/types": "8.0.0-rc.5",
|
|
110
110
|
"@powerlines/core": "^0.15.22",
|
|
111
|
-
"@powerlines/plugin-alloy": "^0.26.
|
|
111
|
+
"@powerlines/plugin-alloy": "^0.26.130",
|
|
112
112
|
"@powerlines/plugin-automd": "^0.1.506",
|
|
113
113
|
"@powerlines/plugin-babel": "^0.13.41",
|
|
114
114
|
"@powerlines/plugin-plugin": "^0.12.457",
|
|
115
|
-
"@powerlines/schema": "^0.11.
|
|
115
|
+
"@powerlines/schema": "^0.11.25",
|
|
116
116
|
"@storm-software/config-tools": "^1.190.20",
|
|
117
117
|
"@stryke/capnp": "^0.12.102",
|
|
118
118
|
"@stryke/convert": "^0.7.7",
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
},
|
|
132
132
|
"devDependencies": { "@types/node": "^25.9.0", "vite": "^8.0.13" },
|
|
133
133
|
"publishConfig": { "access": "public" },
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "ff6d22768ebad99001bfa73846017aaa9c1b3dab"
|
|
135
135
|
}
|