Skip to content

feat(command): adding the --app command option - #4754

Merged
hansl merged 1 commit into
angular:masterfrom
sumitarora:feat-app
Feb 22, 2017
Merged

hansl merged 1 commit into
angular:masterfrom
sumitarora:feat-app

Conversation

@sumitarora

@sumitarora sumitarora commented Feb 16, 2017 •

Copy link
Copy Markdown
Contributor

Added option for ng serve --app <app_name> to commands build, serve, generate, eject, i18n

@sumitarora
sumitarora requested a review from hansl February 16, 2017 17:20
@sumitarora
sumitarora force-pushed the feat-app branch 9 times, most recently from b246573 to 6cb983b Compare February 17, 2017 18:21

@hansl hansl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

First comments.

@@ -0,0 +1,11 @@
export function getAppFromConfig(apps: any, name: String) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have typing for the configuration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is interface for whole config not apps part.


module.exports = function dynamicPathParser(project, entityName) {
module.exports = function dynamicPathParser(project, entityName, appConfig) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove empty line.

@@ -1,3 +1,5 @@
import * as appUtils from '../../utilities/app-utils';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of import * as, just import the function you need. This is a TypeScript file, not a CommonJS one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here and everywhere.


export default function findParentModule(project: any, currentDir: string): string {
const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, 'app');
export default function findParentModule

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Put as many arguments on the same line as function declaration, then indent 4 (or left align with first argument) the rest.

} else {
try {
this.pathToModule = findParentModule(this.project, this.dynamicPath.dir);
this.pathToModule = findParentModule

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Put as many arguments on the same line as function declaration, then indent 4 (or left align with first argument) the rest.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here and everywhere.

@sumitarora
sumitarora force-pushed the feat-app branch 4 times, most recently from 7e884e9 to 4fed19c Compare February 21, 2017 15:08
@sumitarora
sumitarora force-pushed the feat-app branch 3 times, most recently from 2422388 to 428957f Compare February 21, 2017 16:00
Comment thread packages/@angular/cli/commands/build.ts Outdated

availableOptions: baseBuildCommandOptions.concat([
{ name: 'stats-json', type: Boolean, default: false }
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Watch is now part of the base options, I think you left it here as part of a bad rebase.

Comment thread packages/@angular/cli/commands/e2e.ts Outdated
baseServeCommandOptions.concat([
{ name: 'config', type: String, aliases: ['c'] },
{ name: 'specs', type: Array, default: [], aliases: ['sp'] },
{ name: 'app', type: String, aliases: ['a'] },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add it to baseBuildCommandOptions instead, and build/serve/e2e will all use it.

@@ -0,0 +1,11 @@
export function getAppFromConfig(apps: any, name: String) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a pretty good candidate for a static method on models/config. What do you think?

@sumitarora sumitarora Feb 21, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's used by karma.js too so it's better as independent util function

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I changed the whole testing config setup in the last day so it should be much more like the others.

description: 'Specifies if a spec file is generated.'
},
{
name: 'app',

@filipesilva filipesilva Feb 21, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This gets repeated a lot. It's probably better to make some kind of base BaseAppOptions+AppOptions similar to baseBuildCommandOptions+BuildOptions (or a better abstraction if you can find it).

That way if we need to change it, or add more app options in the future, it's only in one place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure we should do it as a refactoring task as it needs to be done in multiple commands

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's do it separately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we're doing that we should also be doing the same thing with things like flat and spec too

@sumitarora
sumitarora force-pushed the feat-app branch 3 times, most recently from dacbfd5 to 0487edb Compare February 21, 2017 22:58
@googlebot

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@hansl hansl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 more nit.

@@ -0,0 +1,13 @@
import {CliConfig as CliConfigInterface} from '../lib/config/schema';

export function getAppFromConfig(apps: CliConfigInterface['apps'], name: String) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as a fallback, if the name can be used as a number (using name.match(/^[0-9]+$/)), use parseInt(name, 10) to get it. This way users can do ng build --app=1 and get the first app.

@sumitarora
sumitarora force-pushed the feat-app branch 2 times, most recently from d1c30e1 to 55ab668 Compare February 22, 2017 00:32
@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

@sumitarora
sumitarora force-pushed the feat-app branch 2 times, most recently from ce07732 to b213d72 Compare February 22, 2017 14:41
Comment thread packages/@angular/cli/commands/build.ts Outdated
];

export interface BuildTaskOptions extends BuildOptions {
watch?: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is not needed, watch is in BuildOptions;

Comment thread packages/@angular/cli/commands/build.ts Outdated

export interface BuildTaskOptions extends BuildOptions {
watch?: boolean;
app?: String;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@@ -0,0 +1,11 @@
export function getAppFromConfig(apps: any, name: String) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I changed the whole testing config setup in the last day so it should be much more like the others.

Comment thread packages/@angular/cli/plugins/karma.ts Outdated

const init: any = (config: any) => {
const appConfig = CliConfig.fromProject().config.apps[0];
// load Angular CLI config

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't needed anymore, I think you left it here as part of the rebase.

Comment thread packages/@angular/cli/commands/serve.ts Outdated
sslCert?: string;
open?: boolean;
hmr?: boolean;
app?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sumitarora
sumitarora force-pushed the feat-app branch 3 times, most recently from 7a31214 to 839b9ce Compare February 22, 2017 17:07
@mautrok

mautrok commented Apr 6, 2017 •

Copy link
Copy Markdown

I try to do ng build --app 1 where 1 is the index of a configuration inside the "apps" field, but it seesms not work, what do i do wrong?

"apps": [
{
"root": "src",
"outDir": "dist1",
"assets": [
"fonts",
"images",
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"paper.css",
"styles.css",
"style_1.css"
],
"scripts": ["../node_modules/chart.js/dist/Chart.bundle.min.js"],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
},
{
"root": "src",
"outDir": "dist2",
"assets": [
"fonts",
"images",
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"paper.css",
"styles.css",
"style_2.css"
],
"scripts": ["../node_modules/chart.js/dist/Chart.bundle.min.js"],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}

asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this pull request Apr 12, 2017
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 11, 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.

6 participants