nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.97k stars 2.3k forks source link

Problematic command suggestion for nx 19 implicit name/root derive deprecation #22725

Closed prewk closed 3 months ago

prewk commented 4 months ago

Current Behavior

In nx 18, if I run

nx g @nx/angular:library shared/foo/bar

It'll create a library in libs/shared/foo/bar named shared-foo-bar with import path @acme/shared/foo/bar. Nx wants to deprecate this behavior and require explicit arguments, as evident by its suggestion:

In Nx 19, generating projects will no longer derive the name and root.
Please provide the exact project name and root in the future.
Example: nx g @nx/angular:library shared-foo-bar --directory libs/shared/foo/bar

Let's run the suggested command! Output:

In Nx 19, generating projects will no longer derive the name and root.
Please provide the exact project name and root in the future.
Example: nx g @nx/angular:library shared-foo-bar-shared-foo-bar --directory libs/shared/foo/bar/shared-foo-bar

CREATE libs/shared/foo/bar/shared-foo-bar/project.json
...

Expected Behavior

It seems the correct suggestion to achieve the same result would be:

yarn nx g @nx/angular:library bar --directory libs/shared/foo --importPath="@acme/shared/foo/bar"

GitHub Repo

No response

Steps to Reproduce

See further up

Nx Report

Node   : 20.12.0
OS     : darwin-arm64
yarn   : 4.1.1

nx                 : 18.2.3
@nx/js             : 18.2.3
@nx/jest           : 18.2.3
@nx/eslint         : 18.2.3
@nx/workspace      : 18.2.3
@nx/angular        : 18.2.3
@nx/devkit         : 18.2.3
@nx/eslint-plugin  : 18.2.3
@nx/plugin         : 18.2.3
@nx/storybook      : 18.2.3
typescript         : 5.4.4
---------------------------------------
Community plugins:
@ngneat/spectator        : 14.0.0
@ngrx/component          : 17.1.1
@ngrx/component-store    : 17.1.1
@ngrx/effects            : 17.1.1
@ngrx/entity             : 17.1.1
@ngrx/router-store       : 17.1.1
@ngrx/schematics         : 17.1.1
@ngrx/store              : 17.1.1
@ngrx/store-devtools     : 17.1.1
@storybook/angular       : 7.5.3
@testing-library/angular : 14.2.0
---------------------------------------
Local workspace plugins:
     @mon/workspace-plugin


### Failure Logs

_No response_

### Package Manager Version

_No response_

### Operating System

- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)

### Additional Information

_No response_
leosvelperez commented 3 months ago

Thanks for reporting this!

The suggested command is meant to be run with --projectNameAndRootFormat=as-provided. You should get a prompt asking whether to use the command "as provided" or "derived". The warning advises to choose the "as provided" format moving forward.

If you're not getting the prompt, then you probably have generator defaults set in the nx.json file, setting the option to derived. In that case, you need to explicitly provide the --projectNameAndRootFormat=as-provided.

prewk commented 3 months ago

A-ha! You're right. Thanks and sorry.

github-actions[bot] commented 2 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.