Skip to content

Commit fd04936

Browse files
Broccohansl
authored andcommitted
Update serve command to use architect
1 parent 3d91d53 commit fd04936

File tree

2 files changed

+27
-45
lines changed

2 files changed

+27
-45
lines changed
Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,47 @@
1-
import { Command, CommandScope } from '../models/command';
2-
import { BuildOptions } from '../models/build-options';
1+
import { CommandScope, Option } from '../models/command';
32
import { Version } from '../upgrade/version';
4-
import { ServeTaskOptions } from './serve';
5-
6-
// const Command = require('../ember-cli/lib/models/command');
7-
8-
export interface ServeTaskOptions extends BuildOptions {
9-
port?: number;
10-
host?: string;
11-
proxyConfig?: string;
12-
liveReload?: boolean;
13-
publicHost?: string;
14-
disableHostCheck?: boolean;
15-
ssl?: boolean;
16-
sslKey?: string;
17-
sslCert?: string;
18-
open?: boolean;
19-
hmr?: boolean;
20-
servePath?: string;
21-
}
3+
import { ArchitectCommand } from '../models/architect-command';
224

235
// Expose options unrelated to live-reload to other commands that need to run serve
246
export const baseServeCommandOptions: any = [];
257

26-
export default class ServeCommand extends Command {
8+
export interface Options {
9+
app?: string;
10+
configuration?: string;
11+
prod: boolean;
12+
}
13+
14+
export default class ServeCommand extends ArchitectCommand {
2715
public readonly name = 'serve';
16+
public readonly target = 'dev-server';
2817
public readonly description = 'Builds and serves your app, rebuilding on file changes.';
2918
public static aliases = ['server', 's'];
3019
public readonly scope = CommandScope.inProject;
3120
public readonly arguments: string[] = [];
32-
public readonly options = baseServeCommandOptions;
21+
public readonly options: Option[] = [
22+
this.prodOption,
23+
this.configurationOption
24+
];
3325

34-
public validate(_options: ServeTaskOptions) {
26+
public validate(_options: Options) {
3527
// Check Angular and TypeScript versions.
3628
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
3729
Version.assertTypescriptVersion(this.project.root);
3830
return true;
3931
}
4032

41-
public async run(options: ServeTaskOptions) {
42-
const ServeTask = require('../tasks/serve').default;
43-
44-
const serve = new ServeTask({
45-
ui: this.ui,
46-
project: this.project,
33+
public async run(options: Options) {
34+
let configuration = options.configuration;
35+
if (options.prod) {
36+
configuration = 'production';
37+
}
38+
const overrides = {...options};
39+
delete overrides.app;
40+
delete overrides.prod;
41+
return this.runArchitect({
42+
app: options.app,
43+
configuration,
44+
overrides
4745
});
48-
49-
return await serve.run(options);
5046
}
5147
}

packages/@angular/cli/tasks/serve.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)