Skip to content

Commit

Permalink
fix(core): migrate should read both generators and schematics (nrwl#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Apr 13, 2023
1 parent 561c82e commit bd63cbf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/nx/src/command-line/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -1560,8 +1562,10 @@ function readMigrationCollection(packageName: string, root: string) {
packageName,
root
).migrations;
const collection = readJsonFile<MigrationsJson>(collectionPath);
collection.name ??= packageName;
return {
collection: readJsonFile<MigrationsJson>(collectionPath),
collection,
collectionPath,
};
}
Expand Down Expand Up @@ -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.",
],
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/nx/src/config/misc-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface MigrationsJsonEntry {
}

export interface MigrationsJson {
name?: string;
version: string;
collection?: string;
generators?: { [name: string]: MigrationsJsonEntry };
Expand Down

0 comments on commit bd63cbf

Please sign in to comment.