From a086a87ab013ef8aeee29f47f689870af9d988aa Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Fri, 7 Jan 2022 16:08:10 -0500 Subject: [PATCH] fix: support workspace-generators and workspace-schematics --- libs/server/src/lib/utils/get-generators.ts | 23 ++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libs/server/src/lib/utils/get-generators.ts b/libs/server/src/lib/utils/get-generators.ts index 3df891a3d5..7a87c58b1f 100644 --- a/libs/server/src/lib/utils/get-generators.ts +++ b/libs/server/src/lib/utils/get-generators.ts @@ -27,14 +27,8 @@ export async function getGenerators( generatorCollections = [ ...generatorCollections, - ...(await checkAndReadWorkspaceGenerators( - basedir, - join('tools', 'schematics') - )), - ...(await checkAndReadWorkspaceGenerators( - basedir, - join('tools', 'generators') - )), + ...(await checkAndReadWorkspaceGenerators(basedir, 'schematics')), + ...(await checkAndReadWorkspaceGenerators(basedir, 'generators')), ]; return generatorCollections.filter( (collection): collection is CollectionInfo => !!collection.data @@ -43,12 +37,14 @@ export async function getGenerators( async function checkAndReadWorkspaceGenerators( basedir: string, - workspaceGeneratorsPath: string + workspaceGeneratorType: 'generators' | 'schematics' ) { + const workspaceGeneratorsPath = join('tools', workspaceGeneratorType); if (await directoryExists(join(basedir, workspaceGeneratorsPath))) { const collection = await readWorkspaceGeneratorsCollection( basedir, - workspaceGeneratorsPath + workspaceGeneratorsPath, + workspaceGeneratorType ); return collection; } @@ -57,10 +53,13 @@ async function checkAndReadWorkspaceGenerators( async function readWorkspaceGeneratorsCollection( basedir: string, - workspaceGeneratorsPath: string + workspaceGeneratorsPath: string, + workspaceGeneratorType: 'generators' | 'schematics' ): Promise { const collectionDir = join(basedir, workspaceGeneratorsPath); - const collectionName = 'workspace-generator'; + const collectionName = `workspace-${ + workspaceGeneratorType === 'generators' ? 'generator' : 'schematic' + }`; const collectionPath = join(collectionDir, 'collection.json'); if (await fileExists(collectionPath)) { const collection = await readAndCacheJsonFile(