Skip to content

Use default project #10466

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 6 commits into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_script:
- npm --version
- npm run test:packages
- npm run test:cli
- node tests\run_e2e.js --appveyor "--glob=tests/{basic,commands,generate,build/styles}/**" --ng-version="6.0.0-rc.2"
- node tests\run_e2e.js --appveyor "--glob=tests/{basic,commands,generate,build/styles}/**"

build: off

Expand Down
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- attach_workspace:
<<: *attach_workspace_defaults
- run: cp -r /home/circleci/workspace/dist/ ./
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=0 --nosilent --ng-version="6.0.0-rc.2"
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=0 --nosilent

e2e-1:
<<: *defaults
Expand All @@ -88,7 +88,7 @@ jobs:
- attach_workspace:
<<: *attach_workspace_defaults
- run: cp -r /home/circleci/workspace/dist/ ./
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=1 --nosilent --ng-version="6.0.0-rc.2"
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=1 --nosilent

e2e-2:
<<: *defaults
Expand All @@ -99,7 +99,7 @@ jobs:
- attach_workspace:
<<: *attach_workspace_defaults
- run: cp -r /home/circleci/workspace/dist/ ./
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=2 --nosilent --ng-version="6.0.0-rc.2"
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=2 --nosilent

e2e-3:
<<: *defaults
Expand All @@ -110,7 +110,7 @@ jobs:
- attach_workspace:
<<: *attach_workspace_defaults
- run: cp -r /home/circleci/workspace/dist/ ./
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=3 --nosilent --ng-version="6.0.0-rc.2"
- run: xvfb-run -a node tests/run_e2e.js --nobuild --reuse=/home/circleci/workspace/angular-cli-e2e-default/test-project --nb-shards=4 --shard=3 --nosilent

# Master only E2E.
nightly-e2e:
Expand Down
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ matrix:
env: test
- node_js: "8"
os: linux
script: node tests/run_e2e.js --nb-shards=4 --shard=0 --nosilent --ng-version="6.0.0-rc.2"
script: node tests/run_e2e.js --nb-shards=4 --shard=0 --nosilent
env: e2e-0
- node_js: "8"
os: linux
script: node tests/run_e2e.js --nb-shards=4 --shard=1 --nosilent --ng-version="6.0.0-rc.2"
script: node tests/run_e2e.js --nb-shards=4 --shard=1 --nosilent
env: e2e-1
- node_js: "8"
os: linux
script: node tests/run_e2e.js --nb-shards=4 --shard=2 --nosilent --ng-version="6.0.0-rc.2"
script: node tests/run_e2e.js --nb-shards=4 --shard=2 --nosilent
env: e2e-2
- node_js: "8"
os: linux
script: node tests/run_e2e.js --nb-shards=4 --shard=3 --nosilent --ng-version="6.0.0-rc.2"
script: node tests/run_e2e.js --nb-shards=4 --shard=3 --nosilent
env: e2e-3
- node_js: "8"
os: linux
Expand All @@ -69,7 +69,7 @@ matrix:
env: nightly
- node_js: "9"
os: linux
script: node tests/run_e2e.js "--glob=tests/build/**" --ng-version="6.0.0-rc.2"
script: node tests/run_e2e.js "--glob=tests/build/**"
env: node9

# Deploy stage
Expand Down
68 changes: 34 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
},
"homepage": "https://github.com/angular/angular-cli",
"dependencies": {
"@angular-devkit/architect": "angular/angular-devkit-architect-builds",
"@angular-devkit/core": "angular/angular-devkit-core-builds",
"@angular-devkit/schematics": "angular/angular-devkit-schematics-builds",
"@schematics/angular": "angular/schematics-angular-builds",
"@schematics/update": "angular/schematics-update-builds",
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds",
"@angular-devkit/core": "github:angular/angular-devkit-core-builds",
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds",
"@schematics/angular": "github:angular/schematics-angular-builds",
"@schematics/update": "github:angular/schematics-update-builds",
"chalk": "~2.2.0",
"fs-extra": "^4.0.0",
"node-modules-path": "^1.0.0",
"opn": "~5.1.0",
"resolve": "^1.1.7",
"rxjs": "^6.0.0-turbo-rc.4",
"rxjs": "^6.0.0",
"semver": "^5.3.0",
"silent-error": "^1.0.0",
"symbol-observable": "^1.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/commands/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class E2eCommand extends ArchitectCommand {
public readonly description = 'Run e2e tests in existing project.';
public static aliases: string[] = ['e'];
public readonly scope = CommandScope.inProject;
public readonly multiTarget: true;

Choose a reason for hiding this comment

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

Didn't you mean multiTarget = true here? With RC7 the multi target commands are not working anymore because this property is never actually set.

public readonly options: Option[] = [
this.prodOption,
this.configurationOption
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class LintCommand extends ArchitectCommand {
public readonly description = 'Lints code in existing project.';
public static aliases = ['l'];
public readonly scope = CommandScope.inProject;
public readonly multiTarget: true;
public readonly options: Option[] = [
this.configurationOption
];
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class TestCommand extends ArchitectCommand {
public readonly description = 'Run unit tests in existing project.';
public static aliases = ['t'];
public readonly scope = CommandScope.inProject;
public readonly multiTarget: true;
public readonly options: Option[] = [
this.prodOption,
this.configurationOption
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/commands/xi18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class Xi18nCommand extends ArchitectCommand {
public readonly target = 'extract-i18n';
public readonly description = 'Extracts i18n messages from source code.';
public readonly scope = CommandScope.inProject;
public readonly multiTarget: true;
public readonly options: Option[] = [
this.configurationOption
];
Expand Down
37 changes: 26 additions & 11 deletions packages/@angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ import { concatMap, map, tap, toArray } from 'rxjs/operators';
import { WorkspaceLoader } from '../models/workspace-loader';


export interface GenericTargetTargetSpecifier {
target: string;
configuration?: string;
}

export abstract class ArchitectCommand<T = any> extends Command<T> {
private _host = new NodeJsSyncHost();
private _architect: Architect;
private _workspace: experimental.workspace.Workspace;
private _logger = createConsoleLogger();
// If this command supports running multiple targets.
protected multiTarget = false;

readonly Options: Option[] = [{
name: 'configuration',
Expand All @@ -46,7 +43,7 @@ export abstract class ArchitectCommand<T = any> extends Command<T> {
const [project, target] = options.target.split(':');
targetSpec = { project, target };
} else if (this.target) {
const projects = this.getAllProjectsForTargetName(this.target);
const projects = this.getProjectNamesByTarget(this.target);

if (projects.length === 1) {
// If there is a single target, use it to parse overrides.
Expand All @@ -70,12 +67,12 @@ export abstract class ArchitectCommand<T = any> extends Command<T> {
);
})
).toPromise()
.then(() => {});
.then(() => { });
}

public validate(options: any) {
if (!options.project && this.target) {
const projectNames = this.getAllProjectsForTargetName(this.target);
const projectNames = this.getProjectNamesByTarget(this.target);
const overrides = { ...options };
delete overrides.project;
delete overrides.configuration;
Expand Down Expand Up @@ -164,7 +161,7 @@ export abstract class ArchitectCommand<T = any> extends Command<T> {
if (!targetSpec.project && this.target) {
// This runs each target sequentially.
// Running them in parallel would jumble the log messages.
return await from(this.getAllProjectsForTargetName(this.target)).pipe(
return await from(this.getProjectNamesByTarget(this.target)).pipe(
concatMap(project => runSingleTarget({ ...targetSpec, project })),
toArray(),
).toPromise().then(results => results.every(res => res === 0) ? 0 : 1);
Expand Down Expand Up @@ -197,10 +194,28 @@ export abstract class ArchitectCommand<T = any> extends Command<T> {
}
}

private getAllProjectsForTargetName(targetName: string) {
return this._workspace.listProjectNames().map(projectName =>
private getProjectNamesByTarget(targetName: string): string[] {
const allProjectsForTargetName = this._workspace.listProjectNames().map(projectName =>
this._architect.listProjectTargets(projectName).includes(targetName) ? projectName : null
).filter(x => !!x);

if (this.multiTarget) {
// For multi target commands, we always list all projects that have the target.
return allProjectsForTargetName;
} else {
// For single target commands, we try try the default project project first,
// then the full list if it has a single project, then error out.
const maybeDefaultProject = this._workspace.getDefaultProjectName();
if (maybeDefaultProject && allProjectsForTargetName.includes(maybeDefaultProject)) {
return [maybeDefaultProject];
}

if (allProjectsForTargetName.length === 1) {
return allProjectsForTargetName;
}

throw new Error(`Could not determine a single project for the '${targetName} target.`);
}
}

private _loadWorkspaceAndArchitect() {
Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"node-modules-path": "^1.0.0",
"opn": "~5.1.0",
"resolve": "^1.1.7",
"rxjs": "^6.0.0-turbo-rc.4",
"rxjs": "^6.0.0",
"semver": "^5.1.0",
"silent-error": "^1.0.0",
"symbol-observable": "^1.2.0",
Expand Down
Loading