fix(misc): handle migrating packages with numbers in the name (#8598)

This commit is contained in:
Jason Jean 2022-01-19 17:21:24 -05:00 committed by GitHub
parent c5b63958e6
commit 736df256b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -673,6 +673,10 @@ describe('Migration', () => {
});
it('should handle different variations of the target package', () => {
expect(parseMigrationsOptions(['@angular/core'])).toMatchObject({
targetPackage: '@angular/core',
targetVersion: 'latest',
});
expect(parseMigrationsOptions(['8.12'])).toMatchObject({
targetPackage: '@nrwl/workspace',
targetVersion: '8.12.0',
@ -681,6 +685,10 @@ describe('Migration', () => {
targetPackage: '@nrwl/workspace',
targetVersion: '8.0.0',
});
expect(parseMigrationsOptions(['12'])).toMatchObject({
targetPackage: '@nrwl/workspace',
targetVersion: '12.0.0',
});
expect(parseMigrationsOptions(['next'])).toMatchObject({
targetPackage: '@nrwl/workspace',
targetVersion: 'next',
@ -697,6 +705,10 @@ describe('Migration', () => {
targetPackage: 'mypackage',
targetVersion: 'latest',
});
expect(parseMigrationsOptions(['mypackage2'])).toMatchObject({
targetPackage: 'mypackage2',
targetVersion: 'latest',
});
expect(parseMigrationsOptions(['@nrwl/workspace@latest'])).toMatchObject({
targetPackage: '@nrwl/workspace',
targetVersion: 'latest',

View File

@ -359,7 +359,11 @@ function parseTargetPackageAndVersion(args: string) {
return { targetPackage, targetVersion };
}
} else {
if (args.match(/[0-9]/) || args === 'latest' || args === 'next') {
if (
args.match(/^\d+(?:\.\d+)?(?:\.\d+)?$/) ||
args === 'latest' ||
args === 'next'
) {
return {
targetPackage: '@nrwl/workspace',
targetVersion: normalizeVersionWithTagCheck(args),