-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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): add entity generation as part of feature schematic #3850
Conversation
✅ Deploy Preview for ngrx-io ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
@timdeschryver I've refactored my local branch based on your recommendations - that turned out to be a much simpler change to the code base than my initial commits. Before I push my changes, I wanted to get your workflow preference: There were enough changes between my commits and the v16 release (congrats!) that I ran |
Thanks in advance @wgd3. |
commit f8407f5be9e4f2f9106957d625475fd0e6bdf403 Author: wgd3 <[email protected]> Date: Wed May 10 11:17:24 2023 -0400 added pluralization to entity actions where necessary commit 757ccfe06178ce566afcf64f9ba0515248369d80 Author: wgd3 <[email protected]> Date: Wed May 10 11:00:48 2023 -0400 updated tests to reflect files generated commit e7879737616660d693506b4ab3d7c88c90a39016 Author: wgd3 <[email protected]> Date: Wed May 10 10:36:38 2023 -0400 removed selectors schematic from feature entity, duplicate effort commit a8d8e1d426704a60e0fe154fe85bed6830b9fe3e Author: wgd3 <[email protected]> Date: Wed May 10 10:33:02 2023 -0400 got entity generation working without clobbering files
With the new snapshots in place, I rebased and ran the tests for this PR again. One of the first things caught in the pipeline: - 'Add Foos': props<{ foo: Foo[] }>(),
+ 'Add Foos': props<{ foos: Foo[] }>(),
- 'Upsert Foos': props<{ foo: Foo[] }>(),
+ 'Upsert Foos': props<{ foos: Foo[] }>(), This came from a change in the actions template of the Entity schematic that I made in one of the older commits. I reverted that with 87b34e9. The other test/snapshot failure was that the order of imports had changed in the generated code for Entity: - StoreModule.forFeature(fromFoo.fooFeatureKey, fromFoo.reducer),
- EffectsModule.forFeature([FooEffects])
+ EffectsModule.forFeature([FooEffects]),
+ StoreModule.forFeature(fromFoo.fooFeatureKey, fromFoo.reducer) This was remedied in 0460889 by changing the order in which schematics are run as part of the Feature schematic. Please let me know if you have any other feedback! |
@@ -269,4 +271,40 @@ describe('Feature Schematic', () => { | |||
|
|||
expect(fileContent).toMatchSnapshot(); | |||
}); | |||
|
|||
it('should create all files of a feature with an entity', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we use snapshot tests for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I forgot about this.
Thanks for the rebase, this gives the confidence that the current implementation is still working for the other configs.
As @brandonroberts mentioned, I agree that including snapshots for the generated files is helpfull.
@timdeschryver I've removed the Actions spec file as well as the Selector/Selector spec files from the code in your commit. The Entity schematic doesn't have templates for any of these files at the moment. You mentioned that we should let the Entity schematic handle these things for now. If you/the team would prefer that selectors be generated as well, I can update the Feature schematic to run the Selector schematic every time. Snapshots have been updated! |
export const { | ||
selectIds, | ||
selectEntities, | ||
selectAll, | ||
selectTotal, | ||
} = foosFeature; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timdeschryver I've removed the Actions spec file as well as the Selector/Selector spec files from the code in your commit. The Entity schematic doesn't have templates for any of these files at the moment.
You mentioned that we should let the Entity schematic handle these things for now. If you/the team would prefer that selectors be generated as well, I can update the Feature schematic to run the Selector schematic every time.
Snapshots have been updated!
The selectors are already included within this feature file.
If I'm missing something feel free to correct me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the updates @wgd3 !
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
If a user wishes to create an entity as part of a new feature state, they must run multiple commands:
Closes #3260
What is the new behavior?
Users can now optionally generate an entity when running the
feature
schematic:Does this PR introduce a breaking change?
Other information
This functionality does not allow for custom entity names - instead, a boolean is passed to the
feature
schematic. If this needs to be changed I'm happy to update this PR allowing for custom entity names.