@powerlines/plugin-env 0.16.122 → 0.16.123

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.
@@ -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: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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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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 { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport { TypeScriptCompilerPluginUserConfig } from \"@powerlines/plugin-tsc\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\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 { VIRTUAL_MODULE_PREFIX } from \"powerlines/constants\";\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 deepkit(options.deepkit),\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 deepkit: {\n reflection: \"default\",\n level: \"all\"\n },\n tsc: {} as TypeScriptCompilerPluginUserConfig[\"tsc\"]\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 if (config.env.types || config.env.secrets) {\n config.tsc.filter = {\n id: [\n new RegExp(\n `^(${VIRTUAL_MODULE_PREFIX})?${joinPaths(\n this.builtinsPath,\n \"env.ts\"\n )\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\\//g, \"\\\\/\")\n .replace(/\\./g, \"\\\\.\")\n .replace(/\\$/g, \"\\\\$\")}$`\n )\n ]\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 \"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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAI,aAAc,IAAM,MAAQ;AAC/B,IAAI,SAAK;AACT,QAAI;;;;;AA4CL,MAAE,SAAA,cAAyB,UAAA,EAAA,KAAA;AACzB,QAAA;EAAA,QAAA,QAAA,QAA+B;EAAA,MAAA,QAAA,MAAA;EAAA;GAC/B,MAAA;GACA,MAAA,SAAA;AACA,SAAA,MAAA,yEAAqB;IACrB,MAAA,SAAkB;KAClB,KAAA,KAAA,SAAA;MACQ,OAAO,EAAC;MACT,UAAW;MACX,QAAA;;MAEF,CAAA;cAEC,SAAQ,CAAA,eAAY,EAC1B;KACM,SAAE;MACR,YAAA;MACF,OAAA;;KAEE,KAAA,EAAA;KACG;AACH,QAAA,YAAA,OAAA,IAAA,MAAA,IAAA,OAAA,IAAA,SAAA,YAAA,OAAA,IAAA,MAAA,KAAA,EAAA;AACK,YAAM,IAAM,QAAI,oBAAiB,OAAA,IAAkB,MAAC;KACzD,MAAS,OAAA,MAAgB,KAAI,GAAA,QAAA,OAAA,IAAA,MAAA,KAAA;AAC1B,SAAA,KACI,QAAA,IAAA,MAAA,OAAA;WAEC;AACN,UAAA,KAAA,4FAAA;KACE,MAAO,2BAAS,MAAA,4BAAA,KAAA;KAChB,MAAM,OAAS,MAAA,KAAA,GAAA,QAAA,yBAAA,K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UAAW,EAAA,EAAA,EACvB,YAAC,kBAED,KAEH;MACA,CAAC,UAAS,QAAQ,CAAC;GACvB;EAAE;;GAED,MAAM,EACJ,gBAAe,aAAc,SAAQ,iBAAA;AACnC,WAAM,EACJ,WAAK,KAAO,QAAA,KAAA,QACb;MACA;UAAC;IAAA;IAAA;IAAA;IAAA,CAAA;GAEP;EAAE,OAAO,QAAE,OAAW;EAAA;GACtB;OAAO;CAAgB;QAAgB,EAAA;CAAA;CAAA;CAA2B,CAAA"}
@@ -53,7 +53,7 @@ const __ΩEnvPluginOptions = [
53
53
  "Babel configuration options to use when injecting environment variables into the source code.",
54
54
  "automd",
55
55
  "AutoMD configuration options to allow injecting environment variables documentation into a markdown file such as a README.md.",
56
- "alloy",
56
+ "deepkit",
57
57
  "Alloy configuration options to use when injecting environment variables into the source code.",
58
58
  "EnvPluginOptions",
59
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"
@@ -1,9 +1,9 @@
1
1
  import { EnvInterface, SecretsInterface } from "./runtime.cjs";
2
2
  import { Children } from "@alloy-js/core";
3
3
  import { Reflection } from "@powerlines/deepkit/types";
4
- import { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
5
4
  import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
6
5
  import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
6
+ import { DeepkitPluginContext, DeepkitPluginOptions, DeepkitPluginResolvedConfig, DeepkitPluginUserConfig } from "@powerlines/plugin-deepkit/types/plugin";
7
7
  import { DotenvParseOutput } from "@stryke/env/types";
8
8
  import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
9
9
 
@@ -62,14 +62,14 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
62
62
  * Alloy configuration options to use when injecting environment variables into the source code.
63
63
  *
64
64
  * @remarks
65
- * 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.
65
+ * This option allows you to customize the Deepkit transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Deepkit settings.
66
66
  */
67
- alloy?: AlloyPluginOptions;
67
+ deepkit?: DeepkitPluginOptions;
68
68
  };
69
- type EnvPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & {
69
+ type EnvPluginUserConfig = BabelPluginUserConfig & DeepkitPluginUserConfig & {
70
70
  env: EnvPluginOptions;
71
71
  };
72
- type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & {
72
+ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & DeepkitPluginResolvedConfig & {
73
73
  env: Required<Pick<DotenvConfiguration, "additionalFiles">> & Required<Pick<EnvPluginOptions, "defaultConfig">> & {
74
74
  /**
75
75
  * The type definition for the expected env variable parameters
@@ -108,7 +108,7 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedCo
108
108
  prefix: string[];
109
109
  };
110
110
  };
111
- interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig> {
111
+ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, DeepkitPluginContext<TResolvedConfig> {
112
112
  env: {
113
113
  /**
114
114
  * The type definitions reflection for the env variables and secrets
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;KAyCY,OAAA;AAAA,KAEA,gBAAA,GAAmB,IAAA,CAAK,mBAAA;EAFxB;;;EAMV,KAAA,GAAQ,uBAAA;EANS;AAEnB;;EASE,OAAA,GAAU,uBAAA;E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;EATwB;;;;;;EAiBlC,MAAA;EA8CU;;;;;EAvCV,MAAA;EApBQ;;;;;EA2BR,QAAA;EAQA;;;;;;EAAA,aAAA,GAAgB,QAAA;EAwBN;;;AAGZ;;;EAnBE,KAAA,GAAQ,kBAAA;EAoBR;;;;;;EAZA,MAAA,GAAS,mBAAA;EAaF;;;AAGT;;;EARE,OAAA,GAAU,oBAAA;AAAA;AAAA,KAGA,mBAAA,GAAsB,qBAAA,GAChC,uBAAA;EACE,GAAA,EAAK,gBAAA;AAAA;AAAA,KAGG,uBAAA,GAA0B,yBAAA,GACpC,2BAAA;EACE,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,mBAAA,wBACjB,QAAA,CAAS,IAAA,CAAK,gBAAA;IAAd;;;;;;IAOE,KAAA,EAAO,cAAA;IARX;;;;;;IAgBI,OAAA,EAAS,cAAA;IART;;;;;;IAgBA,MAAA;IAgBM;;AAId;;;;IAZQ,QAAA;IAgBe;;;;;;IARf,MAAA;EAAA;AAAA;AAAA,UAIS,gBAAA,yBACS,uBAAA,GAA0B,uBAAA,UAGhD,kBAAA,CAAmB,eAAA,GACnB,oBAAA,CAAqB,eAAA;EACvB,GAAA;IADE;;;;;;IAQA,KAAA;MATmB;;;MAajB,GAAA,EAAK,UAAA;MAJP;;;MASE,OAAA,EAAS,UAAA;IAAA;IASX;;;;;;IAAA,IAAA;MAkBA;;;MAdE,GAAA,EAAK,UAAA,CAAW,YAAA;MAsBE;;;MAjBlB,OAAA,EAAS,UAAA,CAAW,gBAAA;IAAA;;;;;;;IAStB,MAAA,EAAQ,iBAAA;;;;;;;IAQR,QAAA,EAAU,UAAA;EAAA;AAAA"}
@@ -2,9 +2,9 @@ import { EnvInterface, SecretsInterface } from "./runtime.mjs";
2
2
  import { DotenvParseOutput } from "@stryke/env/types";
3
3
  import { Children } from "@alloy-js/core";
4
4
  import { Reflection } from "@powerlines/deepkit/types";
5
- import { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
6
5
  import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
7
6
  import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
7
+ import { DeepkitPluginContext, DeepkitPluginOptions, DeepkitPluginResolvedConfig, DeepkitPluginUserConfig } from "@powerlines/plugin-deepkit/types/plugin";
8
8
  import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
9
9
 
10
10
  //#region src/types/plugin.d.ts
@@ -62,14 +62,14 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
62
62
  * Alloy configuration options to use when injecting environment variables into the source code.
63
63
  *
64
64
  * @remarks
65
- * 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.
65
+ * This option allows you to customize the Deepkit transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Deepkit settings.
66
66
  */
67
- alloy?: AlloyPluginOptions;
67
+ deepkit?: DeepkitPluginOptions;
68
68
  };
69
- type EnvPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & {
69
+ type EnvPluginUserConfig = BabelPluginUserConfig & DeepkitPluginUserConfig & {
70
70
  env: EnvPluginOptions;
71
71
  };
72
- type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & {
72
+ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & DeepkitPluginResolvedConfig & {
73
73
  env: Required<Pick<DotenvConfiguration, "additionalFiles">> & Required<Pick<EnvPluginOptions, "defaultConfig">> & {
74
74
  /**
75
75
  * The type definition for the expected env variable parameters
@@ -108,7 +108,7 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedCo
108
108
  prefix: string[];
109
109
  };
110
110
  };
111
- interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig> {
111
+ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, DeepkitPluginContext<TResolvedConfig> {
112
112
  env: {
113
113
  /**
114
114
  * The type definitions reflection for the env variables and secrets
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;KAyCY,OAAA;AAAA,KAEA,gBAAA,GAAmB,IAAA,CAAK,mBAAA;EAFxB;;;EAMV,KAAA,GAAQ,uBAAA;EANS;AAEnB;;EASE,OAAA,GAAU,uBAAA;EATwB;;;;;;EAiBlC,MAAA;EA8CQ;;;;;EAvCR,MAAA;EApBQ;;;;;EA2BR,QAAA;EAQA;;;;;;EAAA,aAAA,GAAgB,QAAA;EAwBR;;;AAGV;;;EAnBE,KAAA,GAAQ,kBAAA;EAoBR;;;;;;EAZA,MAAA,GAAS,mBAAA;EAaF;;;AAGT;;;EARE,KAAA,GAAQ,kBAAA;AAAA;AAAA,KAGE,mBAAA,GAAsB,qBAAA,GAChC,qBAAA;EACE,GAAA,EAAK,gBAAA;AAAA;AAAA,KAGG,uBAAA,GAA0B,yBAAA,GACpC,yBAAA;EACE,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,mBAAA,wBACjB,QAAA,CAAS,IAAA,CAAK,gBAAA;IAAd;;;;;;IAOE,KAAA,EAAO,cAAA;IARX;;;;;;IAgBI,OAAA,EAAS,cAAA;IART;;;;;;IAgBA,MAAA;IAgBM;;AAId;;;;IAZQ,QAAA;IAgBe;;;;;;IARf,MAAA;EAAA;AAAA;AAAA,UAIS,gBAAA,yBACS,uBAAA,GAA0B,uBAAA,UAGhD,kBAAA,CAAmB,eAAA,GACnB,kBAAA,CAAmB,eAAA;EACrB,GAAA;IADE;;;;;;IAQA,KAAA;MATmB;;;MAajB,GAAA,EAAK,UAAA;MAJP;;;MASE,OAAA,EAAS,UAAA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A;IAAA;IASX;;;;;;IAAA,IAAA;MAkBA;;;MAdE,GAAA,EAAK,UAAA,CAAW,YAAA;MAsBE;;;MAjBlB,OAAA,EAAS,UAAA,CAAW,gBAAA;IAAA;;;;;;;IAStB,MAAA,EAAQ,iBAAA;;;;;;;IAQR,QAAA,EAAU,UAAA;EAAA;AAAA"}
@@ -51,7 +51,7 @@ const __ΩEnvPluginOptions = [
51
51
  "Babel configuration options to use when injecting environment variables into the source code.",
52
52
  "automd",
53
53
  "AutoMD configuration options to allow injecting environment variables documentation into a markdown file such as a README.md.",
54
- "alloy",
54
+ "deepkit",
55
55
  "Alloy configuration options to use when injecting environment variables into the source code.",
56
56
  "EnvPluginOptions",
57
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"
@@ -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":";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"}
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 { AutoMDPluginOptions } from \"@powerlines/plugin-automd/types/plugin\";\nimport {\n BabelPluginContext,\n BabelPluginOptions,\n BabelPluginResolvedConfig,\n BabelPluginUserConfig\n} from \"@powerlines/plugin-babel/types\";\nimport {\n DeepkitPluginContext,\n DeepkitPluginOptions,\n DeepkitPluginResolvedConfig,\n DeepkitPluginUserConfig\n} from \"@powerlines/plugin-deepkit/types/plugin\";\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 Deepkit transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Deepkit settings.\n */\n deepkit?: DeepkitPluginOptions;\n};\n\nexport type EnvPluginUserConfig = BabelPluginUserConfig &\n DeepkitPluginUserConfig & {\n env: EnvPluginOptions;\n };\n\nexport type EnvPluginResolvedConfig = BabelPluginResolvedConfig &\n DeepkitPluginResolvedConfig & {\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 DeepkitPluginContext<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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-env",
3
- "version": "0.16.122",
3
+ "version": "0.16.123",
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"],
@@ -306,13 +306,13 @@
306
306
  "@alloy-js/typescript": "0.23.0-dev.4",
307
307
  "@babel/core": "^7.29.0",
308
308
  "@babel/types": "^7.29.0",
309
- "@powerlines/plugin-alloy": "^0.26.16",
310
- "@powerlines/plugin-automd": "^0.1.397",
311
- "@powerlines/plugin-babel": "^0.12.393",
312
- "@powerlines/plugin-plugin": "^0.12.348",
313
- "@powerlines/deepkit": "^0.8.1",
314
- "@powerlines/plugin-deepkit": "^0.11.278",
315
- "@storm-software/config-tools": "^1.189.75",
309
+ "@powerlines/plugin-alloy": "^0.26.17",
310
+ "@powerlines/plugin-automd": "^0.1.398",
311
+ "@powerlines/plugin-babel": "^0.12.394",
312
+ "@powerlines/plugin-plugin": "^0.12.349",
313
+ "@powerlines/deepkit": "^0.8.2",
314
+ "@powerlines/plugin-deepkit": "^0.11.279",
315
+ "@storm-software/config-tools": "^1.189.76",
316
316
  "@stryke/capnp": "^0.12.92",
317
317
  "@stryke/convert": "^0.6.58",
318
318
  "@stryke/env": "^0.20.83",
@@ -325,10 +325,10 @@
325
325
  "@stryke/types": "^0.11.3",
326
326
  "automd": "^0.4.3",
327
327
  "defu": "^6.1.7",
328
- "powerlines": "^0.42.38",
328
+ "powerlines": "^0.42.39",
329
329
  "c12": "^3.3.4"
330
330
  },
331
331
  "devDependencies": { "@types/node": "^25.6.0", "vite": "^8.0.8" },
332
332
  "publishConfig": { "access": "public" },
333
- "gitHead": "9cec72510580fd8ee2cafc64ccae8ca65e7746a4"
333
+ "gitHead": "dbee10b00be4d975152b4e5b82422c2a94455f70"
334
334
  }