-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Weird Behavior in NestJS Generators #29076
Comments
thanks @bzp2010 for following up and reporting that issue. Will work on it, something should get clarified within ~1 week. |
1 similar comment
thanks @bzp2010 for following up and reporting that issue. Will work on it, something should get clarified within ~1 week. |
there is a bug on Github :D it doubles comments 😆 |
Hi, You are correct. It will be fixed stay tuned for the PR, thanks for reporting! |
…licate when provided closes: #29076
…licate when provided closes: #29076
…licate when provided closes: #29076
…licate when provided closes: #29076
…licate when provided closes: #29076
…licate when provided closes: #29076
…licate when provided (#29084) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> When we run the nest generators (interceptor, resource, guard etc...) it tends to duplicate the path and leads to unexpected folder creations. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> It should generate in the path provided. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #29076
…licate when provided (#29084) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> When we run the nest generators (interceptor, resource, guard etc...) it tends to duplicate the path and leads to unexpected folder creations. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> It should generate in the path provided. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #29076 (cherry picked from commit 25c5643)
I have started using Nx 20.1.4 and now these generators are working fine. I've noticed that Anyway, it works fine now. |
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. |
Current Behavior
The NestJS generator is used in a way that doesn't match the documentation and is very different from previous releases.
According to my #28910 (Additional Information), and another reporter's checks (#28910 (comment)), this does exist.
@pawel-twardziak also proves (#28910 (comment)) that these generators are not quite normal, at least, it doesn't match the documentation. It also doesn't work as well as the previous implementation in Nx 19. As mentioned there, I'd better create a new issue to keep track.
In detail: #28910
I would kindly ask you to indicate the correct way to use the nestjs generator, as it is very different from the way I used it during nx 16-19.
I know we've switched to the default as-provided, but it also looks like the nestjs generator doesn't support directory but uses path instead.
I've read https://nx.dev/deprecated/as-provided-vs-derived#generate-paths-and-names-asprovided, but it doesn't look like that's what actually works, which I don't understand.
For example, when I try to generate code for a project in the root directory, I use the --path option and the files are generated in the wrong path.
It is duplicated in the
apps/my-workspace/src
section and I have to move it manually which I think might be wrong, it should be able to work correctly, in the past I used--directory
to deal with the problem directly, but now it seems that it no longer exists.I saw that section included in
--path
and maybe it was the cause of the error, so I went into that folder and generated it again.Now, the generated path is correct, but again, I noticed that the generated file names
app.guard.ts
and classesAppGuard
in them do not follow the input valueauth
, but appear to be automatically inferred from the pathapp
. It's not just guard, but other nestjs code generators have similar problems, such as controllers and filters.If I want to make sure the filename is correct, I have to make sure that the last part of the path in
--path
is the filename prefix I want. Just like:But unfortunately the two methods above fall back into the cycle of problems about paths mentioned above.
It looks like I have to enter the
app
directory to generate the file atauth/auth.guard.ts
.This breaks the intuition of the previous generator's use of
--directory
, and--path
forces me to infer where I should be generating files and return the up-level directory in that location.Also, I don't want to place the generated files inside a directory, well, at least not every time, e.g. I want to generate
auth.guard.ts
instead ofauth/auth.guard.ts
, which, if memory serves me correctly, was the behavior when I used --directory before.Expected Behavior
It is desirable that these generators continue to support the
--directory
option that was supported in Nx19 and earlier, which is the most intuitive to use. The current--path
option is extremely unintuitive.Back then, I used commands like:
Of course, I'm using the As-provided pattern, so it generates:
No misplaced paths, no duplicate paths, no weird nested folders, everything is fine.
This is exactly what I expected, nothing that forces me to have to guess and infer paths, and the generated files are not nested by their folder prefixes. The files are generated in exactly the folder I specify, which is fairly intuitive.
GitHub Repo
No response
Steps to Reproduce
Nx Report
Failure Logs
Package Manager Version
pnpm 9.14.1
Operating System
Additional Information
This issue is derived from another issue #28910. I've transferred as much of the relevant background and errors as I can here, and if not here, there may be more information there. If information is still missing, I will add it.
The text was updated successfully, but these errors were encountered: