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

fix(core): propagate verbose flag when running init generator dur… #21868

Merged
merged 1 commit into from Feb 19, 2024

Conversation

tinesoft
Copy link
Contributor

…ing nx add command

Current Behavior

When using the new nx add <plugin> to install a plugin (as devDependencies) and initializes it (if a init generator exists),
any raw error thrown when calling that generator, is not sent back to user, even if the --verbose flag is provided to the nx add command.

Instead, a generic and not so useful " > NX Failed to initialize @nxrocks/nx-spring-boot. Please check the error above for more details." is displayed...

Here is an example:

$ npx nx add @nxrocks/nx-spring-boot@latest --verbose

✔ Installing @nxrocks/nx-spring-boot@latest...
✖ Initializing @nxrocks/nx-spring-boot...

Command failed: npx nx g @nxrocks/nx-spring-boot:project --keepExistingVersions


 >  NX   Failed to initialize @nxrocks/nx-spring-boot. Please check the error above for more details.

After manually tweaking the @node_modules/nx/src/command-line/add/add.js file, to consider the --verbose flag, I managed to get more helpful insight about the actual underlying error that occurred in my init generator (here, the generator was expecting a required "name" option that was, of course, not provided)

Here is output, when that flag was considered:

AzureAD+TineKondo@LAVA-1T8QJS3 MINGW64 /d/Workspace/git/nx18 (main)
$ npx nx add @nxrocks/nx-spring-boot@latest --verbose

✔ Installing @nxrocks/nx-spring-boot@latest...
⠹ Initializing @nxrocks/nx-spring-boot...
>  NX  Generating @nxrocks/nx-spring-boot:project


 >  NX   Required property 'name' is missing


✖ Initializing @nxrocks/nx-spring-boot...

Command failed: npx nx g @nxrocks/nx-spring-boot:project --keepExistingVersions


 >  NX   Failed to initialize @nxrocks/nx-spring-boot. Please check the error above for more details.

Expected Behavior

Propagate the --verbose flag when running the init generator, so that more information can be output to user if calling that generator failed for some reason.

If not provided at all, or provided with --verbose=false, no extra log is printed (current behavior)

Related Issue(s)

Fixes #

@tinesoft tinesoft requested a review from a team as a code owner February 19, 2024 14:09
Copy link

vercel bot commented Feb 19, 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 Feb 19, 2024 2:10pm

@AgentEnder
Copy link
Member

Vite failure is unrelated

@AgentEnder AgentEnder merged commit 003b961 into nrwl:master Feb 19, 2024
4 of 6 checks passed
@tinesoft tinesoft deleted the fix/nx-add branch February 19, 2024 21:34
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 Feb 25, 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.

None yet

2 participants