Skip to content

Commit 1444212

Browse files
committed
feat(angular): document and pass along --watch option to ng
1 parent 453f08b commit 1444212

File tree

7 files changed

+33
-17
lines changed

7 files changed

+33
-17
lines changed

packages/ionic/src/commands/cordova/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class BuildCommand extends CordovaCommand implements CommandPreRun {
3636

3737
if (runner) {
3838
const libmetadata = await runner.getCommandMetadata();
39-
options.push(...libmetadata.options || []);
39+
options.push(...(libmetadata.options || []).filter(o => o.groups && o.groups.includes('cordova')));
4040
footnotes.push(...libmetadata.footnotes || []);
4141
}
4242

packages/ionic/src/commands/cordova/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class RunCommand extends CordovaCommand implements CommandPreRun {
100100
if (buildRunner) {
101101
const libmetadata = await buildRunner.getCommandMetadata();
102102
groups.push(...libmetadata.groups || []);
103-
options.push(...libmetadata.options || []);
103+
options.push(...(libmetadata.options || []).filter(o => o.groups && o.groups.includes('cordova')));
104104
footnotes.push(...libmetadata.footnotes || []);
105105
}
106106

packages/ionic/src/definitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ export interface AngularBuildOptions extends BuildOptions<'angular'> {
547547
configuration?: string;
548548
sourcemaps?: boolean;
549549
cordovaAssets?: boolean;
550+
watch?: boolean;
550551
}
551552

552553
export interface ReactBuildOptions extends BuildOptions<'react'> {

packages/ionic/src/lib/project/angular/build.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,24 @@ const NG_BUILD_OPTIONS = [
1212
aliases: ['c'],
1313
summary: 'Specify the configuration to use.',
1414
type: String,
15-
groups: [MetadataGroup.ADVANCED],
15+
groups: [MetadataGroup.ADVANCED, 'cordova'],
1616
hint: weak('[ng]'),
1717
spec: { value: 'conf' },
1818
},
19+
{
20+
name: 'source-map',
21+
summary: 'Output source maps',
22+
type: Boolean,
23+
groups: [MetadataGroup.ADVANCED, 'cordova'],
24+
hint: weak('[ng]'),
25+
},
26+
{
27+
name: 'watch',
28+
summary: 'Rebuild when files change',
29+
type: Boolean,
30+
groups: [MetadataGroup.ADVANCED],
31+
hint: weak('[ng]'),
32+
},
1933
];
2034

2135
export interface AngularBuildRunnerDeps extends BuildRunnerDeps {
@@ -45,13 +59,6 @@ ${input('ionic build')} uses the Angular CLI. Use ${input('ng build --help')} to
4559
type: Boolean,
4660
hint: weak('[ng]'),
4761
},
48-
{
49-
name: 'source-map',
50-
summary: 'Output source maps',
51-
type: Boolean,
52-
groups: [MetadataGroup.ADVANCED],
53-
hint: weak('[ng]'),
54-
},
5562
...NG_BUILD_OPTIONS,
5663
{
5764
name: 'cordova-assets',
@@ -63,6 +70,7 @@ ${input('ionic build')} uses the Angular CLI. Use ${input('ng build --help')} to
6370
],
6471
exampleCommands: [
6572
'--prod',
73+
'--watch',
6674
],
6775
};
6876
}
@@ -73,12 +81,14 @@ ${input('ionic build')} uses the Angular CLI. Use ${input('ng build --help')} to
7381
const configuration = options['configuration'] ? String(options['configuration']) : (prod ? 'production' : undefined);
7482
const sourcemaps = typeof options['source-map'] === 'boolean' ? Boolean(options['source-map']) : undefined;
7583
const cordovaAssets = typeof options['cordova-assets'] === 'boolean' ? Boolean(options['cordova-assets']) : undefined;
84+
const watch = typeof options['watch'] === 'boolean' ? Boolean(options['watch']) : undefined;
7685

7786
return {
7887
...baseOptions,
7988
configuration,
8089
sourcemaps,
8190
cordovaAssets,
91+
watch,
8292
type: 'angular',
8393
};
8494
}
@@ -114,6 +124,7 @@ export class AngularBuildCLI extends BuildCLI<AngularBuildOptions> {
114124
_: [],
115125
'source-map': options.sourcemaps !== false ? options.sourcemaps : 'false',
116126
'cordova-assets': options.cordovaAssets !== false ? undefined : 'false',
127+
'watch': options.watch !== false ? options.watch : 'false',
117128
};
118129

119130
const projectArgs = [];

packages/ionic/src/lib/project/ionic-angular/app-scripts.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,41 @@ export const APP_SCRIPTS_OPTIONS: CommandMetadataOption[] = [
2323
name: 'prod',
2424
summary: 'Build the application for production',
2525
type: Boolean,
26-
groups: ['app-scripts'],
26+
groups: ['app-scripts', 'cordova'],
2727
hint: weak('[app-scripts]'),
2828
},
2929
{
3030
name: 'aot',
3131
summary: 'Perform ahead-of-time compilation for this build',
3232
type: Boolean,
33-
groups: [MetadataGroup.ADVANCED, 'app-scripts'],
33+
groups: [MetadataGroup.ADVANCED, 'app-scripts', 'cordova'],
3434
hint: weak('[app-scripts]'),
3535
},
3636
{
3737
name: 'minifyjs',
3838
summary: 'Minify JS for this build',
3939
type: Boolean,
40-
groups: [MetadataGroup.ADVANCED, 'app-scripts'],
40+
groups: [MetadataGroup.ADVANCED, 'app-scripts', 'cordova'],
4141
hint: weak('[app-scripts]'),
4242
},
4343
{
4444
name: 'minifycss',
4545
summary: 'Minify CSS for this build',
4646
type: Boolean,
47-
groups: [MetadataGroup.ADVANCED, 'app-scripts'],
47+
groups: [MetadataGroup.ADVANCED, 'app-scripts', 'cordova'],
4848
hint: weak('[app-scripts]'),
4949
},
5050
{
5151
name: 'optimizejs',
5252
summary: 'Perform JS optimizations for this build',
5353
type: Boolean,
54-
groups: [MetadataGroup.ADVANCED, 'app-scripts'],
54+
groups: [MetadataGroup.ADVANCED, 'app-scripts', 'cordova'],
5555
hint: weak('[app-scripts]'),
5656
},
5757
{
5858
name: 'env',
5959
summary: '',
60-
groups: [MetadataGroup.HIDDEN, MetadataGroup.ADVANCED, 'app-scripts'],
60+
groups: [MetadataGroup.HIDDEN, MetadataGroup.ADVANCED, 'app-scripts', 'cordova'],
6161
hint: weak('[app-scripts]'),
6262
},
6363
];

packages/ionic/src/lib/project/ionic-angular/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ${input('ionic build')} uses ${strong('@ionic/app-scripts')}. See the project's
3838
name: 'source-map',
3939
summary: 'Output sourcemaps',
4040
type: Boolean,
41-
groups: [MetadataGroup.ADVANCED],
41+
groups: [MetadataGroup.ADVANCED, 'cordova'],
4242
hint: weak('[app-scripts]'),
4343
},
4444
...APP_SCRIPTS_OPTIONS,

packages/ionic/src/lib/project/react/build.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,25 @@ export class ReactBuildRunner extends BuildRunner<ReactBuildOptions> {
3131
name: 'public-url',
3232
summary: `You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). `,
3333
type: String,
34+
groups: ['cordova'],
3435
},
3536
{
3637
name: 'ci',
3738
summary: `Treat all warnings as build failures. Also makes the test runner non-watching.`,
3839
type: Boolean,
40+
groups: ['cordova'],
3941
},
4042
{
4143
name: 'source-map',
4244
summary: `When set to false, source maps are not generated.`,
4345
type: Boolean,
46+
groups: ['cordova'],
4447
},
4548
{
4649
name: 'inline-runtime-chunk',
4750
summary: `By default a runtime script is included in index.html. When set to false, the script will not be embedded and will be imported as usual. This is normally required when dealing with CSP.`,
4851
type: Boolean,
52+
groups: ['cordova'],
4953
},
5054
],
5155
groups: [MetadataGroup.BETA],

0 commit comments

Comments
 (0)