Skip to content

Commit a033e50

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular/cli): add verbose option to update and add
At the moment there is no way to turn on the verbose logging for `ng update` and `ng add`. This is useful for use so that when users report issues such as npmrc is not read we can see the lookup locations. This also removes some reduncant that were being provided in `executeSchematic`. Related to #14993
1 parent e4d5b85 commit a033e50

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

packages/angular/cli/commands/add-impl.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { dirname, join } from 'path';
1111
import { intersects, prerelease, rcompare, satisfies, valid, validRange } from 'semver';
1212
import { isPackageNameSafeForAnalytics } from '../models/analytics';
1313
import { Arguments } from '../models/interface';
14-
import { SchematicCommand } from '../models/schematic-command';
14+
import { RunSchematicOptions, SchematicCommand } from '../models/schematic-command';
1515
import npmInstall from '../tasks/npm-install';
1616
import { colors } from '../utilities/color';
1717
import { getPackageManager } from '../utilities/package-manager';
@@ -65,6 +65,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
6565
packageMetadata = await fetchPackageMetadata(packageIdentifier.name, this.logger, {
6666
registry: options.registry,
6767
usingYarn,
68+
verbose: options.verbose,
6869
});
6970
} catch (e) {
7071
this.logger.error('Unable to fetch package metadata: ' + e.message);
@@ -116,6 +117,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
116117
try {
117118
const manifest = await fetchPackageManifest(packageIdentifier, this.logger, {
118119
registry: options.registry,
120+
verbose: options.verbose,
119121
usingYarn,
120122
});
121123

@@ -174,12 +176,10 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
174176
collectionName: string,
175177
options: string[] = [],
176178
): Promise<number | void> {
177-
const runOptions = {
179+
const runOptions: RunSchematicOptions = {
178180
schematicOptions: options,
179-
workingDir: this.workspace.root,
180181
collectionName,
181182
schematicName: 'ng-add',
182-
allowPrivate: true,
183183
dryRun: false,
184184
force: false,
185185
};

packages/angular/cli/commands/add.json

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"format": "hostname"
3131
}
3232
]
33+
},
34+
"verbose": {
35+
"description": "Display additional details about internal operations during execution.",
36+
"type": "boolean",
37+
"default": false
3338
}
3439
},
3540
"required": [

packages/angular/cli/commands/update-impl.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import * as path from 'path';
1111
import * as semver from 'semver';
1212
import { Arguments, Option } from '../models/interface';
1313
import { SchematicCommand } from '../models/schematic-command';
14-
import { findUp } from '../utilities/find-up';
1514
import { getPackageManager } from '../utilities/package-manager';
1615
import {
1716
PackageIdentifier,
@@ -134,6 +133,7 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
134133
additionalOptions: {
135134
force: options.force || false,
136135
next: options.next || false,
136+
verbose: options.verbose || false,
137137
packageManager,
138138
packages: options.all ? Object.keys(rootDependencies) : [],
139139
},
@@ -240,6 +240,7 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
240240
package: packageName,
241241
collection: migrations,
242242
from: options.from,
243+
verbose: options.verbose || false,
243244
to: options.to || packageNode.package.version,
244245
},
245246
});
@@ -286,7 +287,7 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
286287
try {
287288
// Metadata requests are internally cached; multiple requests for same name
288289
// does not result in additional network traffic
289-
metadata = await fetchPackageMetadata(packageName, this.logger);
290+
metadata = await fetchPackageMetadata(packageName, this.logger, { verbose: options.verbose });
290291
} catch (e) {
291292
this.logger.error(`Error fetching metadata for '${packageName}': ` + e.message);
292293

@@ -339,6 +340,7 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
339340
dryRun: !!options.dryRun,
340341
showNothingDone: false,
341342
additionalOptions: {
343+
verbose: options.verbose || false,
342344
force: options.force || false,
343345
packageManager,
344346
packages: packagesToUpdate,

packages/angular/cli/commands/update.json

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"allowDirty": {
5858
"description": "Whether to allow updating when the repository contains modified or untracked files.",
5959
"type": "boolean"
60+
},
61+
"verbose": {
62+
"description": "Display additional details about internal operations during execution.",
63+
"type": "boolean",
64+
"default": false
6065
}
6166
}
6267
}

0 commit comments

Comments
 (0)