c12 2.0.0-beta.1 → 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
@@ -304,7 +304,7 @@ export default {
304
304
  };
305
305
  ```
306
306
 
307
- 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`.
308
308
 
309
309
  Refer to [unjs/giget](https://giget.unjs.io) for more information.
310
310
 
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const loader = require('./shared/c12.CkVjnBFL.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
@@ -111,7 +111,7 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
111
111
  resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
112
112
  jiti?: Jiti;
113
113
  jitiOptions?: JitiOptions;
114
- giget?: DownloadTemplateOptions;
114
+ giget?: false | DownloadTemplateOptions;
115
115
  merger?: (...sources: Array<T | null | undefined>) => T;
116
116
  extend?: false | {
117
117
  extendKey?: string | string[];
package/dist/index.d.mts CHANGED
@@ -111,7 +111,7 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
111
111
  resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
112
112
  jiti?: Jiti;
113
113
  jitiOptions?: JitiOptions;
114
- giget?: DownloadTemplateOptions;
114
+ giget?: false | DownloadTemplateOptions;
115
115
  merger?: (...sources: Array<T | null | undefined>) => T;
116
116
  extend?: false | {
117
117
  extendKey?: string | string[];
package/dist/index.d.ts CHANGED
@@ -111,7 +111,7 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
111
111
  resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
112
112
  jiti?: Jiti;
113
113
  jitiOptions?: JitiOptions;
114
- giget?: DownloadTemplateOptions;
114
+ giget?: false | DownloadTemplateOptions;
115
115
  merger?: (...sources: Array<T | null | undefined>) => T;
116
116
  extend?: false | {
117
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.72yV1YOl.mjs';
2
- export { a as loadDotenv, s as setupDotenv } from './shared/c12.72yV1YOl.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';
@@ -300,7 +300,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
300
300
  }
301
301
  }
302
302
  const _merger = options.merger || defu.defu;
303
- if (GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
303
+ if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
304
304
  const { downloadTemplate } = await import('giget');
305
305
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + ohash.hash(source);
306
306
  let cloneDir;
@@ -283,7 +283,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
283
283
  }
284
284
  }
285
285
  const _merger = options.merger || defu;
286
- if (GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
286
+ if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
287
287
  const { downloadTemplate } = await import('giget');
288
288
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + hash(source);
289
289
  let cloneDir;
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.CkVjnBFL.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) {
@@ -64,7 +68,7 @@ async function updateConfig(opts) {
64
68
  }
65
69
  function _tryResolve(path, cwd, exts) {
66
70
  return mlly.resolvePath(path, {
67
- url: cwd,
71
+ url: pathe.join(cwd, "_index.js"),
68
72
  extensions: exts
69
73
  }).catch(() => void 0);
70
74
  }
package/dist/update.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolvePath } from 'mlly';
2
- import { S as SUPPORTED_EXTENSIONS } from './shared/c12.72yV1YOl.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) {
@@ -62,7 +66,7 @@ async function updateConfig(opts) {
62
66
  }
63
67
  function _tryResolve(path, cwd, exts) {
64
68
  return resolvePath(path, {
65
- url: cwd,
69
+ url: join(cwd, "_index.js"),
66
70
  extensions: exts
67
71
  }).catch(() => void 0);
68
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c12",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Smart Config Loader",
5
5
  "repository": "unjs/c12",
6
6
  "license": "MIT",
@@ -41,35 +41,35 @@
41
41
  "defu": "^6.1.4",
42
42
  "dotenv": "^16.4.5",
43
43
  "giget": "^1.2.3",
44
- "jiti": "^2.0.0-beta.3",
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",
48
48
  "perfect-debounce": "^1.0.0",
49
- "pkg-types": "^1.1.2",
49
+ "pkg-types": "^1.2.0",
50
50
  "rc9": "^2.1.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/node": "^20.14.9",
54
- "@vitest/coverage-v8": "^1.6.0",
55
- "automd": "^0.3.7",
53
+ "@types/node": "^20.16.3",
54
+ "@vitest/coverage-v8": "^2.0.5",
55
+ "automd": "^0.3.8",
56
56
  "changelogen": "^0.5.5",
57
- "eslint": "^9.6.0",
57
+ "eslint": "^9.9.1",
58
58
  "eslint-config-unjs": "^0.3.2",
59
- "expect-type": "^0.19.0",
60
- "magicast": "^0.3.4",
61
- "prettier": "^3.3.2",
62
- "typescript": "^5.5.3",
63
- "unbuild": "^3.0.0-rc.3",
64
- "vitest": "^1.6.0"
59
+ "expect-type": "^0.20.0",
60
+ "magicast": "^0.3.5",
61
+ "prettier": "^3.3.3",
62
+ "typescript": "^5.5.4",
63
+ "unbuild": "3.0.0-rc.7",
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.4.0"
74
+ "packageManager": "pnpm@9.9.0"
75
75
  }