@powerlines/plugin-env 0.16.302 → 0.16.304

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 (143) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +0 -14
  2. package/dist/babel/plugin.cjs +3 -11
  3. package/dist/babel/plugin.mjs +3 -5
  4. package/dist/babel/plugin.mjs.map +1 -1
  5. package/dist/components/docs.cjs +3 -14
  6. package/dist/components/docs.mjs +3 -8
  7. package/dist/components/docs.mjs.map +1 -1
  8. package/dist/components/env-builtin.cjs +15 -21
  9. package/dist/components/env-builtin.d.cts.map +1 -1
  10. package/dist/components/env-builtin.d.mts.map +1 -1
  11. package/dist/components/env-builtin.mjs +15 -15
  12. package/dist/components/env-builtin.mjs.map +1 -1
  13. package/dist/helpers/automd-generator.cjs +1 -9
  14. package/dist/helpers/automd-generator.mjs +2 -4
  15. package/dist/helpers/automd-generator.mjs.map +1 -1
  16. package/dist/helpers/index.cjs +1 -1
  17. package/dist/helpers/index.mjs +1 -1
  18. package/dist/helpers/load.cjs +3 -13
  19. package/dist/helpers/load.d.cts +2 -2
  20. package/dist/helpers/load.d.mts +2 -2
  21. package/dist/helpers/load.mjs +2 -7
  22. package/dist/helpers/load.mjs.map +1 -1
  23. package/dist/helpers/schema.cjs +2 -18
  24. package/dist/helpers/schema.mjs +3 -13
  25. package/dist/helpers/schema.mjs.map +1 -1
  26. package/dist/helpers/source-file-env.cjs +1 -12
  27. package/dist/helpers/source-file-env.mjs +1 -6
  28. package/dist/helpers/source-file-env.mjs.map +1 -1
  29. package/dist/index.cjs +9 -9
  30. package/dist/index.mjs +8 -8
  31. package/dist/types/plugin.d.mts +1 -1
  32. package/package.json +12 -137
  33. package/dist/_virtual/_rolldown/runtime.mjs +0 -18
  34. package/dist/babel/plugin.test.cjs +0 -16
  35. package/dist/babel/plugin.test.d.cts +0 -1
  36. package/dist/babel/plugin.test.d.mts +0 -1
  37. package/dist/babel/plugin.test.mjs +0 -18
  38. package/dist/babel/plugin.test.mjs.map +0 -1
  39. package/dist/components/docs.test.cjs +0 -16
  40. package/dist/components/docs.test.d.cts +0 -1
  41. package/dist/components/docs.test.d.mts +0 -1
  42. package/dist/components/docs.test.mjs +0 -18
  43. package/dist/components/docs.test.mjs.map +0 -1
  44. package/dist/components/env-builtin.test.cjs +0 -16
  45. package/dist/components/env-builtin.test.d.cts +0 -1
  46. package/dist/components/env-builtin.test.d.mts +0 -1
  47. package/dist/components/env-builtin.test.mjs +0 -18
  48. package/dist/components/env-builtin.test.mjs.map +0 -1
  49. package/dist/helpers/automd-generator.test.cjs +0 -16
  50. package/dist/helpers/automd-generator.test.d.cts +0 -1
  51. package/dist/helpers/automd-generator.test.d.mts +0 -1
  52. package/dist/helpers/automd-generator.test.mjs +0 -18
  53. package/dist/helpers/automd-generator.test.mjs.map +0 -1
  54. package/dist/helpers/load.test.cjs +0 -16
  55. package/dist/helpers/load.test.d.cts +0 -1
  56. package/dist/helpers/load.test.d.mts +0 -1
  57. package/dist/helpers/load.test.mjs +0 -18
  58. package/dist/helpers/load.test.mjs.map +0 -1
  59. package/dist/helpers/schema.test.cjs +0 -16
  60. package/dist/helpers/schema.test.d.cts +0 -1
  61. package/dist/helpers/schema.test.d.mts +0 -1
  62. package/dist/helpers/schema.test.mjs +0 -18
  63. package/dist/helpers/schema.test.mjs.map +0 -1
  64. package/dist/helpers/source-file-env.test.cjs +0 -16
  65. package/dist/helpers/source-file-env.test.d.cts +0 -1
  66. package/dist/helpers/source-file-env.test.d.mts +0 -1
  67. package/dist/helpers/source-file-env.test.mjs +0 -18
  68. package/dist/helpers/source-file-env.test.mjs.map +0 -1
  69. package/dist/index.test.cjs +0 -30
  70. package/dist/index.test.d.cts +0 -1
  71. package/dist/index.test.d.mts +0 -1
  72. package/dist/index.test.mjs +0 -32
  73. package/dist/index.test.mjs.map +0 -1
  74. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -78
  75. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -78
  76. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +0 -1
  77. package/dist/node_modules/.pnpm/@vitest_expect@4.1.7/node_modules/@vitest/expect/dist/index.cjs +0 -1487
  78. package/dist/node_modules/.pnpm/@vitest_expect@4.1.7/node_modules/@vitest/expect/dist/index.mjs +0 -1473
  79. package/dist/node_modules/.pnpm/@vitest_expect@4.1.7/node_modules/@vitest/expect/dist/index.mjs.map +0 -1
  80. package/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.cjs +0 -889
  81. package/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.mjs +0 -888
  82. package/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.mjs.map +0 -1
  83. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/chunk-artifact.cjs +0 -1614
  84. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/chunk-artifact.mjs +0 -1594
  85. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +0 -1
  86. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/index.cjs +0 -1
  87. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/index.mjs +0 -3
  88. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/utils.cjs +0 -1
  89. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/utils.mjs +0 -3
  90. package/dist/node_modules/.pnpm/@vitest_snapshot@4.1.7/node_modules/@vitest/snapshot/dist/index.cjs +0 -923
  91. package/dist/node_modules/.pnpm/@vitest_snapshot@4.1.7/node_modules/@vitest/snapshot/dist/index.mjs +0 -922
  92. package/dist/node_modules/.pnpm/@vitest_snapshot@4.1.7/node_modules/@vitest/snapshot/dist/index.mjs.map +0 -1
  93. package/dist/node_modules/.pnpm/@vitest_spy@4.1.7/node_modules/@vitest/spy/dist/index.cjs +0 -391
  94. package/dist/node_modules/.pnpm/@vitest_spy@4.1.7/node_modules/@vitest/spy/dist/index.mjs +0 -386
  95. package/dist/node_modules/.pnpm/@vitest_spy@4.1.7/node_modules/@vitest/spy/dist/index.mjs.map +0 -1
  96. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.cjs +0 -82
  97. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +0 -82
  98. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +0 -1
  99. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/diff.cjs +0 -1358
  100. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/diff.mjs +0 -1357
  101. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/diff.mjs.map +0 -1
  102. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/display.cjs +0 -561
  103. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/display.mjs +0 -559
  104. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/display.mjs.map +0 -1
  105. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/error.cjs +0 -37
  106. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/error.mjs +0 -38
  107. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/error.mjs.map +0 -1
  108. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/helpers.cjs +0 -197
  109. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/helpers.mjs +0 -181
  110. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/helpers.mjs.map +0 -1
  111. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/offset.cjs +0 -29
  112. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/offset.mjs +0 -27
  113. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/offset.mjs.map +0 -1
  114. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/serialize.cjs +0 -77
  115. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/serialize.mjs +0 -77
  116. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/serialize.mjs.map +0 -1
  117. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/source-map.cjs +0 -374
  118. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/source-map.mjs +0 -374
  119. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/source-map.mjs.map +0 -1
  120. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/timers.cjs +0 -38
  121. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/timers.mjs +0 -37
  122. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/timers.mjs.map +0 -1
  123. package/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.cjs +0 -2978
  124. package/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.mjs +0 -2973
  125. package/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.mjs.map +0 -1
  126. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +0 -939
  127. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +0 -940
  128. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs.map +0 -1
  129. package/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.cjs +0 -87
  130. package/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.mjs +0 -87
  131. package/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.mjs.map +0 -1
  132. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.cjs +0 -6
  133. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +0 -6
  134. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +0 -1
  135. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/rpc.MzXet3jl.cjs +0 -54
  136. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +0 -52
  137. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +0 -1
  138. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/test.DNmyFkvJ.cjs +0 -2696
  139. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +0 -2697
  140. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +0 -1
  141. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.cjs +0 -47
  142. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +0 -45
  143. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { formatEnvField, removeEnvPrefix } from "./source-file-env.mjs";
2
2
  import { loadEnv, loadEnvFromContext } from "./load.mjs";
3
- import { env } from "./automd-generator.mjs";
4
3
  import { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultConfig, getDefaultSecrets, resolveRuntimeTypeFile, writeEnv } from "./schema.mjs";
4
+ import { env } from "./automd-generator.mjs";
5
5
 
6
6
  export { env, extractEnv, formatEnvField, getCacheDirectory, getCacheFilePath, getDefaultConfig, getDefaultSecrets, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile, writeEnv };
@@ -2,8 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_types_plugin = require('../types/plugin.cjs');
4
4
  const require_helpers_source_file_env = require('./source-file-env.cjs');
5
- let defu = require("defu");
6
- defu = require_runtime.__toESM(defu, 1);
7
5
  let _powerlines_schema = require("@powerlines/schema");
8
6
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
9
7
  let _storm_software_config_tools_get_config = require("@storm-software/config-tools/get-config");
@@ -12,13 +10,11 @@ let _stryke_env_load_env = require("@stryke/env/load-env");
12
10
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
13
11
  let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
14
12
  let c12 = require("c12");
13
+ let defu = require("defu");
14
+ defu = require_runtime.__toESM(defu, 1);
15
15
  let powerlines_constants = require("powerlines/constants");
16
16
 
17
17
  //#region src/helpers/load.ts
18
- var load_exports = /* @__PURE__ */ require_runtime.__exportAll({
19
- loadEnv: () => loadEnv,
20
- loadEnvFromContext: () => loadEnvFromContext
21
- });
22
18
  function __assignType(fn, args) {
23
19
  fn.__type = args;
24
20
  return fn;
@@ -144,10 +140,4 @@ loadEnv.__type = [
144
140
 
145
141
  //#endregion
146
142
  exports.loadEnv = loadEnv;
147
- exports.loadEnvFromContext = loadEnvFromContext;
148
- Object.defineProperty(exports, 'load_exports', {
149
- enumerable: true,
150
- get: function () {
151
- return load_exports;
152
- }
153
- });
143
+ exports.loadEnvFromContext = loadEnvFromContext;
@@ -24,11 +24,11 @@ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvPar
24
24
  ERROR_URL: string | undefined;
25
25
  ORGANIZATION: string | undefined;
26
26
  PLATFORM: "node" | "browser" | "neutral";
27
- MODE: "test" | "development" | "production";
27
+ MODE: "development" | "test" | "production";
28
28
  TEST: boolean;
29
29
  DEBUG: boolean;
30
30
  STACKTRACE: boolean;
31
- RUNTIME: "edge" | "browser" | "nodejs" | "workerd" | undefined;
31
+ RUNTIME: "browser" | "nodejs" | "workerd" | "edge" | undefined;
32
32
  ENVIRONMENT: string;
33
33
  };
34
34
  declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options?: EnvPluginOptions): Promise<TEnv>;
@@ -24,11 +24,11 @@ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvPar
24
24
  ERROR_URL: string | undefined;
25
25
  ORGANIZATION: string | undefined;
26
26
  PLATFORM: "node" | "browser" | "neutral";
27
- MODE: "test" | "development" | "production";
27
+ MODE: "development" | "test" | "production";
28
28
  TEST: boolean;
29
29
  DEBUG: boolean;
30
30
  STACKTRACE: boolean;
31
- RUNTIME: "edge" | "browser" | "nodejs" | "workerd" | undefined;
31
+ RUNTIME: "browser" | "nodejs" | "workerd" | "edge" | undefined;
32
32
  ENVIRONMENT: string;
33
33
  };
34
34
  declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options?: EnvPluginOptions): Promise<TEnv>;
@@ -1,7 +1,5 @@
1
- import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
1
  import { __ΩEnvPluginContext, __ΩEnvPluginOptions } from "../types/plugin.mjs";
3
2
  import { removeEnvPrefix } from "./source-file-env.mjs";
4
- import defu from "defu";
5
3
  import { getProperties } from "@powerlines/schema";
6
4
  import { isSetObject } from "@stryke/type-checks/is-set-object";
7
5
  import { tryGetWorkspaceConfig } from "@storm-software/config-tools/get-config";
@@ -10,13 +8,10 @@ import { loadEnv as loadEnv$1, loadEnvFile } from "@stryke/env/load-env";
10
8
  import { joinPaths } from "@stryke/path/join-paths";
11
9
  import { kebabCase } from "@stryke/string-format/kebab-case";
12
10
  import { loadConfig } from "c12";
11
+ import defu from "defu";
13
12
  import { DEFAULT_ENVIRONMENT } from "powerlines/constants";
14
13
 
15
14
  //#region src/helpers/load.ts
16
- var load_exports = /* @__PURE__ */ __exportAll({
17
- loadEnv: () => loadEnv,
18
- loadEnvFromContext: () => loadEnvFromContext
19
- });
20
15
  function __assignType(fn, args) {
21
16
  fn.__type = args;
22
17
  return fn;
@@ -141,5 +136,5 @@ loadEnv.__type = [
141
136
  ];
142
137
 
143
138
  //#endregion
144
- export { loadEnv, loadEnvFromContext, load_exports };
139
+ export { loadEnv, loadEnvFromContext };
145
140
  //# sourceMappingURL=load.mjs.map
@@ -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 { getProperties } from \"@powerlines/schema\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopmentMode,\n isTestMode,\n toMode\n} from \"@stryke/env/environment-checks\";\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/constants\";\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 context: EnvPluginContext,\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: context.config.framework?.name || \"powerlines\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || 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 workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\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: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: toMode(context.config.mode),\n TEST: isTestMode(context.config.mode),\n DEBUG: isDevelopmentMode(context.config.mode),\n STACKTRACE: context.config.mode !== \"production\",\n RUNTIME: context.config.environment.runtime,\n ENVIRONMENT:\n !context.config.environment.name ||\n context.config.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.config.environment.name\n },\n isSetObject(context.env.config)\n ? Object.entries(getProperties(context.env.config)).reduce(\n (ret, [name, prop]) => {\n ret[name] = parsed[name] ?? prop?.default;\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions = context.config.env\n): Promise<TEnv> {\n const workspaceConfig = await tryGetWorkspaceConfig();\n\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.cwd,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env, workspaceConfig),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;AA6BA,eAAS,aAAkB,SAAM,MAAU,KAAC;CAC5C,IAAM,MAAG,MAAA,UAAqB,KAAK,IAAE;CACrC,IAAM,QAAG,mBAAkB,QAAA,iBAA4B,SAAY,GAAC;EACpE,MAAS,qBAAsB,MAAI,QAAO,IAAK,QAAI,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,GAAA,GAAA;GAAA;GAAA;GAAA;EAAA,CAAA,CAAA,CAAA;sDAE7C,MAAA,KAAS,mBAAkB,GAAA;CAE/B;CACA,OAAK,gBAAA,GAAA;AACP;AACA,aAAY,SAAM;OAAW;CAAW;CAAA;CAAA;CAAA;CAAA;AAAA;AACxC,eAAc,iBAAkB,SAAS,SAAA,WAAiB,MAAS,UAAG,aAAA,iBAAA;CACpE,MAAE,CAA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QAAA,OAAA,YAAA,SAAA,sBAAA,QAAA,OAAA,OAAA,QAAA,OAAA,YAAA;;EAEF,IAAM,QAAM,OAAS,SAAS,MAAA;EAChC,OAAA;;;;;;;AAEA;AACA,mBAAa,SAAe;OAAA;CAAyB;CAAS;CAAO;CAAA;CAAA;CAAA;AAAA;AACrE,eAAC,QAAA,SAAA,UAAA,QAAA,OAAA,KAAA;CACC,MAAE,kBAAoB,MAAQ,sBAAsB;CACpD,MAAE,CAAK,SAAS,WAAW,UAAQ,MAAA,QAAa,IAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,MAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,KAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,SAAA,QAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;CAAA,CAAA;CAChD,OAAE,KAAU,mBAAmB,SAAI,QAAO,KAAA,eAAa,GAAA,SAAA,WAAA,MAAA;AACzD;AACA,QAAO,SAAS;OAAA;CAAkB;OAAA;CAAA;OAAA,QAAA,OAAA;CAAA;CAAA;AAAA"}
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 { getProperties } from \"@powerlines/schema\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopmentMode,\n isTestMode,\n toMode\n} from \"@stryke/env/environment-checks\";\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/constants\";\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 context: EnvPluginContext,\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: context.config.framework?.name || \"powerlines\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || 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 workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\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: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: toMode(context.config.mode),\n TEST: isTestMode(context.config.mode),\n DEBUG: isDevelopmentMode(context.config.mode),\n STACKTRACE: context.config.mode !== \"production\",\n RUNTIME: context.config.environment.runtime,\n ENVIRONMENT:\n !context.config.environment.name ||\n context.config.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.config.environment.name\n },\n isSetObject(context.env.config)\n ? Object.entries(getProperties(context.env.config)).reduce(\n (ret, [name, prop]) => {\n ret[name] = parsed[name] ?? prop?.default;\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions = context.config.env\n): Promise<TEnv> {\n const workspaceConfig = await tryGetWorkspaceConfig();\n\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.cwd,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env, workspaceConfig),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;AA6BA,eAAS,aAAkB,SAAM,MAAU,KAAC;CAC5C,IAAM,MAAG,MAAA,UAAqB,KAAK,IAAE;CACrC,IAAM,QAAG,mBAAkB,QAAA,iBAA4B,SAAY,GAAC;EACpE,MAAS,qBAAsB,MAAI,QAAO,IAAK,QAAI,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,GAAA,GAAA;GAAA;GAAA;GAAA;EAAA,CAAA,CAAA,CAAA;sDAE7C,MAAA,KAAS,mBAAkB,GAAA;CAE/B;CACA,OAAK,gBAAA,GAAA;AACP;AACA,aAAY,SAAM;OAAW;CAAW;CAAA;CAAA;CAAA;CAAA;AAAA;AACxC,eAAc,iBAAkB,SAAS,SAAA,WAAiB,MAAS,UAAG,aAAA,iBAAA;CACpE,MAAE,CAAK,WAAC,aAA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YAAA,SAAA,sBAAA,QAAA,OAAA,OAAA,QAAA,OAAA,YAAA;;EAEF,IAAM,QAAM,OAAS,SAAS,MAAA;EAChC,OAAA;;;;;;;AAEA;AACA,mBAAa,SAAe;OAAA;CAAyB;CAAS;CAAO;CAAA;CAAA;CAAA;AAAA;AACrE,eAAC,QAAA,SAAA,UAAA,QAAA,OAAA,KAAA;CACC,MAAE,kBAAoB,MAAQ,sBAAsB;CACpD,MAAE,CAAK,SAAS,WAAW,UAAQ,MAAA,QAAa,IAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,MAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,KAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,SAAA,QAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;CAAA,CAAA;CAChD,OAAE,KAAU,mBAAmB,SAAI,QAAO,KAAA,eAAa,GAAA,SAAA,WAAA,MAAA;AACzD;AACA,QAAO,SAAS;OAAA;CAAkB;OAAA;CAAA;OAAA,QAAA,OAAA;CAAA;CAAA;AAAA"}
@@ -1,24 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_types_plugin = require('../types/plugin.cjs');
4
3
  const require_helpers_load = require('./load.cjs');
5
- let _stryke_path_join = require("@stryke/path/join");
6
4
  let _powerlines_schema = require("@powerlines/schema");
7
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
8
5
  let _stryke_helpers_omit = require("@stryke/helpers/omit");
6
+ let _stryke_path_join = require("@stryke/path/join");
9
7
  let _stryke_type_checks_is_set_array = require("@stryke/type-checks/is-set-array");
8
+ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
10
9
  let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
11
10
 
12
11
  //#region src/helpers/schema.ts
13
- var schema_exports = /* @__PURE__ */ require_runtime.__exportAll({
14
- extractEnv: () => extractEnv,
15
- getCacheDirectory: () => getCacheDirectory,
16
- getCacheFilePath: () => getCacheFilePath,
17
- getDefaultConfig: () => getDefaultConfig,
18
- getDefaultSecrets: () => getDefaultSecrets,
19
- resolveRuntimeTypeFile: () => resolveRuntimeTypeFile,
20
- writeEnv: () => writeEnv
21
- });
22
12
  function __assignType(fn, args) {
23
13
  fn.__type = args;
24
14
  return fn;
@@ -235,10 +225,4 @@ exports.getCacheFilePath = getCacheFilePath;
235
225
  exports.getDefaultConfig = getDefaultConfig;
236
226
  exports.getDefaultSecrets = getDefaultSecrets;
237
227
  exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
238
- Object.defineProperty(exports, 'schema_exports', {
239
- enumerable: true,
240
- get: function () {
241
- return schema_exports;
242
- }
243
- });
244
228
  exports.writeEnv = writeEnv;
@@ -1,23 +1,13 @@
1
- import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
1
  import { __ΩEnvSchema } from "../types/plugin.mjs";
3
2
  import { loadEnv } from "./load.mjs";
4
- import { joinPaths } from "@stryke/path/join";
5
3
  import { extract, getProperties, getPropertiesList, isSchema, isSchemaObject, merge, writeSchema } from "@powerlines/schema";
6
- import { isSetObject } from "@stryke/type-checks/is-set-object";
7
4
  import { omit } from "@stryke/helpers/omit";
5
+ import { joinPaths } from "@stryke/path/join";
8
6
  import { isSetArray } from "@stryke/type-checks/is-set-array";
7
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
9
8
  import { isSetString } from "@stryke/type-checks/is-set-string";
10
9
 
11
10
  //#region src/helpers/schema.ts
12
- var schema_exports = /* @__PURE__ */ __exportAll({
13
- extractEnv: () => extractEnv,
14
- getCacheDirectory: () => getCacheDirectory,
15
- getCacheFilePath: () => getCacheFilePath,
16
- getDefaultConfig: () => getDefaultConfig,
17
- getDefaultSecrets: () => getDefaultSecrets,
18
- resolveRuntimeTypeFile: () => resolveRuntimeTypeFile,
19
- writeEnv: () => writeEnv
20
- });
21
11
  function __assignType(fn, args) {
22
12
  fn.__type = args;
23
13
  return fn;
@@ -228,5 +218,5 @@ writeEnv.__type = [
228
218
  ];
229
219
 
230
220
  //#endregion
231
- export { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultConfig, getDefaultSecrets, resolveRuntimeTypeFile, schema_exports, writeEnv };
221
+ export { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultConfig, getDefaultSecrets, resolveRuntimeTypeFile, writeEnv };
232
222
  //# sourceMappingURL=schema.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.mjs","names":[],"sources":["../../src/helpers/schema.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n extract,\n getProperties,\n getPropertiesList,\n isSchema,\n isSchemaObject,\n JsonSchemaObject,\n merge,\n Schema,\n writeSchema\n} from \"@powerlines/schema\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { FileReference } from \"@stryke/types/configuration\";\nimport { UnresolvedContext } from \"powerlines\";\nimport { EnvPluginContext, EnvSchema } from \"../types/plugin\";\nimport { loadEnv } from \"./load\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<string> {\n const resolved = await context.fs.resolve(\"@powerlines/plugin-env/types/env\");\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getDefaultConfig<TContext extends UnresolvedContext>(\n context: TContext\n): Promise<FileReference> {\n return {\n file: await resolveRuntimeTypeFile(context),\n export: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getDefaultSecrets<TContext extends UnresolvedContext>(\n context: TContext\n): Promise<FileReference> {\n return {\n file: await resolveRuntimeTypeFile(context),\n export: \"SecretsInterface\"\n };\n}\n\n/**\n * A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.\n *\n * @param context - The context object providing access to the cache path.\n * @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the \"schemas\" subdirectory.\n */\nexport function getCacheDirectory<TContext extends EnvPluginContext>(\n context: TContext\n): string {\n return joinPaths(context.cachePath, \"env\");\n}\n\nexport function getCacheFilePath<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): string {\n return joinPaths(getCacheDirectory(context), `${variant}.json`);\n}\n\nasync function writeActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\",\n schema: EnvSchema\n) {\n if (!isSchema(schema)) {\n throw new Error(\n `The provided input is not a valid env schema. A valid schema must have a \"variant\" property indicating the type of the input and a \"schema\" property containing the parsed JSON Schema object.`\n );\n }\n\n await context.fs.write(\n getCacheFilePath(context, variant),\n JSON.stringify(schema.schema)\n );\n}\n\nasync function readActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): Promise<string[]> {\n if (!context.fs.existsSync(getCacheFilePath(context, variant))) {\n return [];\n }\n\n const data = await context.fs.read(getCacheFilePath(context, variant));\n if (!data) {\n return [];\n }\n\n return JSON.parse(data);\n}\n\n/**\n * Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.\n *\n * @remarks\n * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void> {\n const defaultConfig = await getDefaultConfig(context);\n const defaultSecrets = await getDefaultSecrets(context);\n\n context.debug({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.config\n ? JSON.stringify(context.config.env.config, null, 2)\n : \"None\"\n }\\nEnvironment Secret configuration: ${\n context.config.env.secrets\n ? JSON.stringify(context.config.env.secrets, null, 2)\n : \"None\"\n }`\n });\n\n context.env ??= {} as EnvPluginContext[\"env\"];\n context.env.parsed ??= {};\n context.env.injected ??= [];\n\n context.env.config = (await extract(\n context,\n context.config.env.config\n )) as EnvSchema;\n context.env.config.active = await readActive(context, \"config\");\n\n if (\n (isSetString(context.config.env.config) &&\n new RegExp(`${defaultConfig.file}[:#;@]?${defaultConfig.export}`).test(\n context.config.env.config\n ) === false) ||\n (isSetObject(context.config.env.config) &&\n ((context.config.env.config as FileReference).file !==\n defaultConfig.file ||\n (context.config.env.config as FileReference).export !==\n defaultConfig.export))\n ) {\n context.env.config.schema = merge(\n await extract(context, defaultConfig),\n context.env.config\n ) as JsonSchemaObject;\n }\n\n context.env.secrets = (await extract(\n context,\n context.config.env.secrets\n )) as EnvSchema;\n context.env.secrets.active = await readActive(context, \"secrets\");\n\n if (\n (isSetString(context.config.env.secrets) &&\n new RegExp(`${defaultSecrets.file}[:#;@]?${defaultSecrets.export}`).test(\n context.config.env.secrets\n ) === false) ||\n (isSetObject(context.config.env.secrets) &&\n ((context.config.env.secrets as FileReference).file !==\n defaultSecrets.file ||\n (context.config.env.secrets as FileReference).export !==\n defaultSecrets.export))\n ) {\n context.env.secrets.schema = merge(\n await extract(context, defaultSecrets),\n context.env.secrets\n ) as JsonSchemaObject;\n }\n\n const properties = getProperties(context.env.config);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.config ? \"\" : \"Defaulted \"\n }${\n context.env.config.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.config.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.config.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.config.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : context.env.config.variant === \"valibot\"\n ? \"Valibot schema\"\n : context.env.config.variant === \"untyped\"\n ? \"Untyped configuration\"\n : \"Typescript exported type\"\n }${context.config.env.config ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n context.config.env.secrets ? \"\" : \"Defaulted \"\n }${\n context.env.secrets.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.secrets.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.secrets.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.secrets.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : context.env.secrets.variant === \"valibot\"\n ? \"Valibot schema\"\n : context.env.secrets.variant === \"untyped\"\n ? \"Untyped configuration\"\n : \"Typescript exported type\"\n }${context.config.env.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? getPropertiesList(context.env.secrets).length\n : \"0\"\n } parameters\\nEnvironment variable Prefixes: ${context.config.env.prefix.join(\n \", \"\n )}\\nShould inject values: ${\n context.config.env.inject ? \"Yes\" : \"No\"\n }\\nShould validate configuration: ${\n context.config.env.validate ? \"Yes\" : \"No\"\n }`\n });\n\n const aliases = Object.fromEntries(\n Object.entries(properties).flatMap(\n ([key, prop]) =>\n (isSetArray(prop.alias)\n ? prop.alias?.map(alias => [\n alias,\n {\n ...prop,\n name: alias,\n alias: [...(prop.alias?.filter(a => a !== alias) ?? []), key]\n }\n ])\n : []) as [string, typeof prop][]\n )\n );\n\n context.env.parsed = await loadEnv(context);\n for (const [key, value] of Object.entries(context.env.parsed)) {\n const unprefixedKey = context.config.env.prefix.reduce((ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n }, key);\n if (properties[unprefixedKey]) {\n if (!properties[unprefixedKey]?.runtime) {\n const propertySchema = getProperties(context.env.config.schema)?.[\n unprefixedKey\n ];\n if (propertySchema) {\n propertySchema.default = value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey]?.runtime) {\n const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;\n const aliasSchema = getProperties(context.env.config.schema)?.[alias];\n if (aliasSchema) {\n aliasSchema.default = value;\n }\n }\n }\n }\n\n if (!isSchemaObject(context.env.config)) {\n throw new Error(\n \"Invalid environment variable schema extracted. Please ensure the `env.types` option points to a valid TypeScript type definition file that exports an interface representing the environment variable schema.\"\n );\n }\n}\n\n/**\n * Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.\n *\n * @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.\n * @returns A promise that resolves when the schema has been successfully written to the cache directory.\n */\nexport async function writeEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void[]> {\n return Promise.all([\n writeSchema(context, omit(context.env.config, [\"active\"]) as Schema),\n writeSchema(context, omit(context.env.secrets, [\"active\"]) as Schema),\n writeActive(context, \"config\", context.env.config),\n writeActive(context, \"secrets\", context.env.secrets)\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;;;;;;;AA+BA,eAAS,uBAAoC,SAAS;CACtD,MAAQ,WAAW,MAAM,QAAO,GAAA,QAAA,kCAAA;gBAE9B,MAAA,IAAA,MAAA,yJAAA;CAED,OAAA;AACD;AACA,uBAAuB,SAAM;CAAA;CAAe;CAAqB;CAAS;AAAA;;;;;;;AAO1E,eAAmB,iBAAA,SAAA;CACjB,OAAK;EACH,MAAC,MAAA,uBAAA,OAAA;EACH,QAAA;;AAEF;AACA,iBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;AAMA,eAAgB,kBAAwB,SAAQ;CAC9C,OAAA;EACF,MAAO,MAAM,uBAA0B,OAAA;EACrC,QAAS;CACT;AACF;AACA,kBAAgB,SAAA;CAAA;CAAuB;CAAQ;AAAA;;;;;;;AAO/C,SAAU,kBAAqB,SAAO;CACpC,OAAE,UAAY,QAAQ,WAAK,KAAc;AAC3C;AACA,kBAAa,SAAS;CAAA;CAAiB;CAAkB;CAAkB;AAAA;AAC3E,SAAW,iBAAA,SAAA,SAAA;CACT,OAAC,UAAQ,kBAAe,OAAA,GAAA,GAAA,QAAA,MAAA;AAC1B;AACA,iBAAgB,SAAA;CAAA;CAAsB;CAAS;CAAA;CAA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C,MAAG,QAAI,QAAA,gBAAA,QAAA,MAAA;IACT,MAAA,cAAoB,cAAgB,QAAA,IAAA,OAAA,MAAA,IAAA;IACpC,IAAA,aACI,YAAK,UAAiB;GAE3B;;;CAGH,IAAA,CAAA,eAAmB,QAAG,IAAA,MAAgB,GACtC,MAAQ,IAAI,MAAM,+MAAO;;AAG3B,WAAU,SAAU;CAAC;CAAS;CAAO;CAAA;AAAA;;;;;;;AAOrC,eAAiB,SAAc,SAAK;CAClC,OAAO,QAAQ,IAAG;EAAA,YAAc,SAAS,KAAK,QAAA,IAAA,QAAoB,CAAC,QAAO,CAAA,CAAA;EAAA,YAAA,SAAA,KAAA,QAAA,IAAA,SAAA,CAAA,QAAA,CAAA,CAAA;EAAA,YAAA,SAAA,UAAA,QAAA,IAAA,MAAA;EAAA,YAAA,SAAA,WAAA,QAAA,IAAA,OAAA;CAAA,CAAA;AAC5E;AACA,SAAS,SAAS;CAAC;CAAC;CAAA;CAAA;AAAA"}
1
+ {"version":3,"file":"schema.mjs","names":[],"sources":["../../src/helpers/schema.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n extract,\n getProperties,\n getPropertiesList,\n isSchema,\n isSchemaObject,\n JsonSchemaObject,\n merge,\n Schema,\n writeSchema\n} from \"@powerlines/schema\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { FileReference } from \"@stryke/types/configuration\";\nimport { UnresolvedContext } from \"powerlines\";\nimport { EnvPluginContext, EnvSchema } from \"../types/plugin\";\nimport { loadEnv } from \"./load\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<string> {\n const resolved = await context.fs.resolve(\"@powerlines/plugin-env/types/env\");\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getDefaultConfig<TContext extends UnresolvedContext>(\n context: TContext\n): Promise<FileReference> {\n return {\n file: await resolveRuntimeTypeFile(context),\n export: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getDefaultSecrets<TContext extends UnresolvedContext>(\n context: TContext\n): Promise<FileReference> {\n return {\n file: await resolveRuntimeTypeFile(context),\n export: \"SecretsInterface\"\n };\n}\n\n/**\n * A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.\n *\n * @param context - The context object providing access to the cache path.\n * @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the \"schemas\" subdirectory.\n */\nexport function getCacheDirectory<TContext extends EnvPluginContext>(\n context: TContext\n): string {\n return joinPaths(context.cachePath, \"env\");\n}\n\nexport function getCacheFilePath<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): string {\n return joinPaths(getCacheDirectory(context), `${variant}.json`);\n}\n\nasync function writeActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\",\n schema: EnvSchema\n) {\n if (!isSchema(schema)) {\n throw new Error(\n `The provided input is not a valid env schema. A valid schema must have a \"variant\" property indicating the type of the input and a \"schema\" property containing the parsed JSON Schema object.`\n );\n }\n\n await context.fs.write(\n getCacheFilePath(context, variant),\n JSON.stringify(schema.schema)\n );\n}\n\nasync function readActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): Promise<string[]> {\n if (!context.fs.existsSync(getCacheFilePath(context, variant))) {\n return [];\n }\n\n const data = await context.fs.read(getCacheFilePath(context, variant));\n if (!data) {\n return [];\n }\n\n return JSON.parse(data);\n}\n\n/**\n * Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.\n *\n * @remarks\n * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void> {\n const defaultConfig = await getDefaultConfig(context);\n const defaultSecrets = await getDefaultSecrets(context);\n\n context.debug({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.config\n ? JSON.stringify(context.config.env.config, null, 2)\n : \"None\"\n }\\nEnvironment Secret configuration: ${\n context.config.env.secrets\n ? JSON.stringify(context.config.env.secrets, null, 2)\n : \"None\"\n }`\n });\n\n context.env ??= {} as EnvPluginContext[\"env\"];\n context.env.parsed ??= {};\n context.env.injected ??= [];\n\n context.env.config = (await extract(\n context,\n context.config.env.config\n )) as EnvSchema;\n context.env.config.active = await readActive(context, \"config\");\n\n if (\n (isSetString(context.config.env.config) &&\n new RegExp(`${defaultConfig.file}[:#;@]?${defaultConfig.export}`).test(\n context.config.env.config\n ) === false) ||\n (isSetObject(context.config.env.config) &&\n ((context.config.env.config as FileReference).file !==\n defaultConfig.file ||\n (context.config.env.config as FileReference).export !==\n defaultConfig.export))\n ) {\n context.env.config.schema = merge(\n await extract(context, defaultConfig),\n context.env.config\n ) as JsonSchemaObject;\n }\n\n context.env.secrets = (await extract(\n context,\n context.config.env.secrets\n )) as EnvSchema;\n context.env.secrets.active = await readActive(context, \"secrets\");\n\n if (\n (isSetString(context.config.env.secrets) &&\n new RegExp(`${defaultSecrets.file}[:#;@]?${defaultSecrets.export}`).test(\n context.config.env.secrets\n ) === false) ||\n (isSetObject(context.config.env.secrets) &&\n ((context.config.env.secrets as FileReference).file !==\n defaultSecrets.file ||\n (context.config.env.secrets as FileReference).export !==\n defaultSecrets.export))\n ) {\n context.env.secrets.schema = merge(\n await extract(context, defaultSecrets),\n context.env.secrets\n ) as JsonSchemaObject;\n }\n\n const properties = getProperties(context.env.config);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.config ? \"\" : \"Defaulted \"\n }${\n context.env.config.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.config.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.config.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.config.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : context.env.config.variant === \"valibot\"\n ? \"Valibot schema\"\n : context.env.config.variant === \"untyped\"\n ? \"Untyped configuration\"\n : \"Typescript exported type\"\n }${context.config.env.config ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n context.config.env.secrets ? \"\" : \"Defaulted \"\n }${\n context.env.secrets.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.secrets.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.secrets.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.secrets.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : context.env.secrets.variant === \"valibot\"\n ? \"Valibot schema\"\n : context.env.secrets.variant === \"untyped\"\n ? \"Untyped configuration\"\n : \"Typescript exported type\"\n }${context.config.env.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? getPropertiesList(context.env.secrets).length\n : \"0\"\n } parameters\\nEnvironment variable Prefixes: ${context.config.env.prefix.join(\n \", \"\n )}\\nShould inject values: ${\n context.config.env.inject ? \"Yes\" : \"No\"\n }\\nShould validate configuration: ${\n context.config.env.validate ? \"Yes\" : \"No\"\n }`\n });\n\n const aliases = Object.fromEntries(\n Object.entries(properties).flatMap(\n ([key, prop]) =>\n (isSetArray(prop.alias)\n ? prop.alias?.map(alias => [\n alias,\n {\n ...prop,\n name: alias,\n alias: [...(prop.alias?.filter(a => a !== alias) ?? []), key]\n }\n ])\n : []) as [string, typeof prop][]\n )\n );\n\n context.env.parsed = await loadEnv(context);\n for (const [key, value] of Object.entries(context.env.parsed)) {\n const unprefixedKey = context.config.env.prefix.reduce((ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n }, key);\n if (properties[unprefixedKey]) {\n if (!properties[unprefixedKey]?.runtime) {\n const propertySchema = getProperties(context.env.config.schema)?.[\n unprefixedKey\n ];\n if (propertySchema) {\n propertySchema.default = value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey]?.runtime) {\n const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;\n const aliasSchema = getProperties(context.env.config.schema)?.[alias];\n if (aliasSchema) {\n aliasSchema.default = value;\n }\n }\n }\n }\n\n if (!isSchemaObject(context.env.config)) {\n throw new Error(\n \"Invalid environment variable schema extracted. Please ensure the `env.types` option points to a valid TypeScript type definition file that exports an interface representing the environment variable schema.\"\n );\n }\n}\n\n/**\n * Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.\n *\n * @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.\n * @returns A promise that resolves when the schema has been successfully written to the cache directory.\n */\nexport async function writeEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void[]> {\n return Promise.all([\n writeSchema(context, omit(context.env.config, [\"active\"]) as Schema),\n writeSchema(context, omit(context.env.secrets, [\"active\"]) as Schema),\n writeActive(context, \"config\", context.env.config),\n writeActive(context, \"secrets\", context.env.secrets)\n ]);\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;;;;;;;AA+BA,eAAS,uBAAoC,SAAS;CACtD,MAAQ,WAAW,MAAM,QAAO,GAAA,QAAA,kCAAA;gBAE9B,MAAA,IAAA,MAAA,yJAAA;CAED,OAAA;AACD;AACA,uBAAuB,SAAM;CAAA;CAAe;CAAqB;CAAS;AAAA;;;;;;;AAO1E,eAAmB,iBAAA,SAAA;CACjB,OAAK;EACH,MAAC,MAAA,uBAAA,OAAA;EACH,QAAA;;AAEF;AACA,iBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;AAMA,eAAgB,kBAAwB,SAAQ;CAC9C,OAAA;EACF,MAAO,MAAM,uBAA0B,OAAA;EACrC,QAAS;CACT;AACF;AACA,kBAAgB,SAAA;CAAA;CAAuB;CAAQ;AAAA;;;;;;;AAO/C,SAAU,kBAAqB,SAAO;CACpC,OAAE,UAAY,QAAQ,WAAK,KAAc;AAC3C;AACA,kBAAa,SAAS;CAAA;CAAiB;CAAkB;CAAkB;AAAA;AAC3E,SAAW,iBAAA,SAAA,SAAA;CACT,OAAC,UAAQ,kBAAe,OAAA,GAAA,GAAA,QAAA,MAAA;AAC1B;AACA,iBAA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f;OAAI,CAAA,QAAK,gBAAkB,SAAW;IACpC,MAAG,QAAI,QAAA,gBAAA,QAAA,MAAA;IACT,MAAA,cAAoB,cAAgB,QAAA,IAAA,OAAA,MAAA,IAAA;IACpC,IAAA,aACI,YAAK,UAAiB;GAE3B;;;CAGH,IAAA,CAAA,eAAmB,QAAG,IAAA,MAAgB,GACtC,MAAQ,IAAI,MAAM,+MAAO;;AAG3B,WAAU,SAAU;CAAC;CAAS;CAAO;CAAA;AAAA;;;;;;;AAOrC,eAAiB,SAAc,SAAK;CAClC,OAAO,QAAQ,IAAG;EAAA,YAAc,SAAS,KAAK,QAAA,IAAA,QAAoB,CAAC,QAAO,CAAA,CAAA;EAAA,YAAA,SAAA,KAAA,QAAA,IAAA,SAAA,CAAA,QAAA,CAAA,CAAA;EAAA,YAAA,SAAA,UAAA,QAAA,IAAA,MAAA;EAAA,YAAA,SAAA,WAAA,QAAA,IAAA,OAAA;CAAA,CAAA;AAC5E;AACA,SAAS,SAAS;CAAC;CAAC;CAAA;CAAA;AAAA"}
@@ -1,14 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _stryke_env_types = require("@stryke/env/types");
4
3
  let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
5
4
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
6
5
 
7
6
  //#region src/helpers/source-file-env.ts
8
- var source_file_env_exports = /* @__PURE__ */ require_runtime.__exportAll({
9
- formatEnvField: () => formatEnvField,
10
- removeEnvPrefix: () => removeEnvPrefix
11
- });
12
7
  function __assignType(fn, args) {
13
8
  fn.__type = args;
14
9
  return fn;
@@ -60,10 +55,4 @@ formatEnvField.__type = [
60
55
 
61
56
  //#endregion
62
57
  exports.formatEnvField = formatEnvField;
63
- exports.removeEnvPrefix = removeEnvPrefix;
64
- Object.defineProperty(exports, 'source_file_env_exports', {
65
- enumerable: true,
66
- get: function () {
67
- return source_file_env_exports;
68
- }
69
- });
58
+ exports.removeEnvPrefix = removeEnvPrefix;
@@ -1,13 +1,8 @@
1
- import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
1
  import { ENV_PREFIXES } from "@stryke/env/types";
3
2
  import { camelCase } from "@stryke/string-format/camel-case";
4
3
  import { isString } from "@stryke/type-checks/is-string";
5
4
 
6
5
  //#region src/helpers/source-file-env.ts
7
- var source_file_env_exports = /* @__PURE__ */ __exportAll({
8
- formatEnvField: () => formatEnvField,
9
- removeEnvPrefix: () => removeEnvPrefix
10
- });
11
6
  function __assignType(fn, args) {
12
7
  fn.__type = args;
13
8
  return fn;
@@ -58,5 +53,5 @@ formatEnvField.__type = [
58
53
  ];
59
54
 
60
55
  //#endregion
61
- export { formatEnvField, removeEnvPrefix, source_file_env_exports };
56
+ export { formatEnvField, removeEnvPrefix };
62
57
  //# sourceMappingURL=source-file-env.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-file-env.mjs","names":[],"sources":["../../src/helpers/source-file-env.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 type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\ntype TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;\n\nexport function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(\n env: TEnv\n): TReturned<TEnv> {\n if (isString(env)) {\n let name: string = ENV_PREFIXES.reduce((ret, prefix) => {\n if (ret.startsWith(prefix)) {\n ret = ret.slice(prefix.length);\n }\n\n return ret;\n }, env.toUpperCase());\n\n while (name.startsWith(\"_\")) {\n name = name.slice(1);\n }\n\n return name as TReturned<TEnv>;\n }\n\n return Object.keys(env).reduce((ret, key) => {\n const name = removeEnvPrefix(key);\n if (name) {\n (ret as DotenvParseOutput)[name] = env[key];\n }\n\n return ret;\n }, {} as TReturned<TEnv>);\n}\n\nexport function formatEnvField(key: string): string {\n return camelCase(removeEnvPrefix(key));\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;CAE9B,OAAO;;AAKT,MAAK,eAAe;CAAE;CAAQ;CAAC;AAAoC;;CAElE,IAAA,SAAc,GAAG,GAAG;EACpB,IAAA,OAAc,aAAY,OAAQ,cAAW,KAAM,WAAS;GAC5D,IAAA,IAAa,WAAW,MAAE,GACnB,MAAM,IAAI,MAAM,OAAG,MAAQ;GAE7B,OAAO;;;;;;;EAET,OAAO,KAAK,WAAW,GAAG;EAG9B,OAAS;CACT;CACA,OAAS,OAAA,KAAW,GAAI,EAAE,OAAO,cAAa,KAAG,QAAO;;EAEpD,IAAC;EAGH,OAAK;CACL,GAAC;EAAA;EAAU;EAAM;EAAA;CAAA,CAAA,GAAA,CAAA,CAAA;AACnB;AACA,gBAAc,SAAS;CAAA;OAAa;CAAa;CAAW;AAAA;AAC5D,SAAc,eAAiB,KAAG;CAChC,OAAM,UAAU,gBAAa,GAAO,CAAA;AACtC"}
1
+ {"version":3,"file":"source-file-env.mjs","names":[],"sources":["../../src/helpers/source-file-env.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 type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\ntype TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;\n\nexport function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(\n env: TEnv\n): TReturned<TEnv> {\n if (isString(env)) {\n let name: string = ENV_PREFIXES.reduce((ret, prefix) => {\n if (ret.startsWith(prefix)) {\n ret = ret.slice(prefix.length);\n }\n\n return ret;\n }, env.toUpperCase());\n\n while (name.startsWith(\"_\")) {\n name = name.slice(1);\n }\n\n return name as TReturned<TEnv>;\n }\n\n return Object.keys(env).reduce((ret, key) => {\n const name = removeEnvPrefix(key);\n if (name) {\n (ret as DotenvParseOutput)[name] = env[key];\n }\n\n return ret;\n }, {} as TReturned<TEnv>);\n}\n\nexport function formatEnvField(key: string): string {\n return camelCase(removeEnvPrefix(key));\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;CAE9B,OAAO;;AAKT,MAAK,eAAe;CAAE;CAAQ;CAAC;AAAoC;;CAElE,IAAA,SAAc,GAAG,GAAG;EACpB,IAAA,OAAc,aAAY,OAAQ,cAAW,KAAM,WAAS;GAC5D,IAAA,IAAa,WAAW,MAAE,GACnB,MAAM,IAAI,MAAM,OAAG,MAAQ;GAE7B,OAAO;;;;;;;EAET,OAAO,KAAK,WAAW,GAAG;EAG9B,OAAS;CACT;CACA,OAAS,OAAA,KAAW,GAAI,EAAE,OAAO,cAAa,KAAG,QAAO;;EAEpD,IAAC;EAGH,OAAK;CACL,GAAC;EAAA;EAAU;EAAM;EAAA;CAAA,CAAA,GAAA,CAAA,CAAA;AACnB;AACA,gBAAc,SAAS;CAAA;OAAa;CAAa;CAAW;AAAA;AAC5D,SAAc,eAAiB,KAAG;CAChC,OAAM,UAAU,gBAAa,GAAO,CAAA;AACtC"}
package/dist/index.cjs CHANGED
@@ -1,25 +1,25 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_types_plugin = require('./types/plugin.cjs');
4
- const require_babel_plugin = require('./babel/plugin.cjs');
4
+ const require_types_env = require('./types/env.cjs');
5
+ const require_helpers_schema = require('./helpers/schema.cjs');
6
+ const require_helpers_automd_generator = require('./helpers/automd-generator.cjs');
5
7
  const require_components_docs = require('./components/docs.cjs');
6
8
  const require_components_env_builtin = require('./components/env-builtin.cjs');
7
- const require_helpers_automd_generator = require('./helpers/automd-generator.cjs');
8
- const require_helpers_schema = require('./helpers/schema.cjs');
9
- const require_types_env = require('./types/env.cjs');
9
+ const require_babel_plugin = require('./babel/plugin.cjs');
10
+ let _stryke_path_join = require("@stryke/path/join");
11
+ let defu = require("defu");
12
+ defu = require_runtime.__toESM(defu);
13
+ let powerlines_plugin_utils = require("powerlines/plugin-utils");
10
14
  let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
15
+ let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
11
16
  let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
12
17
  let _powerlines_plugin_automd = require("@powerlines/plugin-automd");
13
18
  _powerlines_plugin_automd = require_runtime.__toESM(_powerlines_plugin_automd);
14
19
  let _powerlines_plugin_babel = require("@powerlines/plugin-babel");
15
20
  _powerlines_plugin_babel = require_runtime.__toESM(_powerlines_plugin_babel);
16
21
  let _stryke_convert_to_array = require("@stryke/convert/to-array");
17
- let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
18
- let _stryke_path_join = require("@stryke/path/join");
19
22
  let _stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
20
- let defu = require("defu");
21
- defu = require_runtime.__toESM(defu);
22
- let powerlines_plugin_utils = require("powerlines/plugin-utils");
23
23
 
24
24
  //#region src/index.tsx
25
25
  function __assignType(fn, args) {
package/dist/index.mjs CHANGED
@@ -1,20 +1,20 @@
1
1
  import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType } from "./types/plugin.mjs";
2
- import { envBabelPlugin } from "./babel/plugin.mjs";
2
+ import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/env.mjs";
3
+ import { extractEnv, getDefaultConfig, getDefaultSecrets, writeEnv } from "./helpers/schema.mjs";
4
+ import { env } from "./helpers/automd-generator.mjs";
3
5
  import { EnvDocsFile } from "./components/docs.mjs";
4
6
  import { EnvBuiltin } from "./components/env-builtin.mjs";
5
- import { env } from "./helpers/automd-generator.mjs";
6
- import { extractEnv, getDefaultConfig, getDefaultSecrets, writeEnv } from "./helpers/schema.mjs";
7
- import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/env.mjs";
7
+ import { envBabelPlugin } from "./babel/plugin.mjs";
8
+ import { joinPaths } from "@stryke/path/join";
9
+ import defu from "defu";
10
+ import { getDocsOutputPath } from "powerlines/plugin-utils";
8
11
  import { createComponent } from "@alloy-js/core/jsx-runtime";
12
+ import { getUnique } from "@stryke/helpers/get-unique";
9
13
  import { render } from "@powerlines/plugin-alloy/render";
10
14
  import automd from "@powerlines/plugin-automd";
11
15
  import babel from "@powerlines/plugin-babel";
12
16
  import { toArray } from "@stryke/convert/to-array";
13
- import { getUnique } from "@stryke/helpers/get-unique";
14
- import { joinPaths } from "@stryke/path/join";
15
17
  import { constantCase } from "@stryke/string-format/constant-case";
16
- import defu from "defu";
17
- import { getDocsOutputPath } from "powerlines/plugin-utils";
18
18
 
19
19
  //#region src/index.tsx
20
20
  function __assignType(fn, args) {
@@ -1,6 +1,6 @@
1
+ import { DotenvParseOutput } from "@stryke/env/types";
1
2
  import { JsonSchemaObject, Schema, SchemaInput } from "@powerlines/schema";
2
3
  import { Children } from "@alloy-js/core";
3
- import { DotenvParseOutput } from "@stryke/env/types";
4
4
  import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
5
5
  import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
6
6
  import { RequiredKeys } from "@stryke/types";