Skip to content

feat(@angular/cli): make appRoot customizable #7775

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

Merged
merged 1 commit into from
Oct 4, 2017

Conversation

vsavkin
Copy link
Contributor

@vsavkin vsavkin commented Sep 21, 2017

Currently, the CLI hardcodes appRoot to app, which is a reasonable default.

In complex projects with many apps (some of which aren't actually bundles shipped to the client), the prefix gets in a way. It looks awkward.

Using schematics we can generate apps that do not follow the default. Currently if you do that, ng generate won't work for those apps.

The PR changes the CLI to allow the provisioning of appRoot

Copy link
Contributor

@Brocco Brocco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a few minor things.
@hansl has done some work on appRoot changes recently, so I'd like him to review as well.

const appRoot = path.join(sourceDir, 'app');

const p = options.appConfig.appRoot === undefined ? 'app' : options.appConfig.appRoot;
const appRoot = path.join(sourceDir, options.appConfig.appRoot);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating local variable p with the determined root, but tot using it within the join on line 18

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it. Bad rebase.

@@ -1,5 +1,5 @@
// tslint:disable:max-line-length
import { mkdirsSync, pathExistsSync, readFile, readFileSync } from 'fs-extra';
import { mkdirsSync, pathExistsSync, readFile, readFileSync, writeFileSync } from 'fs-extra';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New import is not being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it

@@ -16,6 +20,17 @@ export function setupProject() {
});
}

function addAppToProject(): Promise<any> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required, but would be nice to have:
Add parameter(s) here to specify values for the app being created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is: since this function is called by a single caller, it would make it unnecessary complex.

But I can make a change, if you think it is better this way.

@Brocco Brocco requested a review from hansl September 21, 2017 14:55
@vsavkin vsavkin force-pushed the make_app_customizable branch 2 times, most recently from 1dea1bf to 10b0478 Compare September 21, 2017 15:03
@filipesilva filipesilva requested a review from Brocco September 25, 2017 10:41
@vsavkin vsavkin force-pushed the make_app_customizable branch from 10b0478 to e6b1eb6 Compare October 4, 2017 17:44
Copy link
Contributor

@Brocco Brocco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@raghulrajnkl
Copy link

i want create three different application, and first secenrio merge three and other one first and second merge, how its possible?

@raghulrajnkl
Copy link

i created three app folder (app, newapp1,newapp2), seperate module, and developed three team seperaetly.
after finished i merge three module as per my plan of router configuration ..is it right way or else any new solutions?

@raghulrajnkl
Copy link

raghulrajnkl commented Oct 28, 2017

i need ng generate module in newapp folder? how it is possble?
because three web apps merge in one application, help me, give solutions

@towertop
Copy link

@Brocco I think the wiki for config schema should be updated accordingly。

https://github.com/angular/angular-cli/wiki/angular-cli
https://github.com/angular/angular-cli/wiki/stories-multiple-apps

For I just come to this issue from that wiki. Thx~

@playground
Copy link

playground commented Dec 21, 2017

How would you target a new module or component to a specific app?

I guess this works "ng g module app2/new-module"

@vvolodin
Copy link

How do I use this? Is there any documentation on appRoot?
I need to keep my app in a directory different from app and this breaks ng generate.

@towertop
Copy link

towertop commented Jan 3, 2018

@playground

Most ng subcommand have an option "--app" to specify the name of app.

@vvolodin

No document get updated as I mentioned above. But you can use it this way for an app "common" sibling to the default "app".

    },
    {
      "name": "common",
      "appRoot": "common",
      "root": "src",
      "tsconfig": "tsconfig.app.json",

@PierreChavaroche
Copy link

PierreChavaroche commented May 28, 2018

Do you have any idea how we have to configure with Angular 6 "angular.json" config?

Thank you very much!

@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.

@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 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants