From 4f89b0d6a591774308f2bae879f7c86f80e8a516 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Mon, 28 Jun 2021 13:12:59 -0400 Subject: [PATCH] fix: read and combine both schematics and generators --- .../lib/utils/read-schematic-collections.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/libs/server/src/lib/utils/read-schematic-collections.ts b/libs/server/src/lib/utils/read-schematic-collections.ts index 59e0d78f18..20924c27c2 100644 --- a/libs/server/src/lib/utils/read-schematic-collections.ts +++ b/libs/server/src/lib/utils/read-schematic-collections.ts @@ -165,17 +165,15 @@ async function readCollectionSchematics( collectionName: string, collectionJson: any ) { - const schematicCollection = { - name: collectionName, - schematics: [] as Schematic[], - }; + const generators = new Set(); + try { Object.entries( - collectionJson.schematics || collectionJson.generators + Object.assign({}, collectionJson.schematics, collectionJson.generators) ).forEach(async ([k, v]: [any, any]) => { try { if (canAdd(k, v)) { - schematicCollection.schematics.push({ + generators.add({ name: k, collection: collectionName, description: v.description || '', @@ -192,7 +190,10 @@ async function readCollectionSchematics( console.error(e); console.error(`Invalid package.json for schematic ${collectionName}`); } - return schematicCollection; + return { + name: collectionName, + schematics: Array.from(generators), + }; } export async function readSchematicOptions( @@ -211,7 +212,12 @@ export async function readSchematicOptions( collectionPackageJson.json.generators, dirname(collectionPackageJson.path) ); - const schematics = collectionJson.json.schematics || collectionJson.json.generators; + const schematics = Object.assign( + {}, + collectionJson.json.schematics, + collectionJson.json.generators + ); + const schematicSchema = readAndCacheJsonFile( schematics[schematicName].schema, dirname(collectionJson.path)