fix(core): change name schema order in project.json #13409
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current Behavior
The addProjectToWorkspaceJson generator utility is creating a project.json with first the schema property and afterwards the name and rest of the projectConfiguration. This works ok, but has unexpected behavior when you use another generator (for example @nrwl/angular:application) that does a formatting on the project configuration files. The 'wrongly' sorted project.json files will show as updated in the changed files list. Which is something we like to prevent in a large monorepo with multiple codeowners.
Expected Behavior
Expected behavior is that every schematic/generator and utility is generating the project.json in the same way so that generated files are formatted correctly and not show up as unrelated changes when you create a new app or lib.
Steps to Reproduce
I created a small reproduction path on nx-examples: nrwl/nx-examples#250
If you checkout this code and run
nx g @nrwl/angular:app test-app --dry-run
you will see that the output shows:UPDATE libs/cart/cart-page/project.json
which isn't expected when you generate a new app called test-app.
Solution
The solution to this issue is as simple as changing the order of the properties in the project configuration in the addProjectToWorkspaceJson utility