From bd63cbfad6d2c7b43a10284dd659303c98d1cda9 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Thu, 13 Apr 2023 17:52:35 -0400 Subject: [PATCH] fix(core): migrate should read both generators and schematics (#16294) --- packages/nx/src/command-line/migrate.ts | 20 ++++++++++++-------- packages/nx/src/config/misc-interfaces.ts | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/nx/src/command-line/migrate.ts b/packages/nx/src/command-line/migrate.ts index f54196a82a..f1a0afc0d3 100644 --- a/packages/nx/src/command-line/migrate.ts +++ b/packages/nx/src/command-line/migrate.ts @@ -874,7 +874,7 @@ function createFetcher() { migrations = fetchMigrations(packageName, packageVersion, setCache).then( (result) => { if (result.schematics) { - result.generators = result.schematics; + result.generators = { ...result.schematics, ...result.generators }; delete result.schematics; } resolvedVersion = result.version; @@ -903,12 +903,14 @@ async function getPackageMigrationsUsingRegistry( if (!migrationsConfig) { return { + name: packageName, version: packageVersion, }; } if (!migrationsConfig.migrations) { return { + name: packageName, version: packageVersion, packageGroup: migrationsConfig.packageGroup, }; @@ -1560,8 +1562,10 @@ function readMigrationCollection(packageName: string, root: string) { packageName, root ).migrations; + const collection = readJsonFile(collectionPath); + collection.name ??= packageName; return { - collection: readJsonFile(collectionPath), + collection, collectionPath, }; } @@ -1637,20 +1641,20 @@ function isAngularMigration( if (useAngularDevkitToRunMigration && shouldBeNx) { output.warn({ - title: `The migration '${collectionPath}:${name}' appears to be an Angular CLI migration, but is located in the 'generators' section of migrations.json.`, + title: `The migration '${collection.name}:${name}' appears to be an Angular CLI migration, but is located in the 'generators' section of migrations.json.`, bodyLines: [ - 'In the future, migrations in the generators section will be assumed to be Nx migrations.', - "Please open an issue on the Nx repository if you believe this is an error, or on the plugin's repository so that the author can move it to the appropriate section.", + 'In Nx 17, migrations inside `generators` will be treated as Angular Devkit migrations.', + "Please open an issue on the plugin's repository if you believe this is an error.", ], }); } if (!useAngularDevkitToRunMigration && entry.cli === 'nx' && shouldBeNg) { output.warn({ - title: `The migration '${collectionPath}:${name}' appears to be an Nx migration, but is located in the 'schematics' section of migrations.json.`, + title: `The migration '${collection.name}:${name}' appears to be an Nx migration, but is located in the 'schematics' section of migrations.json.`, bodyLines: [ - 'In the future, migrations in the schematics section will be assumed to be Angular CLI migrations.', - "Please open an issue on the Nx repository if you believe this is an error, or on the plugin's repository so that the author can move it to the appropriate section.", + 'In Nx 17, migrations inside `generators` will be treated as nx devkit migrations.', + "Please open an issue on the plugin's repository if you believe this is an error.", ], }); } diff --git a/packages/nx/src/config/misc-interfaces.ts b/packages/nx/src/config/misc-interfaces.ts index ce55f07da4..1a500e37ea 100644 --- a/packages/nx/src/config/misc-interfaces.ts +++ b/packages/nx/src/config/misc-interfaces.ts @@ -75,6 +75,7 @@ export interface MigrationsJsonEntry { } export interface MigrationsJson { + name?: string; version: string; collection?: string; generators?: { [name: string]: MigrationsJsonEntry };