Custom root / --source-dir path causes components to be generated in wrong folders
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0-rc.1
Node: 6.9.1
OS: win32 x64
Angular: 4.4.6
... common, compiler, core, forms, platform-browser
... platform-browser-dynamic, router
@angular/animations: 4.4.5
@angular/cli: 1.5.0-rc.1
@angular/compiler-cli: 4.4.5
@angular/http: 4.4.5
@angular/language-service: 4.4.5
@angular/tsc-wrapped: 4.4.5
@angular-devkit/build-optimizer: 0.0.28
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.1
@schematics/angular: 0.0.46
typescript: 2.3.4
webpack: 3.7.1
Repro steps.
Step 1:
ng new fooGui --prefix foo --style scss --routing true --skip-git true --source-dir src/main/client
Step 2:
cd fooGui
Step 3:
ng g c helloWorld --skip-import
The log given by the failure.
Output is:
create src/main/client/src/main/client/app/hello-world/hello-world.component.html (30 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.spec.ts (657 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.ts (289 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.scss (0 bytes)
Desired functionality.
IMHO, component files should be created inside:
create src/main/client/app/hello-world/hello-world.component.html (30 bytes)
create src/main/client/app/hello-world/hello-world.component.spec.ts (657 bytes)
create src/main/client/app/hello-world/hello-world.component.ts (289 bytes)
create src/main/client/app/hello-world/hello-world.component.scss (0 bytes)
Mention any other details that might be useful.
I was not able to reproduce this with 1.5.0-rc.5
I created the project as you described and ran:
ng g c helloWorld --skip-import --dry-run
and saw the following output:
create src/main/client/app/hello-world/hello-world.component.scss (0 bytes)
create src/main/client/app/hello-world/hello-world.component.html (30 bytes)
create src/main/client/app/hello-world/hello-world.component.spec.ts (657 bytes)
create src/main/client/app/hello-world/hello-world.component.ts (289 bytes)
Please update your version and retry?
It still occurs for Angular CLI: 1.5.0-rc.6. Steps:
ng new fooGui --prefix foo --style scss --routing true --skip-git true --source-dir src/main/client
cd fooGui
ng g c helloWorld --skip-import
Output:
create src/main/client/src/main/client/app/hello-world/hello-world.component.html (30 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.spec.ts (657 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.ts (289 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.scss (0 bytes)
Project was generated with globally installed Angular CLI: 1.5.0-rc.6 and ng --version in the project folder returns:
Angular CLI: 1.5.0-rc.6
Node: 6.9.1
OS: win32 x64
Angular: 4.4.6
... common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, tsc-wrapped
@angular/animations: 4.4.5
@angular/cli: 1.5.0-rc.6
@angular/http: 4.4.5
@angular-devkit/build-optimizer: 0.0.31
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.6
@schematics/angular: 0.0.48
typescript: 2.3.4
webpack: 3.8.1
What is interesting... for rc5 I also get the same issue.
I've tried it on different machine, result is the same (error). Here's full console output:
drago@DESKTOP-983MMB6 C:\Users\drago
> npm i @angular/[email protected] -g
C:\Users\drago\AppData\Roaming\npm\ng -> C:\Users\drago\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
+ @angular/[email protected]
added 58 packages, removed 5 packages and updated 49 packages in 52.906s
drago@DESKTOP-983MMB6 C:\Users\drago
> ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.5.0-rc.6
Node: 8.4.0
OS: win32 x64
Angular:
...
drago@DESKTOP-983MMB6 C:\Users\drago
> ng new fooGui --prefix foo --style scss --routing true --skip-git true --source-dir src/main/client
create fooGui/e2e/app.e2e-spec.ts (289 bytes)
create fooGui/e2e/app.po.ts (208 bytes)
create fooGui/e2e/tsconfig.e2e.json (235 bytes)
create fooGui/karma.conf.js (923 bytes)
create fooGui/package.json (1317 bytes)
create fooGui/protractor.conf.js (722 bytes)
create fooGui/README.md (1027 bytes)
create fooGui/tsconfig.json (363 bytes)
create fooGui/tslint.json (2985 bytes)
create fooGui/.angular-cli.json (1322 bytes)
create fooGui/.editorconfig (245 bytes)
create fooGui/src/assets/.gitkeep (0 bytes)
create fooGui/src/environments/environment.prod.ts (51 bytes)
create fooGui/src/environments/environment.ts (387 bytes)
create fooGui/src/favicon.ico (5430 bytes)
create fooGui/src/index.html (293 bytes)
create fooGui/src/main.ts (370 bytes)
create fooGui/src/polyfills.ts (2667 bytes)
create fooGui/src/styles.scss (80 bytes)
create fooGui/src/test.ts (1085 bytes)
create fooGui/src/tsconfig.app.json (211 bytes)
create fooGui/src/tsconfig.spec.json (304 bytes)
create fooGui/src/typings.d.ts (104 bytes)
create fooGui/src/main/client/app/app-routing.module.ts (245 bytes)
create fooGui/src/main/client/app/app.module.ts (393 bytes)
create fooGui/src/main/client/app/app.component.html (1152 bytes)
create fooGui/src/main/client/app/app.component.spec.ts (1103 bytes)
create fooGui/src/main/client/app/app.component.ts (208 bytes)
create fooGui/src/main/client/app/app.component.scss (0 bytes)
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Project 'fooGui' successfully created.
drago@DESKTOP-983MMB6 C:\Users\drago
> cd fooGui
drago@DESKTOP-983MMB6 C:\Users\drago\fooGui
> ng g c helloWorld --skip-import --dry-run
create src/main/client/src/main/client/app/hello-world/hello-world.component.html (30 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.spec.ts (657 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.ts (289 bytes)
create src/main/client/src/main/client/app/hello-world/hello-world.component.scss (0 bytes)
NOTE: Run with "dry run" no changes were made.
Hello,
I have the same error using @angular/cli 1.4.9.
ng new test-app --directory dir --source-dir package/test
$ ng g m testmodule --dry-run
create package/test/package/test/app/testmodule/testmodule.module.ts (194 bytes)
NOTE: Run with "dry run" no changes were made.
when app[X].root is modified, it breaks code scaffolding.
I found that the error comes from 1.4.0 release, it is working fine in 1.3.2 and not in 1.4.0.
We see the exact same problem on a Windows machine. On a Mac, the identical command produces the correct output.
My guess is that the error only happens on Windows machines with Angular CLI versions later than 1.4.x.
Good point, I am on Windows
Still does not work on windows:
Angular CLI: 1.6.0-rc.0
Node: 8.9.1
OS: win32 x64
Angular: 5.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.0-rc.0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0-rc.0
@schematics/angular: 0.1.7
typescript: 2.4.2
webpack: 3.8.1
It seems to be related to the depth of the root-path. It works when set to two directories but breaks with a depth of three or more.
Defined two additional apps in .angular-cli.json
{
"name": "a",
"root": "x/y/z"
},
{
"name": "b",
"root": "y/z"
}
Creating modules:
$ ng g m a --app=a
create x/y/z/x/y/z/app/a/a.module.ts (185 bytes)
$ ng g m a --app=b
create y/z/app/a/a.module.ts (185 bytes)
Also an empty x/y/z/app directory is created for --app=a.
I'm on
Angular CLI: 1.6.0-rc.0
Node: 8.8.1
OS: win32 x64
Issue resolved with 1.6.0 :+1:
The option '--source-dir' is not registered with the new command. Run
ng new --helpfor a list of supported options.`
and not mentioned in changelog :face_with_head_bandage:
Just tested with latest release 1.6.7, the --source-dir still not working.
With the new workspace in 6.x, there's no flag but it's possible to do it by creating an empty workspace and adding a new application where you want. The paths have also been fixed.
Closing this as fixed.
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.