Skip to content

Commit d37d29f

Browse files
committed
fix(@angular/cli): clean up architect options
Fix #10699
1 parent 89242be commit d37d29f

File tree

9 files changed

+178
-253
lines changed

9 files changed

+178
-253
lines changed

package-lock.json

+95-89
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+4-25
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import { ArchitectCommand } from '../models/architect-command';
21
import { Option, CommandScope } from '../models/command';
32
import { Version } from '../upgrade/version';
4-
5-
export interface Options {
6-
project?: string;
7-
configuration?: string;
8-
prod: boolean;
9-
}
3+
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
104

115
export default class BuildCommand extends ArchitectCommand {
126
public readonly name = 'build';
@@ -20,29 +14,14 @@ export default class BuildCommand extends ArchitectCommand {
2014
this.configurationOption
2115
];
2216

23-
public validate(options: Options) {
17+
public validate(options: ArchitectCommandOptions) {
2418
// Check Angular and TypeScript versions.
2519
Version.assertCompatibleAngularVersion(this.project.root);
2620
Version.assertTypescriptVersion(this.project.root);
2721
return super.validate(options);
2822
}
2923

30-
public async run(options: Options) {
31-
let configuration = options.configuration;
32-
if (!configuration && options.prod) {
33-
configuration = 'production';
34-
}
35-
36-
const overrides = { ...options };
37-
delete overrides.project;
38-
delete overrides.configuration;
39-
delete overrides.prod;
40-
41-
return this.runArchitectTarget({
42-
project: options.project,
43-
target: this.target,
44-
configuration,
45-
overrides
46-
}, options);
24+
public async run(options: ArchitectCommandOptions) {
25+
return this.runArchitectTarget(options);
4726
}
4827
}

packages/@angular/cli/commands/e2e.ts

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { CommandScope, Option } from '../models/command';
2-
import { ArchitectCommand } from '../models/architect-command';
2+
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
33

4-
export interface Options {
5-
project?: string;
6-
configuration?: string;
7-
prod: boolean;
8-
}
94

105
export default class E2eCommand extends ArchitectCommand {
116
public readonly name = 'e2e';
@@ -19,21 +14,7 @@ export default class E2eCommand extends ArchitectCommand {
1914
this.configurationOption
2015
];
2116

22-
public run(options: Options) {
23-
let configuration = options.configuration;
24-
if (!configuration && options.prod) {
25-
configuration = 'production';
26-
}
27-
28-
const overrides = { ...options };
29-
delete overrides.project;
30-
delete overrides.prod;
31-
32-
return this.runArchitectTarget({
33-
project: options.project,
34-
target: this.target,
35-
configuration,
36-
overrides
37-
}, options);
17+
public run(options: ArchitectCommandOptions) {
18+
return this.runArchitectTarget(options);
3819
}
3920
}
+3-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { CommandScope, Option } from '../models/command';
2-
import { ArchitectCommand } from '../models/architect-command';
2+
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
33

4-
export interface Options {
5-
project?: string;
6-
configuration?: string;
7-
}
84

95
export default class LintCommand extends ArchitectCommand {
106
public readonly name = 'lint';
@@ -17,14 +13,7 @@ export default class LintCommand extends ArchitectCommand {
1713
this.configurationOption
1814
];
1915

20-
public async run(options: Options) {
21-
const overrides = { ...options };
22-
delete overrides.project;
23-
return this.runArchitectTarget({
24-
project: options.project,
25-
target: this.target,
26-
configuration: options.configuration,
27-
overrides
28-
}, options);
16+
public async run(options: ArchitectCommandOptions) {
17+
return this.runArchitectTarget(options);
2918
}
3019
}

packages/@angular/cli/commands/run.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { CommandScope, Option } from '../models/command';
2-
import { ArchitectCommand } from '../models/architect-command';
2+
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
33

4-
export interface RunOptions {
5-
target: string;
6-
}
74

85
export default class RunCommand extends ArchitectCommand {
96
public readonly name = 'run';
@@ -14,17 +11,9 @@ export default class RunCommand extends ArchitectCommand {
1411
this.configurationOption
1512
];
1613

17-
public async run(options: RunOptions) {
14+
public async run(options: ArchitectCommandOptions) {
1815
if (options.target) {
19-
const [project, target, configuration] = options.target.split(':');
20-
const overrides = { ...options };
21-
delete overrides.target;
22-
return this.runArchitectTarget({
23-
project,
24-
target,
25-
configuration,
26-
overrides
27-
}, options);
16+
return this.runArchitectTarget(options);
2817
} else {
2918
throw new Error('Invalid architect target.');
3019
}
+4-24
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { CommandScope, Option } from '../models/command';
22
import { Version } from '../upgrade/version';
3-
import { ArchitectCommand } from '../models/architect-command';
3+
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
44

5-
export interface Options {
6-
project?: string;
7-
configuration?: string;
8-
prod: boolean;
9-
}
105

116
export default class ServeCommand extends ArchitectCommand {
127
public readonly name = 'serve';
@@ -19,29 +14,14 @@ export default class ServeCommand extends ArchitectCommand {
1914
this.configurationOption
2015
];
2116

22-
public validate(_options: Options) {
17+
public validate(_options: ArchitectCommandOptions) {
2318
// Check Angular and TypeScript versions.
2419
Version.assertCompatibleAngularVersion(this.project.root);
2520
Version.assertTypescriptVersion(this.project.root);
2621
return true;
2722
}
2823

29-
public async run(options: Options) {
30-
let configuration = options.configuration;
31-
if (!configuration && options.prod) {
32-
configuration = 'production';
33-
}
34-
35-
const overrides = { ...options };
36-
delete overrides.project;
37-
delete overrides.configuration;
38-
delete overrides.prod;
39-
40-
return this.runArchitectTarget({
41-
project: options.project,
42-
target: this.target,
43-
configuration,
44-
overrides
45-
}, options);
24+
public async run(options: ArchitectCommandOptions) {
25+
return this.runArchitectTarget(options);
4626
}
4727
}
+3-23
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { CommandScope, Option } from '../models/command';
2-
import { ArchitectCommand } from '../models/architect-command';
2+
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
33

4-
export interface Options {
5-
project?: string;
6-
configuration?: string;
7-
prod: boolean;
8-
}
94

105
export default class TestCommand extends ArchitectCommand {
116
public readonly name = 'test';
@@ -19,22 +14,7 @@ export default class TestCommand extends ArchitectCommand {
1914
this.configurationOption
2015
];
2116

22-
public async run(options: Options) {
23-
let configuration = options.configuration;
24-
if (!configuration && options.prod) {
25-
configuration = 'production';
26-
}
27-
28-
const overrides = { ...options };
29-
delete overrides.project;
30-
delete overrides.configuration;
31-
delete overrides.prod;
32-
33-
return this.runArchitectTarget({
34-
project: options.project,
35-
target: this.target,
36-
configuration,
37-
overrides
38-
}, options);
17+
public async run(options: ArchitectCommandOptions) {
18+
return this.runArchitectTarget(options);
3919
}
4020
}
+3-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { CommandScope, Option } from '../models/command';
2-
import { ArchitectCommand } from '../models/architect-command';
2+
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
33

4-
export interface Options {
5-
project?: string;
6-
configuration?: string;
7-
}
84

95
export default class Xi18nCommand extends ArchitectCommand {
106
public readonly name = 'xi18n';
@@ -16,14 +12,7 @@ export default class Xi18nCommand extends ArchitectCommand {
1612
this.configurationOption
1713
];
1814

19-
public async run(options: Options) {
20-
const overrides = { ...options };
21-
delete overrides.project;
22-
return this.runArchitectTarget({
23-
project: options.project,
24-
target: this.target,
25-
configuration: options.configuration,
26-
overrides
27-
}, options);
15+
public async run(options: ArchitectCommandOptions) {
16+
return this.runArchitectTarget(options);
2817
}
2918
}

0 commit comments

Comments
 (0)