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

Fail on schematics when directories starting with "_" gets changed to "-" #489

Closed
ruslanguns opened this issue Nov 30, 2019 · 7 comments
Closed
Labels

Comments

@ruslanguns
Copy link

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When you generate something with schematics, directory's name starting with "_" on result it ignore it and creates with "-".

Expected behavior

It should respect the "_" or any special character on directory's name.

Minimal reproduction of the problem with instructions

Just generate something e.g.:
nest g co auth/_users/user.module

image

Environment

image

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for that :)?

@ruslanguns
Copy link
Author

I feel motivated, will try to study this code as soon as it is possible. 👍 I have an opportunity to leave my name in this incredible project.

@dario-rodriguez
Copy link

Hello,
As a hint, it's probably related to this line: https://github.com/nestjs/schematics/blob/2c732fb2718d7b33adfe64415d315aceee497c44/src/lib/controller/controller.factory.ts#L49

It's in the controller.factory but I think this line is present in most schematics.

@emilgodsk
Copy link
Contributor

Hi,
Took a quick look at it. What @dario-rodriguez says might be true once the command is sent to the schematics handler, however the nest-cli also "dasherize" the name option, as seen here:

.dasherize(this.value as string)

So that the name options is already from the nest-cli sent to the schematic handler with --name=auth/-users/users instead of the expected --name=auth/_users/users for the following command: nest g controller auth/_users/users --no-spec

However while looking at this, my initial thoughts, is that the dasherize command is there for converting camelCase, spaces, and underscores of a the file name to use dashes instead. I have quick couple of questions:

  1. Should the behavior be changed such that both filenames and directory names are kept in their original format (besides space)? Or should it only be directories, which should not be dasherized?
  2. If the dasherize function is changed to something else, what kind of behaviors would we expect as standard for both directories and file names?

I believe this might kind of go hand-in-hand with #462 when determining the naming behavior, but a standard should also be set.

cc @kamilmysliwiec

@tukusejssirs
Copy link

I have stumbled upon this issue. I wanted to create a project with project_name, but it was changed to project-name.

Any progress on this?

Anyway, I wanted to manually change the name, so I grepped all the files within the generated project. I’d be quite easy to rename the root folder and the project name in package.json and package-lock.json, however, I have found that that in node_modules/, many (all?) packages contain in their package.json the absolute paths of some other files (in _where and man key/object name). I presume this might be an issue when I move the project to a different folder; is this the correct behaviour?

@stanimirovv
Copy link
Contributor

@kamilmysliwiec I was looking for a good first contribution and this caught my eye.
I've attached a PR with proposed changes.

@kamilmysliwiec
Copy link
Member

Thank you @stanimirovv, let's track this here #1551

Repository owner moved this from 🤔 I'll investigate later to ✅ LGTM in My contributions to NestJS framework 😻 Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants