@powerlines/plugin-env 0.16.7 → 0.16.9

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.
Files changed (48) hide show
  1. package/dist/babel/plugin.cjs +3 -3
  2. package/dist/babel/plugin.d.cts +3 -3
  3. package/dist/babel/plugin.d.cts.map +1 -1
  4. package/dist/babel/plugin.d.mts +3 -3
  5. package/dist/babel/plugin.d.mts.map +1 -1
  6. package/dist/babel/plugin.mjs +1 -1
  7. package/dist/babel/plugin.mjs.map +1 -1
  8. package/dist/components/docs.cjs +1 -1
  9. package/dist/components/docs.mjs +1 -1
  10. package/dist/components/env.cjs +2 -2
  11. package/dist/components/env.mjs +2 -2
  12. package/dist/helpers/automd-generator.cjs +3 -3
  13. package/dist/helpers/automd-generator.d.cts +1 -1
  14. package/dist/helpers/automd-generator.d.mts +1 -1
  15. package/dist/helpers/automd-generator.mjs +2 -2
  16. package/dist/helpers/automd-generator.mjs.map +1 -1
  17. package/dist/helpers/docs-helper.cjs +2 -2
  18. package/dist/helpers/docs-helper.mjs +2 -2
  19. package/dist/helpers/docs-helper.mjs.map +1 -1
  20. package/dist/helpers/index.cjs +2 -2
  21. package/dist/helpers/index.mjs +2 -2
  22. package/dist/helpers/load.cjs +8 -8
  23. package/dist/helpers/load.d.cts +2 -2
  24. package/dist/helpers/load.d.mts +2 -2
  25. package/dist/helpers/load.mjs +6 -6
  26. package/dist/helpers/load.mjs.map +1 -1
  27. package/dist/helpers/persistence.cjs +7 -7
  28. package/dist/helpers/persistence.d.cts +1 -1
  29. package/dist/helpers/persistence.d.mts +1 -1
  30. package/dist/helpers/persistence.mjs +3 -3
  31. package/dist/helpers/persistence.mjs.map +1 -1
  32. package/dist/helpers/reflect.cjs +1 -1
  33. package/dist/helpers/reflect.mjs +1 -1
  34. package/dist/index.cjs +10 -56
  35. package/dist/index.d.cts +8 -17
  36. package/dist/index.d.cts.map +1 -1
  37. package/dist/index.d.mts +8 -17
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +11 -20
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs +1 -1
  42. package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs +1 -1
  43. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.cjs +1 -1
  44. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +1 -1
  45. package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.cjs +1 -1
  46. package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs +1 -1
  47. package/dist/types/plugin.d.mts +1 -1
  48. package/package.json +12 -12
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_types_plugin = require('../types/plugin.cjs');
3
- let powerlines_types_babel = require("powerlines/types/babel");
3
+ let __powerlines_plugin_babel_types_config = require("@powerlines/plugin-babel/types/config");
4
4
  let __babel_core = require("@babel/core");
5
5
  let __powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
6
6
  let __powerlines_plugin_babel_helpers_create_plugin = require("@powerlines/plugin-babel/helpers/create-plugin");
@@ -92,7 +92,7 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
92
92
  }
93
93
  extractEnv.__type = [
94
94
  "node",
95
- () => powerlines_types_babel.__ΩBabelPluginPass,
95
+ () => __powerlines_plugin_babel_types_config.__ΩBabelPluginPass,
96
96
  "pass",
97
97
  "isInjectable",
98
98
  "isUsingBuiltin",
@@ -128,7 +128,7 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
128
128
  }, [
129
129
  () => __babel_core.NodePath,
130
130
  "path",
131
- () => powerlines_types_babel.__ΩBabelPluginPass,
131
+ () => __powerlines_plugin_babel_types_config.__ΩBabelPluginPass,
132
132
  "pass",
133
133
  "MemberExpression",
134
134
  "PP!7!2\"n#2$\"/%"
@@ -1,9 +1,9 @@
1
1
  import { EnvPluginContext, EnvPluginResolvedConfig } from "../types/plugin.cjs";
2
- import "../index.cjs";
3
- import * as powerlines_types0 from "powerlines/types";
2
+ import "../types/index.cjs";
3
+ import * as _powerlines_plugin_babel0 from "@powerlines/plugin-babel";
4
4
 
5
5
  //#region src/babel/plugin.d.ts
6
- declare const envBabelPlugin: powerlines_types0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
6
+ declare const envBabelPlugin: _powerlines_plugin_babel0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
7
7
  //#endregion
8
8
  export { envBabelPlugin };
9
9
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,gBAAc,iBAAA,CAAA,kCAAA,iBA4M1B,uBAAA,GA5M0B"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAiCa,gBAAc,yBAAA,CAAA,kCAAA,iBA4M1B,uBAAA,GA5M0B"}
@@ -1,9 +1,9 @@
1
1
  import { EnvPluginContext, EnvPluginResolvedConfig } from "../types/plugin.mjs";
2
- import "../index.mjs";
3
- import * as powerlines_types0 from "powerlines/types";
2
+ import "../types/index.mjs";
3
+ import * as _powerlines_plugin_babel0 from "@powerlines/plugin-babel";
4
4
 
5
5
  //#region src/babel/plugin.d.ts
6
- declare const envBabelPlugin: powerlines_types0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
6
+ declare const envBabelPlugin: _powerlines_plugin_babel0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
7
7
  //#endregion
8
8
  export { envBabelPlugin };
9
9
  //# sourceMappingURL=plugin.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,gBAAc,iBAAA,CAAA,kCAAA,iBA4M1B,uBAAA,GA5M0B"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":[],"mappings":";;;;;cAiCa,gBAAc,yBAAA,CAAA,kCAAA,iBA4M1B,uBAAA,GA5M0B"}
@@ -1,5 +1,5 @@
1
1
  import { __ΩEnvPluginContext } from "../types/plugin.mjs";
2
- import { __ΩBabelPluginPass } from "powerlines/types/babel";
2
+ import { __ΩBabelPluginPass } from "@powerlines/plugin-babel/types/config";
3
3
  import { NodePath } from "@babel/core";
4
4
  import { stringifyDefaultValue } from "@powerlines/deepkit/utilities";
5
5
  import { createBabelPlugin } from "@powerlines/plugin-babel/helpers/create-plugin";
@@ -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 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,KAAK,MAAM;GACjB,MAAA,SAAA,QAAA,OAAA,IAAA,OAAA,KAAA,cAAA,QAAA,KAAA,QACU,KAAK,K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A;;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"}
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\";\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { BabelPluginPass } from \"@powerlines/plugin-babel/types/config\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\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,kBAAU,kBAAA,IAAA,CAAA,OAAA,qBAAA,KAAA,CAAA,EAAA,kBAAA,OAAA,cAAA,EAAA,KAAA,cAAA;CACnB,SAAS,WAAW,MAAA,MAAA,eAAA,OAAA,iBAAA,OAAA;EAChB,MAAM,0BAAa,QAAA,IAAA,MAAA,KACb,eAAY,CACb,OAAO,cAAO,SAAA,KAAA,U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AAE,MAAM,OAAO,CAAC,IACpC,KACH,IAAA,SAAA,iBAEc,aAAa,EAAE,MAAM,WAAW,CAAC,IACjD,KAAA,IAAA,WAAA,EAAA,cAAA,EAAA;GAEU,MAAK,aAAA,KAAA,IAAA,WAAA,EAAA;AACL,OAAI,CAAC,WAAW,KACZ;;AAGJ,QAAK,wBAAwB,OAAO,WAAW,OAAO;AACtD,aAAU,MAAC;IACP,QAAQ,GAAG,QAAQ,OAAO,aAAY,aAAA;IAC9C,MAAA;IACO,UAAA;IACF,CAAC;aAEG,KACJ,IAAI,SAAS,EACZ,IAAI,WAAW,EACnB,aAAA,EAAA,MAAA,OAAA,CAAA,IACE,KAAK,IAAI,SAAS,EAAE,IAAI,SAAS,EAAE,gBAAA,IACnC,KAAK,IAAI,WAAC,EAAA,cAAA,EAAA;GAEV,MAAI,aAAA,KAAA,IAAA,WAAA,EAAA;AACJ,OAAI,CAAC,WAAU,KACX;AAEP,cAAA,YAAA,MAAA,OAAA,MAAA;AACL,QAAA,wBAAA,OAAA,WAAA,OAAA;AACK,aAAA,MAAA;IACA,QAAA,GAAA,QAAA,OAAA,aAAA,aAAA;IACO,MAAM;IACN,UAAU;IACjB,CAAA;aAEQ,KAAK,IAAI,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC,IAC/D,KAAA,IAAA,WAAA,EAAA,cAAA,EAAA;GAES,MAAE,aAAA,KAAA,IAAA,WAAA,EAAA;AACH,OAAA,CAAA,WAAA,KACF;AAEG,cAAM,YAAA,MAAA,OAAA,KAAA;;IAEf;QAAA;EAAA;QAAA;EAAA;EAAA;EAAA;EAAA,CAAA,EACH,EACH"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.cjs');
3
3
  const require_helpers_docs_helper = require('../helpers/docs-helper.cjs');
4
- let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
5
4
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
+ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
6
  let __alloy_js_core = require("@alloy-js/core");
7
7
  let __alloy_js_markdown = require("@alloy-js/markdown");
8
8
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
@@ -1,7 +1,7 @@
1
1
  import { joinPaths } from "../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs";
2
2
  import { getDocsOutputPath } from "../helpers/docs-helper.mjs";
3
- import { stringifyType } from "@powerlines/deepkit/vendor/type";
4
3
  import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
4
+ import { stringifyType } from "@powerlines/deepkit/vendor/type";
5
5
  import { Show, code } from "@alloy-js/core";
6
6
  import { Heading, Link } from "@alloy-js/markdown";
7
7
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
@@ -1,9 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_defu = require('../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs');
3
3
  const require_helpers_load = require('../helpers/load.cjs');
4
- let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
5
- let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
6
4
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
+ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
6
  let __alloy_js_core = require("@alloy-js/core");
8
7
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
8
  let __alloy_js_typescript = require("@alloy-js/typescript");
@@ -13,6 +12,7 @@ let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@pow
13
12
  let __powerlines_plugin_alloy_typescript_components_interface_declaration = require("@powerlines/plugin-alloy/typescript/components/interface-declaration");
14
13
  let __powerlines_plugin_alloy_typescript_components_object_declaration = require("@powerlines/plugin-alloy/typescript/components/object-declaration");
15
14
  let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
15
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
16
16
 
17
17
  //#region src/components/env.tsx
18
18
  /**
@@ -1,8 +1,7 @@
1
1
  import { defu } from "../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs";
2
2
  import { loadEnvFromContext } from "../helpers/load.mjs";
3
- import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
4
- import { titleCase } from "@stryke/string-format/title-case";
5
3
  import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
4
+ import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
6
5
  import { For, Show, code, computed, splitProps } from "@alloy-js/core";
7
6
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
7
  import { ClassDeclaration, ClassMethod, ElseIfClause, FunctionDeclaration, IfStatement, NewExpression, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
@@ -12,6 +11,7 @@ import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/buil
12
11
  import { InterfaceDeclaration } from "@powerlines/plugin-alloy/typescript/components/interface-declaration";
13
12
  import { ObjectDeclaration } from "@powerlines/plugin-alloy/typescript/components/object-declaration";
14
13
  import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
14
+ import { titleCase } from "@stryke/string-format/title-case";
15
15
 
16
16
  //#region src/components/env.tsx
17
17
  /**
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.cjs');
3
- let powerlines_types_context = require("powerlines/types/context");
3
+ let powerlines = require("powerlines");
4
4
  let automd = require("automd");
5
5
 
6
6
  //#region src/helpers/automd-generator.ts
@@ -17,12 +17,12 @@ function __assignType(fn, args) {
17
17
  const env = __assignType((context) => (0, automd.defineGenerator)({
18
18
  name: "env",
19
19
  generate: __assignType(async function generate() {
20
- const envDocFile = require_join_paths.joinPaths(context.config.projectRoot, "docs", "generated", "env.md");
20
+ const envDocFile = require_join_paths.joinPaths(context.config.root, "docs", "generated", "env.md");
21
21
  if (!context.fs.existsSync(envDocFile)) return { contents: "" };
22
22
  return { contents: await context.fs.read(envDocFile) || "" };
23
23
  }, ["generate", "P\"/!"])
24
24
  }), [
25
- () => powerlines_types_context.__ΩUnresolvedContext,
25
+ () => powerlines.__ΩUnresolvedContext,
26
26
  "context",
27
27
  "",
28
28
  "Pn!2\"\"/#"
@@ -1,5 +1,5 @@
1
- import { UnresolvedContext } from "powerlines/types/context";
2
1
  import * as automd0 from "automd";
2
+ import { UnresolvedContext } from "powerlines";
3
3
 
4
4
  //#region src/helpers/automd-generator.d.ts
5
5
 
@@ -1,4 +1,4 @@
1
- import { UnresolvedContext } from "powerlines/types/context";
1
+ import { UnresolvedContext } from "powerlines";
2
2
  import * as automd0 from "automd";
3
3
 
4
4
  //#region src/helpers/automd-generator.d.ts
@@ -1,5 +1,5 @@
1
1
  import { joinPaths } from "../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs";
2
- import { __ΩUnresolvedContext } from "powerlines/types/context";
2
+ import { __ΩUnresolvedContext } from "powerlines";
3
3
  import { defineGenerator } from "automd";
4
4
 
5
5
  //#region src/helpers/automd-generator.ts
@@ -16,7 +16,7 @@ function __assignType(fn, args) {
16
16
  const env = __assignType((context) => defineGenerator({
17
17
  name: "env",
18
18
  generate: __assignType(async function generate() {
19
- const envDocFile = joinPaths(context.config.projectRoot, "docs", "generated", "env.md");
19
+ const envDocFile = joinPaths(context.config.root, "docs", "generated", "env.md");
20
20
  if (!context.fs.existsSync(envDocFile)) return { contents: "" };
21
21
  return { contents: await context.fs.read(envDocFile) || "" };
22
22
  }, ["generate", "P\"/!"])
@@ -1 +1 @@
1
- {"version":3,"file":"automd-generator.mjs","names":[],"sources":["../../src/helpers/automd-generator.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 { joinPaths } from \"@stryke/path/join-paths\";\nimport { defineGenerator } from \"automd\";\nimport { UnresolvedContext } from \"powerlines/types/context\";\n\n/**\n * AutoMD generator to generate environment variable documentation\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const env = (context: UnresolvedContext) =>\n defineGenerator({\n name: \"env\",\n async generate() {\n const envDocFile = joinPaths(\n context.config.projectRoot,\n \"docs\",\n \"generated\",\n \"env.md\"\n );\n\n if (!context.fs.existsSync(envDocFile)) {\n return {\n contents: \"\"\n };\n }\n\n const contents = await context.fs.read(envDocFile);\n\n return {\n contents: contents || \"\"\n };\n }\n });\n"],"mappings":";;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AA2BX,MAAa,MAAM,cAAE,YAAA,gBAAA;CACjB,MAAM;CACN,UAAU,aAAa,eAAO,WAAA;EAC1B,MAAM,aAAA,UAAA,QAAA,OAAA,aAAA,QAAA,aAAA,SAAA;AACN,MAAI,CAAC,QAAM,GAAA,WAAA,WAAA,CACP,QAAG,EACR,UAAA;AAIC,SAAO,EACN,UAFM,MAAA,QAAA,GAAA,KAAA,WAAA,IAEN,IACH;;CAEL,CAAC,EAAE;OAAO;CAAsB;CAAW;CAAI;CAAQ,CAAA"}
1
+ {"version":3,"file":"automd-generator.mjs","names":[],"sources":["../../src/helpers/automd-generator.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 { joinPaths } from \"@stryke/path/join-paths\";\nimport { defineGenerator } from \"automd\";\nimport { UnresolvedContext } from \"powerlines\";\n\n/**\n * AutoMD generator to generate environment variable documentation\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const env = (context: UnresolvedContext) =>\n defineGenerator({\n name: \"env\",\n async generate() {\n const envDocFile = joinPaths(\n context.config.root,\n \"docs\",\n \"generated\",\n \"env.md\"\n );\n\n if (!context.fs.existsSync(envDocFile)) {\n return {\n contents: \"\"\n };\n }\n\n const contents = await context.fs.read(envDocFile);\n\n return {\n contents: contents || \"\"\n };\n }\n });\n"],"mappings":";;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AA2BX,MAAa,MAAM,cAAE,YAAA,gBAAA;CACjB,MAAM;CACN,UAAU,aAAa,eAAA,WAAA;EACnB,MAAM,aAAA,UAAA,QAAA,OAAA,MAAA,QAAA,aAAA,SAAA;AACN,MAAI,CAAC,QAAM,GAAA,WAAA,WAAA,CACP,QAAG,EACR,UAAA;AAIC,SAAO,EACN,UAFM,MAAA,QAAA,GAAA,KAAA,WAAA,IAEN,IACH;;CAEL,CAAC,EAAE;OAAO;CAAsB;CAAW;CAAI;CAAQ,CAAA"}
@@ -1,5 +1,5 @@
1
- const require_types_plugin = require('../types/plugin.cjs');
2
1
  const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.cjs');
2
+ const require_types_plugin = require('../types/plugin.cjs');
3
3
 
4
4
  //#region src/helpers/docs-helper.ts
5
5
  /**
@@ -9,7 +9,7 @@ const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.26.6/no
9
9
  * @returns The output path for the generated environment documentation.
10
10
  */
11
11
  function getDocsOutputPath(context) {
12
- return require_join_paths.joinPaths(context.config.projectRoot, "docs", "generated");
12
+ return require_join_paths.joinPaths(context.config.root, "docs", "generated");
13
13
  }
14
14
  getDocsOutputPath.__type = [
15
15
  () => require_types_plugin.__ΩEnvPluginContext,
@@ -1,5 +1,5 @@
1
- import { __ΩEnvPluginContext } from "../types/plugin.mjs";
2
1
  import { joinPaths } from "../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs";
2
+ import { __ΩEnvPluginContext } from "../types/plugin.mjs";
3
3
 
4
4
  //#region src/helpers/docs-helper.ts
5
5
  /**
@@ -9,7 +9,7 @@ import { joinPaths } from "../node_modules/.pnpm/@stryke_path@0.26.6/node_module
9
9
  * @returns The output path for the generated environment documentation.
10
10
  */
11
11
  function getDocsOutputPath(context) {
12
- return joinPaths(context.config.projectRoot, "docs", "generated");
12
+ return joinPaths(context.config.root, "docs", "generated");
13
13
  }
14
14
  getDocsOutputPath.__type = [
15
15
  () => __ΩEnvPluginContext,
@@ -1 +1 @@
1
- {"version":3,"file":"docs-helper.mjs","names":[],"sources":["../../src/helpers/docs-helper.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 { joinPaths } from \"@stryke/path/join\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Gets the output path for the generated environment documentation.\n *\n * @param context - The environment plugin context.\n * @returns The output path for the generated environment documentation.\n */\nexport function getDocsOutputPath(context: EnvPluginContext): string {\n return joinPaths(context.config.projectRoot, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAE,kBAAA,SAAA;AACE,QAAO,UAAU,QAAQ,OAAO,aAAa,QAAQ,YAAY;;AAErE,kBAAA,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"docs-helper.mjs","names":[],"sources":["../../src/helpers/docs-helper.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 { joinPaths } from \"@stryke/path/join\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Gets the output path for the generated environment documentation.\n *\n * @param context - The environment plugin context.\n * @returns The output path for the generated environment documentation.\n */\nexport function getDocsOutputPath(context: EnvPluginContext): string {\n return joinPaths(context.config.root, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAE,kBAAA,SAAA;AACE,QAAO,UAAU,QAAQ,OAAO,MAAM,QAAQ,YAAY;;AAE9D,kBAAA,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1,8 +1,8 @@
1
+ const require_helpers_source_file_env = require('./source-file-env.cjs');
2
+ const require_helpers_load = require('./load.cjs');
1
3
  const require_helpers_reflect = require('./reflect.cjs');
2
4
  const require_helpers_persistence = require('./persistence.cjs');
3
5
  const require_helpers_template_helpers = require('./template-helpers.cjs');
4
- const require_helpers_source_file_env = require('./source-file-env.cjs');
5
- const require_helpers_load = require('./load.cjs');
6
6
  const require_helpers_create_reflection_resource = require('./create-reflection-resource.cjs');
7
7
 
8
8
  exports.BaseEnv = require_helpers_reflect.BaseEnv;
@@ -1,8 +1,8 @@
1
+ import { formatEnvField, removeEnvPrefix } from "./source-file-env.mjs";
2
+ import { loadEnv, loadEnvFromContext } from "./load.mjs";
1
3
  import { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./reflect.mjs";
2
4
  import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./persistence.mjs";
3
5
  import { createTemplateReflection } from "./template-helpers.mjs";
4
- import { formatEnvField, removeEnvPrefix } from "./source-file-env.mjs";
5
- import { loadEnv, loadEnvFromContext } from "./load.mjs";
6
6
  import { createReflection } from "./create-reflection-resource.mjs";
7
7
 
8
8
  export { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createReflection, createSecretsReflection, createTemplateReflection, formatEnvField, getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, loadEnv, loadEnvFromContext, mergeEnvReflections, mergeSecretsReflections, readEnvReflection, readEnvTypeReflection, readSecretsReflection, reflectEnv, reflectSecrets, removeEnvPrefix, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
@@ -1,14 +1,14 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_types_plugin = require('../types/plugin.cjs');
3
2
  const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.cjs');
4
- const require_helpers_source_file_env = require('./source-file-env.cjs');
5
3
  const require_defu = require('../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs');
4
+ const require_types_plugin = require('../types/plugin.cjs');
6
5
  const require_index = require('../node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs');
7
- let powerlines_types_config = require("powerlines/types/config");
6
+ const require_helpers_source_file_env = require('./source-file-env.cjs');
7
+ let powerlines = require("powerlines");
8
8
  let __stryke_env_load_env = require("@stryke/env/load-env");
9
9
  let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
10
10
  let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
11
- let powerlines_lib_constants_environments = require("powerlines/lib/constants/environments");
11
+ let powerlines_utils = require("powerlines/utils");
12
12
 
13
13
  //#region src/helpers/load.ts
14
14
  function __assignType(fn, args) {
@@ -62,7 +62,7 @@ loadEnvDirectory.__type = [
62
62
  "mode",
63
63
  "cacheDir",
64
64
  "packageJson",
65
- () => powerlines_types_config.__ΩWorkspaceConfig,
65
+ () => powerlines.__ΩWorkspaceConfig,
66
66
  "workspaceConfig",
67
67
  "loadEnvDirectory",
68
68
  "Pn!2\"&2#&2$&2%!2&n'2(\"`/)"
@@ -88,12 +88,12 @@ function loadEnvFromContext(context, parsed) {
88
88
  LOG_LEVEL: context.config.logLevel === "trace" ? "debug" : context.config.logLevel,
89
89
  ERROR_URL: context.workspaceConfig.error?.url,
90
90
  ORGANIZATION: context.config.organization || ((0, __stryke_type_checks_is_set_object.isSetObject)(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization),
91
- PLATFORM: context.config.build.platform,
91
+ PLATFORM: context.config.platform,
92
92
  MODE: context.config.mode,
93
93
  TEST: context.config.mode === "test",
94
94
  DEBUG: context.config.mode === "development",
95
95
  STACKTRACE: context.config.mode !== "production",
96
- ENVIRONMENT: !context.environment.name || context.environment.name === powerlines_lib_constants_environments.DEFAULT_ENVIRONMENT ? context.config.mode : context.environment.name
96
+ ENVIRONMENT: !context.environment.name || context.environment.name === powerlines_utils.DEFAULT_ENVIRONMENT ? context.config.mode : context.environment.name
97
97
  }, (0, __stryke_type_checks_is_set_object.isSetObject)(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce(__assignType((ret, prop) => {
98
98
  ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
99
99
  return ret;
@@ -114,7 +114,7 @@ loadEnvFromContext.__type = [
114
114
  ];
115
115
  async function loadEnv(context, options) {
116
116
  const [project, workspace, config] = await Promise.all([
117
- (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.config.projectRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
117
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.config.root, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
118
118
  (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
119
119
  (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig))
120
120
  ]);
@@ -23,8 +23,8 @@ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvPar
23
23
  LOG_LEVEL: "error" | "warn" | "info" | "debug" | null;
24
24
  ERROR_URL: string | undefined;
25
25
  ORGANIZATION: string | undefined;
26
- PLATFORM: "node" | "browser" | "neutral" | undefined;
27
- MODE: "test" | "development" | "production";
26
+ PLATFORM: "node" | "browser" | "neutral";
27
+ MODE: "development" | "test" | "production";
28
28
  TEST: boolean;
29
29
  DEBUG: boolean;
30
30
  STACKTRACE: boolean;
@@ -23,8 +23,8 @@ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvPar
23
23
  LOG_LEVEL: "error" | "warn" | "info" | "debug" | null;
24
24
  ERROR_URL: string | undefined;
25
25
  ORGANIZATION: string | undefined;
26
- PLATFORM: "node" | "browser" | "neutral" | undefined;
27
- MODE: "test" | "development" | "production";
26
+ PLATFORM: "node" | "browser" | "neutral";
27
+ MODE: "development" | "test" | "production";
28
28
  TEST: boolean;
29
29
  DEBUG: boolean;
30
30
  STACKTRACE: boolean;
@@ -1,13 +1,13 @@
1
- import { __ΩEnvPluginContext, __ΩEnvPluginOptions } from "../types/plugin.mjs";
2
1
  import { joinPaths } from "../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs";
3
- import { removeEnvPrefix } from "./source-file-env.mjs";
4
2
  import { defu } from "../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs";
3
+ import { __ΩEnvPluginContext, __ΩEnvPluginOptions } from "../types/plugin.mjs";
5
4
  import { loadConfig } from "../node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs";
6
- import { __ΩWorkspaceConfig } from "powerlines/types/config";
5
+ import { removeEnvPrefix } from "./source-file-env.mjs";
6
+ import { __ΩWorkspaceConfig } from "powerlines";
7
7
  import { loadEnv as loadEnv$1, loadEnvFile } from "@stryke/env/load-env";
8
8
  import { kebabCase } from "@stryke/string-format/kebab-case";
9
9
  import { isSetObject } from "@stryke/type-checks/is-set-object";
10
- import { DEFAULT_ENVIRONMENT } from "powerlines/lib/constants/environments";
10
+ import { DEFAULT_ENVIRONMENT } from "powerlines/utils";
11
11
 
12
12
  //#region src/helpers/load.ts
13
13
  function __assignType(fn, args) {
@@ -87,7 +87,7 @@ function loadEnvFromContext(context, parsed) {
87
87
  LOG_LEVEL: context.config.logLevel === "trace" ? "debug" : context.config.logLevel,
88
88
  ERROR_URL: context.workspaceConfig.error?.url,
89
89
  ORGANIZATION: context.config.organization || (isSetObject(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization),
90
- PLATFORM: context.config.build.platform,
90
+ PLATFORM: context.config.platform,
91
91
  MODE: context.config.mode,
92
92
  TEST: context.config.mode === "test",
93
93
  DEBUG: context.config.mode === "development",
@@ -113,7 +113,7 @@ loadEnvFromContext.__type = [
113
113
  ];
114
114
  async function loadEnv(context, options) {
115
115
  const [project, workspace, config] = await Promise.all([
116
- (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.config.projectRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
116
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.config.root, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
117
117
  (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
118
118
  (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig))
119
119
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/lib/constants/environments\";\nimport { WorkspaceConfig } from \"powerlines/types/config\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: workspaceConfig.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput\n) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization),\n PLATFORM: context.config.build.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.projectRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAS,aAAa,IAAI,MAAM;AAC5B,IAAG,SAAS;;;AA4BhB,eAAe,aAAY,SAAA,MAAA,KAAA;CACvB,IAAI,MAAM,MAAA,UAAA,KAAA,KAAA;AACV,KAAI,QAAI,mBAAA,QAAA,iBAAA,SAAA,GAAA;EACJ,MAAM,qBAAG,MAAA,QAAA,IAAA,QAAA,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA,CAAA;AACT,OAAK,MAAM,qBAAqB,mBAC5B,OAAM,KAAK,mBAAmB,IAAI;;AAG1C,QAAO,gBAAgB,IAAI;;AAE/B,aAAK,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;CAED,MAAM,CAAC,WAAW,aAAa,MAAM,QAAQ,IAAI,EAC5C,aAAa,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,aAAK,SAAA,MAAA,UAAA,GACpC,WAAA;EACF,KAAA;;EAEU,SAAS;EACrB,UAAA;;GAEgB,MAAM;GACN,KAAK,gBAAgB;GACpC;EACW,UAAU;EACV,aAAO;EACP,QAAE;EACF,aAAM;GACF,SAAS,UAAC,UAAA,OAAA;GACV,aAAa;GACjB;EACH,CAAC,CACL,CAAC;AACF,QAAO,KAAI,WAAA,UAAA,QAAA,gBAAA;;AAEf,iBAAiB,SAAE;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQnB,SAAgB,mBAAO,SA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AAE,iBAAiB,SAAS,QAAQ,OAAO,aAAK,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,QAAA,gBAAA;GAC5E,iBAAiB,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,iBAAa,SAAA,QAAA,gBAAA,eAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,QAAA,gBAAA;GAC3C,iBAAiB,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,iBAAiB,SAAA,QAAA,SAAA,QAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,QAAA,gBAAA;EACnD,CAAC;AACF,QAAO,KAAK,mBAAmB,SAAS,QAAQ,IAAI,EAAE,SAAS,WAAW,OAAC;;AAE/E,QAAQ,SAAS;OAAC;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/utils\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: workspaceConfig.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput\n) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;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AC,EAAE,iBAAiB,SAAA,QAAA,SAAA,QAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,QAAA,gBAAA;EACnD,CAAC;AACF,QAAO,KAAK,mBAAmB,SAAS,QAAQ,IAAI,EAAE,SAAS,WAAW,OAAC;;AAE/E,QAAQ,SAAS;OAAC;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1,9 +1,10 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_types_plugin = require('../types/plugin.cjs');
3
2
  const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.cjs');
3
+ const require_types_plugin = require('../types/plugin.cjs');
4
4
  const require_helpers_reflect = require('./reflect.cjs');
5
5
  let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
- let powerlines_types_context = require("powerlines/types/context");
6
+ let powerlines = require("powerlines");
7
+ let node_fs = require("node:fs");
7
8
  let __powerlines_deepkit_capnp = require("@powerlines/deepkit/capnp");
8
9
  let __powerlines_deepkit_resolve_reflections = require("@powerlines/deepkit/resolve-reflections");
9
10
  let __powerlines_deepkit_schemas_reflection = require("@powerlines/deepkit/schemas/reflection");
@@ -11,7 +12,6 @@ let __stryke_capnp = require("@stryke/capnp");
11
12
  __stryke_capnp = require_rolldown_runtime.__toESM(__stryke_capnp);
12
13
  let __stryke_fs_buffer = require("@stryke/fs/buffer");
13
14
  let __stryke_type_checks_is_empty_object = require("@stryke/type-checks/is-empty-object");
14
- let node_fs = require("node:fs");
15
15
 
16
16
  //#region src/helpers/persistence.ts
17
17
  /**
@@ -26,7 +26,7 @@ async function resolveRuntimeTypeFile(context) {
26
26
  return resolved;
27
27
  }
28
28
  resolveRuntimeTypeFile.__type = [
29
- () => powerlines_types_context.__ΩUnresolvedContext,
29
+ () => powerlines.__ΩUnresolvedContext,
30
30
  () => require_types_plugin.__ΩEnvPluginResolvedConfig,
31
31
  "context",
32
32
  "resolveRuntimeTypeFile",
@@ -46,7 +46,7 @@ async function getEnvDefaultTypeDefinition(context) {
46
46
  };
47
47
  }
48
48
  getEnvDefaultTypeDefinition.__type = [
49
- () => powerlines_types_context.__ΩUnresolvedContext,
49
+ () => powerlines.__ΩUnresolvedContext,
50
50
  () => require_types_plugin.__ΩEnvPluginResolvedConfig,
51
51
  "context",
52
52
  "getEnvDefaultTypeDefinition",
@@ -65,7 +65,7 @@ async function getSecretsDefaultTypeDefinition(context) {
65
65
  };
66
66
  }
67
67
  getSecretsDefaultTypeDefinition.__type = [
68
- () => powerlines_types_context.__ΩUnresolvedContext,
68
+ () => powerlines.__ΩUnresolvedContext,
69
69
  () => require_types_plugin.__ΩEnvPluginResolvedConfig,
70
70
  "context",
71
71
  "getSecretsDefaultTypeDefinition",
@@ -82,7 +82,7 @@ function getEnvTypeReflectionsPath(context, name = "env") {
82
82
  return require_join_paths.joinPaths((0, __powerlines_deepkit_resolve_reflections.getReflectionsPath)(context), "env", `${name}-types.bin`);
83
83
  }
84
84
  getEnvTypeReflectionsPath.__type = [
85
- () => powerlines_types_context.__ΩContext,
85
+ () => powerlines.__ΩContext,
86
86
  () => require_types_plugin.__ΩEnvPluginResolvedConfig,
87
87
  "context",
88
88
  () => require_types_plugin.__ΩEnvType,
@@ -1,7 +1,7 @@
1
1
  import { EnvPluginContext, EnvPluginResolvedConfig, EnvType } from "../types/plugin.cjs";
2
2
  import { TypeDefinition } from "@stryke/types/configuration";
3
3
  import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
4
- import { Context, UnresolvedContext } from "powerlines/types/context";
4
+ import { Context, UnresolvedContext } from "powerlines";
5
5
 
6
6
  //#region src/helpers/persistence.d.ts
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { EnvPluginContext, EnvPluginResolvedConfig, EnvType } from "../types/plugin.mjs";
2
2
  import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
3
- import { Context, UnresolvedContext } from "powerlines/types/context";
3
+ import { Context, UnresolvedContext } from "powerlines";
4
4
  import { TypeDefinition } from "@stryke/types/configuration";
5
5
 
6
6
  //#region src/helpers/persistence.d.ts
@@ -1,15 +1,15 @@
1
- import { __ΩEnvPluginContext, __ΩEnvPluginResolvedConfig, __ΩEnvType } from "../types/plugin.mjs";
2
1
  import { joinPaths } from "../node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs";
2
+ import { __ΩEnvPluginContext, __ΩEnvPluginResolvedConfig, __ΩEnvType } from "../types/plugin.mjs";
3
3
  import { createEnvReflection } from "./reflect.mjs";
4
4
  import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
5
- import { __ΩContext, __ΩUnresolvedContext } from "powerlines/types/context";
5
+ import { __ΩContext, __ΩUnresolvedContext } from "powerlines";
6
+ import { existsSync } from "node:fs";
6
7
  import { convertFromCapnp, convertToCapnp } from "@powerlines/deepkit/capnp";
7
8
  import { getReflectionsPath } from "@powerlines/deepkit/resolve-reflections";
8
9
  import { SerializedTypes } from "@powerlines/deepkit/schemas/reflection";
9
10
  import * as capnp from "@stryke/capnp";
10
11
  import { readFileBuffer, writeFileBuffer, writeFileBufferSync } from "@stryke/fs/buffer";
11
12
  import { isEmptyObject } from "@stryke/type-checks/is-empty-object";
12
- import { existsSync } from "node:fs";
13
13
 
14
14
  //#region src/helpers/persistence.ts
15
15
  /**