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

Ng generate always assumes an app folder #9370

Open
mikehallishere opened this issue Jan 24, 2018 · 14 comments
Open

Ng generate always assumes an app folder #9370

mikehallishere opened this issue Jan 24, 2018 · 14 comments
Labels
area: schematics/angular feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature workaround1: obvious
Milestone

Comments

@mikehallishere
Copy link

mikehallishere commented Jan 24, 2018

Our project setup doesn't have an immediate sub-folder of app, however, it appears that running ng generate always assume that you have an app folder under the app root folder you specified in .angular-cli.json

Versions

Angular CLI: 1.6.0
Node: 7.0.0
OS: darwin x64
Angular:
...

Repro steps

  • Setup a simple .angular-cli.json with:
{
  "apps": [
    {
      "name": "client",
      "root": "projects/client"
    }
  ]
}
  • Run:
ng g c form-inputs/mike --skip-import --dry-run --app=client

Observed behavior

You'll see the output path always assumes an app folder:

  create projects/client/app/form-inputs/mike/mike.component.css (0 bytes)
  create projects/client/app/form-inputs/mike/mike.component.html (23 bytes)
  create projects/client/app/form-inputs/mike/mike.component.spec.ts (614 bytes)
  create projects/client/app/form-inputs/mike/mike.component.ts (261 bytes)

Desired behavior

I'd like an option to be able to configure whether your project has the app folder or not. Or maybe an option to configure the whole path the component gets created in.

@mikehallishere mikehallishere changed the title Ng generate assumes an app folder Ng generate always assumes an app folder Jan 24, 2018
@PoiScript
Copy link

Actually, there is an undocumented option in .angular-cli.json called appRoot which is probably you're looking for.

@martinsik
Copy link

@PoiScript is right, there's appRoot options for this, see #7775.

@leonadler
Copy link

Using appRoot leads to an error "Workspace needs to be loaded before it is used."
and is not included in the json-schema for angular.json.

@PoiScript
Copy link

@leonadler appRoot is used for angular cli 1.x project. angular cli 6 introduces a new configuration schema. Each projects now has individual root and sourceRoot options, see https://github.com/angular/angular-cli/wiki/angular-workspace

@jacobjojan
Copy link

ng generate is adding app to the path by default. How to remove 'app' ?
"root": "",
"sourceRoot": "ui-lib/src",
"projectType": "library",

ng g module dashboard/widget -d
CREATE src/app/dashboard/widget/widget.module.spec.ts (275 bytes)
CREATE src/app/dashboard/widget/widget.module.ts (190 bytes)

@wasif-digitalnet
Copy link

I'm having the same issue as @jacobjojan, every time I run ng generate it generates by default in app folder, I want to generate out of app folder, how to do that?

@giolf
Copy link

giolf commented Aug 22, 2018

@wasif-digitalnet what about

ng generate module ../my-module

CREATE src/my-module/my-module.module.spec.ts (292 bytes)
CREATE src/my-module/my-module.module.ts (192 bytes)

@wasif-digitalnet
Copy link

@giolf I have tried it, I guess there was some issues while generating the project, I made a new project and it's working fine now,

@giolf
Copy link

giolf commented Aug 28, 2018

@wasif-digitalnet probably you run that command in a nested folder of your project ?

Anyway I’m glad to hear that you could solve it

@ilivestrong
Copy link

@giolf Your solution worked... Cheers!

@giolf
Copy link

giolf commented Oct 8, 2018

@ilivestrong
Cool

@ngbot ngbot bot added this to the needsTriage milestone Jan 24, 2019
@Paitum
Copy link

Paitum commented Jul 31, 2019

This problem is still unresolved.

We have a code-base similar to Angular Material, where the library modules folders are directly beneath the main library folder.

We have recently replaced our custom build systems in favor of the Angular CLI, but when using the ng generate commands, they automatically add either app or lib depending on the project type (application or library).

Why can't this be configurable? Why isn't "sourceRoot" the literal root?

@filipesilva filipesilva added feature Issue that requests a new feature and removed type: RFC / discussion / question labels Oct 8, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Oct 8, 2019
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Feb 1, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 1, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 1, 2022
@angular-robot angular-robot bot removed the feature: votes required Feature request which is currently still in the voting phase label Feb 21, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added the feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: schematics/angular feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature workaround1: obvious
Projects
None yet
Development

No branches or pull requests