From 23e7f168e6fc94333b60a04ffe004672ef152151 Mon Sep 17 00:00:00 2001 From: Xukai Wu Date: Mon, 4 Mar 2019 17:31:14 +0800 Subject: [PATCH 1/2] Fix basicSemverOperatorRegex When running `yarn upgrade --latest`, if the range operator is '>=', the matched result is '>', which is not correct --- src/cli/commands/upgrade.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/commands/upgrade.js b/src/cli/commands/upgrade.js index 9a149951c4..38dc69c847 100644 --- a/src/cli/commands/upgrade.js +++ b/src/cli/commands/upgrade.js @@ -12,7 +12,7 @@ import {Install} from './install.js'; // used to detect whether a semver range is simple enough to preserve when doing a --latest upgrade. // when not matched, the upgraded version range will default to `^` the same as the `add` command would. -const basicSemverOperatorRegex = new RegExp('^(\\^|~|>|<=|>=)?[^ |&,]+$'); +const basicSemverOperatorRegex = new RegExp('^(\\^|~|>=|<=|>)?[^ |&,]+$'); // used to detect if a passed parameter is a scope or a package name. const validScopeRegex = /^@[a-zA-Z0-9-][a-zA-Z0-9_.-]*\/$/; From 404c7f290b8eb8400d4f6ac693cf509a25156749 Mon Sep 17 00:00:00 2001 From: Xukai Wu Date: Tue, 5 Mar 2019 09:00:07 +0800 Subject: [PATCH 2/2] remove '>' from regex --- CHANGELOG.md | 4 ++++ src/cli/commands/upgrade.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 550e3f5114..e7be24d421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa ## Master +- Fixes yarn `upgrade --latest` for dependencies using `>` or `>=` range specifier + + [#7080](https://github.com/yarnpkg/yarn/pull/7080) - [**Xukai Wu**](https://github.com/shilcare) + - Fixes `--modules-folder` handling in several places (ex: `yarn check` now respects `--modules-folder`) [#6850](https://github.com/yarnpkg/yarn/pull/6850) - [**Jeff Valore**](https://twitter.com/codingwithspike) diff --git a/src/cli/commands/upgrade.js b/src/cli/commands/upgrade.js index 38dc69c847..53d19f6474 100644 --- a/src/cli/commands/upgrade.js +++ b/src/cli/commands/upgrade.js @@ -12,7 +12,7 @@ import {Install} from './install.js'; // used to detect whether a semver range is simple enough to preserve when doing a --latest upgrade. // when not matched, the upgraded version range will default to `^` the same as the `add` command would. -const basicSemverOperatorRegex = new RegExp('^(\\^|~|>=|<=|>)?[^ |&,]+$'); +const basicSemverOperatorRegex = new RegExp('^(\\^|~|>=|<=)?[^ |&,]+$'); // used to detect if a passed parameter is a scope or a package name. const validScopeRegex = /^@[a-zA-Z0-9-][a-zA-Z0-9_.-]*\/$/; @@ -74,7 +74,7 @@ function setUserRequestedPackageVersions( } // this function attempts to determine the range operator on the semver range. -// this will only handle the simple cases of a semver starting with '^', '~', '>', '>=', '<=', or an exact version. +// this will only handle the simple cases of a semver starting with '^', '~', '>=', '<=', or an exact version. // "exotic" semver ranges will not be handled. function getRangeOperator(version): string { const result = basicSemverOperatorRegex.exec(version);