1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const build_1 = require("./build");
|
4 | const config_1 = require("../models/config");
|
5 | const version_1 = require("../upgrade/version");
|
6 | const check_port_1 = require("../utilities/check-port");
|
7 | const override_options_1 = require("../utilities/override-options");
|
8 | const Command = require('../ember-cli/lib/models/command');
|
9 | const config = config_1.CliConfig.fromProject() || config_1.CliConfig.fromGlobal();
|
10 | const defaultPort = process.env.PORT || config.get('defaults.serve.port');
|
11 | const defaultHost = config.get('defaults.serve.host');
|
12 | const defaultSsl = config.get('defaults.serve.ssl');
|
13 | const defaultSslKey = config.get('defaults.serve.sslKey');
|
14 | const defaultSslCert = config.get('defaults.serve.sslCert');
|
15 |
|
16 | exports.baseServeCommandOptions = override_options_1.overrideOptions([
|
17 | ...build_1.baseBuildCommandOptions,
|
18 | {
|
19 | name: 'port',
|
20 | type: Number,
|
21 | default: defaultPort,
|
22 | aliases: ['p'],
|
23 | description: 'Port to listen to for serving.'
|
24 | },
|
25 | {
|
26 | name: 'host',
|
27 | type: String,
|
28 | default: defaultHost,
|
29 | aliases: ['H'],
|
30 | description: `Listens only on ${defaultHost} by default.`
|
31 | },
|
32 | {
|
33 | name: 'proxy-config',
|
34 | type: 'Path',
|
35 | aliases: ['pc'],
|
36 | description: 'Proxy configuration file.'
|
37 | },
|
38 | {
|
39 | name: 'ssl',
|
40 | type: Boolean,
|
41 | default: defaultSsl,
|
42 | description: 'Serve using HTTPS.'
|
43 | },
|
44 | {
|
45 | name: 'ssl-key',
|
46 | type: String,
|
47 | default: defaultSslKey,
|
48 | description: 'SSL key to use for serving HTTPS.'
|
49 | },
|
50 | {
|
51 | name: 'ssl-cert',
|
52 | type: String,
|
53 | default: defaultSslCert,
|
54 | description: 'SSL certificate to use for serving HTTPS.'
|
55 | },
|
56 | {
|
57 | name: 'open',
|
58 | type: Boolean,
|
59 | default: false,
|
60 | aliases: ['o'],
|
61 | description: 'Opens the url in default browser.',
|
62 | },
|
63 | {
|
64 | name: 'live-reload',
|
65 | type: Boolean,
|
66 | default: true,
|
67 | aliases: ['lr'],
|
68 | description: 'Whether to reload the page on change, using live-reload.'
|
69 | },
|
70 | {
|
71 | name: 'live-reload-client',
|
72 | type: String,
|
73 | description: 'Specify the URL that the live reload browser client will use.'
|
74 | },
|
75 | {
|
76 | name: 'hmr',
|
77 | type: Boolean,
|
78 | default: false,
|
79 | description: 'Enable hot module replacement.',
|
80 | }
|
81 | ], [
|
82 | {
|
83 | name: 'watch',
|
84 | default: true,
|
85 | description: 'Rebuild on change.'
|
86 | }
|
87 | ]);
|
88 | const ServeCommand = Command.extend({
|
89 | name: 'serve',
|
90 | description: 'Builds and serves your app, rebuilding on file changes.',
|
91 | aliases: ['server', 's'],
|
92 | availableOptions: exports.baseServeCommandOptions,
|
93 | run: function (commandOptions) {
|
94 | const ServeTask = require('../tasks/serve').default;
|
95 | version_1.Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
|
96 | return check_port_1.checkPort(commandOptions.port, commandOptions.host, defaultPort)
|
97 | .then(port => {
|
98 | commandOptions.port = port;
|
99 | const serve = new ServeTask({
|
100 | ui: this.ui,
|
101 | project: this.project,
|
102 | });
|
103 | return serve.run(commandOptions);
|
104 | });
|
105 | }
|
106 | });
|
107 | exports.default = ServeCommand;
|
108 |
|
\ | No newline at end of file |