|
1 | 1 | import { MetadataGroup, ParsedArgs, unparseArgs } from '@ionic/cli-framework';
|
2 | 2 | import { stripAnsi } from '@ionic/cli-framework/utils/format';
|
| 3 | +import { str2num } from '@ionic/cli-framework/utils/string'; |
3 | 4 | import { findClosestOpenPort } from '@ionic/utils-network';
|
4 | 5 | import chalk from 'chalk';
|
5 | 6 |
|
6 | 7 | import { AngularServeOptions, CommandLineInputs, CommandLineOptions, CommandMetadata, ServeDetails } from '../../../definitions';
|
7 | 8 | import { input, strong, weak } from '../../color';
|
8 |
| -import { BIND_ALL_ADDRESS, LOCAL_ADDRESSES, SERVE_SCRIPT, ServeCLI, ServeRunner, ServeRunnerDeps } from '../../serve'; |
| 9 | +import { BIND_ALL_ADDRESS, DEFAULT_DEV_LOGGER_PORT as DEFAULT_CONSOLE_LOGS_PORT, LOCAL_ADDRESSES, SERVE_SCRIPT, ServeCLI, ServeRunner, ServeRunnerDeps } from '../../serve'; |
9 | 10 |
|
10 | 11 | import { AngularProject } from './';
|
11 | 12 |
|
@@ -36,6 +37,22 @@ The dev server can use HTTPS via the ${input('--ssl')} option ${chalk.bold.red('
|
36 | 37 | },
|
37 | 38 | ],
|
38 | 39 | options: [
|
| 40 | + { |
| 41 | + name: 'consolelogs', |
| 42 | + summary: 'Print app console logs to the terminal', |
| 43 | + type: Boolean, |
| 44 | + groups: [MetadataGroup.ADVANCED, 'cordova'], |
| 45 | + // aliases: ['c'], Already used by ng cli for --configuration |
| 46 | + hint: weak('[ng]'), |
| 47 | + }, |
| 48 | + { |
| 49 | + name: 'consolelogs-port', |
| 50 | + summary: 'Use specific port for console logs server', |
| 51 | + type: String, |
| 52 | + groups: [MetadataGroup.ADVANCED, 'cordova'], |
| 53 | + hint: weak('[ng]'), |
| 54 | + spec: { value: 'port' }, |
| 55 | + }, |
39 | 56 | {
|
40 | 57 | name: 'ssl',
|
41 | 58 | summary: 'Use HTTPS for the dev server',
|
@@ -85,9 +102,19 @@ The dev server can use HTTPS via the ${input('--ssl')} option ${chalk.bold.red('
|
85 | 102 | const ssl = options['ssl'] ? Boolean(options['ssl']) : undefined;
|
86 | 103 | const configuration = options['configuration'] ? String(options['configuration']) : (prod ? 'production' : undefined);
|
87 | 104 | const sourcemaps = typeof options['source-map'] === 'boolean' ? Boolean(options['source-map']) : undefined;
|
| 105 | + let consolelogs = typeof options['consolelogs'] === 'boolean' ? Boolean(options['consolelogs']) : undefined; |
| 106 | + let consolelogsPort = consolelogs ? str2num(options['consolelogs-port'], DEFAULT_CONSOLE_LOGS_PORT) : undefined; |
| 107 | + |
| 108 | + // if not defined, default to true for devapp |
| 109 | + if (options.devapp) { |
| 110 | + consolelogs = consolelogs === undefined ? true : consolelogs; |
| 111 | + consolelogsPort = str2num(options['consolelogs-port'], DEFAULT_CONSOLE_LOGS_PORT); |
| 112 | + } |
88 | 113 |
|
89 | 114 | return {
|
90 | 115 | ...baseOptions,
|
| 116 | + consolelogs, |
| 117 | + consolelogsPort, |
91 | 118 | ssl,
|
92 | 119 | configuration,
|
93 | 120 | sourcemaps,
|
@@ -215,6 +242,8 @@ export class AngularServeCLI extends ServeCLI<AngularServeOptions> {
|
215 | 242 | if (options.devapp) {
|
216 | 243 | args.cordovaMock = true;
|
217 | 244 | }
|
| 245 | + args.consolelogs = options.consolelogs ? true : undefined; |
| 246 | + args['consolelogs-port'] = options.consolelogsPort ? String(options.consolelogsPort) : undefined; |
218 | 247 | }
|
219 | 248 |
|
220 | 249 | if (this.resolvedProgram !== this.program) {
|
|
0 commit comments