-
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): migrate project dependencies to new project…
… versions This change reuses the v10 migration with update package versions to ensure that an updated project matches the development dependency versions of a newly generated project. (cherry picked from commit 644c2d7)
- Loading branch information
Showing
2 changed files
with
56 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
51 changes: 51 additions & 0 deletions
51
packages/schematics/angular/migrations/update-11/update-dependencies.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,51 @@ | ||
/** | ||
* @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 { Rule } from '@angular-devkit/schematics'; | ||
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; | ||
import { | ||
addPackageJsonDependency, | ||
getPackageJsonDependency, | ||
} from '../../utility/dependencies'; | ||
import { latestVersions } from '../../utility/latest-versions'; | ||
|
||
export default function (): Rule { | ||
return (host, context) => { | ||
const dependenciesToUpdate: Record<string, string> = { | ||
'@types/jasmine': '~3.6.0', | ||
'codelyzer': '^6.0.0', | ||
'jasmine-core': '~3.6.0', | ||
'jasmine-spec-reporter': '~5.0.0', | ||
'karma-chrome-launcher': '~3.1.0', | ||
'karma-coverage': '~2.0.3', | ||
'karma-jasmine': '~4.0.0', | ||
'karma-jasmine-html-reporter': '^1.5.0', | ||
'tslib': '^2.0.0', | ||
}; | ||
|
||
let hasChanges = false; | ||
for (const [name, version] of Object.entries(dependenciesToUpdate)) { | ||
const current = getPackageJsonDependency(host, name); | ||
if (!current || current.version === version) { | ||
continue; | ||
} | ||
|
||
addPackageJsonDependency(host, { | ||
type: current.type, | ||
name, | ||
version, | ||
overwrite: true, | ||
}); | ||
|
||
hasChanges = true; | ||
} | ||
|
||
if (hasChanges) { | ||
context.addTask(new NodePackageInstallTask()); | ||
} | ||
}; | ||
} |