@powerlines/plugin-env 0.16.0 → 0.16.2

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.
@@ -13,7 +13,7 @@ function __assignType(fn, args) {
13
13
  return fn;
14
14
  }
15
15
  const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, __powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin)("env", __assignType(({ log, context }) => {
16
- function extractEnv(node, pass, isInjectable = false) {
16
+ function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
17
17
  const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
18
18
  "prop",
19
19
  "",
@@ -87,6 +87,7 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
87
87
  "",
88
88
  "P\"2!\"/\""
89
89
  ])).join("\n")} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`);
90
+ else if (pass.filename && isUsingBuiltin) context.warn(`The "${name}" environment variable is used in the source code file ${pass.filename}, but is not defined in the \`env\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`);
90
91
  }
91
92
  }
92
93
  extractEnv.__type = [
@@ -94,14 +95,15 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
94
95
  () => powerlines_types_babel.__ΩBabelPluginPass,
95
96
  "pass",
96
97
  "isInjectable",
98
+ "isUsingBuiltin",
97
99
  "extractEnv",
98
- "P!2!n\"2#\"2$\"/%"
100
+ "P!2!n\"2#\"2$\"2%\"/&"
99
101
  ];
100
102
  return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
101
103
  if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
102
104
  const identifier = path.get("property")?.node;
103
105
  if (!identifier.name) return;
104
- extractEnv(identifier, pass, false);
106
+ extractEnv(identifier, pass, false, false);
105
107
  path.replaceWithSourceString(`env.${identifier.name}`);
106
108
  (0, __powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
107
109
  module: `${context.config.framework || "powerlines"}:env`,
@@ -111,7 +113,7 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
111
113
  } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
112
114
  const identifier = path.get("property")?.node;
113
115
  if (!identifier.name) return;
114
- extractEnv(identifier, pass, false);
116
+ extractEnv(identifier, pass, false, false);
115
117
  path.replaceWithSourceString(`env.${identifier.name}`);
116
118
  (0, __powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
117
119
  module: `${context.config.framework || "powerlines"}:env`,
@@ -121,7 +123,7 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
121
123
  } else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
122
124
  const identifier = path.get("property")?.node;
123
125
  if (!identifier.name) return;
124
- extractEnv(identifier, pass, false);
126
+ extractEnv(identifier, pass, false, true);
125
127
  }
126
128
  }, [
127
129
  () => __babel_core.NodePath,
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,gBAAc,iBAAA,CAAA,kCAAA,iBAmM1B,uBAAA,GAnM0B"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,gBAAc,iBAAA,CAAA,kCAAA,iBA4M1B,uBAAA,GA5M0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,gBAAc,iBAAA,CAAA,kCAAA,iBAmM1B,uBAAA,GAnM0B"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,gBAAc,iBAAA,CAAA,kCAAA,iBA4M1B,uBAAA,GA5M0B"}
@@ -12,7 +12,7 @@ function __assignType(fn, args) {
12
12
  return fn;
13
13
  }
14
14
  const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!"]], createBabelPlugin("env", __assignType(({ log, context }) => {
15
- function extractEnv(node, pass, isInjectable = false) {
15
+ function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
16
16
  const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
17
17
  "prop",
18
18
  "",
@@ -86,6 +86,7 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
86
86
  "",
87
87
  "P\"2!\"/\""
88
88
  ])).join("\n")} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`);
89
+ else if (pass.filename && isUsingBuiltin) context.warn(`The "${name}" environment variable is used in the source code file ${pass.filename}, but is not defined in the \`env\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`);
89
90
  }
90
91
  }
91
92
  extractEnv.__type = [
@@ -93,14 +94,15 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
93
94
  () => __ΩBabelPluginPass,
94
95
  "pass",
95
96
  "isInjectable",
97
+ "isUsingBuiltin",
96
98
  "extractEnv",
97
- "P!2!n\"2#\"2$\"/%"
99
+ "P!2!n\"2#\"2$\"2%\"/&"
98
100
  ];
99
101
  return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
100
102
  if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
101
103
  const identifier = path.get("property")?.node;
102
104
  if (!identifier.name) return;
103
- extractEnv(identifier, pass, false);
105
+ extractEnv(identifier, pass, false, false);
104
106
  path.replaceWithSourceString(`env.${identifier.name}`);
105
107
  addImport(path, {
106
108
  module: `${context.config.framework || "powerlines"}:env`,
@@ -110,7 +112,7 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
110
112
  } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
111
113
  const identifier = path.get("property")?.node;
112
114
  if (!identifier.name) return;
113
- extractEnv(identifier, pass, false);
115
+ extractEnv(identifier, pass, false, false);
114
116
  path.replaceWithSourceString(`env.${identifier.name}`);
115
117
  addImport(path, {
116
118
  module: `${context.config.framework || "powerlines"}:env`,
@@ -120,7 +122,7 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
120
122
  } else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
121
123
  const identifier = path.get("property")?.node;
122
124
  if (!identifier.name) return;
123
- extractEnv(identifier, pass, false);
125
+ extractEnv(identifier, pass, false, true);
124
126
  }
125
127
  }, [
126
128
  () => NodePath,
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\n\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { BabelPluginPass } from \"powerlines/types/babel\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/*\n * The Powerlines - Environment Configuration Babel Plugin\n *\n * @param babel - The Babel core module\n * @returns The Babel plugin object\n */\nexport const envBabelPlugin = createBabelPlugin<EnvPluginContext>(\n \"env\",\n ({ log, context }) => {\n function extractEnv(\n node: t.Identifier,\n pass: BabelPluginPass,\n isInjectable = false\n ) {\n const envTypesAliasProperties = context.env.types.env\n ?.getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n if (node.name) {\n const prefix = context.config.env.prefix.find(\n pre =>\n node.name &&\n node.name.startsWith(pre) &&\n (context.env.types.env?.hasProperty(\n node.name.replace(`${pre}_`, \"\")\n ) ||\n envTypesAliasProperties.some(prop =>\n prop.getAlias().includes(node.name.replace(`${pre}_`, \"\"))\n ))\n );\n\n let name = node.name;\n if (prefix) {\n name = node.name.replace(`${prefix}_`, \"\");\n }\n\n log(\n LogLevelLabel.TRACE,\n `Environment variable ${name} found in ${\n pass.filename || \"unknown file\"\n }.`\n );\n\n if (\n context.env.types.env?.hasProperty(name) ||\n envTypesAliasProperties.some(prop => prop.getAlias().includes(name))\n ) {\n const envProperty = context.env.types.env.hasProperty(name)\n ? context.env.types.env.getProperty(name)\n : envTypesAliasProperties.find(prop =>\n prop.getAlias().includes(name)\n );\n if (!envProperty || envProperty.isIgnored()) {\n return;\n }\n\n if (!context.env.used.env.hasProperty(name)) {\n log(\n LogLevelLabel.DEBUG,\n `Adding \"${name}\" environment variables found in \"${\n pass.filename || \"unknown file\"\n }\" to used environment configuration reflection object.`\n );\n\n context.env.used.env.addProperty(envProperty.property);\n }\n\n if (context.config.env.inject && isInjectable) {\n let value = context.env.parsed?.[name];\n if (value === undefined) {\n const prefix = context.config.env.prefix.find(pre => {\n return context.env.parsed[`${pre.replace(/_$/g, \"\")}_${name}`];\n });\n if (prefix) {\n value =\n context.env.parsed[`${prefix.replace(/_$/g, \"\")}_${name}`];\n }\n }\n\n value ??= envProperty.getDefaultValue();\n\n if (envProperty.isValueRequired() && value === undefined) {\n throw new Error(\n `Environment variable \\`${name}\\` is not defined in the .env configuration files`\n );\n }\n\n return stringifyDefaultValue(envProperty, value);\n }\n } else if (context.config.env.validate) {\n throw new Error(\n `The \"${name}\" environment variable is not defined in the \\`env\\` type definition, but is used in the source code file ${\n pass.filename ? pass.filename : \"unknown\"\n }.\n\n The following environment configuration names are defined in the \\`env\\` type definition: \\n${context.env.types.env\n ?.getPropertyNames()\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map(\n typeDef =>\n ` - ${String(typeDef)} ${\n envTypesAliasProperties.some(\n prop =>\n prop.getNameAsString() === String(typeDef) &&\n prop.getAlias().length > 0\n )\n ? `(Alias: ${envTypesAliasProperties\n ?.find(\n prop => prop.getNameAsString() === String(typeDef)\n )\n ?.getAlias()\n .join(\", \")})`\n : \"\"\n }`\n )\n .join(\n \"\\n\"\n )} \\n\\nUsing the following env prefix: \\n${context.config.env.prefix\n .map(prefix => ` - ${prefix}`)\n .join(\n \"\\n\"\n )} \\n\\nPlease check your \\`env\\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \\n\\n`\n );\n }\n }\n\n return undefined;\n }\n\n return {\n visitor: {\n MemberExpression(\n path: NodePath<t.MemberExpression>,\n pass: BabelPluginPass\n ) {\n if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path\n .get(\"object\")\n ?.get(\"object\")\n ?.isIdentifier({ name: \"process\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // process.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path.get(\"object\")?.get(\"object\")?.isMetaProperty() &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // import.meta.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path.get(\"object\")?.isIdentifier({ name: \"env\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n }\n }\n }\n };\n }\n);\n"],"mappings":";;;;;;;;;AAIA,SAAS,aAAa,IAAI,MAAM;AAC5B,IAAG,SAAS;AACZ,QAAO;;AA8BX,MAAa,kBAAW,kBAAA,IAAA,CAAA,OAAA,qBAAA,KAAA,CAAA,EAAA,kBAAA,OAAA,cAAA,EAAA,KAAA,cAAA;CACpB,SAAS,WAAU,MAAA,MAAA,eAAA,OAAA;EACf,MAAM,0BAAU,QAAA,IAAA,MAAA,KACV,eAAa,CACd,OAAO,cAAK,SAAA,KAAA,UAAA,CAAA,SAAA,GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;AACnB,MAAA,KAAA,MAAA;GACM,MAAM,SAAS,QAAQ,OAAO,IAAI,OAAO,KAAK,cAAA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K,wBAAwB,OAAK,WAAA,OAAA;AACzC,aAAA,MAAA;;IAEW,MAAM;IACN,UAAO;IACV,CAAC;aAEC,KACF,IAAI,SAAS,EACZ,IAAI,WAAW,EACf,aAAI,EAAA,MAAA,OAAA,CAAA,IACN,KAAK,IAAI,SAAS,EAAE,IAAI,SAAS,EAAE,gBAAW,IAC9C,KAAK,IAAI,WAAW,EAAE,cAAK,EAAA;GAE3B,MAAM,aAAa,KAAK,IAAI,WAAO,EAAA;AACnC,OAAI,CAAC,WAAK,KACN;AAEJ,cAAW,YAAI,MAAA,MAAA;AACf,QAAK,wBAAY,OAAA,WAAA,OAAA;AACjB,aAAG,MAAA;IACN,QAAA,GAAA,QAAA,OAAA,aAAA,aAAA;IACL,MAAA;IACK,UAAA;IACA,CAAA;aAEQ,KAAK,IAAI,SAAO,EAAA,aAAA,EAAA,MAAA,OAAA,CAAA,IACxB,KAAA,IAAA,WAAA,EAAA,cAAA,EAAA;GAEG,MAAM,aAAa,KAAK,IAAI,WAAW,EAAE;AAClD,OAAA,CAAA,WAAA,KACH;;;IAIJ;QAAA;EAAA;QAAA;EAAA;EAAA;EAAA;EAAA,CAAA,IAEC;GACF;CAAC;CAAU;CAAC;CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\n\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { BabelPluginPass } from \"powerlines/types/babel\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/*\n * The Powerlines - Environment Configuration Babel Plugin\n *\n * @param babel - The Babel core module\n * @returns The Babel plugin object\n */\nexport const envBabelPlugin = createBabelPlugin<EnvPluginContext>(\n \"env\",\n ({ log, context }) => {\n function extractEnv(\n node: t.Identifier,\n pass: BabelPluginPass,\n isInjectable = false,\n isUsingBuiltin = false\n ) {\n const envTypesAliasProperties = context.env.types.env\n ?.getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n if (node.name) {\n const prefix = context.config.env.prefix.find(\n pre =>\n node.name &&\n node.name.startsWith(pre) &&\n (context.env.types.env?.hasProperty(\n node.name.replace(`${pre}_`, \"\")\n ) ||\n envTypesAliasProperties.some(prop =>\n prop.getAlias().includes(node.name.replace(`${pre}_`, \"\"))\n ))\n );\n\n let name = node.name;\n if (prefix) {\n name = node.name.replace(`${prefix}_`, \"\");\n }\n\n log(\n LogLevelLabel.TRACE,\n `Environment variable ${name} found in ${\n pass.filename || \"unknown file\"\n }.`\n );\n\n if (\n context.env.types.env?.hasProperty(name) ||\n envTypesAliasProperties.some(prop => prop.getAlias().includes(name))\n ) {\n const envProperty = context.env.types.env.hasProperty(name)\n ? context.env.types.env.getProperty(name)\n : envTypesAliasProperties.find(prop =>\n prop.getAlias().includes(name)\n );\n if (!envProperty || envProperty.isIgnored()) {\n return;\n }\n\n if (!context.env.used.env.hasProperty(name)) {\n log(\n LogLevelLabel.DEBUG,\n `Adding \"${name}\" environment variables found in \"${\n pass.filename || \"unknown file\"\n }\" to used environment configuration reflection object.`\n );\n\n context.env.used.env.addProperty(envProperty.property);\n }\n\n if (context.config.env.inject && isInjectable) {\n let value = context.env.parsed?.[name];\n if (value === undefined) {\n const prefix = context.config.env.prefix.find(pre => {\n return context.env.parsed[`${pre.replace(/_$/g, \"\")}_${name}`];\n });\n if (prefix) {\n value =\n context.env.parsed[`${prefix.replace(/_$/g, \"\")}_${name}`];\n }\n }\n\n value ??= envProperty.getDefaultValue();\n\n if (envProperty.isValueRequired() && value === undefined) {\n throw new Error(\n `Environment variable \\`${name}\\` is not defined in the .env configuration files`\n );\n }\n\n return stringifyDefaultValue(envProperty, value);\n }\n } else if (context.config.env.validate) {\n throw new Error(\n `The \"${name}\" environment variable is not defined in the \\`env\\` type definition, but is used in the source code file ${\n pass.filename ? pass.filename : \"unknown\"\n }.\n\n The following environment configuration names are defined in the \\`env\\` type definition: \\n${context.env.types.env\n ?.getPropertyNames()\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map(\n typeDef =>\n ` - ${String(typeDef)} ${\n envTypesAliasProperties.some(\n prop =>\n prop.getNameAsString() === String(typeDef) &&\n prop.getAlias().length > 0\n )\n ? `(Alias: ${envTypesAliasProperties\n ?.find(\n prop => prop.getNameAsString() === String(typeDef)\n )\n ?.getAlias()\n .join(\", \")})`\n : \"\"\n }`\n )\n .join(\n \"\\n\"\n )} \\n\\nUsing the following env prefix: \\n${context.config.env.prefix\n .map(prefix => ` - ${prefix}`)\n .join(\n \"\\n\"\n )} \\n\\nPlease check your \\`env\\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \\n\\n`\n );\n } else if (pass.filename && isUsingBuiltin) {\n context.warn(\n `The \"${\n name\n }\" environment variable is used in the source code file ${\n pass.filename\n }, but is not defined in the \\`env\\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \\`env\\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`\n );\n }\n }\n\n return undefined;\n }\n\n return {\n visitor: {\n MemberExpression(\n path: NodePath<t.MemberExpression>,\n pass: BabelPluginPass\n ) {\n if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path\n .get(\"object\")\n ?.get(\"object\")\n ?.isIdentifier({ name: \"process\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // process.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path.get(\"object\")?.get(\"object\")?.isMetaProperty() &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // import.meta.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path.get(\"object\")?.isIdentifier({ name: \"env\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, true);\n }\n }\n }\n };\n }\n);\n"],"mappings":";;;;;;;;;AAIA,SAAS,aAAa,IAAI,MAAM;AAC5B,IAAG,SAAS;AACZ,QAAO;;AA8BX,MAAa,kBAAW,kBAAA,IAAA,CAAA,OAAA,qBAAA,KAAA,CAAA,EAAA,kBAAA,OAAA,cAAA,EAAA,KAAA,cAAA;CACpB,SAAS,WAAU,MAAA,MAAA,eAAA,OAAA,iBAAA,OAAA;EACf,MAAM,0BAAU,QAAA,IAAA,MAAA,KACV,eAAa,CACd,OAAO,cAAM,SAAA,KAAA,UAAA,CAAA,SAAA,GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;AAClB,MAAI,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a,KAAK,IAAI,WAAA,EAAA;AAC5B,OAAI,CAAC,WAAA,KACD;AAEX,cAAA,YAAA,MAAA,OAAA,MAAA;;AAEO,aAAU,MAAM;IACZ,QAAO,GAAA,QAAA,OAAA,aAAA,aAAA;IACP,MAAM;IACd,UAAA;IACK,CAAC;aAEG,KACJ,IAAI,SAAC,EACJ,IAAI,WAAW,EACf,aAAa,EAAE,MAAM,OAAI,CAAA,IAC7B,KAAA,IAAA,SAAA,EAAA,IAAA,SAAA,EAAA,gBAAA,IACE,KAAK,IAAI,WAAW,EAAE,cAAa,EAAA;GAEnC,MAAM,aAAa,KAAK,IAAI,WAAW,EAAE;AACzC,OAAI,CAAA,WAAA,KACA;AAEJ,cAAG,YAAA,MAAA,OAAA,MAAA;AACN,QAAA,wBAAA,OAAA,WAAA,OAAA;AACL,aAAA,MAAA;IACK,QAAA,GAAA,QAAA,OAAA,aAAA,aAAA;IACA,MAAA;IACO,UAAU;IACb,CAAC;aAEL,KAAA,IAAA,SAAA,EAAA,aAAA,EAAA,MAAA,OAAA,CAAA,IACG,KAAK,IAAI,WAAW,EAAE,cAAc,EAAE;GAEtC,MAAM,aAAa,KAAK,IAAI,WAAI,EAAA;AAChC,OAAE,CAAA,WAAA,KACH;AAEC,cAAW,YAAY,MAAM,OAAO,KAAK;;IAE9C;QAAO;EAAU;QAAc;EAAoB;EAAQ;EAAoB;EAAiB,CAAA,EACvG,EACH;GACF;CAAC;CAAE;CAAA;CAAA,CAAA,CAAA"}
@@ -208,17 +208,27 @@ createSecretsReflection.__type = [
208
208
  "createSecretsReflection",
209
209
  "Pn!2\"n#2$>%P\"7&/'"
210
210
  ];
211
+ /**
212
+ * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
213
+ *
214
+ * @remarks
215
+ * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
216
+ *
217
+ * @param context - The plugin context
218
+ * @param file - The file path to reflect the environment configuration type definition from
219
+ * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
220
+ * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
221
+ */
211
222
  async function reflectEnv(context, file, name) {
212
223
  let config;
213
224
  if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, {
214
225
  file: !require_is_parent_path.isParentPath(file, context.workspaceConfig.workspaceRoot) ? require_join_paths.joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
215
226
  name
216
227
  }));
217
- const defaultConfigType = await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context));
218
228
  return mergeEnvReflections(context, [
219
229
  await require_helpers_persistence.readEnvTypeReflection(context, "env"),
220
230
  config,
221
- (0, __powerlines_deepkit_vendor_type.resolveClassType)(defaultConfigType)
231
+ (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context)))
222
232
  ].filter(Boolean));
223
233
  }
224
234
  reflectEnv.__type = [
@@ -227,19 +237,30 @@ reflectEnv.__type = [
227
237
  "file",
228
238
  "name",
229
239
  "reflectEnv",
230
- "Pn!2\"&2#8&2$8\"/%"
240
+ "Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.",
241
+ "Pn!2\"&2#8&2$8\"/%?&"
231
242
  ];
243
+ /**
244
+ * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.
245
+ *
246
+ * @remarks
247
+ * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
248
+ *
249
+ * @param context - The plugin context
250
+ * @param file - The file path to reflect the secrets configuration type definition from
251
+ * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
252
+ * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
253
+ */
232
254
  async function reflectSecrets(context, file, name) {
233
255
  let config;
234
256
  if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, {
235
257
  file: !require_is_parent_path.isParentPath(file, context.workspaceConfig.workspaceRoot) ? require_join_paths.joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
236
258
  name
237
259
  }));
238
- const defaultSecretsType = await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context));
239
260
  return mergeSecretsReflections(context, [
240
261
  await require_helpers_persistence.readSecretsReflection(context),
241
262
  config,
242
- (0, __powerlines_deepkit_vendor_type.resolveClassType)(defaultSecretsType)
263
+ (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context)))
243
264
  ].filter(Boolean));
244
265
  }
245
266
  reflectSecrets.__type = [
@@ -248,7 +269,8 @@ reflectSecrets.__type = [
248
269
  "file",
249
270
  "name",
250
271
  "reflectSecrets",
251
- "Pn!2\"&2#8&2$8\"/%"
272
+ "Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.",
273
+ "Pn!2\"&2#8&2$8\"/%?&"
252
274
  ];
253
275
 
254
276
  //#endregion
@@ -39,7 +39,29 @@ declare class BaseSecrets implements SecretsInterface {
39
39
  }
40
40
  declare function createEnvReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): ReflectionClass<any>;
41
41
  declare function createSecretsReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): ReflectionClass<any>;
42
+ /**
43
+ * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
44
+ *
45
+ * @remarks
46
+ * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
47
+ *
48
+ * @param context - The plugin context
49
+ * @param file - The file path to reflect the environment configuration type definition from
50
+ * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
51
+ * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
52
+ */
42
53
  declare function reflectEnv(context: EnvPluginContext, file?: string, name?: string): Promise<ReflectionClass<any>>;
54
+ /**
55
+ * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.
56
+ *
57
+ * @remarks
58
+ * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
59
+ *
60
+ * @param context - The plugin context
61
+ * @param file - The file path to reflect the secrets configuration type definition from
62
+ * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
63
+ * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
64
+ */
43
65
  declare function reflectSecrets(context: EnvPluginContext, file?: string, name?: string): Promise<ReflectionClass<any>>;
44
66
  declare type __ΩCreateEnvReflectionOptions = any[];
45
67
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.d.cts","names":[],"sources":["../../src/helpers/reflect.ts"],"sourcesContent":[],"mappings":";;;;;iBAuCgB,mBAAA,UACL,+BACI,yBACZ;iBAQa,uBAAA,UACL,+BACI,yBACZ;AAda,UAsBC,0BAAA,CAtBkB;EACxB,IAAA,CAAA,EAsBF,iBAtBE,GAsBkB,SAtBlB;EACI,eAAA,CAAA,EAsBK,eAtBL,CAAA,GAAA,CAAA;;AACG,cAwBL,OAAA,YAAmB,YAxBd,CAAA;EAQF,QAAA,EAAA,MAAA;EACL,WAAA,EAAA,MAAA;EACI,QAAA,EAAA,MAAA;EACZ,eAAA,EAAA,MAAA;EAAe,cAAA,EAAA,MAAA;EAQD,UAAA,EAAA,MAAA;EACR,WAAA,EAAA,MAAA;EAAoB,YAAA,EAAA,MAAA;EACT,QAAA,EAAA,MAAA,GAAA,SAAA,GAAA,SAAA;EAAe,IAAA,EAAA,aAAA,GAAA,MAAA,GAAA,YAAA;EAGtB,WAAQ,EAAA,MAAA;EAgDR,KAAA,EAAA,OAAY;EAIT,IAAA,EAAA,OAAA;EACL,OAAA,EAAA,OAAA;EACA,QAAA,EAAA,OAAA;EACR,WAAA,EAAA,MAAA,GAAA,OAAA;EAAe,eAAA,EAAA,MAAA,GAAA,OAAA;EAyCF,UAAA,EAAA,OAAA;EACL,kBAAA,EAAA,OAAA;EACA,SAAA,EAAA,MAAA;EACR,gBAAA,EAAA,MAAA;EAAe,cAAA,EAAA,MAAA;EAyCI,EAAA,EAAA,OAAA;;AAGP,cA/FF,WAAA,YAAuB,gBA+FrB,CAAA;EAAA,cAAA,EAAA,MAAA;;AAwCO,iBAnIN,mBAAA,CAmIoB,OAAA,EAlIzB,gBAkIyB,EAAA,OAAA,CAAA,EAjIzB,0BAiIyB,CAAA,EAhIjC,eAgIiC,CAAA,GAAA,CAAA;AACzB,iBAxFK,uBA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EAAA,MAAA,GAAA,OAAA;EAyCF,UAAA,EAAA,OAAA;EACL,kBAAA,EAAA,OAAA;EACA,SAAA,EAAA,MAAA;EACR,gBAAA,EAAA,MAAA;EAAe,cAAA,EAAA,MAAA;EAoDI,EAAA,EAAA,OAAA;;AAGP,cA1GF,WAAA,YAAuB,gBA0GrB,CAAA;EAAA,cAAA,EAAA,MAAA;;AAqCO,iBA3IN,mBAAA,CA2IoB,OAAA,EA1IzB,gBA0IyB,EAAA,OAAA,CAAA,EAzIzB,0BAyIyB,CAAA,EAxIjC,eAwIiC,CAAA,GAAA,CAAA;AACzB,iBAhGK,uBAAA,CAgGL,OAAA,EA/FA,gBA+FA,EAAA,OAAA,CAAA,EA9FA,0BA8FA,CAAA,EA7FR,eA6FQ,CAAA,GAAA,CAAA;;;;;;;;;;;;iBAzCW,UAAA,UACX,iDAEI,QAAA;;;;;;;;;;;;iBAqCO,cAAA,UACX,iDAEI,QAAA"}
@@ -39,7 +39,29 @@ declare class BaseSecrets implements SecretsInterface {
39
39
  }
40
40
  declare function createEnvReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): ReflectionClass<any>;
41
41
  declare function createSecretsReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): ReflectionClass<any>;
42
+ /**
43
+ * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
44
+ *
45
+ * @remarks
46
+ * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
47
+ *
48
+ * @param context - The plugin context
49
+ * @param file - The file path to reflect the environment configuration type definition from
50
+ * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
51
+ * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
52
+ */
42
53
  declare function reflectEnv(context: EnvPluginContext, file?: string, name?: string): Promise<ReflectionClass<any>>;
54
+ /**
55
+ * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.
56
+ *
57
+ * @remarks
58
+ * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
59
+ *
60
+ * @param context - The plugin context
61
+ * @param file - The file path to reflect the secrets configuration type definition from
62
+ * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
63
+ * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
64
+ */
43
65
  declare function reflectSecrets(context: EnvPluginContext, file?: string, name?: string): Promise<ReflectionClass<any>>;
44
66
  declare type __ΩCreateEnvReflectionOptions = any[];
45
67
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.d.mts","names":[],"sources":["../../src/helpers/reflect.ts"],"sourcesContent":[],"mappings":";;;;;iBAuCgB,mBAAA,UACL,+BACI,yBACZ;iBAQa,uBAAA,UACL,+BACI,yBACZ;AAda,UAsBC,0BAAA,CAtBkB;EACxB,IAAA,CAAA,EAsBF,iBAtBE,GAsBkB,SAtBlB;EACI,eAAA,CAAA,EAsBK,eAtBL,CAAA,GAAA,CAAA;;AACG,cAwBL,OAAA,YAAmB,YAxBd,CAAA;EAQF,QAAA,EAAA,MAAA;EACL,WAAA,EAAA,MAAA;EACI,QAAA,EAAA,MAAA;EACZ,eAAA,EAAA,MAAA;EAAe,cAAA,EAAA,MAAA;EAQD,UAAA,EAAA,MAAA;EACR,WAAA,EAAA,MAAA;EAAoB,YAAA,EAAA,MAAA;EACT,QAAA,EAAA,MAAA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27 @@ createSecretsReflection.__type = [
207
207
  "createSecretsReflection",
208
208
  "Pn!2\"n#2$>%P\"7&/'"
209
209
  ];
210
+ /**
211
+ * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
212
+ *
213
+ * @remarks
214
+ * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
215
+ *
216
+ * @param context - The plugin context
217
+ * @param file - The file path to reflect the environment configuration type definition from
218
+ * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
219
+ * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
220
+ */
210
221
  async function reflectEnv(context, file, name) {
211
222
  let config;
212
223
  if (file) config = resolveClassType(await reflectType(context, {
213
224
  file: !isParentPath(file, context.workspaceConfig.workspaceRoot) ? joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
214
225
  name
215
226
  }));
216
- const defaultConfigType = await reflectType(context, await getEnvDefaultTypeDefinition(context));
217
227
  return mergeEnvReflections(context, [
218
228
  await readEnvTypeReflection(context, "env"),
219
229
  config,
220
- resolveClassType(defaultConfigType)
230
+ resolveClassType(await reflectType(context, await getEnvDefaultTypeDefinition(context)))
221
231
  ].filter(Boolean));
222
232
  }
223
233
  reflectEnv.__type = [
@@ -226,19 +236,30 @@ reflectEnv.__type = [
226
236
  "file",
227
237
  "name",
228
238
  "reflectEnv",
229
- "Pn!2\"&2#8&2$8\"/%"
239
+ "Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.",
240
+ "Pn!2\"&2#8&2$8\"/%?&"
230
241
  ];
242
+ /**
243
+ * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.
244
+ *
245
+ * @remarks
246
+ * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
247
+ *
248
+ * @param context - The plugin context
249
+ * @param file - The file path to reflect the secrets configuration type definition from
250
+ * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
251
+ * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
252
+ */
231
253
  async function reflectSecrets(context, file, name) {
232
254
  let config;
233
255
  if (file) config = resolveClassType(await reflectType(context, {
234
256
  file: !isParentPath(file, context.workspaceConfig.workspaceRoot) ? joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
235
257
  name
236
258
  }));
237
- const defaultSecretsType = await reflectType(context, await getSecretsDefaultTypeDefinition(context));
238
259
  return mergeSecretsReflections(context, [
239
260
  await readSecretsReflection(context),
240
261
  config,
241
- resolveClassType(defaultSecretsType)
262
+ resolveClassType(await reflectType(context, await getSecretsDefaultTypeDefinition(context)))
242
263
  ].filter(Boolean));
243
264
  }
244
265
  reflectSecrets.__type = [
@@ -247,7 +268,8 @@ reflectSecrets.__type = [
247
268
  "file",
248
269
  "name",
249
270
  "reflectSecrets",
250
- "Pn!2\"&2#8&2$8\"/%"
271
+ "Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.",
272
+ "Pn!2\"&2#8&2$8\"/%?&"
251
273
  ];
252
274
 
253
275
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport { EnvInterface, SecretsInterface } from \"../types/runtime\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n const defaultConfigType = await reflectType(\n context,\n await getEnvDefaultTypeDefinition(context)\n );\n\n const reflection = await readEnvTypeReflection(context, \"env\");\n\n // const defaultConfig = resolveClassType(defaultConfigType);\n // if (config) {\n // defaultConfig.getProperties().forEach(prop => {\n // if (!config!.hasProperty(prop.getName())) {\n // config!.addProperty(prop.property);\n // }\n // });\n // } else {\n // config = defaultConfig;\n // }\n\n return mergeEnvReflections(\n context,\n [reflection, config, resolveClassType(defaultConfigType)].filter(\n Boolean\n ) as ReflectionClass<any>[]\n );\n}\n\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n const defaultSecretsType = await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n );\n\n const reflection = await readSecretsReflection(context);\n\n // const defaultConfig = resolveClassType(defaultConfigType);\n // if (config) {\n // defaultConfig.getProperties().forEach(prop => {\n // if (!config!.hasProperty(prop.getName())) {\n // config!.addProperty(prop.property);\n // }\n // });\n // } else {\n // config = defaultConfig;\n // }\n\n return mergeSecretsReflections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AAA,MAAA,YAAA,SAAA,MAAA,4BAAA,QAAA,CAAA;AAYL,QAAO,oBAAoB,SAAS;EAX1B,MAAA,sBAAA,SAAA,MAAA;EAW2B;EAAA,iBAAA,kBAAA;EAAA,CAAA,OAAA,QAAA,CAAA;;AAEzC,WAAW,SAAI;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACf,eAAsB,eAAO,SAAA,MAAA,MAAA;CACzB,IAAI;AACJ,KAAI,KAOA,UAAA,iBANmB,MAAM,YAAY,SAAS;EAC1C,MAAM,CAAC,aAAO,MAAA,QAAA,gBAAA,cAAA,GACR,UAAA,QAAA,gBAAA,eAAA,KAAA,GACA;EACN;EACH,CAAC,CACF;CAEJ,MAAM,qBAAqB,MAAM,YAAC,SAAA,MAAA,gCAAA,QAAA,CAAA;AAYlC,QAAO,wBAAwB,SAAK;EAXjB,MAAM,sBAAsB,QAAQ;EAWnB;EAAA,iBAAA,mBAAA;EAAA,CAAA,OAAA,QAAA,CAAA;;AAExC,eAAe,SAAS;OAAO;CAAqB;CAAW;CAAQ;CAAQ;CAAkB;CAAU"}
1
+ {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport { EnvInterface, SecretsInterface } from \"../types/runtime\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAS,aAAa,IAAI,MAAM;AAC5B,IAAG,SAAS;AACZ,QAAO;;AAyBX,SAAgB,oBAAM,SAAA,aAAA;AAIlB,uCAFI,MAAM,MAAM,YAAY,IAAG,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EAC9B,CAAC;;AAGN,oBAAoB,SAAS;OAAO;CAAc;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;AAClD,SAAgB,wBAAwB,SAAS,aAAa;AAI9D,QAHI,wBAAA,SAAA;;;;OAEC,CAAC;;AAGN,wBAAwB,SAAS;OAAM;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;AACvC,MAAM,gCAAqB;OAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;AAE3B,IAAa,UAAb,MAAqB;CASjB,WAAW;CACX,OAAO;;CAGP,OAAO;CACP,UAAU;;CAEV,cAAc;;CAEd,aAAa;;;CAMb,OAAO,SAAS;EAAC;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA;EAAA;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAA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AA,CAAA,aAAA,MAAA,QAAA,gBAAA,cAAA,GACe,UAAG,QAAA,gBAAA,eAAA,KAAA;EAET;EACZ,CAAA;AAGI,QAAO,oBAAgB,SAAA;EACnB,MAAM,sBAAsB,SAAK,MAAA;EACjC;EACA,iBAAO,MAAA,YAAA,SAAA,MAAA,4BAAA,QAAA,CAAA,CAAA;EACV,CAAC,OAAO,QAAQ,CAAC;;AAEtB,WAAW,SAAS;OAAO;CAAK;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYhC,eAAsB,eAAA,SAAA,MAAA,MAAA;CAClB,IAAI;AACJ,KAAI,KAOA,UAAS,iBANX,MAAA,YAAA,SAAA;EACA,MAAA,CAAA,aAAA,MAAA,QAAA,gBAAA,cAAA,GACY,UAAO,QAAA,gBAAA,eAAA,KAAA;EAEb;EACH,CAAC,CAC8B;AAEpC,QAAO,wBAAwB,SAAS;EACpC,MAAM,sBAAY,QAAA;EAClB;EACA,iBAAgB,MAAA,YAAA,SAAA,MAAA,gCAAA,QAAA,CAAA,CAAA;EACnB,CAAC,OAAG,QAAA,CAAA;;AAET,eAAK,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
package/dist/index.cjs CHANGED
@@ -4,7 +4,6 @@ const require_types_runtime = require('./types/runtime.cjs');
4
4
  const require_types_plugin = require('./types/plugin.cjs');
5
5
  require('./types/index.cjs');
6
6
  const require_join_paths = require('./node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.cjs');
7
- const require_is_parent_path = require('./node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/is-parent-path.cjs');
8
7
  const require_helpers_reflect = require('./helpers/reflect.cjs');
9
8
  const require_helpers_persistence = require('./helpers/persistence.cjs');
10
9
  const require_helpers_template_helpers = require('./helpers/template-helpers.cjs');
@@ -60,12 +59,14 @@ const plugin = (options = {}) => {
60
59
  else {
61
60
  this.warn("The `env.types` configuration parameter was not provided. Please ensure this is expected.");
62
61
  const envDefaultTypeDefinition = await require_helpers_persistence.getEnvDefaultTypeDefinition(this);
63
- config.env.types = require_parse_type_definition.parseTypeDefinition(`${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`);
62
+ const file = await this.fs.resolve(envDefaultTypeDefinition.file);
63
+ if (file) config.env.types = require_parse_type_definition.parseTypeDefinition(`${file}#${envDefaultTypeDefinition.name}`);
64
64
  }
65
65
  if (config.env.secrets) config.env.secrets = require_parse_type_definition.parseTypeDefinition(config.env.secrets);
66
66
  else {
67
67
  const secretsDefaultTypeDefinition = await require_helpers_persistence.getSecretsDefaultTypeDefinition(this);
68
- config.env.secrets = require_parse_type_definition.parseTypeDefinition(`${secretsDefaultTypeDefinition.file}#${secretsDefaultTypeDefinition.name}`);
68
+ const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);
69
+ if (file) config.env.secrets = require_parse_type_definition.parseTypeDefinition(`${file}#${secretsDefaultTypeDefinition.name}`);
69
70
  }
70
71
  config.env.prefix = require_to_array.toArray(config.env.prefix ?? []).reduce((ret, prefix) => {
71
72
  const formattedPrefix = (0, __stryke_string_format_constant_case.constantCase)(prefix);
@@ -84,11 +85,7 @@ const plugin = (options = {}) => {
84
85
  },
85
86
  async configResolved() {
86
87
  this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
87
- this.env = require_defu.defu({
88
- parsed: await require_helpers_load.loadEnv(this, this.config.env),
89
- validate: !!this.config.env.validate,
90
- inject: !!this.config.env.inject
91
- }, this.env ?? {}, {
88
+ this.env = require_defu.defu({ parsed: await require_helpers_load.loadEnv(this, this.config.env) }, this.env ?? {}, {
92
89
  types: { env: {} },
93
90
  used: {
94
91
  env: {},
@@ -105,10 +102,10 @@ const plugin = (options = {}) => {
105
102
  if ((0, __stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await require_helpers_persistence.readSecretsReflection(this);
106
103
  } else {
107
104
  this.debug(`Starting environment configuration reflection initialization.`);
108
- this.env.types.env = await require_helpers_reflect.reflectEnv(this, this.config.env.types?.file ? require_is_parent_path.isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : require_join_paths.joinPaths(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
105
+ this.env.types.env = await require_helpers_reflect.reflectEnv(this, this.config.env.types?.file, this.config.env.types?.name);
109
106
  if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
110
107
  await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.env, "env");
111
- this.env.types.secrets = await require_helpers_reflect.reflectSecrets(this, this.config.env.secrets?.file ? require_is_parent_path.isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : require_join_paths.joinPaths(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
108
+ this.env.types.secrets = await require_helpers_reflect.reflectSecrets(this, this.config.env.secrets?.file, this.config.env.secrets?.name);
112
109
  if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
113
110
  await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
114
111
  this.debug(`Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;cAoEa,0BAA2B,mBAAmB,4BAChD,qBA2VJ,OAAO"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;cAmEa,0BAA2B,mBAAmB,4BAChD,qBA2UJ,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;cAoEa,0BAA2B,mBAAmB,4BAChD,qBA2VJ,OAAO"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;cAmEa,0BAA2B,mBAAmB,4BAChD,qBA2UJ,OAAO"}
package/dist/index.mjs CHANGED
@@ -2,7 +2,6 @@ import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.mjs";
2
2
  import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
3
3
  import "./types/index.mjs";
4
4
  import { joinPaths } from "./node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs";
5
- import { isParentPath } from "./node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/is-parent-path.mjs";
6
5
  import { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
7
6
  import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.mjs";
8
7
  import { createTemplateReflection } from "./helpers/template-helpers.mjs";
@@ -55,12 +54,14 @@ const plugin = (options = {}) => {
55
54
  else {
56
55
  this.warn("The `env.types` configuration parameter was not provided. Please ensure this is expected.");
57
56
  const envDefaultTypeDefinition = await getEnvDefaultTypeDefinition(this);
58
- config.env.types = parseTypeDefinition(`${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`);
57
+ const file = await this.fs.resolve(envDefaultTypeDefinition.file);
58
+ if (file) config.env.types = parseTypeDefinition(`${file}#${envDefaultTypeDefinition.name}`);
59
59
  }
60
60
  if (config.env.secrets) config.env.secrets = parseTypeDefinition(config.env.secrets);
61
61
  else {
62
62
  const secretsDefaultTypeDefinition = await getSecretsDefaultTypeDefinition(this);
63
- config.env.secrets = parseTypeDefinition(`${secretsDefaultTypeDefinition.file}#${secretsDefaultTypeDefinition.name}`);
63
+ const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);
64
+ if (file) config.env.secrets = parseTypeDefinition(`${file}#${secretsDefaultTypeDefinition.name}`);
64
65
  }
65
66
  config.env.prefix = toArray(config.env.prefix ?? []).reduce((ret, prefix) => {
66
67
  const formattedPrefix = constantCase(prefix);
@@ -79,11 +80,7 @@ const plugin = (options = {}) => {
79
80
  },
80
81
  async configResolved() {
81
82
  this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
82
- this.env = defu({
83
- parsed: await loadEnv(this, this.config.env),
84
- validate: !!this.config.env.validate,
85
- inject: !!this.config.env.inject
86
- }, this.env ?? {}, {
83
+ this.env = defu({ parsed: await loadEnv(this, this.config.env) }, this.env ?? {}, {
87
84
  types: { env: {} },
88
85
  used: {
89
86
  env: {},
@@ -100,10 +97,10 @@ const plugin = (options = {}) => {
100
97
  if (existsSync(getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await readSecretsReflection(this);
101
98
  } else {
102
99
  this.debug(`Starting environment configuration reflection initialization.`);
103
- this.env.types.env = await reflectEnv(this, this.config.env.types?.file ? isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : joinPaths(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
100
+ this.env.types.env = await reflectEnv(this, this.config.env.types?.file, this.config.env.types?.name);
104
101
  if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
105
102
  await writeEnvTypeReflection(this, this.env.types.env, "env");
106
- this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file ? isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : joinPaths(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
103
+ this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file, this.config.env.secrets?.name);
107
104
  if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
108
105
  await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
109
106
  this.debug(`Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["ReflectionClass","ReflectionKind","alloy","render","automd","babel","parseTypeDefinition","toArray","ENV_PREFIXES","existsSync","isParentPath","joinPaths","constantCase","defu","envBabelPlugin","EnvDocsFile","EnvBuiltin","env","getDocsOutputPath","loadEnv","getEnvDefaultTypeDefinition","getEnvReflectionsPath","getEnvTypeReflectionsPath","getSecretsDefaultTypeDefinition","readEnvReflection","readEnvTypeReflection","readSecretsReflection","writeEnvReflection","writeEnvTypeReflection","reflectEnv","reflectSecrets","plugin","options","name","config","debug","types","validate","inject","prefix","transform","plugins","warn","envDefaultTypeDefinition","file","secrets","secretsDefaultTypeDefinition","reduce","ret","formattedPrefix","includes","push","framework","filter","Boolean","replace","configResolved","parsed","used","injected","command","skipCache","persistedMeta","checksum","meta","workspaceConfig","workspaceRoot","projectRoot","undefined","Error","getProperties","length","envWithAlias","prop","getAlias","Object","entries","forEach","key","value","unprefixedKey","startsWith","slice","aliasKey","find","reverse","hasProperty","getProperty","setDefaultValue","kind","objectLiteral","typeName","description","prepare","_self$","result","_$createComponent","defaultConfig","reflection","order","handler","trace","docs","levelOffset","buildEnd","reflectionPath","generators","vite","envPrefix"],"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 { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env\";\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 * from \"./babel\";\nexport * from \"./components\";\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n alloy(options.alloy),\n babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n validate: false,\n inject: false,\n prefix: []\n }),\n transform: {\n babel: {\n plugins: [envBabelPlugin]\n }\n }\n };\n\n if (config.env.types) {\n config.env.types = parseTypeDefinition(\n config.env.types\n ) as TypeDefinition;\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 config.env.types = parseTypeDefinition(\n `${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`\n ) as TypeDefinition;\n }\n\n if (config.env.secrets) {\n config.env.secrets = parseTypeDefinition(\n config.env.secrets\n ) as TypeDefinition;\n } else {\n const secretsDefaultTypeDefinition =\n await getSecretsDefaultTypeDefinition(this);\n config.env.secrets = parseTypeDefinition(\n `${secretsDefaultTypeDefinition.file}#${\n secretsDefaultTypeDefinition.name\n }`\n ) as TypeDefinition;\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 = 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 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 validate: !!this.config.env.validate,\n inject: !!this.config.env.inject\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 ? isParentPath(\n this.config.env.types?.file,\n this.workspaceConfig.workspaceRoot\n )\n ? this.config.env.types?.file\n : joinPaths(\n this.config.projectRoot,\n this.config.env.types?.file\n )\n : undefined,\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 ? isParentPath(\n this.config.env.secrets?.file,\n this.workspaceConfig.workspaceRoot\n )\n ? this.config.env.secrets?.file\n : joinPaths(\n this.config.projectRoot,\n this.config.env.secrets?.file\n )\n : undefined,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAa+B,UACXC,UAA4B,EAAE,KAC3B;AACH,QAAO;EACL9B,MAAM8B,QAAQ9B,MAAM;EACpBG,MAAM2B,QAAQ3B,MAAM;EACpB;GACE4B,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MACH,yEACD;IAED,MAAMD,SAAS;KACbjB,KAAKJ,KAAKmB,SAAS;MACjBI,OAAO,EAA6B;MACpCC,UAAU;MACVC,QAAQ;MACRC,QAAQ,EAAA;MACT,CAAC;KACFC,WAAW,EACTnC,OA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AAI,KAAKnF,IAAIyC,KAAKzC,IAAIqD,eAAe,CAACC,SAAS,GAAG;AAChD,WAAK8B,MACH,4DAA4DhF,sBAC1D,MACA,MACD,CAAA,GACF;AACD,YAAMM,mBAAmB,MAAM,KAAKV,IAAIyC,KAAKzC,KAAK,MAAM;;AAG1D,SAAI,KAAKA,IAAIyC,KAAKb,QAAQyB,eAAe,CAACC,SAAS,GAAG;AACpD,WAAK8B,MACH,uDAAuDhF,sBACrD,MACA,UACD,CAAA,GACF;AACD,YAAMM,mBAAmB,MAAM,KAAKV,IAAIyC,KAAKb,SAAS,UAAU;;;IAGrE;GACD,MAAMyD,OAAO;AACX,SAAKnE,MACH,8DAA8DxB,UAC5DO,kBAAkB,KAAK,EACvB,SACD,CAAA,GACF;IAED,MAAM6E,SAAS,MAAMtE,sBAAsB,MAAM,MAAM;AAEvD,WAAOtB,OACL,MAAI6F,gBACHjF,aAAW;KAACwF,aAAa;KAAGL,YAAYH;KAAM,CACjD,CAAC;;GAEH,MAAMS,WAAW;IACf,MAAMC,iBAAiBpF,sBAAsB,MAAM,MAAM;AAEzD,SAAKc,MAAM,mCAAmCsE,eAAc,GAAI;AAEhE,UAAM9E,mBAAmB,MAAM,KAAKV,IAAIyC,KAAKzC,KAAK,MAAM;;GAE3D;EACD;GACEgB,MAAM;GACNC,SAAS;AACP,WAAO,EACL9B,QAAQS,KAAKmB,QAAQ5B,UAAU,EAAE,EAAE,EACjCsG,YAAY,EACVzF,KAAKA,IAAI,KAAI,EACf,EACD,CAAA,EACF;;GAEJ;EACD;GACEgB,MAAM;GACN0E,MAAM,EACJnD,iBAA+B;AAC7B,WAAO,EACLoD,WAAW,KAAK1E,QAAQjB,KAAKsB,QAC9B;MAEL;GACD;EACDnC,OAAO4B,QAAQ5B,OAAO;EACvB;;AAGH,kBAAe2B"}
1
+ {"version":3,"file":"index.mjs","names":["ReflectionClass","ReflectionKind","alloy","render","automd","babel","parseTypeDefinition","toArray","ENV_PREFIXES","existsSync","joinPaths","constantCase","defu","envBabelPlugin","EnvDocsFile","EnvBuiltin","env","getDocsOutputPath","loadEnv","getEnvDefaultTypeDefinition","getEnvReflectionsPath","getEnvTypeReflectionsPath","getSecretsDefaultTypeDefinition","readEnvReflection","readEnvTypeReflection","readSecretsReflection","writeEnvReflection","writeEnvTypeReflection","reflectEnv","reflectSecrets","plugin","options","name","config","debug","types","validate","inject","prefix","transform","plugins","warn","envDefaultTypeDefinition","file","fs","resolve","secrets","secretsDefaultTypeDefinition","reduce","ret","formattedPrefix","includes","push","framework","filter","Boolean","replace","configResolved","parsed","used","injected","command","skipCache","persistedMeta","checksum","meta","Error","getProperties","length","envWithAlias","prop","getAlias","Object","entries","forEach","key","value","unprefixedKey","startsWith","slice","aliasKey","find","reverse","hasProperty","getProperty","setDefaultValue","kind","objectLiteral","typeName","description","prepare","_self$","result","_$createComponent","defaultConfig","reflection","order","handler","trace","docs","levelOffset","buildEnd","reflectionPath","generators","vite","envPrefix"],"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 { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env\";\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 * from \"./babel\";\nexport * from \"./components\";\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n alloy(options.alloy),\n babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n types: {} as TypeDefinitionParameter,\n validate: false,\n inject: false,\n prefix: []\n }),\n transform: {\n babel: {\n plugins: [envBabelPlugin]\n }\n }\n };\n\n if (config.env.types) {\n config.env.types = parseTypeDefinition(\n config.env.types\n ) as TypeDefinition;\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 (config.env.secrets) {\n config.env.secrets = parseTypeDefinition(\n config.env.secrets\n ) as TypeDefinition;\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 = 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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa8B,UACXC,UAA4B,EAAE,KAC3B;AACH,QAAO;EACL7B,MAAM6B,QAAQ7B,MAAM;EACpBG,MAAM0B,QAAQ1B,MAAM;EACpB;GACE2B,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MACH,yEACD;IAED,MAAMD,SAAS;KACbjB,KAAKJ,KAAKmB,SAAS;MACjBI,OAAO,EAA6B;MACpCC,UAAU;MACVC,QAAQ;MACRC,QAAQ,EAAA;MACT,CAAC;KACFC,WAAW,EACTlC,OAAO,EACLmC,SAAS,CAAC3B,eAAc,EAC1B,EACF;KACD;AAED,QAAIoB,OAAOjB,IAAImB,MACbF,QAAOjB,IAAImB,QAAQ7B,oBACjB2B,OAAOjB,IAAImB,MACM;SACd;AACL,UAAKM,KACH,4FACD;KAED,MAAMC,2BACJ,MAAMvB,4BAA4B,KAAK;KAEzC,MAAMwB,OAAO,MAAM,KAAKC,GAAGC,QAAQH,yBAAyBC,KAAK;AACjE,SAAIA,KACFV,QAAOjB,IAAImB,QAAQ7B,oBACjB,GAAGqC,KAAI,GAAID,yBAAyBV,OACnB;;AAIvB,QAAIC,OAAOjB,IAAI8B,QACbb,QAAOjB,IAAI8B,UAAUxC,oBACnB2B,OAAOjB,IAAI8B,QACM;SACd;KACL,MAAMC,+BACJ,MAAMzB,gCAAgC,KAAK;KAE7C,MAAMqB,OAAO,MAAM,KAAKC,GAAGC,QAAQE,6BAA6BJ,KAAK;AACrE,SAAIA,KACFV,QAAOjB,IAAI8B,UAAUxC,oBACnB,GAAGqC,KAAI,GAAII,6BAA6Bf,OACvB;;AAIvBC,WAAOjB,IAAIsB,SAAS/B,QACjB0B,OAAOjB,IAAIsB,UAAU,EACxB,CAAC,CAACU,QACCC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Ae0B"}
@@ -88,19 +88,15 @@ const __ΩEnvPluginResolvedConfig = [
88
88
  "The type definition for the expected env variable parameters",
89
89
  "secrets",
90
90
  "The type definition for the expected env secret parameters",
91
- () => __ΩEnvPluginOptions,
92
- "inject",
93
91
  "inject",
94
92
  "Should the plugin inject the env variables in the source code with their values?",
95
- () => __ΩEnvPluginOptions,
96
- "validate",
97
93
  "validate",
98
94
  "Should the plugin validate the loaded environment variables against the provided type definitions?",
99
95
  "prefix",
100
96
  "The prefix used for environment variables",
101
97
  "env",
102
98
  "EnvPluginResolvedConfig",
103
- "Pn!n\"PP!.%o$#o#\"n(.)o'#o&\"P!4*?+!4,?-n../f40?1n2.3f44?5&F46?7MK48MKw9y"
99
+ "Pn!n\"PP!.%o$#o#\"n(.)o'#o&\"P!4*?+!4,?-)4.?/)40?1&F42?3MK44MKw5y"
104
100
  ];
105
101
  const __ΩEnvPluginContext = [
106
102
  () => __ΩEnvPluginResolvedConfig,
@@ -91,14 +91,14 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedCo
91
91
  * @remarks
92
92
  * This value is the result of reflecting the {@link EnvPluginOptions.inject} option.
93
93
  */
94
- inject: EnvPluginOptions["inject"];
94
+ inject: boolean;
95
95
  /**
96
96
  * Should the plugin validate the loaded environment variables against the provided type definitions?
97
97
  *
98
98
  * @remarks
99
99
  * This value is the result of reflecting the {@link EnvPluginOptions.validate} option.
100
100
  */
101
- validate: EnvPluginOptions["validate"];
101
+ validate: boolean;
102
102
  /**
103
103
  * The prefix used for environment variables
104
104
  *
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAyCY,OAAA;KAEA,gBAAA,GAAmB,KAAK;EAFxB;AAEZ;;EAA+B,KAAA,CAAA,EAIrB,uBAJqB;EAIrB;;;EA2CA,OAAA,CAAA,EAtCE,uBAsCF;EAQC;;;AAWX;;;EAES,MAAA,C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;;;;UA4BA,yCACS,0BAA0B,iCAGhD,mBAAmB,kBACnB,mBAAmB;;;;;;;;;;;;WAYZ;;;;eAKI;;;;;;;;;;;;WAaJ,WAAW;;;;eAKP,WAAW;;;;;;;;YASd;;;;;;;cAQE"}
@@ -91,14 +91,14 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedCo
91
91
  * @remarks
92
92
  * This value is the result of reflecting the {@link EnvPluginOptions.inject} option.
93
93
  */
94
- inject: EnvPluginOptions["inject"];
94
+ inject: boolean;
95
95
  /**
96
96
  * Should the plugin validate the loaded environment variables against the provided type definitions?
97
97
  *
98
98
  * @remarks
99
99
  * This value is the result of reflecting the {@link EnvPluginOptions.validate} option.
100
100
  */
101
- validate: EnvPluginOptions["validate"];
101
+ validate: boolean;
102
102
  /**
103
103
  * The prefix used for environment variables
104
104
  *
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAyCY,OAAA;KAEA,gBAAA,GAAmB,KAAK;EAFxB;AAEZ;;EAA+B,KAAA,CAAA,EAIrB,uBAJqB;EAIrB;;;EA2CA,OAAA,CAAA,EAtCE,uBAsCF;EAQC;;;AAWX;;;EAES,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EAAgB;AAGzB;;;;EAEkB,MAAA,CAAA,EAAA,OAAA;EAAT;;;;;EAgBQ,QAAA,CAAA,EAAA,OAAA;EAQD;;;AAoBhB;;;EAIuB,aAAA,CAAA,EAlFL,QAkFK;EACA;;;;;;EAmCR,KAAA,CAAA,EA9GL,kBA8GK;EASH;;;;;;WA/GD;;;;;;;UAQD;;KAGE,mBAAA,GAAsB,wBAChC;OACO;;KAGG,uBAAA,GAA0B,4BACpC;OACO,SAAS,KAAK,2CACjB,SAAS,KAAK;;;;;;;WAOL;;;;;;;aAQE;;;;;;;YAQD;;;;;;;cAQE;;;;;;;;;;UAYD,yCACS,0BAA0B,iCAGhD,mBAAmB,kBACnB,mBAAmB;;;;;;;;;;;;WAYZ;;;;eAKI;;;;;;;;;;;;WAaJ,WAAW;;;;eAKP,WAAW;;;;;;;;YASd;;;;;;;cAQE"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAyCY,OAAA;KAEA,gBAAA,GAAmB,KAAK;EAFxB;AAEZ;;EAA+B,KAAA,CAAA,EAIrB,uBAJqB;EAIrB;;;EA2CA,OAAA,CAAA,EAtCE,uBAsCF;EAQC;;;AAWX;;;EAES,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EAAgB;AAGzB;;;;EAEkB,MAAA,CAAA,EAAA,OAAA;EAAT;;;;;EAgBQ,QAAA,CAAA,EAAA,OAAA;EAAc;AA4B/B;;;;;EAiBW,aAAA,CAAA,EA/FO,QA+FP;EAKI;;;;;;EAmCD,KAAA,CAAA,EA/HJ,kBA+HI;EArDV;;;;;;WAlEO;;;;;;;UAQD;;KAGE,mBAAA,GAAsB,wBAChC;OACO;;KAGG,uBAAA,GAA0B,4BACpC;OACO,SAAS,KAAK,2CACjB,SAAS,KAAK;;;;;;;WAOL;;;;;;;aAQE;;;;;;;;;;;;;;;;;;;;;;;;UA4BA,yCACS,0BAA0B,iCAGhD,mBAAmB,kBACnB,mBAAmB;;;;;;;;;;;;WAYZ;;;;eAKI;;;;;;;;;;;;WAaJ,WAAW;;;;eAKP,WAAW;;;;;;;;YASd;;;;;;;cAQE"}
@@ -87,19 +87,15 @@ const __ΩEnvPluginResolvedConfig = [
87
87
  "The type definition for the expected env variable parameters",
88
88
  "secrets",
89
89
  "The type definition for the expected env secret parameters",
90
- () => __ΩEnvPluginOptions,
91
- "inject",
92
90
  "inject",
93
91
  "Should the plugin inject the env variables in the source code with their values?",
94
- () => __ΩEnvPluginOptions,
95
- "validate",
96
92
  "validate",
97
93
  "Should the plugin validate the loaded environment variables against the provided type definitions?",
98
94
  "prefix",
99
95
  "The prefix used for environment variables",
100
96
  "env",
101
97
  "EnvPluginResolvedConfig",
102
- "Pn!n\"PP!.%o$#o#\"n(.)o'#o&\"P!4*?+!4,?-n../f40?1n2.3f44?5&F46?7MK48MKw9y"
98
+ "Pn!n\"PP!.%o$#o#\"n(.)o'#o&\"P!4*?+!4,?-)4.?/)40?1&F42?3MK44MKw5y"
103
99
  ];
104
100
  const __ΩEnvPluginContext = [
105
101
  () => __ΩEnvPluginResolvedConfig,
@@ -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: EnvPluginOptions[\"inject\"];\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: EnvPluginOptions[\"validate\"];\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;CAAK;CAAK;CAAQ;CAAY;;;;;;;AA0B/C,MAAM,aAAa;CAAC;CAAA;CAAA;CAAA;CAAA;AAEpB,MAAM,sBAAqB;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAE3B,MAAM,yBAAyB;OAAO;OAAC;OAAA;CAAA;CAAA;CAAA;CAAA;AAEvC,MAAM,6BAAC;OAAA;OAAA;OAAA;OAAA;CAAA;OAAA;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEP,MAAM,sBAAU;OAAA;CAAA;OAAA;OAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;OAAA;OAAA;CAAA;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;OAAA;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 {\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;CAAK;CAAK;CAAQ;CAAY;;;;;;;AA0B/C,MAAM,aAAa;CAAC;CAAA;CAAA;CAAA;CAAA;AAEpB,MAAM,sBAAqB;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAE3B,MAAM,yBAAyB;OAAO;OAAC;OAAA;CAAA;CAAA;CAAA;CAAA;AAEvC,MAAM,6BAAC;OAAA;OAAA;OAAA;OAAA;CAAA;OAAA;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEP,MAAM,sBAAU;OAAA;CAAA;OAAA;OAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;OAAA;OAAA;CAAA;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;OAAA;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.0",
3
+ "version": "0.16.2",
4
4
  "type": "module",
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
  "repository": {
@@ -328,5 +328,5 @@
328
328
  },
329
329
  "publishConfig": { "access": "public" },
330
330
  "types": "./dist/index.d.cts",
331
- "gitHead": "a4606073f8199469d0d13203b6bde03f9b3b4c6c"
331
+ "gitHead": "9f1424c86b1e1e3429776ec2afd1e4b15b390047"
332
332
  }