c12 2.0.1 → 2.0.3

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/README.md CHANGED
@@ -33,6 +33,7 @@ c12 (pronounced as /siːtwelv/, like c-twelve) is a smart configuration loader.
33
33
  - [Changelogen](https://changelogen.unjs.io)
34
34
  - [RemixKit](https://github.com/jrestall/remix-kit)
35
35
  - [Hey API](https://github.com/hey-api/openapi-ts)
36
+ - [kysely-ctl](https://github.com/kysely-org/kysely-ctl)
36
37
 
37
38
  ## Usage
38
39
 
package/dist/index.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const loader = require('./shared/c12.CLRr5qYj.cjs');
3
+ const loader = require('./shared/c12.CMG3XLfD.cjs');
4
4
  const perfectDebounce = require('perfect-debounce');
5
5
  const pathe = require('pathe');
6
- const ohash = require('ohash');
7
6
  require('node:fs');
8
7
  require('node:fs/promises');
9
8
  require('node:os');
@@ -50,6 +49,7 @@ async function watchConfig(options) {
50
49
  )
51
50
  ];
52
51
  const watch = await import('chokidar').then((r) => r.watch || r.default || r);
52
+ const { diff } = await import('ohash/utils');
53
53
  const _fswatcher = watch(watchingFiles, {
54
54
  ignoreInitial: true,
55
55
  ...options.chokidarOptions
@@ -71,7 +71,7 @@ async function watchConfig(options) {
71
71
  const changeCtx = {
72
72
  newConfig,
73
73
  oldConfig,
74
- getDiff: () => ohash.diff(oldConfig.config, config.config)
74
+ getDiff: () => diff(oldConfig.config, config.config)
75
75
  };
76
76
  if (options.acceptHMR) {
77
77
  const changeHandled = await options.acceptHMR(changeCtx);
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Jiti, JitiOptions } from 'jiti';
2
2
  import { DownloadTemplateOptions } from 'giget';
3
3
  import { ChokidarOptions } from 'chokidar';
4
- import { diff } from 'ohash';
4
+ import { diff } from 'ohash/utils';
5
5
 
6
6
  interface DotenvOptions {
7
7
  /**
@@ -123,6 +123,7 @@ declare function createDefineConfig<T extends UserInputConfig = UserInputConfig,
123
123
  declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts", ".json", ".jsonc", ".json5", ".yaml", ".yml", ".toml"];
124
124
  declare function loadConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta>(options: LoadConfigOptions<T, MT>): Promise<ResolvedConfig<T, MT>>;
125
125
 
126
+ type DiffEntries = ReturnType<typeof diff>;
126
127
  type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
127
128
  watchingFiles: string[];
128
129
  unwatch: () => Promise<void>;
@@ -135,7 +136,7 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
135
136
  path: string;
136
137
  }) => void | Promise<void>;
137
138
  acceptHMR?: (context: {
138
- getDiff: () => ReturnType<typeof diff>;
139
+ getDiff: () => DiffEntries;
139
140
  newConfig: ResolvedConfig<T, MT>;
140
141
  oldConfig: ResolvedConfig<T, MT>;
141
142
  }) => void | boolean | Promise<void | boolean>;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Jiti, JitiOptions } from 'jiti';
2
2
  import { DownloadTemplateOptions } from 'giget';
3
3
  import { ChokidarOptions } from 'chokidar';
4
- import { diff } from 'ohash';
4
+ import { diff } from 'ohash/utils';
5
5
 
6
6
  interface DotenvOptions {
7
7
  /**
@@ -123,6 +123,7 @@ declare function createDefineConfig<T extends UserInputConfig = UserInputConfig,
123
123
  declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts", ".json", ".jsonc", ".json5", ".yaml", ".yml", ".toml"];
124
124
  declare function loadConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta>(options: LoadConfigOptions<T, MT>): Promise<ResolvedConfig<T, MT>>;
125
125
 
126
+ type DiffEntries = ReturnType<typeof diff>;
126
127
  type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
127
128
  watchingFiles: string[];
128
129
  unwatch: () => Promise<void>;
@@ -135,7 +136,7 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
135
136
  path: string;
136
137
  }) => void | Promise<void>;
137
138
  acceptHMR?: (context: {
138
- getDiff: () => ReturnType<typeof diff>;
139
+ getDiff: () => DiffEntries;
139
140
  newConfig: ResolvedConfig<T, MT>;
140
141
  oldConfig: ResolvedConfig<T, MT>;
141
142
  }) => void | boolean | Promise<void | boolean>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Jiti, JitiOptions } from 'jiti';
2
2
  import { DownloadTemplateOptions } from 'giget';
3
3
  import { ChokidarOptions } from 'chokidar';
4
- import { diff } from 'ohash';
4
+ import { diff } from 'ohash/utils';
5
5
 
6
6
  interface DotenvOptions {
7
7
  /**
@@ -123,6 +123,7 @@ declare function createDefineConfig<T extends UserInputConfig = UserInputConfig,
123
123
  declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts", ".json", ".jsonc", ".json5", ".yaml", ".yml", ".toml"];
124
124
  declare function loadConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta>(options: LoadConfigOptions<T, MT>): Promise<ResolvedConfig<T, MT>>;
125
125
 
126
+ type DiffEntries = ReturnType<typeof diff>;
126
127
  type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
127
128
  watchingFiles: string[];
128
129
  unwatch: () => Promise<void>;
@@ -135,7 +136,7 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
135
136
  path: string;
136
137
  }) => void | Promise<void>;
137
138
  acceptHMR?: (context: {
138
- getDiff: () => ReturnType<typeof diff>;
139
+ getDiff: () => DiffEntries;
139
140
  newConfig: ResolvedConfig<T, MT>;
140
141
  oldConfig: ResolvedConfig<T, MT>;
141
142
  }) => void | boolean | Promise<void | boolean>;
package/dist/index.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import { l as loadConfig, S as SUPPORTED_EXTENSIONS } from './shared/c12.B4fc1S0C.mjs';
2
- export { a as loadDotenv, s as setupDotenv } from './shared/c12.B4fc1S0C.mjs';
1
+ import { l as loadConfig, S as SUPPORTED_EXTENSIONS } from './shared/c12.PQMoYrit.mjs';
2
+ export { a as loadDotenv, s as setupDotenv } from './shared/c12.PQMoYrit.mjs';
3
3
  import { debounce } from 'perfect-debounce';
4
4
  import { resolve } from 'pathe';
5
- import { diff } from 'ohash';
6
5
  import 'node:fs';
7
6
  import 'node:fs/promises';
8
7
  import 'node:os';
@@ -49,6 +48,7 @@ async function watchConfig(options) {
49
48
  )
50
49
  ];
51
50
  const watch = await import('chokidar').then((r) => r.watch || r.default || r);
51
+ const { diff } = await import('ohash/utils');
52
52
  const _fswatcher = watch(watchingFiles, {
53
53
  ignoreInitial: true,
54
54
  ...options.chokidarOptions
@@ -8,7 +8,6 @@ const jiti = require('jiti');
8
8
  const mlly = require('mlly');
9
9
  const rc9 = require('rc9');
10
10
  const defu = require('defu');
11
- const ohash = require('ohash');
12
11
  const pkgTypes = require('pkg-types');
13
12
  const dotenv = require('dotenv');
14
13
 
@@ -166,6 +165,9 @@ async function loadConfig(options) {
166
165
  _configs.main = _mainConfig.config;
167
166
  r.configFile = _mainConfig.configFile;
168
167
  }
168
+ if (_mainConfig.meta) {
169
+ r.meta = _mainConfig.meta;
170
+ }
169
171
  if (options.rcFile) {
170
172
  const rcSources = [];
171
173
  rcSources.push(rc9__namespace.read({ name: options.rcFile, dir: options.cwd }));
@@ -303,7 +305,8 @@ async function resolveConfig(source, options, sourceOptions = {}) {
303
305
  const _merger = options.merger || defu.defu;
304
306
  if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
305
307
  const { downloadTemplate } = await import('giget');
306
- const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + ohash.hash(source);
308
+ const { digest } = await import('ohash');
309
+ const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
307
310
  let cloneDir;
308
311
  const localNodeModules = pathe.resolve(options.cwd, "node_modules");
309
312
  const parentDir = pathe.dirname(options.cwd);
@@ -6,7 +6,6 @@ import { createJiti } from 'jiti';
6
6
  import { fileURLToPath } from 'mlly';
7
7
  import * as rc9 from 'rc9';
8
8
  import { defu } from 'defu';
9
- import { hash } from 'ohash';
10
9
  import { findWorkspaceDir, readPackageJSON } from 'pkg-types';
11
10
  import * as dotenv from 'dotenv';
12
11
 
@@ -149,6 +148,9 @@ async function loadConfig(options) {
149
148
  _configs.main = _mainConfig.config;
150
149
  r.configFile = _mainConfig.configFile;
151
150
  }
151
+ if (_mainConfig.meta) {
152
+ r.meta = _mainConfig.meta;
153
+ }
152
154
  if (options.rcFile) {
153
155
  const rcSources = [];
154
156
  rcSources.push(rc9.read({ name: options.rcFile, dir: options.cwd }));
@@ -286,7 +288,8 @@ async function resolveConfig(source, options, sourceOptions = {}) {
286
288
  const _merger = options.merger || defu;
287
289
  if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
288
290
  const { downloadTemplate } = await import('giget');
289
- const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + hash(source);
291
+ const { digest } = await import('ohash');
292
+ const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
290
293
  let cloneDir;
291
294
  const localNodeModules = resolve(options.cwd, "node_modules");
292
295
  const parentDir = dirname(options.cwd);
package/dist/update.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const mlly = require('mlly');
4
- const loader = require('./shared/c12.CLRr5qYj.cjs');
4
+ const loader = require('./shared/c12.CMG3XLfD.cjs');
5
5
  const pathe = require('pathe');
6
6
  const promises = require('node:fs/promises');
7
7
  const node_path = require('node:path');
@@ -10,7 +10,6 @@ require('node:os');
10
10
  require('jiti');
11
11
  require('rc9');
12
12
  require('defu');
13
- require('ohash');
14
13
  require('pkg-types');
15
14
  require('dotenv');
16
15
 
package/dist/update.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolvePath } from 'mlly';
2
- import { S as SUPPORTED_EXTENSIONS } from './shared/c12.B4fc1S0C.mjs';
2
+ import { S as SUPPORTED_EXTENSIONS } from './shared/c12.PQMoYrit.mjs';
3
3
  import { join } from 'pathe';
4
4
  import { mkdir, writeFile, readFile } from 'node:fs/promises';
5
5
  import { dirname, extname } from 'node:path';
@@ -8,7 +8,6 @@ import 'node:os';
8
8
  import 'jiti';
9
9
  import 'rc9';
10
10
  import 'defu';
11
- import 'ohash';
12
11
  import 'pkg-types';
13
12
  import 'dotenv';
14
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c12",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Smart Config Loader",
5
5
  "repository": "unjs/c12",
6
6
  "license": "MIT",
@@ -8,14 +8,24 @@
8
8
  "type": "module",
9
9
  "exports": {
10
10
  ".": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.cjs",
13
- "types": "./dist/index.d.ts"
11
+ "import": {
12
+ "types": "./dist/index.d.mts",
13
+ "default:": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default:": "./dist/index.cjs"
18
+ }
14
19
  },
15
20
  "./update": {
16
- "import": "./dist/update.mjs",
17
- "require": "./dist/update.cjs",
18
- "types": "./dist/update.d.ts"
21
+ "import": {
22
+ "types": "./dist/update.d.mts",
23
+ "default:": "./dist/update.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/update.d.cts",
27
+ "default:": "./dist/update.cjs"
28
+ }
19
29
  }
20
30
  },
21
31
  "main": "./dist/index.cjs",
@@ -36,32 +46,32 @@
36
46
  "test:types": "tsc --noEmit"
37
47
  },
38
48
  "dependencies": {
39
- "chokidar": "^4.0.1",
40
- "confbox": "^0.1.7",
49
+ "chokidar": "^4.0.3",
50
+ "confbox": "^0.1.8",
41
51
  "defu": "^6.1.4",
42
- "dotenv": "^16.4.5",
43
- "giget": "^1.2.3",
44
- "jiti": "^2.3.0",
45
- "mlly": "^1.7.1",
46
- "ohash": "^1.1.4",
47
- "pathe": "^1.1.2",
52
+ "dotenv": "^16.4.7",
53
+ "giget": "^1.2.4",
54
+ "jiti": "^2.4.2",
55
+ "mlly": "^1.7.4",
56
+ "ohash": "^2.0.4",
57
+ "pathe": "^2.0.3",
48
58
  "perfect-debounce": "^1.0.0",
49
- "pkg-types": "^1.2.0",
59
+ "pkg-types": "^1.3.1",
50
60
  "rc9": "^2.1.2"
51
61
  },
52
62
  "devDependencies": {
53
- "@types/node": "^22.7.4",
54
- "@vitest/coverage-v8": "^2.1.2",
55
- "automd": "^0.3.10",
63
+ "@types/node": "^22.13.4",
64
+ "@vitest/coverage-v8": "^3.0.6",
65
+ "automd": "^0.3.12",
56
66
  "changelogen": "^0.5.7",
57
- "eslint": "^9.12.0",
58
- "eslint-config-unjs": "^0.4.1",
59
- "expect-type": "^1.0.0",
67
+ "eslint": "^9.20.1",
68
+ "eslint-config-unjs": "^0.4.2",
69
+ "expect-type": "^1.1.0",
60
70
  "magicast": "^0.3.5",
61
- "prettier": "^3.3.3",
62
- "typescript": "^5.6.2",
63
- "unbuild": "3.0.0-rc.8",
64
- "vitest": "^2.1.2"
71
+ "prettier": "^3.5.1",
72
+ "typescript": "^5.7.3",
73
+ "unbuild": "^3.3.1",
74
+ "vitest": "^3.0.6"
65
75
  },
66
76
  "peerDependencies": {
67
77
  "magicast": "^0.3.5"
@@ -71,5 +81,5 @@
71
81
  "optional": true
72
82
  }
73
83
  },
74
- "packageManager": "pnpm@9.11.0"
84
+ "packageManager": "pnpm@10.4.1"
75
85
  }