|
1 |
| -import { Command, CommandScope } from '../models/command'; |
2 |
| -import { BuildOptions } from '../models/build-options'; |
| 1 | +import { CommandScope, Option } from '../models/command'; |
3 | 2 | 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'; |
22 | 4 |
|
23 | 5 | // Expose options unrelated to live-reload to other commands that need to run serve
|
24 | 6 | export const baseServeCommandOptions: any = [];
|
25 | 7 |
|
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 { |
27 | 15 | public readonly name = 'serve';
|
| 16 | + public readonly target = 'dev-server'; |
28 | 17 | public readonly description = 'Builds and serves your app, rebuilding on file changes.';
|
29 | 18 | public static aliases = ['server', 's'];
|
30 | 19 | public readonly scope = CommandScope.inProject;
|
31 | 20 | public readonly arguments: string[] = [];
|
32 |
| - public readonly options = baseServeCommandOptions; |
| 21 | + public readonly options: Option[] = [ |
| 22 | + this.prodOption, |
| 23 | + this.configurationOption |
| 24 | + ]; |
33 | 25 |
|
34 |
| - public validate(_options: ServeTaskOptions) { |
| 26 | + public validate(_options: Options) { |
35 | 27 | // Check Angular and TypeScript versions.
|
36 | 28 | Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
|
37 | 29 | Version.assertTypescriptVersion(this.project.root);
|
38 | 30 | return true;
|
39 | 31 | }
|
40 | 32 |
|
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 |
47 | 45 | });
|
48 |
| - |
49 |
| - return await serve.run(options); |
50 | 46 | }
|
51 | 47 | }
|
0 commit comments