Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): migrate should read both generators and schematics #16294

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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