Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support workspace-generators and workspace-schematics #1209

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions libs/server/src/lib/utils/get-generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -57,10 +53,13 @@ async function checkAndReadWorkspaceGenerators(

async function readWorkspaceGeneratorsCollection(
basedir: string,
workspaceGeneratorsPath: string
workspaceGeneratorsPath: string,
workspaceGeneratorType: 'generators' | 'schematics'
): Promise<CollectionInfo[]> {
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(
Expand Down