c12 0.1.4 → 0.2.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
@@ -182,8 +182,8 @@ Layers:
182
182
 
183
183
  - Clone this repository
184
184
  - Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)
185
- - Install dependencies using `yarn install`
186
- - Run interactive tests using `yarn dev`
185
+ - Install dependencies using `pnpm install`
186
+ - Run interactive tests using `pnpm dev`
187
187
 
188
188
  ## License
189
189
 
package/dist/index.cjs CHANGED
@@ -130,9 +130,17 @@ async function loadConfig(opts) {
130
130
  Object.assign(configRC, rc9__namespace.read({ name: opts.rcFile, dir: opts.cwd }));
131
131
  }
132
132
  r.config = defu__default(opts.overrides, config, configRC);
133
+ const baseLayers = [
134
+ opts.overrides && { config: opts.overrides, configFile: void 0, cwd: void 0 },
135
+ { config, configFile: opts.configFile, cwd: opts.cwd },
136
+ opts.rcFile && { config: configRC, configFile: opts.rcFile }
137
+ ].filter((l) => l && l.config && Object.keys(l.config).length);
133
138
  if (opts.extend) {
134
139
  await extendConfig(r.config, opts);
135
- r.layers = r.config._layers;
140
+ r.layers = [
141
+ ...baseLayers,
142
+ ...r.config._layers
143
+ ];
136
144
  delete r.config._layers;
137
145
  r.config = defu__default(r.config, ...r.layers.map((e) => e.config));
138
146
  }
package/dist/index.d.ts CHANGED
@@ -36,11 +36,14 @@ declare function loadDotenv(opts: DotenvOptions): Promise<Env>;
36
36
 
37
37
  interface InputConfig extends Record<string, any> {
38
38
  }
39
- interface ResolvedConfig<T extends InputConfig = InputConfig> {
39
+ interface ConfigLayer<T extends InputConfig = InputConfig> {
40
40
  config: T;
41
41
  cwd?: string;
42
42
  configFile?: string;
43
- layers?: ResolvedConfig<T>[];
43
+ }
44
+ interface ResolvedConfig<T extends InputConfig = InputConfig> extends ConfigLayer<T> {
45
+ layers?: ConfigLayer<T>[];
46
+ cwd?: string;
44
47
  }
45
48
  interface ResolveConfigOptions {
46
49
  cwd: string;
@@ -61,4 +64,4 @@ interface LoadConfigOptions<T extends InputConfig = InputConfig> {
61
64
  }
62
65
  declare function loadConfig<T extends InputConfig = InputConfig>(opts: LoadConfigOptions<T>): Promise<ResolvedConfig<T>>;
63
66
 
64
- export { DotenvOptions, Env, InputConfig, LoadConfigOptions, ResolveConfigOptions, ResolvedConfig, loadConfig, loadDotenv, setupDotenv };
67
+ export { ConfigLayer, DotenvOptions, Env, InputConfig, LoadConfigOptions, ResolveConfigOptions, ResolvedConfig, loadConfig, loadDotenv, setupDotenv };
package/dist/index.mjs CHANGED
@@ -106,9 +106,17 @@ async function loadConfig(opts) {
106
106
  Object.assign(configRC, rc9.read({ name: opts.rcFile, dir: opts.cwd }));
107
107
  }
108
108
  r.config = defu(opts.overrides, config, configRC);
109
+ const baseLayers = [
110
+ opts.overrides && { config: opts.overrides, configFile: void 0, cwd: void 0 },
111
+ { config, configFile: opts.configFile, cwd: opts.cwd },
112
+ opts.rcFile && { config: configRC, configFile: opts.rcFile }
113
+ ].filter((l) => l && l.config && Object.keys(l.config).length);
109
114
  if (opts.extend) {
110
115
  await extendConfig(r.config, opts);
111
- r.layers = r.config._layers;
116
+ r.layers = [
117
+ ...baseLayers,
118
+ ...r.config._layers
119
+ ];
112
120
  delete r.config._layers;
113
121
  r.config = defu(r.config, ...r.layers.map((e) => e.config));
114
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c12",
3
- "version": "0.1.4",
3
+ "version": "0.2.2",
4
4
  "description": "Smart Config Loader",
5
5
  "repository": "unjs/c12",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "dev": "vitest dev",
24
24
  "lint": "eslint --ext .ts,.js,.mjs,.cjs .",
25
25
  "prepack": "unbuild",
26
- "release": "yarn test && standard-version && git push --follow-tags && npm publish",
26
+ "release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
27
27
  "test": "vitest run --coverage"
28
28
  },
29
29
  "dependencies": {
@@ -43,5 +43,6 @@
43
43
  "typescript": "latest",
44
44
  "unbuild": "latest",
45
45
  "vitest": "latest"
46
- }
46
+ },
47
+ "packageManager": "pnpm@6.32.3"
47
48
  }