c12 1.11.2 → 2.0.0-beta.2

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
@@ -32,6 +32,7 @@ c12 (pronounced as /siːtwelv/, like c-twelve) is a smart configuration loader.
32
32
  - [Automd](https://automd.unjs.io)
33
33
  - [Changelogen](https://changelogen.unjs.io)
34
34
  - [RemixKit](https://github.com/jrestall/remix-kit)
35
+ - [Hey API](https://github.com/hey-api/openapi-ts)
35
36
 
36
37
  ## Usage
37
38
 
@@ -303,7 +304,7 @@ export default {
303
304
  };
304
305
  ```
305
306
 
306
- You can pass more options to `giget: {}` in layer config.
307
+ You can pass more options to `giget: {}` in layer config or disable it by setting it to `false`.
307
308
 
308
309
  Refer to [unjs/giget](https://giget.unjs.io) for more information.
309
310
 
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const loader = require('./shared/c12.24612422.cjs');
3
+ const loader = require('./shared/c12.Cz0O13VW.cjs');
4
4
  const perfectDebounce = require('perfect-debounce');
5
5
  const pathe = require('pathe');
6
6
  const ohash = require('ohash');
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import { JITI } from 'jiti';
2
- import { JITIOptions } from 'jiti/dist/types';
1
+ import { Jiti, JitiOptions } from 'jiti';
3
2
  import { DownloadTemplateOptions } from 'giget';
4
3
  import { WatchOptions } from 'chokidar';
5
4
  import { diff } from 'ohash';
@@ -110,9 +109,9 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
110
109
  overrides?: ResolvableConfig<T>;
111
110
  omit$Keys?: boolean;
112
111
  resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
113
- jiti?: JITI;
114
- jitiOptions?: JITIOptions;
115
- giget?: DownloadTemplateOptions;
112
+ jiti?: Jiti;
113
+ jitiOptions?: JitiOptions;
114
+ giget?: false | DownloadTemplateOptions;
116
115
  merger?: (...sources: Array<T | null | undefined>) => T;
117
116
  extend?: false | {
118
117
  extendKey?: string | string[];
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { JITI } from 'jiti';
2
- import { JITIOptions } from 'jiti/dist/types';
1
+ import { Jiti, JitiOptions } from 'jiti';
3
2
  import { DownloadTemplateOptions } from 'giget';
4
3
  import { WatchOptions } from 'chokidar';
5
4
  import { diff } from 'ohash';
@@ -110,9 +109,9 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
110
109
  overrides?: ResolvableConfig<T>;
111
110
  omit$Keys?: boolean;
112
111
  resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
113
- jiti?: JITI;
114
- jitiOptions?: JITIOptions;
115
- giget?: DownloadTemplateOptions;
112
+ jiti?: Jiti;
113
+ jitiOptions?: JitiOptions;
114
+ giget?: false | DownloadTemplateOptions;
116
115
  merger?: (...sources: Array<T | null | undefined>) => T;
117
116
  extend?: false | {
118
117
  extendKey?: string | string[];
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { JITI } from 'jiti';
2
- import { JITIOptions } from 'jiti/dist/types';
1
+ import { Jiti, JitiOptions } from 'jiti';
3
2
  import { DownloadTemplateOptions } from 'giget';
4
3
  import { WatchOptions } from 'chokidar';
5
4
  import { diff } from 'ohash';
@@ -110,9 +109,9 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
110
109
  overrides?: ResolvableConfig<T>;
111
110
  omit$Keys?: boolean;
112
111
  resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
113
- jiti?: JITI;
114
- jitiOptions?: JITIOptions;
115
- giget?: DownloadTemplateOptions;
112
+ jiti?: Jiti;
113
+ jitiOptions?: JitiOptions;
114
+ giget?: false | DownloadTemplateOptions;
116
115
  merger?: (...sources: Array<T | null | undefined>) => T;
117
116
  extend?: false | {
118
117
  extendKey?: string | string[];
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { l as loadConfig, S as SUPPORTED_EXTENSIONS } from './shared/c12.cab0c9da.mjs';
2
- export { a as loadDotenv, s as setupDotenv } from './shared/c12.cab0c9da.mjs';
1
+ import { l as loadConfig, S as SUPPORTED_EXTENSIONS } from './shared/c12.cwi6FO2_.mjs';
2
+ export { a as loadDotenv, s as setupDotenv } from './shared/c12.cwi6FO2_.mjs';
3
3
  import { debounce } from 'perfect-debounce';
4
4
  import { resolve } from 'pathe';
5
5
  import { diff } from 'ohash';
@@ -4,15 +4,13 @@ const node_fs = require('node:fs');
4
4
  const promises = require('node:fs/promises');
5
5
  const node_os = require('node:os');
6
6
  const pathe = require('pathe');
7
- const createJiti = require('jiti');
7
+ const jiti = require('jiti');
8
8
  const rc9 = require('rc9');
9
9
  const defu = require('defu');
10
10
  const ohash = require('ohash');
11
11
  const pkgTypes = require('pkg-types');
12
12
  const dotenv = require('dotenv');
13
13
 
14
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
15
-
16
14
  function _interopNamespaceCompat(e) {
17
15
  if (e && typeof e === 'object' && 'default' in e) return e;
18
16
  const n = Object.create(null);
@@ -25,7 +23,6 @@ function _interopNamespaceCompat(e) {
25
23
  return n;
26
24
  }
27
25
 
28
- const createJiti__default = /*#__PURE__*/_interopDefaultCompat(createJiti);
29
26
  const rc9__namespace = /*#__PURE__*/_interopNamespaceCompat(rc9);
30
27
  const dotenv__namespace = /*#__PURE__*/_interopNamespaceCompat(dotenv);
31
28
 
@@ -138,10 +135,9 @@ async function loadConfig(options) {
138
135
  };
139
136
  }
140
137
  const _merger = options.merger || defu.defu;
141
- options.jiti = options.jiti || createJiti__default(void 0, {
138
+ options.jiti = options.jiti || jiti.createJiti(pathe.join(options.cwd, options.configFile), {
142
139
  interopDefault: true,
143
- requireCache: false,
144
- esmResolve: true,
140
+ moduleCache: false,
145
141
  extensions: [...SUPPORTED_EXTENSIONS],
146
142
  ...options.jitiOptions
147
143
  });
@@ -304,7 +300,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
304
300
  }
305
301
  }
306
302
  const _merger = options.merger || defu.defu;
307
- if (GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
303
+ if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
308
304
  const { downloadTemplate } = await import('giget');
309
305
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + ohash.hash(source);
310
306
  let cloneDir;
@@ -332,7 +328,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
332
328
  }
333
329
  const tryResolve = (id) => {
334
330
  try {
335
- return options.jiti.resolve(id, { paths: [options.cwd] });
331
+ return options.jiti.esmResolve(id, { try: true });
336
332
  } catch {
337
333
  }
338
334
  };
@@ -362,7 +358,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
362
358
  const contents = await promises.readFile(res.configFile, "utf8");
363
359
  res.config = asyncLoader(contents);
364
360
  } else {
365
- res.config = options.jiti(res.configFile);
361
+ res.config = await options.jiti.import(res.configFile);
366
362
  }
367
363
  if (res.config instanceof Function) {
368
364
  res.config = await res.config();
@@ -1,8 +1,8 @@
1
1
  import { existsSync, promises } from 'node:fs';
2
2
  import { rm, readFile } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
- import { resolve, dirname, basename, join, extname } from 'pathe';
5
- import createJiti from 'jiti';
4
+ import { resolve, join, dirname, basename, extname } from 'pathe';
5
+ import { createJiti } from 'jiti';
6
6
  import * as rc9 from 'rc9';
7
7
  import { defu } from 'defu';
8
8
  import { hash } from 'ohash';
@@ -118,10 +118,9 @@ async function loadConfig(options) {
118
118
  };
119
119
  }
120
120
  const _merger = options.merger || defu;
121
- options.jiti = options.jiti || createJiti(void 0, {
121
+ options.jiti = options.jiti || createJiti(join(options.cwd, options.configFile), {
122
122
  interopDefault: true,
123
- requireCache: false,
124
- esmResolve: true,
123
+ moduleCache: false,
125
124
  extensions: [...SUPPORTED_EXTENSIONS],
126
125
  ...options.jitiOptions
127
126
  });
@@ -284,7 +283,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
284
283
  }
285
284
  }
286
285
  const _merger = options.merger || defu;
287
- if (GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
286
+ if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
288
287
  const { downloadTemplate } = await import('giget');
289
288
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + hash(source);
290
289
  let cloneDir;
@@ -312,7 +311,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
312
311
  }
313
312
  const tryResolve = (id) => {
314
313
  try {
315
- return options.jiti.resolve(id, { paths: [options.cwd] });
314
+ return options.jiti.esmResolve(id, { try: true });
316
315
  } catch {
317
316
  }
318
317
  };
@@ -342,7 +341,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
342
341
  const contents = await readFile(res.configFile, "utf8");
343
342
  res.config = asyncLoader(contents);
344
343
  } else {
345
- res.config = options.jiti(res.configFile);
344
+ res.config = await options.jiti.import(res.configFile);
346
345
  }
347
346
  if (res.config instanceof Function) {
348
347
  res.config = await res.config();
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.24612422.cjs');
4
+ const loader = require('./shared/c12.Cz0O13VW.cjs');
5
5
  const pathe = require('pathe');
6
6
  const promises = require('node:fs/promises');
7
7
  const node_path = require('node:path');
@@ -25,6 +25,10 @@ async function updateConfig(opts) {
25
25
  `./.config/${opts.configFile}`,
26
26
  opts.cwd,
27
27
  loader.SUPPORTED_EXTENSIONS
28
+ ) || await _tryResolve(
29
+ `./.config/${opts.configFile.split(".")[0]}`,
30
+ opts.cwd,
31
+ loader.SUPPORTED_EXTENSIONS
28
32
  );
29
33
  let created = false;
30
34
  if (!configFile) {
package/dist/update.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolvePath } from 'mlly';
2
- import { S as SUPPORTED_EXTENSIONS } from './shared/c12.cab0c9da.mjs';
2
+ import { S as SUPPORTED_EXTENSIONS } from './shared/c12.cwi6FO2_.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';
@@ -23,6 +23,10 @@ async function updateConfig(opts) {
23
23
  `./.config/${opts.configFile}`,
24
24
  opts.cwd,
25
25
  SUPPORTED_EXTENSIONS
26
+ ) || await _tryResolve(
27
+ `./.config/${opts.configFile.split(".")[0]}`,
28
+ opts.cwd,
29
+ SUPPORTED_EXTENSIONS
26
30
  );
27
31
  let created = false;
28
32
  if (!configFile) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c12",
3
- "version": "1.11.2",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Smart Config Loader",
5
5
  "repository": "unjs/c12",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "lint": "eslint . && prettier -c src test",
32
32
  "lint:fix": "eslint . --fix && prettier -w src test",
33
33
  "prepack": "unbuild",
34
- "release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
34
+ "release": "pnpm build && pnpm test && changelogen --release --prerelease --push --publish --publishTag beta",
35
35
  "test": "pnpm lint && vitest run --coverage && pnpm test:types",
36
36
  "test:types": "tsc --noEmit"
37
37
  },
@@ -41,7 +41,7 @@
41
41
  "defu": "^6.1.4",
42
42
  "dotenv": "^16.4.5",
43
43
  "giget": "^1.2.3",
44
- "jiti": "^1.21.6",
44
+ "jiti": "2.0.0-beta.3",
45
45
  "mlly": "^1.7.1",
46
46
  "ohash": "^1.1.3",
47
47
  "pathe": "^1.1.2",
@@ -50,7 +50,7 @@
50
50
  "rc9": "^2.1.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/node": "^22.5.2",
53
+ "@types/node": "^20.16.3",
54
54
  "@vitest/coverage-v8": "^2.0.5",
55
55
  "automd": "^0.3.8",
56
56
  "changelogen": "^0.5.5",
@@ -60,16 +60,16 @@
60
60
  "magicast": "^0.3.5",
61
61
  "prettier": "^3.3.3",
62
62
  "typescript": "^5.5.4",
63
- "unbuild": "^2.0.0",
63
+ "unbuild": "3.0.0-rc.7",
64
64
  "vitest": "^2.0.5"
65
65
  },
66
66
  "peerDependencies": {
67
- "magicast": "^0.3.4"
67
+ "magicast": "^0.3.5"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "magicast": {
71
71
  "optional": true
72
72
  }
73
73
  },
74
- "packageManager": "pnpm@9.3.0"
74
+ "packageManager": "pnpm@9.9.0"
75
75
  }