@@ -34,6 +34,7 @@ export type AddOn = {
34
34
name : string
35
35
description : string
36
36
link : string
37
+ templates : Array < string >
37
38
main ?: Array < {
38
39
imports : Array < string >
39
40
initialize : Array < string >
@@ -78,6 +79,7 @@ function isDirectory(path: string): boolean {
78
79
79
80
export async function getAllAddOns (
80
81
framework : Framework ,
82
+ template : string ,
81
83
) : Promise < Array < AddOn > > {
82
84
const addOns : Array < AddOn > = [ ]
83
85
@@ -95,6 +97,11 @@ export async function getAllAddOns(
95
97
) ) {
96
98
const filePath = resolve ( addOnsBase , dir , 'info.json' )
97
99
const fileContent = await readFile ( filePath , 'utf-8' )
100
+ const info = JSON . parse ( fileContent )
101
+
102
+ if ( ! info . templates . includes ( template ) ) {
103
+ continue
104
+ }
98
105
99
106
let packageAdditions : Record < string , string > = { }
100
107
if ( existsSync ( resolve ( addOnsBase , dir , 'package.json' ) ) ) {
@@ -109,9 +116,9 @@ export async function getAllAddOns(
109
116
}
110
117
111
118
addOns . push ( {
119
+ ...info ,
112
120
id : dir ,
113
121
type,
114
- ...JSON . parse ( fileContent ) ,
115
122
directory : resolve ( addOnsBase , dir ) ,
116
123
packageAdditions,
117
124
readme,
@@ -125,11 +132,12 @@ export async function getAllAddOns(
125
132
// Turn the list of chosen add-on IDs into a final list of add-ons by resolving dependencies
126
133
export async function finalizeAddOns (
127
134
framework : Framework ,
135
+ template : string ,
128
136
chosenAddOnIDs : Array < string > ,
129
137
) : Promise < Array < AddOn > > {
130
138
const finalAddOnIDs = new Set ( chosenAddOnIDs )
131
139
132
- const addOns = await getAllAddOns ( framework )
140
+ const addOns = await getAllAddOns ( framework , template )
133
141
134
142
for ( const addOnID of finalAddOnIDs ) {
135
143
const addOn = addOns . find ( ( a ) => a . id === addOnID )
0 commit comments