Skip to content

Commit 2dd0cbd

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular/cli): inline @schematics/update:update schematic
This change removes the need for the `@schematics/update` package within the Angular tooling and removes the dependency from the `@angular/cli` package. Only the `update` schematic from the `@schematics/update` package was used and this schematic's logic will eventually be folded into the update command logic directly.
1 parent 51cb318 commit 2dd0cbd

File tree

12 files changed

+28
-19
lines changed

12 files changed

+28
-19
lines changed

packages/angular/cli/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ts_library(
4848
"//packages/angular/cli:commands/version.ts",
4949
"//packages/angular/cli:commands/run.ts",
5050
"//packages/angular/cli:commands/extract-i18n.ts",
51+
"//packages/angular/cli:src/commands/update/schematic/schema.ts",
5152
# @external_end
5253
],
5354
data = glob(
@@ -72,11 +73,13 @@ ts_library(
7273
"//packages/angular_devkit/core",
7374
"//packages/angular_devkit/core/node",
7475
"//packages/angular_devkit/schematics",
76+
"//packages/angular_devkit/schematics/tasks",
7577
"//packages/angular_devkit/schematics/tools",
7678
"@npm//@angular/core",
7779
"@npm//@types/debug",
7880
"@npm//@types/inquirer",
7981
"@npm//@types/node",
82+
"@npm//@types/npm-package-arg",
8083
"@npm//@types/resolve",
8184
"@npm//@types/rimraf",
8285
"@npm//@types/semver",
@@ -274,6 +277,11 @@ ts_json_schema(
274277
],
275278
)
276279

280+
ts_json_schema(
281+
name = "update_schematic_schema",
282+
src = "src/commands/update/schematic/schema.json",
283+
)
284+
277285
ts_library(
278286
name = "angular-cli_test_lib",
279287
testonly = True,
@@ -288,6 +296,10 @@ ts_library(
288296
deps = [
289297
":angular-cli",
290298
"//packages/angular_devkit/core",
299+
"//packages/angular_devkit/schematics",
300+
"//packages/angular_devkit/schematics/testing",
301+
"@npm//@types/semver",
302+
"@npm//rxjs",
291303
],
292304
)
293305

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ const NG_VERSION_9_POST_MSG = colors.cyan(
4747
'For more info, please see: https://v9.angular.io/guide/updating-to-version-9',
4848
);
4949

50+
const UPDATE_SCHEMATIC_COLLECTION = path.join(
51+
__dirname,
52+
'../src/commands/update/schematic/collection.json',
53+
);
54+
5055
/**
5156
* Disable CLI version mismatch checks and forces usage of the invoked CLI
5257
* instead of invoking the local installed version.
@@ -384,7 +389,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
384389

385390
if (packages.length === 0) {
386391
// Show status
387-
const { success } = await this.executeSchematic('@schematics/update', 'update', {
392+
const { success } = await this.executeSchematic(UPDATE_SCHEMATIC_COLLECTION, 'update', {
388393
force: options.force || false,
389394
next: options.next || false,
390395
verbose: options.verbose || false,
@@ -630,7 +635,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
630635
return 0;
631636
}
632637

633-
const { success } = await this.executeSchematic('@schematics/update', 'update', {
638+
const { success } = await this.executeSchematic(UPDATE_SCHEMATIC_COLLECTION, 'update', {
634639
verbose: options.verbose || false,
635640
force: options.force || false,
636641
next: !!options.next,

packages/angular/cli/models/analytics.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export const analyticsPackageSafelist = [
4848
/^@ngtools\//,
4949
'@schematics/angular',
5050
'@schematics/schematics',
51-
'@schematics/update',
5251
];
5352

5453
export function isPackageNameSafeForAnalytics(name: string): boolean {

packages/angular/cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@angular-devkit/core": "0.0.0",
3030
"@angular-devkit/schematics": "0.0.0",
3131
"@schematics/angular": "0.0.0",
32-
"@schematics/update": "0.0.0",
3332
"@yarnpkg/lockfile": "1.1.0",
3433
"ansi-colors": "4.1.1",
3534
"debug": "4.3.1",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"schematics": {
3+
"update": {
4+
"factory": "./index",
5+
"schema": "./schema.json",
6+
"description": "Update one or multiple packages to versions, updating peer dependencies along the way."
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)