Skip to content

"root" path duplicated for new modules when changing "root" path of .angular-cli.json ng generate to more then one subdirectory level #8888

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

Closed
zladuric opened this issue Dec 15, 2017 · 5 comments
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity5: regression type: bug/fix

Comments

@zladuric
Copy link

Versions

Windows 10, Node 8.9.2, npm 5.5.1, ng-cli 1.6.0:

[duricz@msgn07241 ~/temp/my-new-app]$ uname -a
MINGW64_NT-10.0 msgn07241 2.9.0(0.318/5/3) 2017-10-05 15:05 x86_64 Msys
[duricz@msgn07241 ~/temp/my-new-app]$ node -v
v8.9.2
[duricz@msgn07241 ~/temp/my-new-app]$ npm -v
5.5.1
[duricz@msgn07241 ~/temp/my-new-app]$ ng -v
_                      _                 ____ _     ___
/ \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
/ ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
|___/

Angular CLI: 1.6.0
Node: 8.9.2
OS: win32 x64
Angular: 5.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.0
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

Repro steps

If I change the app.root property to more than one level bellow "src" in .angular-cli.json, ng generate duplicates the source path when generating new components.

I mean, if "root" is "src", all is well. If root is "src/subdirectory", still all cool. If root is "src/sub/secondsubdirectory", the path of generated modules is duplicated.

Steps to reproduce:

  • create a new app (ng new my-new-app)
  • generate a new module to make sure module is done properly
  • change the "root" property of .angular-cli.json to "src/main/frontend"
  • generate a new module.

The path that is generated is duplicating the "root" part of the path.

Observed behavior

duricz@msgn07241 ~/temp/my-new-app]$ grep root .angular-cli.json
      "root": "src",
[duricz@msgn07241 ~/temp/my-new-app]$ ng g m module
  create src/app/module/module.module.ts (190 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$ vi .angular-cli.json
[duricz@msgn07241 ~/temp/my-new-app]$ grep root .angular-cli.json
      "root": "src/main/frontend",
[duricz@msgn07241 ~/temp/my-new-app]$ ng g m another
  create src/main/frontend/src/main/frontend/app/another/another.module.ts (191 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$ ng g m another --flat
  create src/main/frontend/src/main/frontend/app/another.module.ts (191 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$
[duricz@msgn07241 ~/temp/my-new-app]$ ng g m nested/module
  create src/main/frontend/src/main/frontend/app/nested/module/module.module.ts (190 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$

Desired behavior

I expect that my new module would be generated directly under src/main/frontend/app. Instead, my new module is made in src/main/frontend/src/main/frontend/app.

Mention any other details that might be useful (optional)

This was mentioned in #58, but closed.

The same happens if I try to generate service, component etc. The problem only appears for more than two levels of directory:

[duricz@msgn07241 ~/temp/my-new-app]$ vi .angular-cli.json
[duricz@msgn07241 ~/temp/my-new-app]$ ng g module mymo
  create srcss/app/mymo/mymo.module.ts (188 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$ vi .angular-cli.json
[duricz@msgn07241 ~/temp/my-new-app]$ ng g module mymo
  create src/single/app/mymo/mymo.module.ts (188 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$ vi .angular-cli.json
[duricz@msgn07241 ~/temp/my-new-app]$ ng g module mymo
  create src/single/twolevels/src/single/twolevels/app/mymo/mymo.module.ts (188 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$ vi .angular-cli.json
[duricz@msgn07241 ~/temp/my-new-app]$ ng g module mymo
  create src/single/twolevels/three/src/single/twolevels/three/app/mymo/mymo.module.ts (188 bytes)
[duricz@msgn07241 ~/temp/my-new-app]$
@filipesilva filipesilva added severity5: regression type: bug/fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Dec 21, 2017
@hansl hansl unassigned Brocco Feb 6, 2018
@ntrp
Copy link

ntrp commented Feb 12, 2018

Any news on this? It's kind of annoying to move all the generated code manually every time..

@zladuric
Copy link
Author

Oh, I forgot to update this ticket. This started working for me, sometimes between 1.6.0 and 1.6.4, not sure which version fixed it. I will leave it open if you guys wanna make sure it works. @ntrp, did you try with the latest versions of ng-cli?

@ntrp
Copy link

ntrp commented Feb 13, 2018

I used 1.6.7 and it was happening.. for now I moved my sources close to the root to avoid the problem and to refactor the project.

@hansl
Copy link
Contributor

hansl commented Sep 27, 2018

Closing this as it should be addressed by the better workspace file in 6.0.

@hansl hansl closed this as completed Sep 27, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity5: regression type: bug/fix
Projects
None yet
Development

No branches or pull requests

5 participants