c12 3.3.3 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Jiti, JitiOptions } from "jiti";
2
- import { ChokidarOptions } from "chokidar";
3
2
  import { DownloadTemplateOptions } from "giget";
3
+ import { ChokidarOptions } from "chokidar";
4
4
  import { diff } from "ohash/utils";
5
5
 
6
6
  //#region src/dotenv.d.ts
package/dist/index.mjs CHANGED
@@ -10,7 +10,6 @@ import * as rc9 from "rc9";
10
10
  import { defu } from "defu";
11
11
  import { findWorkspaceDir, readPackageJSON } from "pkg-types";
12
12
  import { debounce } from "perfect-debounce";
13
-
14
13
  //#region src/dotenv.ts
15
14
  /**
16
15
  * Load and interpolate environment variables into `process.env`.
@@ -57,15 +56,15 @@ function interpolate(target, source = {}, parse = (v) => v) {
57
56
  function getValue(key) {
58
57
  return source[key] === void 0 ? target[key] : source[key];
59
58
  }
60
- function interpolate$1(value, parents = []) {
59
+ function interpolate(value, parents = []) {
61
60
  if (typeof value !== "string") return value;
62
61
  return parse((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
63
62
  const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
64
63
  const prefix = parts[1];
65
- let value$1, replacePart;
64
+ let value, replacePart;
66
65
  if (prefix === "\\") {
67
66
  replacePart = parts[0] || "";
68
- value$1 = replacePart.replace(String.raw`\$`, "$");
67
+ value = replacePart.replace(String.raw`\$`, "$");
69
68
  } else {
70
69
  const key = parts[2];
71
70
  replacePart = (parts[0] || "").slice(prefix.length);
@@ -73,20 +72,19 @@ function interpolate(target, source = {}, parse = (v) => v) {
73
72
  console.warn(`Please avoid recursive environment variables ( loop: ${parents.join(" > ")} > ${key} )`);
74
73
  return "";
75
74
  }
76
- value$1 = getValue(key);
77
- value$1 = interpolate$1(value$1, [...parents, key]);
75
+ value = getValue(key);
76
+ value = interpolate(value, [...parents, key]);
78
77
  }
79
- return value$1 === void 0 ? newValue : newValue.replace(replacePart, value$1);
78
+ return value === void 0 ? newValue : newValue.replace(replacePart, value);
80
79
  }, value));
81
80
  }
82
- for (const key in target) target[key] = interpolate$1(getValue(key));
81
+ for (const key in target) target[key] = interpolate(getValue(key));
83
82
  }
84
83
  function getDotEnvVars(targetEnvironment) {
85
84
  const globalRegistry = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
86
85
  if (!globalRegistry.has(targetEnvironment)) globalRegistry.set(targetEnvironment, /* @__PURE__ */ new Set());
87
86
  return globalRegistry.get(targetEnvironment);
88
87
  }
89
-
90
88
  //#endregion
91
89
  //#region src/loader.ts
92
90
  const _normalize = (p) => p?.replace(/\\/g, "/");
@@ -274,8 +272,8 @@ const GIGET_PREFIXES = [
274
272
  const NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
275
273
  async function resolveConfig(source, options, sourceOptions = {}) {
276
274
  if (options.resolve) {
277
- const res$1 = await options.resolve(source, options);
278
- if (res$1) return res$1;
275
+ const res = await options.resolve(source, options);
276
+ if (res) return res;
279
277
  }
280
278
  const _merger = options.merger || defu;
281
279
  const customProviderKeys = Object.keys(sourceOptions.giget?.providers || {}).map((key) => `${key}:`);
@@ -343,13 +341,11 @@ function tryResolve(id, options) {
343
341
  });
344
342
  return res ? normalize(res) : void 0;
345
343
  }
346
-
347
344
  //#endregion
348
345
  //#region src/types.ts
349
346
  function createDefineConfig() {
350
347
  return (input) => input;
351
348
  }
352
-
353
349
  //#endregion
354
350
  //#region src/watch.ts
355
351
  const eventMap = {
@@ -414,6 +410,5 @@ async function watchConfig(options) {
414
410
  return config[prop];
415
411
  } });
416
412
  }
417
-
418
413
  //#endregion
419
- export { SUPPORTED_EXTENSIONS, createDefineConfig, loadConfig, loadDotenv, setupDotenv, watchConfig };
414
+ export { SUPPORTED_EXTENSIONS, createDefineConfig, loadConfig, loadDotenv, setupDotenv, watchConfig };
package/dist/update.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import * as magicast0 from "magicast";
1
+ import * as magicast from "magicast";
2
2
 
3
3
  //#region src/update.d.ts
4
4
  /**
@@ -10,7 +10,7 @@ interface UpdateConfigResult {
10
10
  created?: boolean;
11
11
  }
12
12
  type MaybePromise<T> = T | Promise<T>;
13
- type MagicAstOptions = Exclude<Parameters<(typeof magicast0)["parseModule"]>[1], undefined>;
13
+ type MagicAstOptions = Exclude<Parameters<(typeof magicast)["parseModule"]>[1], undefined>;
14
14
  interface UpdateConfigOptions {
15
15
  /**
16
16
  * Current working directory
package/dist/update.mjs CHANGED
@@ -1,15 +1,7 @@
1
1
  import { resolveModulePath } from "exsolve";
2
- import "node:fs";
3
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
4
- import "node:url";
5
- import "node:os";
6
3
  import { join, normalize } from "pathe";
7
- import "jiti";
8
- import "rc9";
9
- import "defu";
10
- import "pkg-types";
11
4
  import { dirname, extname } from "node:path";
12
-
13
5
  //#region src/loader.ts
14
6
  const SUPPORTED_EXTENSIONS = Object.freeze([
15
7
  ".js",
@@ -25,7 +17,6 @@ const SUPPORTED_EXTENSIONS = Object.freeze([
25
17
  ".yml",
26
18
  ".toml"
27
19
  ]);
28
-
29
20
  //#endregion
30
21
  //#region src/update.ts
31
22
  const UPDATABLE_EXTS = [
@@ -75,6 +66,5 @@ function tryResolve(path, cwd, extensions) {
75
66
  });
76
67
  return res ? normalize(res) : void 0;
77
68
  }
78
-
79
69
  //#endregion
80
- export { updateConfig };
70
+ export { updateConfig };
package/package.json CHANGED
@@ -1,20 +1,14 @@
1
1
  {
2
2
  "name": "c12",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Smart Config Loader",
5
5
  "repository": "unjs/c12",
6
6
  "license": "MIT",
7
7
  "sideEffects": false,
8
8
  "type": "module",
9
9
  "exports": {
10
- ".": {
11
- "types": "./dist/index.d.mts",
12
- "default": "./dist/index.mjs"
13
- },
14
- "./update": {
15
- "types": "./dist/update.d.mts",
16
- "default": "./dist/update.mjs"
17
- }
10
+ ".": "./dist/index.mjs",
11
+ "./update": "./dist/update.mjs"
18
12
  },
19
13
  "types": "./dist/index.d.mts",
20
14
  "files": [
@@ -25,37 +19,38 @@
25
19
  "dev": "vitest dev",
26
20
  "lint": "eslint . && prettier -c src test",
27
21
  "lint:fix": "automd && eslint . --fix && prettier -w src test",
28
- "release": "pnpm build && pnpm test && changelogen --release --push --publish",
22
+ "prepack": "obuild",
23
+ "release": "pnpm build && pnpm test && changelogen --release --push --publish --publishTag 3x",
29
24
  "test": "pnpm lint && vitest run --coverage && pnpm test:types",
30
25
  "test:types": "tsc --noEmit"
31
26
  },
32
27
  "dependencies": {
33
28
  "chokidar": "^5.0.0",
34
- "confbox": "^0.2.2",
35
- "defu": "^6.1.4",
36
- "dotenv": "^17.2.3",
29
+ "confbox": "^0.2.4",
30
+ "defu": "^6.1.6",
31
+ "dotenv": "^17.3.1",
37
32
  "exsolve": "^1.0.8",
38
- "giget": "^2.0.0",
33
+ "giget": "^3.2.0",
39
34
  "jiti": "^2.6.1",
40
35
  "ohash": "^2.0.11",
41
36
  "pathe": "^2.0.3",
42
- "perfect-debounce": "^2.0.0",
37
+ "perfect-debounce": "^2.1.0",
43
38
  "pkg-types": "^2.3.0",
44
- "rc9": "^2.1.2"
39
+ "rc9": "^3.0.1"
45
40
  },
46
41
  "devDependencies": {
47
- "@types/node": "^25.0.2",
48
- "@vitest/coverage-v8": "^4.0.15",
49
- "automd": "^0.4.2",
42
+ "@types/node": "^25.5.0",
43
+ "@vitest/coverage-v8": "^4.1.2",
44
+ "automd": "^0.4.3",
50
45
  "changelogen": "^0.6.2",
51
- "eslint": "^9.39.2",
52
- "eslint-config-unjs": "^0.5.0",
46
+ "eslint": "^10.1.0",
47
+ "eslint-config-unjs": "^0.6.2",
53
48
  "expect-type": "^1.3.0",
54
- "magicast": "^0.5.1",
55
- "obuild": "^0.4.8",
56
- "prettier": "^3.7.4",
57
- "typescript": "^5.9.3",
58
- "vitest": "^4.0.15"
49
+ "magicast": "^0.5.2",
50
+ "obuild": "^0.4.32",
51
+ "prettier": "^3.8.1",
52
+ "typescript": "^6.0.2",
53
+ "vitest": "^4.1.2"
59
54
  },
60
55
  "peerDependencies": {
61
56
  "magicast": "*"