Skip to content

Commit

Permalink
fix(@angular/cli): add message update updating from non LTS versions …
Browse files Browse the repository at this point in the history
…of the CLI
  • Loading branch information
alan-agius4 authored and clydin committed Apr 14, 2021
1 parent 36a8882 commit d68cb92
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions packages/angular/cli/commands/update-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const pickManifest = require('npm-pick-manifest') as (
selector: string,
) => PackageManifest;

const oldConfigFileNames = ['.angular-cli.json', 'angular-cli.json'];

const NG_VERSION_9_POST_MSG = colors.cyan(
'\nYour project has been updated to Angular version 9!\n' +
'For more info, please see: https://v9.angular.io/guide/updating-to-version-9',
Expand Down Expand Up @@ -367,20 +365,6 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
}

this.logger.info(`Using package manager: '${this.packageManager}'`);

// Special handling for Angular CLI 1.x migrations
if (
options.migrateOnly === undefined &&
options.from === undefined &&
packages.length === 1 &&
packages[0].name === '@angular/cli' &&
this.workspace &&
oldConfigFileNames.includes(path.basename(this.workspace.filePath))
) {
options.migrateOnly = true;
options.from = '1.0.0';
}

this.logger.info('Collecting installed dependencies...');

const rootDependencies = await getProjectDependencies(this.context.root);
Expand Down Expand Up @@ -623,6 +607,28 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
return 1;
}

if (node.package?.name === '@angular/cli') {
// Migrations for non LTS versions of Angular CLI are no longer included in @schematics/angular v12.
const toBeInstalledMajorVersion = +manifest.version.split('.')[0];
const currentMajorVersion = +node.package.version.split('.')[0];
if (currentMajorVersion < 9 && toBeInstalledMajorVersion >= 12) {
const updateVersions: Record<number, number> = {
1: 6,
6: 7,
7: 8,
8: 9,
};

const updateTo = updateVersions[currentMajorVersion];
this.logger.error('Updating multiple major versions at once is not recommended. ' +
`Run 'ng update @angular/cli@${updateTo}' in your workspace directory ` +
`to update to latest '${updateTo}.x' version of '@angular/cli'.\n\n` +
'For more information about the update process, see https://update.angular.io/.');

return 1;
}
}

if (manifest.version === node.package?.version) {
this.logger.info(`Package '${packageName}' is already up to date.`);
continue;
Expand Down

0 comments on commit d68cb92

Please sign in to comment.