From 9933d91a1ba82cbda026d69fd51d489fd91b2df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Wed, 13 Jul 2022 17:26:28 +0100 Subject: [PATCH] fix(core): handle specifying a prerelease version without a package when migrating (#11129) --- packages/nx/src/command-line/migrate.spec.ts | 6 ++++++ packages/nx/src/command-line/migrate.ts | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/nx/src/command-line/migrate.spec.ts b/packages/nx/src/command-line/migrate.spec.ts index a9448d17a793e..bbad6f89494fb 100644 --- a/packages/nx/src/command-line/migrate.spec.ts +++ b/packages/nx/src/command-line/migrate.spec.ts @@ -768,6 +768,12 @@ describe('Migration', () => { targetVersion: '12.0.0', } ); + expect( + parseMigrationsOptions({ packageAndVersion: '8.12.0-beta.0' }) + ).toMatchObject({ + targetPackage: '@nrwl/workspace', + targetVersion: '8.12.0-beta.0', + }); expect( parseMigrationsOptions({ packageAndVersion: 'next' }) ).toMatchObject({ diff --git a/packages/nx/src/command-line/migrate.ts b/packages/nx/src/command-line/migrate.ts index adddfc926c9b3..f30a26a8fe0c2 100644 --- a/packages/nx/src/command-line/migrate.ts +++ b/packages/nx/src/command-line/migrate.ts @@ -394,14 +394,14 @@ function parseTargetPackageAndVersion(args: string) { } } else { if ( - args.match(/^\d+(?:\.\d+)?(?:\.\d+)?$/) || args === 'latest' || - args === 'next' + args === 'next' || + valid(args) || + args.match(/^\d+(?:\.\d+)?(?:\.\d+)?$/) ) { const targetVersion = normalizeVersionWithTagCheck(args); const targetPackage = - args.match(/^\d+(?:\.\d+)?(?:\.\d+)?$/) && - lt(targetVersion, '14.0.0-beta.0') + !['latest', 'next'].includes(args) && lt(targetVersion, '14.0.0-beta.0') ? '@nrwl/workspace' : 'nx';