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

cleanup(misc): clean up init generators #21088

Merged

Conversation

leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Jan 11, 2024

This PR simplifies the tasks performed by init generator in the following way:

  • Remove calls to other init generators
  • Install the minimum required dependencies needed for the plugin to work
    • Most dependencies are only needed and can be installed by the generators invoking the init generators
  • Configure the minimum required for the plugin to work
    • Most configuration changes are only needed and can be done by the generators invoking the init generators

The init generators were always internal and meant to be called by other generators to ensure the base dependencies and configuration were set up. This is changing. While they'll continue to be internal, soon they could also be invoked when running nx add and nx init. In those scenarios, we only need to initialize the minimum required for the plugin to work. We wouldn't be generating anything just yet and can't make assumptions and install/configure things that might not be needed by the workspace.

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

@leosvelperez leosvelperez self-assigned this Jan 11, 2024
Copy link

vercel bot commented Jan 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jan 15, 2024 2:29pm

@leosvelperez leosvelperez force-pushed the misc/pcv3-clean-up-init-generators branch from 70692fa to 31ab88e Compare January 15, 2024 10:58
Copy link
Member

@mandarini mandarini left a comment

Choose a reason for hiding this comment

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

Just two small comments. I'm testing this out locally and then I'll approve.

packages/vue/src/generators/init/init.ts Show resolved Hide resolved
@leosvelperez leosvelperez force-pushed the misc/pcv3-clean-up-init-generators branch from 31ab88e to 09785ce Compare January 15, 2024 14:28
Copy link
Member

@mandarini mandarini left a comment

Choose a reason for hiding this comment

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

Tested it locally:

  • generate new workspace
  • add react app
  • add vue app
  • add nuxt app
  • add storybook

All works as expected.

@jaysoo
Copy link
Member

jaysoo commented Jan 15, 2024

Added a question, the rest LGTM.

? addDependenciesToPackageJson(
const tasks: GeneratorCallback[] = [];
if (!options.skipPackageJson) {
tasks.push(removeDependenciesFromPackageJson(tree, ['@nx/eslint'], []));
Copy link
Contributor

Choose a reason for hiding this comment

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

If the purpose of removing this dependency before re-adding it was to avoid version clash if the same package is installed in dependencies and devDependencies then wouldn't we want to do the same with the other packages listed below - eslint, @nx/eslint-plugin, @typescript-eslint/*?

Copy link
Member

Choose a reason for hiding this comment

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

No, there's follow-up work to use the updated addDependenciesToPackageJson, the util PR is pending merge: #21123

Copy link
Member Author

Choose a reason for hiding this comment

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

I assume that was the reason, but I'm unsure. I just left the existing behavior for this. IMHO, we shouldn't do it for any. AFAIK, the addDependenciesToPackageJson function handles this though maybe differently. I haven't checked.

Copy link
Contributor

@meeroslav meeroslav left a comment

Choose a reason for hiding this comment

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

Left one minor comment but otherwise looks good to me.

@leosvelperez leosvelperez merged commit 047dc22 into nrwl:master Jan 16, 2024
6 checks passed
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants