nx icon indicating copy to clipboard operation
nx copied to clipboard

Don't perform preset-specific actions in workspace:workspace and workspace:new generators

Open luxaritas opened this issue 3 years ago โ€ข 6 comments

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)

luxaritas avatar Feb 09 '22 19:02 luxaritas

Agreed. Would you like to open a PR moving the functionality?

FrozenPandaz avatar Feb 14 '22 23:02 FrozenPandaz

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?

luxaritas avatar Feb 15 '22 01:02 luxaritas

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! ๐Ÿ™

github-actions[bot] avatar Oct 24 '22 00:10 github-actions[bot]

I believe this is still relevant

luxaritas avatar Oct 24 '22 00:10 luxaritas

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! ๐Ÿ™

github-actions[bot] avatar Jul 03 '23 00:07 github-actions[bot]

Not stale

luxaritas avatar Jul 03 '23 20:07 luxaritas

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! ๐Ÿ™

github-actions[bot] avatar Mar 11 '24 00:03 github-actions[bot]

AFAIK still relevant

luxaritas avatar Mar 13 '24 19:03 luxaritas

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.

FrozenPandaz avatar Apr 02 '24 19:04 FrozenPandaz