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

generate --help ignores custom collections #1433

Closed
1 task done
micalevisk opened this issue Nov 30, 2021 · 1 comment · Fixed by #1434
Closed
1 task done

generate --help ignores custom collections #1433

micalevisk opened this issue Nov 30, 2021 · 1 comment · Fixed by #1434

Comments

@micalevisk
Copy link
Member

micalevisk commented Nov 30, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

nest generate --help always outputs this:

image

(a list of available schematics) even when the schematics from @nestjs/schematics aren't available. For instance, using a custom collection

$  cat nest-cli.json 
{
  "collection": "../my-collection-that-doesnt-extends-nestjs-schematics",
  "sourceRoot": "src"
}

then we can't run, for instance, nest generate application

image


basically this is due to the following:

private buildDescription(): string {
return (
'Generate a Nest element.\n' +
' Available schematics:\n' +
this.buildSchematicsListAsTable()
);
}

for (const schematic of NestCollection.getSchematics()) {

public static getSchematics(): Schematic[] {
return NestCollection.schematics.filter(
(item) => item.name !== 'angular-app',
);
}

which doesn't take in count the collection option from nest-cli.json config file

Expected behavior

nest generate --help should list the schematics available in the loaded collection

But I see three problems here:

  • can we fetch all schematics available of a collection programmatically?
  • the config file must be parsed every time someone uses --help, to retrieve the collection name. Which I think will degraded DX (without thinking of caching things around)
  • I don't think we can load the value of --collection option on GenerateCommand#buildDescription method

So, looks like listing the right set of schematics is not possible.

Then what we could do is indicate that the table lists schematics from the collection @nestjs/schematics, not just "Available schematics". This should avoid misusages of NestJS's CLI. Maybe "Schematics available on @nestjs/schematics collection" will be enough?

Package version

8.1.5

NestJS version

8.2.3

@micalevisk micalevisk changed the title generate --help ignore custom collections generate --help ignores custom collections Dec 1, 2021
@kamilmysliwiec
Copy link
Member

Then what we could do is indicate that the table lists schematics from the collection @nestjs/schematics, not just "Available schematics". This should avoid misusages of NestJS's CLI. Maybe "Schematics available on @nestjs/schematics collection" will be enough?

Sounds good! Would you like to create a PR for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants