File tree 5 files changed +51
-11
lines changed
5 files changed +51
-11
lines changed Original file line number Diff line number Diff line change @@ -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:
Original file line number Diff line number Diff line change @@ -255,7 +255,11 @@ async function resolveConfig<
255
255
if ( existsSync ( cloneDir ) ) {
256
256
await rm ( cloneDir , { recursive : true } ) ;
257
257
}
258
- const cloned = await downloadTemplate ( source , { dir : cloneDir } ) ;
258
+ const cloned = await downloadTemplate ( source , {
259
+ dir : cloneDir ,
260
+ ...options . giget ,
261
+ ...sourceOptions . giget ,
262
+ } ) ;
259
263
source = cloned . dir ;
260
264
}
261
265
Original file line number Diff line number Diff line change 1
1
import type { JITI } from "jiti" ;
2
2
import type { JITIOptions } from "jiti/dist/types" ;
3
+ import type { DownloadTemplateOptions } from "giget" ;
3
4
import type { DotenvOptions } from "./dotenv" ;
4
5
5
6
export interface ConfigLayerMeta {
@@ -30,6 +31,7 @@ export interface SourceOptions<
30
31
MT extends ConfigLayerMeta = ConfigLayerMeta ,
31
32
> {
32
33
meta ?: MT ;
34
+ giget ?: DownloadTemplateOptions ;
33
35
overrides ?: T ;
34
36
[ key : string ] : any ;
35
37
}
@@ -88,6 +90,8 @@ export interface LoadConfigOptions<
88
90
jiti ?: JITI ;
89
91
jitiOptions ?: JITIOptions ;
90
92
93
+ giget ?: DownloadTemplateOptions ;
94
+
91
95
extend ?:
92
96
| false
93
97
| {
Original file line number Diff line number Diff line change 1
1
export default {
2
2
theme : "./theme" ,
3
3
extends : [
4
- [ "c12-npm-test" , { userMeta : 123 } ] ,
5
- [ "gh:unjs/c12/test/fixture/_github#main" , { userMeta : 123 } ] ,
4
+ [ "c12-npm-test" ] ,
5
+ [ "gh:unjs/c12/test/fixture/_github#main" , { giget : { } } ] ,
6
6
] ,
7
7
$test : {
8
8
extends : [ "./config.dev" ] ,
Original file line number Diff line number Diff line change @@ -105,14 +105,11 @@ describe("c12", () => {
105
105
"./config.dev",
106
106
[
107
107
"c12-npm-test",
108
- {
109
- "userMeta": 123,
110
- },
111
108
],
112
109
[
113
110
"gh:unjs/c12/test/fixture/_github#main",
114
111
{
115
- "userMeta ": 123 ,
112
+ "giget ": {} ,
116
113
},
117
114
],
118
115
],
@@ -193,9 +190,7 @@ describe("c12", () => {
193
190
"cwd": "<path>/fixture/node_modules/c12-npm-test",
194
191
"meta": {},
195
192
"source": "<path>/fixture/node_modules/c12-npm-test/config.ts",
196
- "sourceOptions": {
197
- "userMeta": 123,
198
- },
193
+ "sourceOptions": {},
199
194
},
200
195
{
201
196
"config": {
@@ -206,7 +201,7 @@ describe("c12", () => {
206
201
"meta": {},
207
202
"source": "config",
208
203
"sourceOptions": {
209
- "userMeta ": 123 ,
204
+ "giget ": {} ,
210
205
},
211
206
},
212
207
{
You can’t perform that action at this time.
0 commit comments