-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@schematics/angular): ensure Angular builders are migrated to lat…
…est versions The package group format required to automatically update the builder packages was not supported until CLI 7.2. For older CLI versions performing the update, this new migration will update the builders instead. Once the CLI is updated to at least 7.2, the update algorithm itself will handle the update.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/schematics/angular/migrations/update-8/update-builders.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import { SchematicContext, Tree } from '@angular-devkit/schematics'; | ||
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; | ||
import { addPackageJsonDependency, getPackageJsonDependency } from '../../utility/dependencies'; | ||
import { latestVersions } from '../../utility/latest-versions'; | ||
|
||
export function updateBuilders() { | ||
return (host: Tree, context: SchematicContext) => { | ||
let updates = false; | ||
|
||
let current = getPackageJsonDependency(host, '@angular-devkit/build-angular'); | ||
if (current && current.version !== latestVersions.DevkitBuildAngular) { | ||
updates = true; | ||
addPackageJsonDependency( | ||
host, | ||
{ | ||
type: current.type, | ||
name: '@angular-devkit/build-angular', | ||
version: latestVersions.DevkitBuildAngular, | ||
overwrite: true, | ||
}, | ||
); | ||
} | ||
|
||
current = getPackageJsonDependency(host, '@angular-devkit/build-ng-packagr'); | ||
if (current && current.version !== latestVersions.DevkitBuildNgPackagr) { | ||
updates = true; | ||
addPackageJsonDependency( | ||
host, | ||
{ | ||
type: current.type, | ||
name: '@angular-devkit/build-ng-packagr', | ||
version: latestVersions.DevkitBuildNgPackagr, | ||
overwrite: true, | ||
}, | ||
); | ||
} | ||
|
||
if (updates) { | ||
context.addTask(new NodePackageInstallTask()); | ||
} | ||
}; | ||
} |