Skip to content

Commit

Permalink
fix(upgrade): Fix yarn upgrade when using --scope with exotic deps (#…
Browse files Browse the repository at this point in the history
…7017)

* fix(upgrade): Fix yarn upgrade when using --scope with exotic dependencies.

Exotic dependencies (github urls for example) were not being unlocked from the lockfile when running
`yarn upgrade --scope @whatever/` which was resulting in dependencies not being upgraded. This was
due to trying to find the dep in the lockfile just by it's url instead of in `name@url` format.

fixes #7016

* updated changelog
  • Loading branch information
rally25rs authored and arcanis committed Feb 18, 2019
1 parent 0e380a1 commit c837fef
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Fix yarn `upgrade --scope` when using exotic (github) dependencies.

[#7017](https://github.com/yarnpkg/yarn/pull/7017) - [**Jeff Valore**](https://twitter.com/codingwithspike)

- Fixes occasionally mismatching upper/lowecases of drive letters in win32 pnp check

[#7007](https://github.com/yarnpkg/yarn/pull/7007) - [**Christoph Werner**](https://github.com/codepunkt)
Expand Down
12 changes: 12 additions & 0 deletions __tests__/commands/upgrade.js
Expand Up @@ -248,6 +248,18 @@ test.concurrent('upgrades dependency packages not in registry', (): Promise<void
});
});

test.concurrent('upgrades scoped packages not in registry', (): Promise<void> => {
return runUpgrade([], {scope: '@yarn/'}, 'package-not-in-registry-scoped', async (config): ?Promise<void> => {
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock')));
const gitRemote = 'https://github.com/yarnpkg/e2e-test-repo';

const lockFileIncludes = sha => lockfile.indexOf(` resolved "${gitRemote}#${sha}"`) > -1;
expect(lockfile.indexOf(`"@yarn/test-git-repo@${gitRemote}#master":`)).toBeGreaterThan(-1);
expect(lockFileIncludes('5c57959f3c55a6cd6004e3855ca59ba98bfff56c')).toEqual(false);
expect(lockFileIncludes('64ed9468f0636a76fbadde0960ed321cc2c2cab0')).toEqual(true);
});
});

test.concurrent('upgrades dev dependency packages not in registry', (): Promise<void> => {
const packages = ['yarn-test-git-repo', 'e2e-test-repo'];
return runUpgrade(packages, {}, 'package-not-in-registry-dev', async (config): ?Promise<void> => {
Expand Down
@@ -0,0 +1,5 @@
{
"dependencies": {
"@yarn/test-git-repo": "https://github.com/yarnpkg/e2e-test-repo#master"
}
}
@@ -0,0 +1,7 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@yarn/test-git-repo@https://github.com/yarnpkg/e2e-test-repo#master":
version "1.0.0"
resolved "https://github.com/yarnpkg/e2e-test-repo#5c57959f3c55a6cd6004e3855ca59ba98bfff56c"
Expand Up @@ -8,4 +8,4 @@

"yarn-test-git-repo@https://github.com/yarnpkg/e2e-test-repo#master":
version "1.0.0"
resolved "https://github.com/yarnpkg/e2e-test-repo#64ed9468f0636a76fbadde0960ed321cc2c2cab0"
resolved "https://github.com/yarnpkg/e2e-test-repo#5c57959f3c55a6cd6004e3855ca59ba98bfff56c"
2 changes: 1 addition & 1 deletion src/cli/commands/upgrade.js
Expand Up @@ -85,7 +85,7 @@ function getRangeOperator(version): string {
// If an explicit operator was specified using --exact, --tilde, --caret, then that will take precedence.
function buildPatternToUpgradeTo(dep, flags): string {
if (dep.latest === 'exotic') {
return dep.url;
return `${dep.name}@${dep.url}`;
}

const toLatest = flags.latest;
Expand Down

0 comments on commit c837fef

Please sign in to comment.