@powerlines/plugin-env 0.15.121 → 0.15.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +0 -4
  2. package/dist/babel/plugin.d.cts +2 -2
  3. package/dist/babel/plugin.d.mts +2 -3
  4. package/dist/components/docs.cjs +2 -2
  5. package/dist/components/docs.d.cts +1 -1
  6. package/dist/components/docs.d.mts +1 -1
  7. package/dist/components/docs.mjs +1 -1
  8. package/dist/components/env.cjs +3 -2
  9. package/dist/components/env.d.cts +2 -2
  10. package/dist/components/env.d.mts +2 -2
  11. package/dist/components/env.mjs +1 -1
  12. package/dist/helpers/automd-generator.cjs +2 -2
  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 +1 -1
  16. package/dist/helpers/docs-helper.cjs +3 -2
  17. package/dist/helpers/docs-helper.mjs +1 -1
  18. package/dist/helpers/load.cjs +10 -9
  19. package/dist/helpers/load.mjs +3 -3
  20. package/dist/helpers/persistence.cjs +3 -3
  21. package/dist/helpers/persistence.d.cts +1 -1
  22. package/dist/helpers/persistence.d.mts +1 -1
  23. package/dist/helpers/persistence.mjs +1 -1
  24. package/dist/helpers/reflect.cjs +4 -4
  25. package/dist/helpers/reflect.mjs +2 -2
  26. package/dist/index.cjs +18 -17
  27. package/dist/index.d.cts +1 -1
  28. package/dist/index.d.mts +1 -1
  29. package/dist/index.mjs +5 -5
  30. package/dist/types/plugin.d.cts +5 -6
  31. package/dist/types/plugin.d.mts +4 -6
  32. package/package.json +7 -7
  33. package/dist/_virtual/rolldown_runtime.mjs +0 -33
  34. package/dist/deepkit/schemas/reflection.d.cts +0 -1560
  35. package/dist/deepkit/src/types.d.cts +0 -10
  36. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/parse-type-definition.cjs +0 -37
  37. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/parse-type-definition.mjs +0 -37
  38. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/to-array.cjs +0 -15
  39. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/to-array.mjs +0 -14
  40. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.cjs +0 -15
  41. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.mjs +0 -14
  42. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/index.cjs +0 -3
  43. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/index.mjs +0 -5
  44. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-buffer.cjs +0 -6
  45. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-buffer.mjs +0 -6
  46. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-collection.cjs +0 -1
  47. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-collection.mjs +0 -3
  48. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-object.cjs +0 -19
  49. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-object.mjs +0 -19
  50. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.cjs +0 -63
  51. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.mjs +0 -63
  52. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-string.cjs +0 -12
  53. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/is-string.mjs +0 -11
  54. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/type-detect.cjs +0 -15
  55. package/dist/node_modules/.pnpm/@stryke_convert@0.6.35/node_modules/@stryke/convert/dist/type-checks/src/type-detect.mjs +0 -16
  56. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/is-parent-path.cjs +0 -32
  57. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/is-parent-path.mjs +0 -32
  58. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/is-type.cjs +0 -28
  59. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/is-type.mjs +0 -28
  60. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/join-paths.cjs +0 -106
  61. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/join-paths.mjs +0 -106
  62. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/regex.cjs +0 -12
  63. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/regex.mjs +0 -8
  64. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/slash.cjs +0 -15
  65. package/dist/node_modules/.pnpm/@stryke_path@0.26.0/node_modules/@stryke/path/dist/slash.mjs +0 -14
  66. package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.cjs +0 -346
  67. package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.mjs +0 -346
  68. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/json5.cjs +0 -786
  69. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/json5.mjs +0 -786
  70. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/jsonc.cjs +0 -3
  71. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/jsonc.mjs +0 -3
  72. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.cjs +0 -23
  73. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.mjs +0 -22
  74. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.cjs +0 -405
  75. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.mjs +0 -404
  76. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/toml.cjs +0 -657
  77. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/toml.mjs +0 -657
  78. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/yaml.cjs +0 -1054
  79. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/yaml.mjs +0 -1054
  80. package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs +0 -43
  81. package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs +0 -42
  82. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +0 -46
  83. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +0 -45
  84. package/dist/node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.cjs +0 -288
  85. package/dist/node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.mjs +0 -285
  86. package/dist/node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.cjs +0 -71
  87. package/dist/node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.mjs +0 -68
  88. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +0 -1013
  89. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +0 -1007
  90. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.cjs +0 -23
  91. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +0 -13
  92. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.cjs +0 -2698
  93. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -2685
  94. package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs +0 -4457
  95. package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs +0 -4454
  96. package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.cjs +0 -29
  97. package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs +0 -29
  98. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -181
  99. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -176
  100. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +0 -22
  101. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +0 -17
  102. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +0 -3967
  103. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +0 -3962
  104. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.cjs +0 -11768
  105. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs +0 -11763
  106. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -25
  107. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs +0 -20
  108. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.cjs +0 -20
  109. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs +0 -17
  110. package/dist/node_modules/.pnpm/nypm@0.6.4/node_modules/nypm/dist/index.cjs +0 -194
  111. package/dist/node_modules/.pnpm/nypm@0.6.4/node_modules/nypm/dist/index.mjs +0 -191
  112. package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.cjs +0 -13
  113. package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs +0 -12
  114. package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.cjs +0 -3
  115. package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.mjs +0 -3
  116. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -145
  117. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -138
  118. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +0 -127
  119. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +0 -125
  120. package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.cjs +0 -138
  121. package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs +0 -136
  122. package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.cjs +0 -629
  123. package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs +0 -627
  124. package/dist/packages/deepkit/schemas/reflection.d.mts +0 -1560
  125. package/dist/packages/deepkit/src/types.d.mts +0 -10
  126. package/dist/packages/plugin-alloy/src/core/components/source-file.d.mts +0 -23
  127. package/dist/packages/plugin-alloy/src/markdown/components/markdown-file.d.mts +0 -8
  128. package/dist/packages/plugin-alloy/src/types/components.d.mts +0 -21
  129. package/dist/packages/plugin-alloy/src/types/index.d.mts +0 -2
  130. package/dist/packages/plugin-alloy/src/types/plugin.d.mts +0 -36
  131. package/dist/packages/plugin-alloy/src/typescript/components/builtin-file.d.mts +0 -26
  132. package/dist/packages/plugin-alloy/src/typescript/components/tsdoc.d.mts +0 -37
  133. package/dist/packages/plugin-alloy/src/typescript/components/typescript-file.d.mts +0 -16
  134. package/dist/packages/plugin-alloy/src/typescript/components/typescript-interface.d.mts +0 -12
  135. package/dist/packages/plugin-automd/src/types/plugin.d.mts +0 -40
  136. package/dist/packages/plugin-automd/src/types/toc.d.mts +0 -33
  137. package/dist/packages/plugin-babel/src/types/index.d.mts +0 -1
  138. package/dist/packages/plugin-babel/src/types/plugin.d.mts +0 -15
  139. package/dist/packages/powerlines/src/internal/helpers/hooks.d.mts +0 -49
  140. package/dist/packages/powerlines/src/types/api.d.mts +0 -104
  141. package/dist/packages/powerlines/src/types/babel.d.mts +0 -23
  142. package/dist/packages/powerlines/src/types/build.d.mts +0 -185
  143. package/dist/packages/powerlines/src/types/commands.d.mts +0 -9
  144. package/dist/packages/powerlines/src/types/config.d.mts +0 -435
  145. package/dist/packages/powerlines/src/types/context.d.mts +0 -514
  146. package/dist/packages/powerlines/src/types/fs.d.mts +0 -486
  147. package/dist/packages/powerlines/src/types/hooks.d.mts +0 -32
  148. package/dist/packages/powerlines/src/types/index.d.mts +0 -12
  149. package/dist/packages/powerlines/src/types/plugin.d.mts +0 -205
  150. package/dist/packages/powerlines/src/types/resolved.d.mts +0 -94
  151. package/dist/packages/powerlines/src/types/tsconfig.d.mts +0 -69
  152. package/dist/packages/powerlines/src/types/unplugin.d.mts +0 -23
  153. package/dist/plugin-alloy/src/core/components/source-file.d.cts +0 -23
  154. package/dist/plugin-alloy/src/markdown/components/markdown-file.d.cts +0 -8
  155. package/dist/plugin-alloy/src/types/components.d.cts +0 -20
  156. package/dist/plugin-alloy/src/types/index.d.cts +0 -2
  157. package/dist/plugin-alloy/src/types/plugin.d.cts +0 -36
  158. package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +0 -26
  159. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +0 -37
  160. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +0 -16
  161. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +0 -12
  162. package/dist/plugin-automd/src/types/plugin.d.cts +0 -38
  163. package/dist/plugin-automd/src/types/toc.d.cts +0 -33
  164. package/dist/plugin-babel/src/types/plugin.d.cts +0 -15
  165. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -47
  166. package/dist/powerlines/src/types/api.d.cts +0 -104
  167. package/dist/powerlines/src/types/babel.d.cts +0 -23
  168. package/dist/powerlines/src/types/build.d.cts +0 -185
  169. package/dist/powerlines/src/types/commands.d.cts +0 -8
  170. package/dist/powerlines/src/types/config.d.cts +0 -435
  171. package/dist/powerlines/src/types/context.d.cts +0 -514
  172. package/dist/powerlines/src/types/fs.d.cts +0 -486
  173. package/dist/powerlines/src/types/hooks.d.cts +0 -32
  174. package/dist/powerlines/src/types/plugin.d.cts +0 -205
  175. package/dist/powerlines/src/types/resolved.d.cts +0 -94
  176. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  177. package/dist/powerlines/src/types/unplugin.d.cts +0 -22
@@ -1,346 +0,0 @@
1
- import { __toESM } from "../../../../../../_virtual/rolldown_runtime.mjs";
2
- import { basename, dirname, extname, join, normalize, resolve } from "../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs";
3
- import { require_main } from "../../../../dotenv@17.2.3/node_modules/dotenv/lib/main.mjs";
4
- import { resolveModulePath } from "../../../../exsolve@1.0.8/node_modules/exsolve/dist/index.mjs";
5
- import { createJiti } from "../../../../jiti@2.6.1/node_modules/jiti/lib/jiti.mjs";
6
- import { defu } from "../../../../defu@6.1.4/node_modules/defu/dist/defu.mjs";
7
- import { read, readUser } from "../../../../rc9@2.1.2/node_modules/rc9/dist/index.mjs";
8
- import { findWorkspaceDir, readPackageJSON } from "../../../../pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs";
9
- import { existsSync, promises, statSync } from "node:fs";
10
- import { homedir } from "node:os";
11
- import { readFile, rm } from "node:fs/promises";
12
- import { pathToFileURL } from "node:url";
13
-
14
- //#region ../../node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.mjs
15
- var import_main = /* @__PURE__ */ __toESM(require_main(), 1);
16
- /**
17
- * Load and interpolate environment variables into `process.env`.
18
- * If you need more control (or access to the values), consider using `loadDotenv` instead
19
- *
20
- */
21
- async function setupDotenv(options) {
22
- const targetEnvironment = options.env ?? process.env;
23
- const environment = await loadDotenv({
24
- cwd: options.cwd,
25
- fileName: options.fileName ?? ".env",
26
- env: targetEnvironment,
27
- interpolate: options.interpolate ?? true
28
- });
29
- const dotenvVars = getDotEnvVars(targetEnvironment);
30
- for (const key in environment) {
31
- if (key.startsWith("_")) continue;
32
- if (targetEnvironment[key] === void 0 || dotenvVars.has(key)) targetEnvironment[key] = environment[key];
33
- }
34
- return environment;
35
- }
36
- /** Load environment variables into an object. */
37
- async function loadDotenv(options) {
38
- const environment = Object.create(null);
39
- const cwd = resolve(options.cwd || ".");
40
- const _fileName = options.fileName || ".env";
41
- const dotenvFiles = typeof _fileName === "string" ? [_fileName] : _fileName;
42
- const dotenvVars = getDotEnvVars(options.env || {});
43
- Object.assign(environment, options.env);
44
- for (const file of dotenvFiles) {
45
- const dotenvFile = resolve(cwd, file);
46
- if (!statSync(dotenvFile, { throwIfNoEntry: false })?.isFile()) continue;
47
- const parsed = import_main.parse(await promises.readFile(dotenvFile, "utf8"));
48
- for (const key in parsed) {
49
- if (key in environment && !dotenvVars.has(key)) continue;
50
- environment[key] = parsed[key];
51
- dotenvVars.add(key);
52
- }
53
- }
54
- if (options.interpolate) interpolate(environment);
55
- return environment;
56
- }
57
- function interpolate(target, source = {}, parse = (v) => v) {
58
- function getValue(key) {
59
- return source[key] === void 0 ? target[key] : source[key];
60
- }
61
- function interpolate$1(value, parents = []) {
62
- if (typeof value !== "string") return value;
63
- return parse((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
64
- const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
65
- const prefix = parts[1];
66
- let value$1, replacePart;
67
- if (prefix === "\\") {
68
- replacePart = parts[0] || "";
69
- value$1 = replacePart.replace(String.raw`\$`, "$");
70
- } else {
71
- const key = parts[2];
72
- replacePart = (parts[0] || "").slice(prefix.length);
73
- if (parents.includes(key)) {
74
- console.warn(`Please avoid recursive environment variables ( loop: ${parents.join(" > ")} > ${key} )`);
75
- return "";
76
- }
77
- value$1 = getValue(key);
78
- value$1 = interpolate$1(value$1, [...parents, key]);
79
- }
80
- return value$1 === void 0 ? newValue : newValue.replace(replacePart, value$1);
81
- }, value));
82
- }
83
- for (const key in target) target[key] = interpolate$1(getValue(key));
84
- }
85
- function getDotEnvVars(targetEnvironment) {
86
- const globalRegistry = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
87
- if (!globalRegistry.has(targetEnvironment)) globalRegistry.set(targetEnvironment, /* @__PURE__ */ new Set());
88
- return globalRegistry.get(targetEnvironment);
89
- }
90
- const _normalize = (p) => p?.replace(/\\/g, "/");
91
- const ASYNC_LOADERS = {
92
- ".yaml": () => import("../../../../confbox@0.2.2/node_modules/confbox/dist/yaml.mjs").then((r) => r.parseYAML),
93
- ".yml": () => import("../../../../confbox@0.2.2/node_modules/confbox/dist/yaml.mjs").then((r) => r.parseYAML),
94
- ".jsonc": () => import("../../../../confbox@0.2.2/node_modules/confbox/dist/jsonc.mjs").then((r) => r.parseJSONC),
95
- ".json5": () => import("../../../../confbox@0.2.2/node_modules/confbox/dist/json5.mjs").then((r) => r.parseJSON5),
96
- ".toml": () => import("../../../../confbox@0.2.2/node_modules/confbox/dist/toml.mjs").then((r) => r.parseTOML)
97
- };
98
- const SUPPORTED_EXTENSIONS = Object.freeze([
99
- ".js",
100
- ".ts",
101
- ".mjs",
102
- ".cjs",
103
- ".mts",
104
- ".cts",
105
- ".json",
106
- ".jsonc",
107
- ".json5",
108
- ".yaml",
109
- ".yml",
110
- ".toml"
111
- ]);
112
- async function loadConfig(options) {
113
- options.cwd = resolve(process.cwd(), options.cwd || ".");
114
- options.name = options.name || "config";
115
- options.envName = options.envName ?? process.env.NODE_ENV;
116
- options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
117
- options.rcFile = options.rcFile ?? `.${options.name}rc`;
118
- if (options.extend !== false) options.extend = {
119
- extendKey: "extends",
120
- ...options.extend
121
- };
122
- const _merger = options.merger || defu;
123
- options.jiti = options.jiti || createJiti(join(options.cwd, options.configFile), {
124
- interopDefault: true,
125
- moduleCache: false,
126
- extensions: [...SUPPORTED_EXTENSIONS],
127
- ...options.jitiOptions
128
- });
129
- const r = {
130
- config: {},
131
- cwd: options.cwd,
132
- configFile: resolve(options.cwd, options.configFile),
133
- layers: [],
134
- _configFile: void 0
135
- };
136
- const rawConfigs = {
137
- overrides: options.overrides,
138
- main: void 0,
139
- rc: void 0,
140
- packageJson: void 0,
141
- defaultConfig: options.defaultConfig
142
- };
143
- if (options.dotenv) await setupDotenv({
144
- cwd: options.cwd,
145
- ...options.dotenv === true ? {} : options.dotenv
146
- });
147
- const _mainConfig = await resolveConfig(".", options);
148
- if (_mainConfig.configFile) {
149
- rawConfigs.main = _mainConfig.config;
150
- r.configFile = _mainConfig.configFile;
151
- r._configFile = _mainConfig._configFile;
152
- }
153
- if (_mainConfig.meta) r.meta = _mainConfig.meta;
154
- if (options.rcFile) {
155
- const rcSources = [];
156
- rcSources.push(read({
157
- name: options.rcFile,
158
- dir: options.cwd
159
- }));
160
- if (options.globalRc) {
161
- const workspaceDir = await findWorkspaceDir(options.cwd).catch(() => {});
162
- if (workspaceDir) rcSources.push(read({
163
- name: options.rcFile,
164
- dir: workspaceDir
165
- }));
166
- rcSources.push(readUser({
167
- name: options.rcFile,
168
- dir: options.cwd
169
- }));
170
- }
171
- rawConfigs.rc = _merger({}, ...rcSources);
172
- }
173
- if (options.packageJson) {
174
- const keys = (Array.isArray(options.packageJson) ? options.packageJson : [typeof options.packageJson === "string" ? options.packageJson : options.name]).filter((t) => t && typeof t === "string");
175
- const pkgJsonFile = await readPackageJSON(options.cwd).catch(() => {});
176
- rawConfigs.packageJson = _merger({}, ...keys.map((key) => pkgJsonFile?.[key]));
177
- }
178
- const configs = {};
179
- for (const key in rawConfigs) {
180
- const value = rawConfigs[key];
181
- configs[key] = await (typeof value === "function" ? value({
182
- configs,
183
- rawConfigs
184
- }) : value);
185
- }
186
- if (Array.isArray(configs.main)) r.config = configs.main;
187
- else {
188
- r.config = _merger(configs.overrides, configs.main, configs.rc, configs.packageJson, configs.defaultConfig);
189
- if (options.extend) {
190
- await extendConfig(r.config, options);
191
- r.layers = r.config._layers;
192
- delete r.config._layers;
193
- r.config = _merger(r.config, ...r.layers.map((e) => e.config));
194
- }
195
- }
196
- r.layers = [...[
197
- configs.overrides && {
198
- config: configs.overrides,
199
- configFile: void 0,
200
- cwd: void 0
201
- },
202
- {
203
- config: configs.main,
204
- configFile: options.configFile,
205
- cwd: options.cwd
206
- },
207
- configs.rc && {
208
- config: configs.rc,
209
- configFile: options.rcFile
210
- },
211
- configs.packageJson && {
212
- config: configs.packageJson,
213
- configFile: "package.json"
214
- }
215
- ].filter((l) => l && l.config), ...r.layers];
216
- if (options.defaults) r.config = _merger(r.config, options.defaults);
217
- if (options.omit$Keys) {
218
- for (const key in r.config) if (key.startsWith("$")) delete r.config[key];
219
- }
220
- if (options.configFileRequired && !r._configFile) throw new Error(`Required config (${r.configFile}) cannot be resolved.`);
221
- return r;
222
- }
223
- async function extendConfig(config, options) {
224
- config._layers = config._layers || [];
225
- if (!options.extend) return;
226
- let keys = options.extend.extendKey;
227
- if (typeof keys === "string") keys = [keys];
228
- const extendSources = [];
229
- for (const key of keys) {
230
- extendSources.push(...(Array.isArray(config[key]) ? config[key] : [config[key]]).filter(Boolean));
231
- delete config[key];
232
- }
233
- for (let extendSource of extendSources) {
234
- const originalExtendSource = extendSource;
235
- let sourceOptions = {};
236
- if (extendSource.source) {
237
- sourceOptions = extendSource.options || {};
238
- extendSource = extendSource.source;
239
- }
240
- if (Array.isArray(extendSource)) {
241
- sourceOptions = extendSource[1] || {};
242
- extendSource = extendSource[0];
243
- }
244
- if (typeof extendSource !== "string") {
245
- console.warn(`Cannot extend config from \`${JSON.stringify(originalExtendSource)}\` in ${options.cwd}`);
246
- continue;
247
- }
248
- const _config = await resolveConfig(extendSource, options, sourceOptions);
249
- if (!_config.config) {
250
- console.warn(`Cannot extend config from \`${extendSource}\` in ${options.cwd}`);
251
- continue;
252
- }
253
- await extendConfig(_config.config, {
254
- ...options,
255
- cwd: _config.cwd
256
- });
257
- config._layers.push(_config);
258
- if (_config.config._layers) {
259
- config._layers.push(..._config.config._layers);
260
- delete _config.config._layers;
261
- }
262
- }
263
- }
264
- const GIGET_PREFIXES = [
265
- "gh:",
266
- "github:",
267
- "gitlab:",
268
- "bitbucket:",
269
- "https://",
270
- "http://"
271
- ];
272
- const NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
273
- async function resolveConfig(source, options, sourceOptions = {}) {
274
- if (options.resolve) {
275
- const res$1 = await options.resolve(source, options);
276
- if (res$1) return res$1;
277
- }
278
- const _merger = options.merger || defu;
279
- const customProviderKeys = Object.keys(sourceOptions.giget?.providers || {}).map((key) => `${key}:`);
280
- const gigetPrefixes = customProviderKeys.length > 0 ? [...new Set([...customProviderKeys, ...GIGET_PREFIXES])] : GIGET_PREFIXES;
281
- if (options.giget !== false && gigetPrefixes.some((prefix) => source.startsWith(prefix))) {
282
- const { downloadTemplate } = await import("../../../../giget@2.0.0/node_modules/giget/dist/index.mjs");
283
- const { digest } = await import("../../../../ohash@2.0.11/node_modules/ohash/dist/index.mjs");
284
- const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
285
- let cloneDir;
286
- const localNodeModules = resolve(options.cwd, "node_modules");
287
- const parentDir = dirname(options.cwd);
288
- if (basename(parentDir) === ".c12") cloneDir = join(parentDir, cloneName);
289
- else if (existsSync(localNodeModules)) cloneDir = join(localNodeModules, ".c12", cloneName);
290
- else cloneDir = process.env.XDG_CACHE_HOME ? resolve(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve(homedir(), ".cache/c12", cloneName);
291
- if (existsSync(cloneDir) && !sourceOptions.install) await rm(cloneDir, { recursive: true });
292
- source = (await downloadTemplate(source, {
293
- dir: cloneDir,
294
- install: sourceOptions.install,
295
- force: sourceOptions.install,
296
- auth: sourceOptions.auth,
297
- ...options.giget,
298
- ...sourceOptions.giget
299
- })).dir;
300
- }
301
- if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
302
- const ext = extname(source);
303
- const isDir = !ext || ext === basename(source);
304
- const cwd = resolve(options.cwd, isDir ? source : dirname(source));
305
- if (isDir) source = options.configFile;
306
- const res = {
307
- config: void 0,
308
- configFile: void 0,
309
- cwd,
310
- source,
311
- sourceOptions
312
- };
313
- res.configFile = tryResolve(resolve(cwd, source), options) || tryResolve(resolve(cwd, ".config", source.replace(/\.config$/, "")), options) || tryResolve(resolve(cwd, ".config", source), options) || source;
314
- if (!existsSync(res.configFile)) return res;
315
- res._configFile = res.configFile;
316
- const configFileExt = extname(res.configFile) || "";
317
- if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await readFile(res.configFile, "utf8"));
318
- else res.config = await options.jiti.import(res.configFile, { default: true });
319
- if (typeof res.config === "function") res.config = await res.config(options.context);
320
- if (options.envName) {
321
- const envConfig = {
322
- ...res.config["$" + options.envName],
323
- ...res.config.$env?.[options.envName]
324
- };
325
- if (Object.keys(envConfig).length > 0) res.config = _merger(envConfig, res.config);
326
- }
327
- res.meta = defu(res.sourceOptions.meta, res.config.$meta);
328
- delete res.config.$meta;
329
- if (res.sourceOptions.overrides) res.config = _merger(res.sourceOptions.overrides, res.config);
330
- res.configFile = _normalize(res.configFile);
331
- res.source = _normalize(res.source);
332
- return res;
333
- }
334
- function tryResolve(id, options) {
335
- const res = resolveModulePath(id, {
336
- try: true,
337
- from: pathToFileURL(join(options.cwd || ".", options.configFile || "/")),
338
- suffixes: ["", "/index"],
339
- extensions: SUPPORTED_EXTENSIONS,
340
- cache: false
341
- });
342
- return res ? normalize(res) : void 0;
343
- }
344
-
345
- //#endregion
346
- export { loadConfig };