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: read and combine both schematics and generators #1103

Merged
merged 1 commit into from
Jun 28, 2021
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
22 changes: 14 additions & 8 deletions libs/server/src/lib/utils/read-schematic-collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,15 @@ async function readCollectionSchematics(
collectionName: string,
collectionJson: any
) {
const schematicCollection = {
name: collectionName,
schematics: [] as Schematic[],
};
const generators = new Set<Schematic>();

try {
Object.entries(
collectionJson.schematics || collectionJson.generators
Object.assign({}, collectionJson.schematics, collectionJson.generators)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to only do one or the other based on whether the workspace is an Angular workspace or a Nx one.

).forEach(async ([k, v]: [any, any]) => {
try {
if (canAdd(k, v)) {
schematicCollection.schematics.push({
generators.add({
name: k,
collection: collectionName,
description: v.description || '',
Expand All @@ -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(
Expand All @@ -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(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here. We should check if the workspace is one or the other, and only read the appropriate schemas.

{},
collectionJson.json.schematics,
collectionJson.json.generators
);

const schematicSchema = readAndCacheJsonFile(
schematics[schematicName].schema,
dirname(collectionJson.path)
Expand Down