@powerlines/plugin-env 0.16.234 → 0.16.236
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 +23 -71
- package/dist/babel/plugin.d.cts.map +1 -1
- package/dist/babel/plugin.d.mts.map +1 -1
- package/dist/babel/plugin.mjs +23 -71
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +14 -14
- package/dist/components/docs.d.cts +0 -2
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +0 -2
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +14 -14
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +233 -426
- package/dist/components/env-builtin.d.cts +1 -4
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts +1 -4
- package/dist/components/env-builtin.d.mts.map +1 -1
- package/dist/components/env-builtin.mjs +236 -428
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/index.cjs +9 -26
- package/dist/helpers/index.d.cts +3 -5
- package/dist/helpers/index.d.mts +3 -5
- package/dist/helpers/index.mjs +3 -5
- package/dist/helpers/load.cjs +8 -7
- package/dist/helpers/load.d.cts +3 -3
- package/dist/helpers/load.d.cts.map +1 -1
- package/dist/helpers/load.d.mts +3 -3
- package/dist/helpers/load.d.mts.map +1 -1
- package/dist/helpers/load.mjs +7 -6
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/schema.cjs +206 -0
- package/dist/helpers/schema.d.cts +53 -0
- package/dist/helpers/schema.d.cts.map +1 -0
- package/dist/helpers/schema.d.mts +53 -0
- package/dist/helpers/schema.d.mts.map +1 -0
- package/dist/helpers/schema.mjs +199 -0
- package/dist/helpers/schema.mjs.map +1 -0
- package/dist/index.cjs +23 -201
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +25 -203
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -0
- 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 +16 -24
- package/dist/types/plugin.d.cts +23 -57
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +23 -57
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +16 -25
- package/dist/types/plugin.mjs.map +1 -1
- package/package.json +12 -26
- package/dist/helpers/create-reflection-resource.cjs +0 -23
- package/dist/helpers/create-reflection-resource.d.cts +0 -13
- package/dist/helpers/create-reflection-resource.d.cts.map +0 -1
- package/dist/helpers/create-reflection-resource.d.mts +0 -13
- package/dist/helpers/create-reflection-resource.d.mts.map +0 -1
- package/dist/helpers/create-reflection-resource.mjs +0 -23
- package/dist/helpers/create-reflection-resource.mjs.map +0 -1
- package/dist/helpers/persistence.cjs +0 -309
- package/dist/helpers/persistence.d.cts +0 -84
- package/dist/helpers/persistence.d.cts.map +0 -1
- package/dist/helpers/persistence.d.mts +0 -84
- package/dist/helpers/persistence.d.mts.map +0 -1
- package/dist/helpers/persistence.mjs +0 -297
- package/dist/helpers/persistence.mjs.map +0 -1
- package/dist/helpers/reflect.cjs +0 -290
- package/dist/helpers/reflect.d.cts +0 -68
- package/dist/helpers/reflect.d.cts.map +0 -1
- package/dist/helpers/reflect.d.mts +0 -68
- package/dist/helpers/reflect.d.mts.map +0 -1
- package/dist/helpers/reflect.mjs +0 -281
- package/dist/helpers/reflect.mjs.map +0 -1
- package/dist/helpers/template-helpers.cjs +0 -70
- package/dist/helpers/template-helpers.d.cts +0 -15
- package/dist/helpers/template-helpers.d.cts.map +0 -1
- package/dist/helpers/template-helpers.d.mts +0 -15
- package/dist/helpers/template-helpers.d.mts.map +0 -1
- package/dist/helpers/template-helpers.mjs +0 -69
- package/dist/helpers/template-helpers.mjs.map +0 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n ReflectionClass,\n ReflectionKind\n} from \"@powerlines/deepkit/vendor/type\";\nimport { 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 type { Plugin, UnresolvedContext } from \"powerlines\";\nimport {\n createVirtualPrefixRegex,\n getDocsOutputPath\n} from \"powerlines/plugin-utils\";\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 { 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 * 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({\n ...options.deepkit,\n reflection: \"default\",\n level: \"all\",\n filter: {}\n }),\n babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n ...options.babel,\n skipTransform: !options.inject,\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 !isSetString(config.env.types?.file)\n ) {\n this.warn(\n \"The `env.types` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n config.env.types = await getEnvDefaultTypeDefinition(\n this as UnresolvedContext\n );\n }\n\n if (\n !isSetString(config.env.secrets) &&\n !isSetString(config.env.secrets?.file)\n ) {\n config.env.secrets = await getSecretsDefaultTypeDefinition(\n this as UnresolvedContext\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?.name &&\n this.config.framework?.name !== \"powerlines\" &&\n `${constantCase(this.config.framework?.name)}_`\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 config.tsc.filter = {\n id: {\n include: [\n createVirtualPrefixRegex(joinPaths(this.builtinsPath, \"env.ts\")),\n createVirtualPrefixRegex(\n `${this.config.framework?.name || \"powerlines\"}:env`\n )\n ]\n }\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 );\n\n if (\n isSetString(this.config.env.types) ||\n (this.config.env.types && isSetString(this.config.env.types.file))\n ) {\n this.config.env.types = parseTypeDefinition(\n this.config.env.types\n ) as TypeDefinition;\n\n const file = await this.fs.resolve(this.config.env.types.file);\n if (file) {\n this.config.env.types.file = file;\n }\n }\n\n if (\n isSetString(this.config.env.secrets) ||\n (this.config.env.secrets && isSetString(this.config.env.secrets.file))\n ) {\n this.config.env.secrets = parseTypeDefinition(\n this.config.env.secrets\n )!;\n\n const file = await this.fs.resolve(this.config.env.secrets.file);\n if (file) {\n this.config.env.secrets.file = file;\n }\n }\n\n this.info({\n meta: {\n category: \"env\"\n },\n message: `Environment configuration definition file: ${\n this.config.env.types.file\n }${this.config.env.types.name ? `#${this.config.env.types.name}` : \"\"}${\n this.config.env.secrets\n ? `\\nSecrets configuration definition file: ${this.config.env.secrets?.file}${\n this.config.env.secrets?.name\n ? `#${this.config.env.secrets?.name}`\n : \"\"\n }`\n : \"\"\n }\\nEnvironment variable Prefixes: ${this.config.env.prefix.join(\", \")}\\nShould inject values: ${\n this.config.env.inject ? \"Yes\" : \"No\"\n }\\nShould validate configuration: ${\n this.config.env.validate ? \"Yes\" : \"No\"\n }`\n });\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 this.debug({\n meta: {\n category: \"env\"\n },\n message: `Found the following environment configuration parameter definitions: \\n${this.env.types.env\n .getProperties()\n .map(\n prop =>\n `- ${prop.getNameAsString()}${\n prop.getAlias().length > 0\n ? ` (aliases: ${prop.getAlias().join(\", \")})`\n : \"\"\n }`\n )\n .join(\"\\n\")}`\n });\n\n if (existsSync(getEnvReflectionsPath(this, \"env\"))) {\n this.env.used.env = await readEnvReflection(this);\n\n this.debug({\n meta: {\n category: \"env\"\n },\n message: `Found the following environment configuration parameters used in project: \\n${this.env.used.env\n .getProperties()\n .map(\n prop =>\n `- ${prop.getNameAsString()}${\n prop.getAlias().length > 0\n ? ` (aliases: ${prop.getAlias().join(\", \")})`\n : \"\"\n }`\n )\n .join(\"\\n\")}`\n });\n }\n\n if (existsSync(getEnvTypeReflectionsPath(this, \"secrets\"))) {\n this.env.types.secrets = await readEnvTypeReflection(\n this,\n \"secrets\"\n );\n\n if (this.env.types.secrets.getProperties().length > 0) {\n this.debug({\n meta: {\n category: \"env\"\n },\n message: `Found the following secret configuration parameter definitions: \\n${this.env.types.secrets\n .getProperties()\n .map(\n prop =>\n `- ${prop.getNameAsString()} (aliases: ${prop.getAlias().join(\", \")})`\n )\n .join(\"\\n\")}`\n });\n }\n }\n\n if (existsSync(getEnvReflectionsPath(this, \"secrets\"))) {\n this.env.used.secrets = await readSecretsReflection(this);\n\n if (this.env.used.secrets.getProperties().length > 0) {\n this.debug({\n meta: {\n category: \"env\"\n },\n message: `Found the following secret configuration parameters used in project: \\n${this.env.used.secrets\n .getProperties()\n .map(\n prop =>\n `- ${prop.getNameAsString()} (aliases: ${prop.getAlias().join(\", \")})`\n )\n .join(\"\\n\")}`\n });\n }\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 this.debug({\n meta: {\n category: \"env\"\n },\n message: `Found the following environment configuration parameter definitions: \\n${this.env.types.env\n .getProperties()\n .map(\n prop =>\n `- ${prop.getNameAsString()} (aliases: ${prop.getAlias().join(\", \")})`\n )\n .join(\"\\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 if (this.env.types.secrets.getProperties().length > 0) {\n this.debug({\n meta: {\n category: \"env\"\n },\n message: `Found the following secret configuration parameter definitions: \\n${this.env.types.secrets\n .getProperties()\n .map(\n prop =>\n `- ${prop.getNameAsString()} (aliases: ${prop.getAlias().join(\", \")})`\n )\n .join(\"\\n\")}`\n });\n }\n\n await writeEnvTypeReflection(this, this.env.types.secrets, \"secrets\");\n\n this.info({\n meta: {\n category: \"env\"\n },\n message: `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.config.root),\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 configResolved() {\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;CAC/B,GAAI,SAAK;CACT,OAAI;;;;;AA4CL,MAAE,SAAA,cAA2B,UAAA,CAAA,MAAA;CAC3B,OAAA;EAAA,QAAA;GACA,GAAA,QAAA;GACA,YAAA;GACA,OAAA;GACA,QAAA,CAAA;EACA,CAAA;EAAA,MAAA,QAAA,KAAqB;EAAA;GACrB,MAAA;GACA,MAAA,SAAA;IACI,KAAI,MAAO,wEAAa;IACxB,MAAG,SAAY;KACb,KAAC,KAAA,SAAkB;;MAElB,UAAQ;;MAET,QAAQ,CAAA;KACd,CAAA;KACM,OAAE;MACR,GAAA,QAAA;MACF,eAAA,CAAA,QAAA;;KAEE;KACG,SAAW;MACd,YAAA;MACK,OAAM;KACX;KACG,KAAA,CAAA;IACH;IACE,IAAA,CAAO,YAAC,OAAA,IAAA,KAAA,KAAA,CAAA,YAAA,OAAA,IAAA,OAAA,IAAA,GAAA;KACJ,KAAC,KAAQ,2FAAO;KAClB,OAAA,IAAa,QAAQ,MAAA,4BAAA,IAAA;IACrB;IACA,IAAA,CAAA,YAAS,OAAA,IAAA,OAAA,KAAA,CAAA,YAAA,OAAA,IAAA,SAAA,IAAA,GACT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C7B;GACF,GAAG;UAAM;IAAO;IAAA;IAAA;GAAA,CAAA,EAClB;;;;AAEJ,GAAG;OAAO;CAAqB;QAAQ,CAAA;CAAe;CAAC;AAAY,CAAA"}
|
|
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 { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport defu from \"defu\";\nimport type { Plugin, UnresolvedContext } from \"powerlines\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\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 {\n extractEnvSchema,\n getDefaultSecretsTypeDefinition,\n getDefaultVarsTypeDefinition,\n readActiveEnv,\n writeActiveEnv\n} from \"./helpers/schema\";\nimport type { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport * 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 babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n ...options.babel,\n skipTransform: !options.inject,\n plugins: [envBabelPlugin]\n }\n };\n\n if (!config.env.vars) {\n this.warn(\n \"The `env.vars` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n config.env.vars = await getDefaultVarsTypeDefinition(\n this as UnresolvedContext\n );\n }\n\n if (!config.env.secrets) {\n config.env.secrets = await getDefaultSecretsTypeDefinition(\n this as UnresolvedContext\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?.name &&\n this.config.framework?.name !== \"powerlines\" &&\n `${constantCase(this.config.framework?.name)}_`\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 await extractEnvSchema(this, options);\n },\n async prepare() {\n this.debug(\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n await readActiveEnv(this);\n\n return render(\n this,\n <EnvBuiltin defaultConfig={this.config.env.defaultConfig} />\n );\n },\n async docs() {\n this.debug(\n `Documenting environment variables configuration values in \"${joinPaths(\n getDocsOutputPath(this.config.root),\n \"env.md\"\n )}\"`\n );\n\n await readActiveEnv(this);\n\n return render(this, <EnvDocsFile levelOffset={0} />);\n },\n async buildEnd() {\n this.debug(\"Writing active environment variables to disk.\");\n\n await writeActiveEnv(this);\n }\n },\n {\n name: \"env:automd-generator\",\n configResolved() {\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":";;;;;;;;;;;;;;;;;;;;CAEE,GAAG,SAAS;;AAEd;;;;AAoCA,MAAa,SAAC,cAAkB,UAAA,CAAA,MAAmB;;;;GAEnD,MAAS;;IAET,KAAQ,MAAQ,wEAAY;IAC1B,MAAU,SAAO;KACX,KAAE,KAAA,SAAgB;MACxB,UAAA;MACF,QAAA;;KAEE,CAAA;KACG,OAAU;MACb,GAAA,QAAA;MACK,eAAgB,CAAA,QAAS;MACtB,SAAC,CAAA,cAAoB;KAC1B;IACH;IACE,IAAM,CAAA,OAAQ,IAAA,MAAM;KACpB,KAAA,KAAA,0FAAA;KACE,OAAO,IAAI,OAAA,MAAA,6BAAA,IAAA;IACX;IACA,IAAE,CAAA,OAAU,IAAA,SACV,OAAG,IAAA,UAAkB,MAAA,gCAAsC,IAAC;;KAG5D,MAAM,kBAAS,aAAA,MAAA;KACf,IAAE,CAAG,IAAE,SAAK,eAAS,GACnB,IAAE,KAAA,eAAe;KAEnB,OAAI;IACN,GAAG;KAAC;KAAE;KAAA;KAAA;IAAA,CAAA,GAAA,CAAA,eAAA,KAAA,OAAA,WAAA,QAAA,KAAA,OAAA,WAAA,SAAA,gBAAA,GAAA,aAAA,KAAA,OAAA,WAAA,IAAA,EAAA,EAAA,EAAA,OAAA,OAAA,CAAA;IACN,OAAI,IAAO,SAAA,UAAA,QAAA,OAAA,IAAA,MAAA,EAAA,OAAA,cAAA,KAAA,WAAA;KACT,IAAI,CAAC,IAAE,SAAQ,OA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types/index.cjs
CHANGED
|
@@ -7,5 +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.__ΩEnvSchemaMetadata = require_types_plugin.__ΩEnvSchemaMetadata;
|
|
10
11
|
exports.__ΩEnvType = require_types_plugin.__ΩEnvType;
|
|
11
12
|
exports.__ΩSecretsInterface = require_types_env.__ΩSecretsInterface;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType } from "./plugin.cjs";
|
|
1
2
|
import { EnvInterface, SecretsInterface } from "./env.cjs";
|
|
2
|
-
|
|
3
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface };
|
|
3
|
+
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType, SecretsInterface };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType } from "./plugin.mjs";
|
|
1
2
|
import { EnvInterface, SecretsInterface } from "./env.mjs";
|
|
2
|
-
|
|
3
|
-
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface };
|
|
3
|
+
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType, SecretsInterface };
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./plugin.mjs";
|
|
1
|
+
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchemaMetadata, __ΩEnvType } from "./plugin.mjs";
|
|
2
2
|
import { __ΩEnvInterface, __ΩSecretsInterface } from "./env.mjs";
|
|
3
3
|
|
|
4
|
-
export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface };
|
|
4
|
+
export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchemaMetadata, __ΩEnvType, __ΩSecretsInterface };
|
package/dist/types/plugin.cjs
CHANGED
|
@@ -35,7 +35,7 @@ const __ΩEnvType = [
|
|
|
35
35
|
const __ΩEnvPluginOptions = [
|
|
36
36
|
() => __ΩOmit,
|
|
37
37
|
"types",
|
|
38
|
-
"
|
|
38
|
+
"vars",
|
|
39
39
|
"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\"`.",
|
|
40
40
|
"secrets",
|
|
41
41
|
"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\"`.",
|
|
@@ -53,29 +53,19 @@ 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
|
-
"deepkit",
|
|
57
|
-
"Alloy configuration options to use when injecting environment variables into the source code.",
|
|
58
56
|
"EnvPluginOptions",
|
|
59
|
-
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?0!418?2!438?
|
|
57
|
+
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?0!418?2!438?4MKw5y"
|
|
60
58
|
];
|
|
61
59
|
const __ΩEnvPluginUserConfig = [
|
|
62
60
|
() => __ΩEnvPluginOptions,
|
|
63
61
|
"env",
|
|
64
62
|
"EnvPluginUserConfig",
|
|
65
|
-
"P
|
|
63
|
+
"P!Pn!4\"MKw#y"
|
|
66
64
|
];
|
|
67
65
|
const __ΩEnvPluginResolvedConfig = [
|
|
68
66
|
() => __ΩRequired,
|
|
69
67
|
() => __ΩPick,
|
|
70
68
|
"additionalFiles",
|
|
71
|
-
() => __ΩRequired,
|
|
72
|
-
() => __ΩPick,
|
|
73
|
-
() => __ΩEnvPluginOptions,
|
|
74
|
-
"defaultConfig",
|
|
75
|
-
"types",
|
|
76
|
-
"The type definition for the expected env variable parameters",
|
|
77
|
-
"secrets",
|
|
78
|
-
"The type definition for the expected env secret parameters",
|
|
79
69
|
"inject",
|
|
80
70
|
"Should the plugin inject the env variables in the source code with their values?",
|
|
81
71
|
"validate",
|
|
@@ -84,27 +74,28 @@ const __ΩEnvPluginResolvedConfig = [
|
|
|
84
74
|
"The prefix used for environment variables",
|
|
85
75
|
"env",
|
|
86
76
|
"EnvPluginResolvedConfig",
|
|
87
|
-
"P
|
|
77
|
+
"P!PP!.#o\"#o!\"!P)4$?%)4&?'&F4(?)MK4*MKw+y"
|
|
78
|
+
];
|
|
79
|
+
const __ΩEnvSchemaMetadata = [
|
|
80
|
+
"active",
|
|
81
|
+
"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
|
+
"EnvSchemaMetadata",
|
|
83
|
+
"P!&F4!?\"Mw#y"
|
|
88
84
|
];
|
|
89
85
|
const __ΩEnvPluginContext = [
|
|
90
86
|
() => __ΩEnvPluginResolvedConfig,
|
|
91
87
|
"TResolvedConfig",
|
|
92
|
-
"
|
|
93
|
-
"The type
|
|
88
|
+
"vars",
|
|
89
|
+
"The type definition for the expected env variable parameters",
|
|
94
90
|
"secrets",
|
|
95
|
-
"The type
|
|
96
|
-
"The type definitions reflection for the env variables and secrets",
|
|
97
|
-
"types",
|
|
98
|
-
"The current env variables reflection",
|
|
99
|
-
"The current env secrets reflection",
|
|
100
|
-
"The current **used** environment variables and secrets reflection",
|
|
101
|
-
"used",
|
|
91
|
+
"The type definition for the expected env secret parameters",
|
|
102
92
|
"parsed",
|
|
103
93
|
"The parsed .env configuration object",
|
|
104
94
|
"injected",
|
|
105
95
|
"The injected environment variables and secrets reflection",
|
|
96
|
+
"env",
|
|
106
97
|
"EnvPluginContext",
|
|
107
|
-
"n!c\"P
|
|
98
|
+
"n!c\"P!P!4#?$!4%?&!4'?(&F4)?*M4+Mw,y"
|
|
108
99
|
];
|
|
109
100
|
|
|
110
101
|
//#endregion
|
|
@@ -112,4 +103,5 @@ exports.__ΩEnvPluginContext = __ΩEnvPluginContext;
|
|
|
112
103
|
exports.__ΩEnvPluginOptions = __ΩEnvPluginOptions;
|
|
113
104
|
exports.__ΩEnvPluginResolvedConfig = __ΩEnvPluginResolvedConfig;
|
|
114
105
|
exports.__ΩEnvPluginUserConfig = __ΩEnvPluginUserConfig;
|
|
106
|
+
exports.__ΩEnvSchemaMetadata = __ΩEnvSchemaMetadata;
|
|
115
107
|
exports.__ΩEnvType = __ΩEnvType;
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { EnvInterface, SecretsInterface } from "./env.cjs";
|
|
2
1
|
import { Children } from "@alloy-js/core";
|
|
3
|
-
import { Reflection } from "@powerlines/deepkit/types";
|
|
4
2
|
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
5
3
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
6
|
-
import {
|
|
4
|
+
import { ObjectSchema, SchemaInput, SchemaMetadata } from "@powerlines/schema";
|
|
7
5
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
8
|
-
import {
|
|
6
|
+
import { RequiredKeys } from "@stryke/types";
|
|
7
|
+
import { DotenvConfiguration } from "@stryke/types/configuration";
|
|
9
8
|
|
|
10
9
|
//#region src/types/plugin.d.ts
|
|
11
10
|
type EnvType = "env" | "secrets";
|
|
@@ -13,11 +12,11 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
13
12
|
/**
|
|
14
13
|
* 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"`.
|
|
15
14
|
*/
|
|
16
|
-
|
|
15
|
+
vars?: SchemaInput;
|
|
17
16
|
/**
|
|
18
17
|
* 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"`.
|
|
19
18
|
*/
|
|
20
|
-
secrets?:
|
|
19
|
+
secrets?: SchemaInput;
|
|
21
20
|
/**
|
|
22
21
|
* An additional prefix (or list of additional prefixes) to apply to the environment variables
|
|
23
22
|
*
|
|
@@ -58,33 +57,12 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
58
57
|
* The README.md file should contain the `<!-- automd:env --><!-- /automd -->` comment block where the documentation will be injected.
|
|
59
58
|
*/
|
|
60
59
|
automd?: AutoMDPluginOptions;
|
|
61
|
-
/**
|
|
62
|
-
* Alloy configuration options to use when injecting environment variables into the source code.
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
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
|
-
*/
|
|
67
|
-
deepkit?: DeepkitPluginOptions;
|
|
68
60
|
};
|
|
69
|
-
type EnvPluginUserConfig = BabelPluginUserConfig &
|
|
61
|
+
type EnvPluginUserConfig = BabelPluginUserConfig & {
|
|
70
62
|
env: EnvPluginOptions;
|
|
71
63
|
};
|
|
72
|
-
type EnvPluginResolvedConfig = BabelPluginResolvedConfig &
|
|
73
|
-
env: Required<Pick<DotenvConfiguration, "additionalFiles">> &
|
|
74
|
-
/**
|
|
75
|
-
* The type definition for the expected env variable parameters
|
|
76
|
-
*
|
|
77
|
-
* @remarks
|
|
78
|
-
* This value is parsed from the {@link EnvPluginOptions.types} option.
|
|
79
|
-
*/
|
|
80
|
-
types: TypeDefinition;
|
|
81
|
-
/**
|
|
82
|
-
* The type definition for the expected env secret parameters
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* This value is parsed from the {@link EnvPluginOptions.secrets} option.
|
|
86
|
-
*/
|
|
87
|
-
secrets: TypeDefinition;
|
|
64
|
+
type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
65
|
+
env: Required<Pick<DotenvConfiguration, "additionalFiles">> & RequiredKeys<EnvPluginOptions, "vars" | "secrets" | "defaultConfig"> & {
|
|
88
66
|
/**
|
|
89
67
|
* Should the plugin inject the env variables in the source code with their values?
|
|
90
68
|
*
|
|
@@ -108,40 +86,28 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & DeepkitPluginResolved
|
|
|
108
86
|
prefix: string[];
|
|
109
87
|
};
|
|
110
88
|
};
|
|
111
|
-
interface
|
|
89
|
+
interface EnvSchemaMetadata extends SchemaMetadata {
|
|
90
|
+
/**
|
|
91
|
+
* 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
|
+
*/
|
|
93
|
+
active: string[];
|
|
94
|
+
}
|
|
95
|
+
interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig> {
|
|
112
96
|
env: {
|
|
113
97
|
/**
|
|
114
|
-
* The type
|
|
98
|
+
* The type definition for the expected env variable parameters
|
|
115
99
|
*
|
|
116
100
|
* @remarks
|
|
117
|
-
*
|
|
101
|
+
* This value is parsed from the {@link EnvPluginOptions.vars} option.
|
|
118
102
|
*/
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The type definitions for the expected env variables
|
|
122
|
-
*/
|
|
123
|
-
env: Reflection;
|
|
124
|
-
/**
|
|
125
|
-
* The type definitions for the expected env secrets
|
|
126
|
-
*/
|
|
127
|
-
secrets: Reflection;
|
|
128
|
-
};
|
|
103
|
+
vars: ObjectSchema<EnvSchemaMetadata>;
|
|
129
104
|
/**
|
|
130
|
-
* The
|
|
105
|
+
* The type definition for the expected env secret parameters
|
|
131
106
|
*
|
|
132
107
|
* @remarks
|
|
133
|
-
* This
|
|
108
|
+
* This value is parsed from the {@link EnvPluginOptions.secrets} option.
|
|
134
109
|
*/
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* The current env variables reflection
|
|
138
|
-
*/
|
|
139
|
-
env: Reflection<EnvInterface>;
|
|
140
|
-
/**
|
|
141
|
-
* The current env secrets reflection
|
|
142
|
-
*/
|
|
143
|
-
secrets: Reflection<SecretsInterface>;
|
|
144
|
-
};
|
|
110
|
+
secrets: ObjectSchema<EnvSchemaMetadata>;
|
|
145
111
|
/**
|
|
146
112
|
* The parsed .env configuration object
|
|
147
113
|
*
|
|
@@ -155,9 +121,9 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
|
|
|
155
121
|
* @remarks
|
|
156
122
|
* This reflection contains the structure of the injected environment variables and secrets that were injected into the source code during the build process.
|
|
157
123
|
*/
|
|
158
|
-
injected:
|
|
124
|
+
injected: string[];
|
|
159
125
|
};
|
|
160
126
|
}
|
|
161
127
|
//#endregion
|
|
162
|
-
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType };
|
|
128
|
+
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType };
|
|
163
129
|
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":"
|
|
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;;;;;;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;IAAA;;;;AAgBM;AAIZ;IAZM,QAAA;IAYqC;;AAInC;AAGR;;;IAXM,MAAA;EAAA;AAAA;AAAA,UAIW,iBAAA,SAA0B,cAAc;EAiB/C;;;EAbR,MAAM;AAAA;AAAA,UAGS,gBAAA,yBACS,uBAAA,GAA0B,uBAAA,UAC1C,kBAAA,CAAmB,eAAA;EAC3B,GAAA;IAFA;;;;;;IASE,IAAA,EAAM,YAAA,CAAa,iBAAA;IAAb;;;;;;IAQN,OAAA,EAAS,YAAA,CAAa,iBAAA;IAgBtB;;AAAQ;;;;IARR,MAAA,EAAQ,iBAAA;;;;;;;IAQR,QAAA;EAAA;AAAA"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { EnvInterface, SecretsInterface } from "./env.mjs";
|
|
2
1
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
3
2
|
import { Children } from "@alloy-js/core";
|
|
4
|
-
import {
|
|
3
|
+
import { ObjectSchema, SchemaInput, SchemaMetadata } from "@powerlines/schema";
|
|
5
4
|
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
6
5
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
7
|
-
import {
|
|
8
|
-
import { DotenvConfiguration
|
|
6
|
+
import { RequiredKeys } from "@stryke/types";
|
|
7
|
+
import { DotenvConfiguration } from "@stryke/types/configuration";
|
|
9
8
|
|
|
10
9
|
//#region src/types/plugin.d.ts
|
|
11
10
|
type EnvType = "env" | "secrets";
|
|
@@ -13,11 +12,11 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
13
12
|
/**
|
|
14
13
|
* 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"`.
|
|
15
14
|
*/
|
|
16
|
-
|
|
15
|
+
vars?: SchemaInput;
|
|
17
16
|
/**
|
|
18
17
|
* 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"`.
|
|
19
18
|
*/
|
|
20
|
-
secrets?:
|
|
19
|
+
secrets?: SchemaInput;
|
|
21
20
|
/**
|
|
22
21
|
* An additional prefix (or list of additional prefixes) to apply to the environment variables
|
|
23
22
|
*
|
|
@@ -58,33 +57,12 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
58
57
|
* The README.md file should contain the `<!-- automd:env --><!-- /automd -->` comment block where the documentation will be injected.
|
|
59
58
|
*/
|
|
60
59
|
automd?: AutoMDPluginOptions;
|
|
61
|
-
/**
|
|
62
|
-
* Alloy configuration options to use when injecting environment variables into the source code.
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
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
|
-
*/
|
|
67
|
-
deepkit?: DeepkitPluginOptions;
|
|
68
60
|
};
|
|
69
|
-
type EnvPluginUserConfig = BabelPluginUserConfig &
|
|
61
|
+
type EnvPluginUserConfig = BabelPluginUserConfig & {
|
|
70
62
|
env: EnvPluginOptions;
|
|
71
63
|
};
|
|
72
|
-
type EnvPluginResolvedConfig = BabelPluginResolvedConfig &
|
|
73
|
-
env: Required<Pick<DotenvConfiguration, "additionalFiles">> &
|
|
74
|
-
/**
|
|
75
|
-
* The type definition for the expected env variable parameters
|
|
76
|
-
*
|
|
77
|
-
* @remarks
|
|
78
|
-
* This value is parsed from the {@link EnvPluginOptions.types} option.
|
|
79
|
-
*/
|
|
80
|
-
types: TypeDefinition;
|
|
81
|
-
/**
|
|
82
|
-
* The type definition for the expected env secret parameters
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* This value is parsed from the {@link EnvPluginOptions.secrets} option.
|
|
86
|
-
*/
|
|
87
|
-
secrets: TypeDefinition;
|
|
64
|
+
type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
65
|
+
env: Required<Pick<DotenvConfiguration, "additionalFiles">> & RequiredKeys<EnvPluginOptions, "vars" | "secrets" | "defaultConfig"> & {
|
|
88
66
|
/**
|
|
89
67
|
* Should the plugin inject the env variables in the source code with their values?
|
|
90
68
|
*
|
|
@@ -108,40 +86,28 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & DeepkitPluginResolved
|
|
|
108
86
|
prefix: string[];
|
|
109
87
|
};
|
|
110
88
|
};
|
|
111
|
-
interface
|
|
89
|
+
interface EnvSchemaMetadata extends SchemaMetadata {
|
|
90
|
+
/**
|
|
91
|
+
* 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
|
+
*/
|
|
93
|
+
active: string[];
|
|
94
|
+
}
|
|
95
|
+
interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig> {
|
|
112
96
|
env: {
|
|
113
97
|
/**
|
|
114
|
-
* The type
|
|
98
|
+
* The type definition for the expected env variable parameters
|
|
115
99
|
*
|
|
116
100
|
* @remarks
|
|
117
|
-
*
|
|
101
|
+
* This value is parsed from the {@link EnvPluginOptions.vars} option.
|
|
118
102
|
*/
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The type definitions for the expected env variables
|
|
122
|
-
*/
|
|
123
|
-
env: Reflection;
|
|
124
|
-
/**
|
|
125
|
-
* The type definitions for the expected env secrets
|
|
126
|
-
*/
|
|
127
|
-
secrets: Reflection;
|
|
128
|
-
};
|
|
103
|
+
vars: ObjectSchema<EnvSchemaMetadata>;
|
|
129
104
|
/**
|
|
130
|
-
* The
|
|
105
|
+
* The type definition for the expected env secret parameters
|
|
131
106
|
*
|
|
132
107
|
* @remarks
|
|
133
|
-
* This
|
|
108
|
+
* This value is parsed from the {@link EnvPluginOptions.secrets} option.
|
|
134
109
|
*/
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* The current env variables reflection
|
|
138
|
-
*/
|
|
139
|
-
env: Reflection<EnvInterface>;
|
|
140
|
-
/**
|
|
141
|
-
* The current env secrets reflection
|
|
142
|
-
*/
|
|
143
|
-
secrets: Reflection<SecretsInterface>;
|
|
144
|
-
};
|
|
110
|
+
secrets: ObjectSchema<EnvSchemaMetadata>;
|
|
145
111
|
/**
|
|
146
112
|
* The parsed .env configuration object
|
|
147
113
|
*
|
|
@@ -155,9 +121,9 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
|
|
|
155
121
|
* @remarks
|
|
156
122
|
* This reflection contains the structure of the injected environment variables and secrets that were injected into the source code during the build process.
|
|
157
123
|
*/
|
|
158
|
-
injected:
|
|
124
|
+
injected: string[];
|
|
159
125
|
};
|
|
160
126
|
}
|
|
161
127
|
//#endregion
|
|
162
|
-
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType };
|
|
128
|
+
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType };
|
|
163
129
|
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":"
|
|
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;IAAA;;;;AAgBM;AAIZ;IAZM,QAAA;IAYqC;;AAInC;AAGR;;;IAXM,MAAA;EAAA;AAAA;AAAA,UAIW,iBAAA,SAA0B,cAAc;EAiB/C;;;EAbR,MAAM;AAAA;AAAA,UAGS,gBAAA,yBACS,uBAAA,GAA0B,uBAAA,UAC1C,kBAAA,CAAmB,eAAA;EAC3B,GAAA;IAFA;;;;;;IASE,IAAA,EAAM,YAAA,CAAa,iBAAA;IAAb;;;;;;IAQN,OAAA,EAAS,YAAA,CAAa,iBAAA;IAgBtB;;AAAQ;;;;IARR,MAAA,EAAQ,iBAAA;;;;;;;IAQR,QAAA;EAAA;AAAA"}
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -33,7 +33,7 @@ const __ΩEnvType = [
|
|
|
33
33
|
const __ΩEnvPluginOptions = [
|
|
34
34
|
() => __ΩOmit,
|
|
35
35
|
"types",
|
|
36
|
-
"
|
|
36
|
+
"vars",
|
|
37
37
|
"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\"`.",
|
|
38
38
|
"secrets",
|
|
39
39
|
"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\"`.",
|
|
@@ -51,29 +51,19 @@ 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
|
-
"deepkit",
|
|
55
|
-
"Alloy configuration options to use when injecting environment variables into the source code.",
|
|
56
54
|
"EnvPluginOptions",
|
|
57
|
-
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?0!418?2!438?
|
|
55
|
+
"P!.\"o!#P!4#8?$!4%8?&P&&FJ4'8?()4)8>*?+)4,8>*?-\"w.4/8?0!418?2!438?4MKw5y"
|
|
58
56
|
];
|
|
59
57
|
const __ΩEnvPluginUserConfig = [
|
|
60
58
|
() => __ΩEnvPluginOptions,
|
|
61
59
|
"env",
|
|
62
60
|
"EnvPluginUserConfig",
|
|
63
|
-
"P
|
|
61
|
+
"P!Pn!4\"MKw#y"
|
|
64
62
|
];
|
|
65
63
|
const __ΩEnvPluginResolvedConfig = [
|
|
66
64
|
() => __ΩRequired,
|
|
67
65
|
() => __ΩPick,
|
|
68
66
|
"additionalFiles",
|
|
69
|
-
() => __ΩRequired,
|
|
70
|
-
() => __ΩPick,
|
|
71
|
-
() => __ΩEnvPluginOptions,
|
|
72
|
-
"defaultConfig",
|
|
73
|
-
"types",
|
|
74
|
-
"The type definition for the expected env variable parameters",
|
|
75
|
-
"secrets",
|
|
76
|
-
"The type definition for the expected env secret parameters",
|
|
77
67
|
"inject",
|
|
78
68
|
"Should the plugin inject the env variables in the source code with their values?",
|
|
79
69
|
"validate",
|
|
@@ -82,29 +72,30 @@ const __ΩEnvPluginResolvedConfig = [
|
|
|
82
72
|
"The prefix used for environment variables",
|
|
83
73
|
"env",
|
|
84
74
|
"EnvPluginResolvedConfig",
|
|
85
|
-
"P
|
|
75
|
+
"P!PP!.#o\"#o!\"!P)4$?%)4&?'&F4(?)MK4*MKw+y"
|
|
76
|
+
];
|
|
77
|
+
const __ΩEnvSchemaMetadata = [
|
|
78
|
+
"active",
|
|
79
|
+
"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
|
+
"EnvSchemaMetadata",
|
|
81
|
+
"P!&F4!?\"Mw#y"
|
|
86
82
|
];
|
|
87
83
|
const __ΩEnvPluginContext = [
|
|
88
84
|
() => __ΩEnvPluginResolvedConfig,
|
|
89
85
|
"TResolvedConfig",
|
|
90
|
-
"
|
|
91
|
-
"The type
|
|
86
|
+
"vars",
|
|
87
|
+
"The type definition for the expected env variable parameters",
|
|
92
88
|
"secrets",
|
|
93
|
-
"The type
|
|
94
|
-
"The type definitions reflection for the env variables and secrets",
|
|
95
|
-
"types",
|
|
96
|
-
"The current env variables reflection",
|
|
97
|
-
"The current env secrets reflection",
|
|
98
|
-
"The current **used** environment variables and secrets reflection",
|
|
99
|
-
"used",
|
|
89
|
+
"The type definition for the expected env secret parameters",
|
|
100
90
|
"parsed",
|
|
101
91
|
"The parsed .env configuration object",
|
|
102
92
|
"injected",
|
|
103
93
|
"The injected environment variables and secrets reflection",
|
|
94
|
+
"env",
|
|
104
95
|
"EnvPluginContext",
|
|
105
|
-
"n!c\"P
|
|
96
|
+
"n!c\"P!P!4#?$!4%?&!4'?(&F4)?*M4+Mw,y"
|
|
106
97
|
];
|
|
107
98
|
|
|
108
99
|
//#endregion
|
|
109
|
-
export { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType };
|
|
100
|
+
export { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchemaMetadata, __ΩEnvType };
|
|
110
101
|
//# 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 {
|
|
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 EnvSchemaMetadata extends SchemaMetadata {\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: ObjectSchema<EnvSchemaMetadata>;\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: ObjectSchema<EnvSchemaMetadata>;\n\n /**\n * The parsed .env configuration object\n *\n * @remarks\n * This value is the result of loading the .env configuration file found in the project root directory and merging it with the values provided at {@link EnvPluginOptions.values}\n */\n parsed: DotenvParseOutput;\n\n /**\n * The injected environment variables and secrets reflection\n *\n * @remarks\n * This reflection contains the structure of the injected environment variables and secrets that were injected into the source code during the build process.\n */\n injected: string[];\n };\n}\n"],"mappings":";AAAA,MAAM,UAAU;CAAC;CAAK;OAAW;OAAe;CAAY;CAAQ;AAAC;;;;;;AAErE,MAAM,UAAU;CAAC;CAAI;CAAM;CAAQ;AAAG;;;;;;;AAEtC,MAAM,aAAS;CAAA;CAAY;CAAW;CAAW;AAAU;AAE3D,MAAM,sBAAmB;OAAQ;CAAS;CAAK;CAAa;CAAO;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;AAInE,MAAC,6BAAkC;OAAO;OAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAE7D,MAAC,uBAA0B;CAAA;CAAQ;CAAkB;CAAA;AAAA;AAErD,MAAM,sBAAqB;OAAQ;CAAC;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA"}
|