-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): resolve nx migrate target version against registry (#23450)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #21418
- Loading branch information
1 parent
7a34a46
commit 8685e10
Showing
3 changed files
with
40 additions
and
12 deletions.
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 |
---|---|---|
|
@@ -1512,6 +1512,9 @@ describe('Migration', () => { | |
|
||
describe('parseMigrationsOptions', () => { | ||
it('should work for generating migrations', async () => { | ||
jest | ||
.spyOn(packageMgrUtils, 'resolvePackageVersionUsingRegistry') | ||
.mockResolvedValue('12.3.0'); | ||
const r = await parseMigrationsOptions({ | ||
packageAndVersion: '8.12.0', | ||
from: '@myscope/[email protected],@myscope/[email protected]', | ||
|
@@ -1544,8 +1547,8 @@ describe('Migration', () => { | |
}); | ||
|
||
it('should handle different variations of the target package', async () => { | ||
jest | ||
.spyOn(packageMgrUtils, 'packageRegistryView') | ||
const packageRegistryViewSpy = jest | ||
.spyOn(packageMgrUtils, 'resolvePackageVersionUsingRegistry') | ||
.mockImplementation((pkg, version) => { | ||
return Promise.resolve(version); | ||
}); | ||
|
@@ -1555,30 +1558,35 @@ describe('Migration', () => { | |
targetPackage: '@angular/core', | ||
targetVersion: 'latest', | ||
}); | ||
packageRegistryViewSpy.mockResolvedValue('8.12.5'); | ||
expect( | ||
await parseMigrationsOptions({ packageAndVersion: '8.12' }) | ||
).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '8.12.0', | ||
targetVersion: '8.12.5', | ||
}); | ||
expect( | ||
await parseMigrationsOptions({ packageAndVersion: '8' }) | ||
).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '8.0.0', | ||
targetVersion: '8.12.5', | ||
}); | ||
packageRegistryViewSpy.mockResolvedValue('12.6.3'); | ||
expect( | ||
await parseMigrationsOptions({ packageAndVersion: '12' }) | ||
).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '12.0.0', | ||
targetVersion: '12.6.3', | ||
}); | ||
expect( | ||
await parseMigrationsOptions({ packageAndVersion: '8.12.0-beta.0' }) | ||
).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '8.12.0-beta.0', | ||
}); | ||
packageRegistryViewSpy.mockImplementation((pkg, version) => | ||
Promise.resolve(version) | ||
); | ||
expect( | ||
await parseMigrationsOptions({ packageAndVersion: 'next' }) | ||
).toMatchObject({ | ||
|
@@ -1597,6 +1605,7 @@ describe('Migration', () => { | |
targetPackage: '@nrwl/workspace', | ||
targetVersion: '13.10.0', | ||
}); | ||
packageRegistryViewSpy.mockResolvedValue('8.12.0'); | ||
expect( | ||
await parseMigrationsOptions({ | ||
packageAndVersion: '@nx/[email protected]', | ||
|
@@ -1611,6 +1620,9 @@ describe('Migration', () => { | |
targetPackage: 'mypackage', | ||
targetVersion: '8.12.0', | ||
}); | ||
packageRegistryViewSpy.mockImplementation((pkg, version) => | ||
Promise.resolve(version) | ||
); | ||
expect( | ||
await parseMigrationsOptions({ packageAndVersion: 'mypackage' }) | ||
).toMatchObject({ | ||
|
@@ -1690,6 +1702,11 @@ describe('Migration', () => { | |
}); | ||
|
||
it('should handle backslashes in package names', async () => { | ||
jest | ||
.spyOn(packageMgrUtils, 'resolvePackageVersionUsingRegistry') | ||
.mockImplementation((pkg, version) => { | ||
return Promise.resolve('12.3.0'); | ||
}); | ||
const r = await parseMigrationsOptions({ | ||
packageAndVersion: '@nx\\[email protected]', | ||
from: '@myscope\\[email protected],@myscope\\[email protected]', | ||
|
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
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