@@ -34,6 +34,7 @@ export type AddOn = {
3434 name : string
3535 description : string
3636 link : string
37+ templates : Array < string >
3738 main ?: Array < {
3839 imports : Array < string >
3940 initialize : Array < string >
@@ -78,6 +79,7 @@ function isDirectory(path: string): boolean {
7879
7980export async function getAllAddOns (
8081 framework : Framework ,
82+ template : string ,
8183) : Promise < Array < AddOn > > {
8284 const addOns : Array < AddOn > = [ ]
8385
@@ -95,6 +97,11 @@ export async function getAllAddOns(
9597 ) ) {
9698 const filePath = resolve ( addOnsBase , dir , 'info.json' )
9799 const fileContent = await readFile ( filePath , 'utf-8' )
100+ const info = JSON . parse ( fileContent )
101+
102+ if ( ! info . templates . includes ( template ) ) {
103+ continue
104+ }
98105
99106 let packageAdditions : Record < string , string > = { }
100107 if ( existsSync ( resolve ( addOnsBase , dir , 'package.json' ) ) ) {
@@ -109,9 +116,9 @@ export async function getAllAddOns(
109116 }
110117
111118 addOns . push ( {
119+ ...info ,
112120 id : dir ,
113121 type,
114- ...JSON . parse ( fileContent ) ,
115122 directory : resolve ( addOnsBase , dir ) ,
116123 packageAdditions,
117124 readme,
@@ -125,11 +132,12 @@ export async function getAllAddOns(
125132// Turn the list of chosen add-on IDs into a final list of add-ons by resolving dependencies
126133export async function finalizeAddOns (
127134 framework : Framework ,
135+ template : string ,
128136 chosenAddOnIDs : Array < string > ,
129137) : Promise < Array < AddOn > > {
130138 const finalAddOnIDs = new Set ( chosenAddOnIDs )
131139
132- const addOns = await getAllAddOns ( framework )
140+ const addOns = await getAllAddOns ( framework , template )
133141
134142 for ( const addOnID of finalAddOnIDs ) {
135143 const addOn = addOns . find ( ( a ) => a . id === addOnID )
0 commit comments