From 9ce386caf6037f21f422a785fec977634406d208 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 27 Oct 2022 21:25:15 +0200 Subject: [PATCH] =?UTF-8?q?fix(@angular/cli):=20exclude=20`@angular/locali?= =?UTF-8?q?ze@<10.0.0`=20from=20ng=20add=20pa=E2=80=A6=20(#24152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(@angular/cli): exclude `@angular/localize@<10.0.0` from ng add package discovery `@angular/localize@<10.0.0` has no peer dependencies. This can cause `ng add` to pick these versions of the package if the newer versions. See: https://app.circleci.com/pipelines/github/angular/angular-cli/27402/workflows/faa64532-541a-4bea-b599-3c53afe42019/jobs/364822 ``` Test Process error Error: Process exit error - "ng add @angular/localize --skip-confirmation": 1... STDOUT: STDERR: npm version 7.4.0 detected. When using npm 7 with the Angular CLI, npm version 7.5.6 or higher is recommended. - Determining package manager... ℹ Using package manager: npm - Searching for compatible package version... ✔ Found compatible package version: @angular/localize@10.0.0-next.7. - Loading package information from registry... ✔ Package information loaded. - Installing packages... ✔ Packages successfully installed. NOT SUPPORTED: keyword "id", use "$id" for schema ID ``` * fixup! fix(@angular/cli): exclude `@angular/localize@<10.0.0` from ng add package discovery Co-authored-by: Charles <19598772+clydin@users.noreply.github.com> Co-authored-by: Charles <19598772+clydin@users.noreply.github.com> (cherry picked from commit 65a0983a416067d160103ce244a580cf04929905) (cherry picked from commit 35e5f4278145b7ef55a75f1692c8e92d6bcd59db) --- packages/angular/cli/src/commands/add/cli.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/angular/cli/src/commands/add/cli.ts b/packages/angular/cli/src/commands/add/cli.ts index 1fd2c58f975c..55768138e4f2 100644 --- a/packages/angular/cli/src/commands/add/cli.ts +++ b/packages/angular/cli/src/commands/add/cli.ts @@ -10,7 +10,7 @@ import { analytics, tags } from '@angular-devkit/core'; import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools'; import npa from 'npm-package-arg'; import { dirname, join } from 'path'; -import { compare, intersects, prerelease, satisfies, valid } from 'semver'; +import { Range, compare, intersects, prerelease, satisfies, valid } from 'semver'; import { Argv } from 'yargs'; import { PackageManager } from '../../../lib/config/workspace-schema'; import { isPackageNameSafeForAnalytics } from '../../analytics/analytics'; @@ -47,10 +47,10 @@ interface AddCommandArgs extends SchematicsCommandArgs { * when attempting to find a compatible version for a package. * The key is a package name and the value is a SemVer range of versions to exclude. */ -const packageVersionExclusions: Record = { - // @angular/localize@9.x versions do not have peer dependencies setup - '@angular/localize': '9.x', - // @angular/material@7.x versions have unbounded peer dependency ranges (>=7.0.0) +const packageVersionExclusions: Record = { + // @angular/localize@9.x and earlier versions as well as @angular/localize@10.0 prereleases do not have peer dependencies setup. + '@angular/localize': '<10.0.0', + // @angular/material@7.x versions have unbounded peer dependency ranges (>=7.0.0). '@angular/material': '7.x', }; @@ -189,7 +189,10 @@ export class AddCommandModule return false; } // Excluded package versions should not be considered - if (versionExclusions && satisfies(value.version, versionExclusions)) { + if ( + versionExclusions && + satisfies(value.version, versionExclusions, { includePrerelease: true }) + ) { return false; }