forked from yarnpkg/yarn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "latest" flag to "yarn upgrade" (yarnpkg#3510)
* Added additional (passing) tests for existing upgrade behavior * [yarnpkg#3384] add --latest/-L flag to * added previously forgotten files to make tests actually pass
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,70 @@ test.concurrent('upgrades from fixed version to latest', (): Promise<void> => { | |
}); | ||
}); | ||
|
||
test.concurrent('upgrades to latest matching package.json semver when no package name passed', (): Promise<void> => { | ||
return runUpgrade([], {}, 'range-to-latest', async (config): ?Promise<void> => { | ||
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock'))); | ||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const lockEntryIndex = lockfile.indexOf('left-pad@<=1.1.1:'); | ||
|
||
expect(lockEntryIndex).toEqual(0); | ||
expect(lockfile[lockEntryIndex + 1]).toContain('1.1.1'); | ||
expect(pkg.dependencies).toEqual({'left-pad': '<=1.1.1'}); | ||
}); | ||
}); | ||
|
||
test.concurrent('--latest upgrades to latest ignoring package.json when no package name passed', (): Promise<void> => { | ||
return runUpgrade([], {latest: true}, 'range-to-latest', async (config): ?Promise<void> => { | ||
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock'))); | ||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const lockEntryIndex = lockfile.indexOf('left-pad@^1.1.3:'); | ||
|
||
expect(lockEntryIndex).toEqual(0); | ||
expect(lockfile.indexOf('left-pad@<=1.1.1:')).toEqual(-1); | ||
expect(lockfile[lockEntryIndex + 1]).toContain('1.1.3'); | ||
expect(pkg.dependencies).toEqual({'left-pad': '^1.1.3'}); | ||
}); | ||
}); | ||
|
||
test.concurrent('upgrades to latest matching semver when package name passed with version', (): Promise<void> => { | ||
return runUpgrade(['left-pad@~1.1.2'], {}, 'range-to-latest', async (config): ?Promise<void> => { | ||
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock'))); | ||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const lockEntryIndex = lockfile.indexOf('left-pad@~1.1.2:'); | ||
|
||
expect(lockEntryIndex).toEqual(0); | ||
expect(lockfile[lockEntryIndex + 1]).toContain('1.1.3'); | ||
expect(pkg.dependencies).toEqual({'left-pad': '~1.1.2'}); | ||
}); | ||
}); | ||
|
||
test.concurrent('--latest upgrades to passed in version when package name passed with version', (): Promise<void> => { | ||
return runUpgrade(['[email protected]'], {latest: true}, 'range-to-latest', async (config): ?Promise<void> => { | ||
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock'))); | ||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const lockEntryIndex = lockfile.indexOf('[email protected]:'); | ||
|
||
expect(lockEntryIndex).toEqual(0); | ||
expect(lockfile.indexOf('left-pad@<=1.1.1:')).toEqual(-1); | ||
expect(lockfile.indexOf('left-pad@^1.1.3:')).toEqual(-1); | ||
expect(lockfile[lockEntryIndex + 1]).toContain('1.1.2'); | ||
expect(pkg.dependencies).toEqual({'left-pad': '1.1.2'}); | ||
}); | ||
}); | ||
|
||
test.concurrent('upgrades to latest ignoring package.json semver when package name passed', (): Promise<void> => { | ||
return runUpgrade(['left-pad'], {}, 'range-to-latest', async (config): ?Promise<void> => { | ||
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock'))); | ||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const lockEntryIndex = lockfile.indexOf('left-pad@^1.1.3:'); | ||
|
||
expect(lockEntryIndex).toEqual(0); | ||
expect(lockfile.indexOf('left-pad@<=1.1.1:')).toEqual(-1); | ||
expect(lockfile[lockEntryIndex + 1]).toContain('1.1.3'); | ||
expect(pkg.dependencies).toEqual({'left-pad': '^1.1.3'}); | ||
}); | ||
}); | ||
|
||
test.concurrent('upgrades dependency packages not in registry', (): Promise<void> => { | ||
const packages = ['yarn-test-git-repo', 'e2e-test-repo']; | ||
return runUpgrade(packages, {}, 'package-not-in-registry', async (config): ?Promise<void> => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"left-pad": "<=1.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters