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

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

Merged
merged 1 commit into from
Feb 22, 2017

Conversation

sumitarora
Copy link
Contributor

@sumitarora sumitarora commented Feb 16, 2017

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
Copy link
Contributor

@hansl hansl left a comment

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

@@ -2,9 +2,10 @@ var path = require('path');
var process = require('process');
var fs = require('fs');

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

Copy link
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
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
Contributor

Choose a reason for hiding this comment

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

Here and everywhere.

@@ -2,11 +2,13 @@ import * as fs from 'fs';
import * as path from 'path';
const SilentError = require('silent-error');

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

this.pathToModule = path.join(this.project.root, parsedPath.dir, parsedPath.base);

if (!fs.existsSync(this.pathToModule)) {
throw 'Module specified does not exist';
}
} else {
try {
this.pathToModule = findParentModule(this.project, this.dynamicPath.dir);
this.pathToModule = findParentModule
Copy link
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
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
@@ -54,7 +56,9 @@ const BuildCommand = Command.extend({
aliases: ['b'],

availableOptions: baseBuildCommandOptions.concat([
{ name: 'stats-json', type: Boolean, default: false }
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
Copy link
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.

@@ -24,6 +24,7 @@ const E2eCommand = Command.extend({
baseServeCommandOptions.concat([
{ name: 'config', type: String, aliases: ['c'] },
{ name: 'specs', type: Array, default: [], aliases: ['sp'] },
{ name: 'app', type: String, aliases: ['a'] },
Copy link
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
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?

Copy link
Contributor Author

@sumitarora sumitarora Feb 21, 2017

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

@@ -11,11 +13,18 @@ export default Blueprint.extend({
name: 'spec',
type: Boolean,
description: 'Specifies if a spec file is generated.'
},
{
name: 'app',
Copy link
Contributor

@filipesilva filipesilva Feb 21, 2017

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

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.

Copy link
Contributor

@hansl hansl left a comment

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

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
}
];

export interface BuildTaskOptions extends BuildOptions {
watch?: boolean;
Copy link
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;

}
];

export interface BuildTaskOptions extends BuildOptions {
watch?: boolean;
app?: String;
Copy link
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
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.

@@ -16,7 +17,12 @@ function isDirectory(path: string) {
}

const init: any = (config: any) => {
const appConfig = CliConfig.fromProject().config.apps[0];
// load Angular CLI config
Copy link
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.

@@ -23,6 +23,7 @@ export interface ServeTaskOptions extends BuildOptions {
sslCert?: string;
open?: boolean;
hmr?: boolean;
app?: string;
Copy link
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
Copy link

mautrok commented Apr 6, 2017

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

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