@@ -14,14 +14,14 @@ import {
14
14
} from './package-manager.js'
15
15
import { DEFAULT_TOOLCHAIN , SUPPORTED_TOOLCHAINS } from './toolchain.js'
16
16
import { CODE_ROUTER , DEFAULT_FRAMEWORK , FILE_ROUTER } from './constants.js'
17
- import { finalizeAddOns , getAllAddOns } from './add-ons.js'
17
+ import { finalizeAddOns , getAllAddOns , loadRemoteAddOn } from './add-ons.js'
18
18
19
- import type { AddOn , CliOptions , Options , Variable } from './types.js'
19
+ import type { AddOn , CliOptions , Options , Overlay , Variable } from './types.js'
20
20
21
21
// If all CLI options are provided, use them directly
22
22
export async function normalizeOptions (
23
23
cliOptions : CliOptions ,
24
- ) : Promise < Required < Options > | undefined > {
24
+ ) : Promise < Options | undefined > {
25
25
// in some cases, if you use windows/powershell, the argument for addons
26
26
// if sepparated by comma is not really passed as an array, but as a string
27
27
// with spaces, We need to normalize this edge case.
@@ -42,14 +42,32 @@ export async function normalizeOptions(
42
42
tailwind = true
43
43
}
44
44
45
+ let mode : typeof FILE_ROUTER | typeof CODE_ROUTER =
46
+ cliOptions . template === 'file-router' ? FILE_ROUTER : CODE_ROUTER
47
+
48
+ const overlay = cliOptions . overlay
49
+ ? ( ( await loadRemoteAddOn ( cliOptions . overlay ) ) as Overlay )
50
+ : undefined
51
+
52
+ if ( overlay ) {
53
+ tailwind = overlay . tailwind
54
+ typescript = overlay . typescript
55
+ cliOptions . framework = overlay . framework
56
+ mode = overlay . mode
57
+ }
58
+
45
59
let addOns = false
46
60
let chosenAddOns : Array < AddOn > = [ ]
47
- if ( Array . isArray ( cliOptions . addOns ) ) {
61
+ if ( Array . isArray ( cliOptions . addOns ) || overlay ?. dependsOn ) {
48
62
addOns = true
63
+ let finalAddOns = [ ...( overlay ?. dependsOn || [ ] ) ]
64
+ if ( cliOptions . addOns && Array . isArray ( cliOptions . addOns ) ) {
65
+ finalAddOns = [ ...finalAddOns , ...cliOptions . addOns ]
66
+ }
49
67
chosenAddOns = await finalizeAddOns (
50
68
cliOptions . framework || DEFAULT_FRAMEWORK ,
51
69
cliOptions . template === 'file-router' ? FILE_ROUTER : CODE_ROUTER ,
52
- cliOptions . addOns ,
70
+ finalAddOns ,
53
71
)
54
72
tailwind = true
55
73
typescript = true
@@ -65,11 +83,12 @@ export async function normalizeOptions(
65
83
getPackageManager ( ) ||
66
84
DEFAULT_PACKAGE_MANAGER ,
67
85
toolchain : cliOptions . toolchain || DEFAULT_TOOLCHAIN ,
68
- mode : cliOptions . template === 'file-router' ? FILE_ROUTER : CODE_ROUTER ,
86
+ mode,
69
87
git : ! ! cliOptions . git ,
70
88
addOns,
71
89
chosenAddOns,
72
90
variableValues : { } ,
91
+ overlay,
73
92
}
74
93
}
75
94
}
0 commit comments