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

feat(schematics): list schematics from extended collections #2096

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

xdissent
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

The CLI lists available schematics from custom collections by parsing the collection.json file directly. This list does not include schematics that may be available via an extends key in the collection.json. It also looks for collection.json in a fixed location, rather than supporting the schematics key of package.json.

Issue Number: N/A

What is the new behavior?

The CLI lists all available schematics (with extends support) and locates the collection.json using the schematics key of package.json. Additionally, schematic names and aliases are deduped and merged to better reflect the actual configuration that will be used by @angular-devkit/schematics: Collections using extends can overwrite extended collection schematics and re-map aliases. An alias may also override a schematic name, causing it to be effectively excluded from the collection.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Has allowing multiple schematic aliases in nest-cli been considered? I think it would make it more clear what is going on with how @angular-devkit/schematics merges schematic names and aliases. Right now there are hidden aliases defined by the schematics that can be used but not listed by the CLI.

@kamilmysliwiec
Copy link
Member

Tests seem to fail for this PR for some reason

@micalevisk
Copy link
Member

@xdissent did you got the unit tests passing in your machine? npm run test

@xdissent
Copy link
Author

Sorry, I was on vacation. Yep, they passed locally. I’ll rebase and try again soon.

@johnny9144
Copy link

johnny9144 commented Jul 23, 2023

hey, guys, thanks for working on this, this pull request not only allowed us to list properly available schematics but fixed the bug that caused the nest command failure when using a relative path of collection.json or a package that doesn't put collection.json in the project root on collection property in nest-cli.json since the original logic of getSchematics in Custom collection class didn't consider relative path either the schematics property in package.json.

I took some time to dig into why the tests failed, I don't think it was caused by the changes, it's because of the unstable test cases in test/lib/compiler/hooks/tsconfig-paths.hook.spec.ts. @kamilmysliwiec has made it skip in this commit.

so, I think we can fix the test cases simply by rebasing the master. @xdissent

@xdissent xdissent force-pushed the feat/list-extended-schematics branch from f9b4585 to a063bbd Compare December 19, 2023 12:17
@xdissent
Copy link
Author

Sorry that took so long, I started a new full-time gig right after I got back from vacation 😅

},
const workflow = new NodeWorkflow(process.cwd(), {});
const collection = workflow.engine.createCollection(this.collection);
const collectionDescs = [
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const collectionDescs = [
const collectionDescriptions = [

Copy link
Member

Choose a reason for hiding this comment

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

nit

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

Successfully merging this pull request may close these issues.

5 participants