nx
nx copied to clipboard
Don't perform preset-specific actions in workspace:workspace and workspace:new generators
- [x] I'd be willing to implement this feature (contributing guide)
Description
Currently, @nrwl/workspace:workspace
and @nrwl/workspace:new
perform a number of actions based on the preset, such as modifying the nx.json, creating the apps/libs/packages directories, adding npm scripts, etc. Instead, these actions should be done in @nrwl/workspace:preset
Motivation
When creating a custom preset via the functionality provided in #8084, this would allow for a preset like core to be extended, while retaining all of its behavior. As currently implemented, create-nx-workspace
calls workspace:new
, which in turn calls workspace:workspace
, then some custom behavior, then gets the preset and runs that. This means if I ran the preset generator in core mode from my preset, it would for example use apps and libs instead of packages.
Suggested Implementation
Moving the preset-specific code from the workspace and new generators to the preset generator
Alternate Implementations
- Consolidating these three generators further, so that
create-nx-workspace
just figures out which preset generator to call (or perhaps creating a workspace with the bare minimum necessary to install the necessary generator), and then the preset generator handles everything else, delegating to composed generators. - As an end-user, not using the preset flag in create-nx-workspace with a custom preset, running it with the intended "base" preset, and then installing the custom plugin and running its preset code (likely what I'll do for now)
Agreed. Would you like to open a PR moving the functionality?
I can work on that soon - do you agree that my approach (moving just the preset-specific functionality, rather than further consolidation) is the way to go?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
I believe this is still relevant
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
Not stale
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
AFAIK still relevant
do you agree that my approach (moving just the preset-specific functionality, rather than further consolidation) is the way to go?
Yes, moving the preset-specific functionality will be the easiest way.