@@ -612,35 +612,40 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
612
612
return 1 ;
613
613
}
614
614
615
- if ( node . package ?. name === '@angular/cli' ) {
616
- // Migrations for non LTS versions of Angular CLI are no longer included in @schematics /angular v12.
615
+ if ( manifest . version === node . package ?. version ) {
616
+ this . logger . info ( `Package '${ packageName } ' is already up to date.` ) ;
617
+ continue ;
618
+ }
619
+
620
+ if ( node . package && / ^ @ (?: a n g u l a r | n g u n i v e r s a l ) \/ / . test ( node . package . name ) ) {
621
+ const { name, version } = node . package ;
617
622
const toBeInstalledMajorVersion = + manifest . version . split ( '.' ) [ 0 ] ;
618
- const currentMajorVersion = + node . package . version . split ( '.' ) [ 0 ] ;
619
- if ( currentMajorVersion < 9 && toBeInstalledMajorVersion >= 12 ) {
620
- const updateVersions : Record < number , number > = {
621
- 1 : 6 ,
622
- 6 : 7 ,
623
- 7 : 8 ,
624
- 8 : 9 ,
625
- } ;
626
-
627
- const updateTo = updateVersions [ currentMajorVersion ] ;
628
- this . logger . error (
629
- 'Updating multiple major versions at once is not recommended. ' +
630
- `Run 'ng update @angular/cli@${ updateTo } ' in your workspace directory ` +
631
- `to update to latest '${ updateTo } .x' version of '@angular/cli'.\n\n` +
632
- 'For more information about the update process, see https://update.angular.io/.' ,
633
- ) ;
623
+ const currentMajorVersion = + version . split ( '.' ) [ 0 ] ;
624
+
625
+ if ( toBeInstalledMajorVersion - currentMajorVersion > 1 ) {
626
+ // Only allow updating a single version at a time.
627
+ if ( currentMajorVersion < 6 ) {
628
+ // Before version 6, the major versions were not always sequential.
629
+ // Example @angular /core skipped version 3, @angular/cli skipped versions 2-5.
630
+ this . logger . error (
631
+ `Updating multiple major versions of '${ name } ' at once is not supported. Please migrate each major version individually.\n` +
632
+ `For more information about the update process, see https://update.angular.io/.` ,
633
+ ) ;
634
+ } else {
635
+ const nextMajorVersionFromCurrent = currentMajorVersion + 1 ;
636
+
637
+ this . logger . error (
638
+ `Updating multiple major versions of '${ name } ' at once is not supported. Please migrate each major version individually.\n` +
639
+ `Run 'ng update ${ name } @${ nextMajorVersionFromCurrent } ' in your workspace directory ` +
640
+ `to update to latest '${ nextMajorVersionFromCurrent } .x' version of '${ name } '.\n\n` +
641
+ `For more information about the update process, see https://update.angular.io/?v=${ currentMajorVersion } .0-${ nextMajorVersionFromCurrent } .0` ,
642
+ ) ;
643
+ }
634
644
635
645
return 1 ;
636
646
}
637
647
}
638
648
639
- if ( manifest . version === node . package ?. version ) {
640
- this . logger . info ( `Package '${ packageName } ' is already up to date.` ) ;
641
- continue ;
642
- }
643
-
644
649
packagesToUpdate . push ( requestIdentifier . toString ( ) ) ;
645
650
}
646
651
0 commit comments