c12 1.5.0 → 1.5.1
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 +37 -0
- package/dist/index.cjs +5 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +5 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -123,6 +123,10 @@ Custom [unjs/jiti](https://github.com/unjs/jiti) instance used to import configu
|
|
|
123
123
|
|
|
124
124
|
Custom [unjs/jiti](https://github.com/unjs/jiti) options to import configuration files.
|
|
125
125
|
|
|
126
|
+
### `giget`
|
|
127
|
+
|
|
128
|
+
Options passed to [unjs/giget](https://github.com/unjs/giget) when extending layer from git source.
|
|
129
|
+
|
|
126
130
|
### `envName`
|
|
127
131
|
|
|
128
132
|
Environment name used for [environment specific configuration](#environment-specific-configuration).
|
|
@@ -205,6 +209,39 @@ Layers:
|
|
|
205
209
|
]
|
|
206
210
|
```
|
|
207
211
|
|
|
212
|
+
## Extending Config Layer from Remote Sources
|
|
213
|
+
|
|
214
|
+
You can also extend configuration from remote sources such as npm or github.
|
|
215
|
+
|
|
216
|
+
In the repo, there should be a `config.ts` (or `config.{name}.ts`) file to be considered as a valid config layer.
|
|
217
|
+
|
|
218
|
+
**Example:** Extend from a github repository
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
// config.ts
|
|
222
|
+
export default {
|
|
223
|
+
extends: "gh:repo/owner",
|
|
224
|
+
};
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Example:** Extend from a github repository with branch and subpath
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
// config.ts
|
|
231
|
+
export default {
|
|
232
|
+
extends: "gh:repo/owner/theme#dev",
|
|
233
|
+
};
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Example:** Extend with custom configuration ([giget](https://github.com/unjs/giget) options)
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
// config.ts
|
|
240
|
+
export default {
|
|
241
|
+
extends: ["gh:repo/owner", { giget: { auth: process.env.GITHUB_TOKEN } }],
|
|
242
|
+
};
|
|
243
|
+
```
|
|
244
|
+
|
|
208
245
|
## Environment-specific configuration
|
|
209
246
|
|
|
210
247
|
Users can define environment-specific configuration using these config keys:
|
package/dist/index.cjs
CHANGED
|
@@ -271,7 +271,11 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
271
271
|
if (node_fs.existsSync(cloneDir)) {
|
|
272
272
|
await promises.rm(cloneDir, { recursive: true });
|
|
273
273
|
}
|
|
274
|
-
const cloned = await downloadTemplate(source, {
|
|
274
|
+
const cloned = await downloadTemplate(source, {
|
|
275
|
+
dir: cloneDir,
|
|
276
|
+
...options.giget,
|
|
277
|
+
...sourceOptions.giget
|
|
278
|
+
});
|
|
275
279
|
source = cloned.dir;
|
|
276
280
|
}
|
|
277
281
|
if (NPM_PACKAGE_RE.test(source)) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JITI } from 'jiti';
|
|
2
2
|
import { JITIOptions } from 'jiti/dist/types';
|
|
3
|
+
import { DownloadTemplateOptions } from 'giget';
|
|
3
4
|
import { WatchOptions } from 'chokidar';
|
|
4
5
|
import { diff } from 'ohash';
|
|
5
6
|
|
|
@@ -54,6 +55,7 @@ interface C12InputConfig<T extends UserInputConfig = UserInputConfig, MT extends
|
|
|
54
55
|
type InputConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = C12InputConfig<T, MT> & T;
|
|
55
56
|
interface SourceOptions<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> {
|
|
56
57
|
meta?: MT;
|
|
58
|
+
giget?: DownloadTemplateOptions;
|
|
57
59
|
overrides?: T;
|
|
58
60
|
[key: string]: any;
|
|
59
61
|
}
|
|
@@ -84,6 +86,7 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
|
|
|
84
86
|
resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
|
|
85
87
|
jiti?: JITI;
|
|
86
88
|
jitiOptions?: JITIOptions;
|
|
89
|
+
giget?: DownloadTemplateOptions;
|
|
87
90
|
extend?: false | {
|
|
88
91
|
extendKey?: string | string[];
|
|
89
92
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JITI } from 'jiti';
|
|
2
2
|
import { JITIOptions } from 'jiti/dist/types';
|
|
3
|
+
import { DownloadTemplateOptions } from 'giget';
|
|
3
4
|
import { WatchOptions } from 'chokidar';
|
|
4
5
|
import { diff } from 'ohash';
|
|
5
6
|
|
|
@@ -54,6 +55,7 @@ interface C12InputConfig<T extends UserInputConfig = UserInputConfig, MT extends
|
|
|
54
55
|
type InputConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = C12InputConfig<T, MT> & T;
|
|
55
56
|
interface SourceOptions<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> {
|
|
56
57
|
meta?: MT;
|
|
58
|
+
giget?: DownloadTemplateOptions;
|
|
57
59
|
overrides?: T;
|
|
58
60
|
[key: string]: any;
|
|
59
61
|
}
|
|
@@ -84,6 +86,7 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
|
|
|
84
86
|
resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
|
|
85
87
|
jiti?: JITI;
|
|
86
88
|
jitiOptions?: JITIOptions;
|
|
89
|
+
giget?: DownloadTemplateOptions;
|
|
87
90
|
extend?: false | {
|
|
88
91
|
extendKey?: string | string[];
|
|
89
92
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JITI } from 'jiti';
|
|
2
2
|
import { JITIOptions } from 'jiti/dist/types';
|
|
3
|
+
import { DownloadTemplateOptions } from 'giget';
|
|
3
4
|
import { WatchOptions } from 'chokidar';
|
|
4
5
|
import { diff } from 'ohash';
|
|
5
6
|
|
|
@@ -54,6 +55,7 @@ interface C12InputConfig<T extends UserInputConfig = UserInputConfig, MT extends
|
|
|
54
55
|
type InputConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = C12InputConfig<T, MT> & T;
|
|
55
56
|
interface SourceOptions<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> {
|
|
56
57
|
meta?: MT;
|
|
58
|
+
giget?: DownloadTemplateOptions;
|
|
57
59
|
overrides?: T;
|
|
58
60
|
[key: string]: any;
|
|
59
61
|
}
|
|
@@ -84,6 +86,7 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
|
|
|
84
86
|
resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
|
|
85
87
|
jiti?: JITI;
|
|
86
88
|
jitiOptions?: JITIOptions;
|
|
89
|
+
giget?: DownloadTemplateOptions;
|
|
87
90
|
extend?: false | {
|
|
88
91
|
extendKey?: string | string[];
|
|
89
92
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -251,7 +251,11 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
251
251
|
if (existsSync(cloneDir)) {
|
|
252
252
|
await rm(cloneDir, { recursive: true });
|
|
253
253
|
}
|
|
254
|
-
const cloned = await downloadTemplate(source, {
|
|
254
|
+
const cloned = await downloadTemplate(source, {
|
|
255
|
+
dir: cloneDir,
|
|
256
|
+
...options.giget,
|
|
257
|
+
...sourceOptions.giget
|
|
258
|
+
});
|
|
255
259
|
source = cloned.dir;
|
|
256
260
|
}
|
|
257
261
|
if (NPM_PACKAGE_RE.test(source)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c12",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Smart Config Loader",
|
|
5
5
|
"repository": "unjs/c12",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lint": "eslint --ext .ts,.js,.mjs,.cjs . && prettier -c src test",
|
|
26
26
|
"lint:fix": "eslint --ext .ts,.js,.mjs,.cjs . --fix && prettier -w src test",
|
|
27
27
|
"prepack": "unbuild",
|
|
28
|
-
"release": "changelogen --release && npm publish && git push --follow-tags",
|
|
28
|
+
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
|
|
29
29
|
"test": "pnpm lint && vitest run --coverage && pnpm test:types",
|
|
30
30
|
"test:types": "tsc --noEmit"
|
|
31
31
|
},
|