feat(core): remove usage of cli property from migration definitions (#30855)
Removes the usage of the `cli` property from migration definitions. BREAKING CHANGE: The `cli` property from migration generator definitions is no longer used. The CLI to run the migration generator will be identified based on whether the definition is contained in `generators` (Nx) or `schematics` (Angular CLI).
This commit is contained in:
parent
c0aa245d9c
commit
73077fec66
@ -76,7 +76,6 @@ import {
|
|||||||
readProjectsConfigurationFromProjectGraph,
|
readProjectsConfigurationFromProjectGraph,
|
||||||
} from '../../project-graph/project-graph';
|
} from '../../project-graph/project-graph';
|
||||||
import { formatFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';
|
import { formatFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';
|
||||||
import { dirSync } from 'tmp';
|
|
||||||
|
|
||||||
export interface ResolvedMigrationConfiguration extends MigrationsJson {
|
export interface ResolvedMigrationConfiguration extends MigrationsJson {
|
||||||
packageGroup?: ArrayPackageGroup;
|
packageGroup?: ArrayPackageGroup;
|
||||||
@ -1394,7 +1393,6 @@ function addSplitConfigurationMigrationIfAvailable(
|
|||||||
version: '15.7.0-beta.0',
|
version: '15.7.0-beta.0',
|
||||||
description:
|
description:
|
||||||
'Split global configuration files into individual project.json files. This migration has been added automatically to the beginning of your migration set to retroactively make them work with the new version of Nx.',
|
'Split global configuration files into individual project.json files. This migration has been added automatically to the beginning of your migration set to retroactively make them work with the new version of Nx.',
|
||||||
cli: 'nx',
|
|
||||||
implementation:
|
implementation:
|
||||||
'./src/migrations/update-15-7-0/split-configuration-into-project-json-files',
|
'./src/migrations/update-15-7-0/split-configuration-into-project-json-files',
|
||||||
package: '@nrwl/workspace',
|
package: '@nrwl/workspace',
|
||||||
@ -1447,7 +1445,6 @@ export async function executeMigrations(
|
|||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
version: string;
|
version: string;
|
||||||
cli?: 'nx' | 'angular';
|
|
||||||
}[],
|
}[],
|
||||||
isVerbose: boolean,
|
isVerbose: boolean,
|
||||||
shouldCreateCommits: boolean,
|
shouldCreateCommits: boolean,
|
||||||
@ -1528,7 +1525,6 @@ export async function runNxOrAngularMigration(
|
|||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
version: string;
|
version: string;
|
||||||
cli?: 'nx' | 'angular';
|
|
||||||
},
|
},
|
||||||
isVerbose: boolean,
|
isVerbose: boolean,
|
||||||
shouldCreateCommits: boolean,
|
shouldCreateCommits: boolean,
|
||||||
@ -1545,7 +1541,7 @@ export async function runNxOrAngularMigration(
|
|||||||
root
|
root
|
||||||
);
|
);
|
||||||
let changes: FileChange[] = [];
|
let changes: FileChange[] = [];
|
||||||
if (!isAngularMigration(collection, collectionPath, migration.name)) {
|
if (!isAngularMigration(collection, migration.name)) {
|
||||||
changes = await runNxMigration(
|
changes = await runNxMigration(
|
||||||
root,
|
root,
|
||||||
collectionPath,
|
collectionPath,
|
||||||
@ -1662,7 +1658,6 @@ async function runMigrations(
|
|||||||
package: string;
|
package: string;
|
||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
cli?: 'nx' | 'angular';
|
|
||||||
}[] = readJsonFile(join(root, opts.runMigrations)).migrations;
|
}[] = readJsonFile(join(root, opts.runMigrations)).migrations;
|
||||||
|
|
||||||
const migrationsWithNoChanges = await executeMigrations(
|
const migrationsWithNoChanges = await executeMigrations(
|
||||||
@ -1894,29 +1889,8 @@ function addToNodePath(dir: string) {
|
|||||||
process.env.NODE_PATH = paths.join(delimiter);
|
process.env.NODE_PATH = paths.join(delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (v21): Remove CLI determination of Angular Migration
|
function isAngularMigration(collection: MigrationsJson, name: string) {
|
||||||
function isAngularMigration(
|
return !collection.generators?.[name] && collection.schematics?.[name];
|
||||||
collection: MigrationsJson,
|
|
||||||
collectionPath: string,
|
|
||||||
name: string
|
|
||||||
) {
|
|
||||||
const entry = collection.generators?.[name] || collection.schematics?.[name];
|
|
||||||
const shouldBeNx = !!collection.generators?.[name];
|
|
||||||
const shouldBeNg = !!collection.schematics?.[name];
|
|
||||||
if (entry.cli && entry.cli !== 'nx' && collection.generators?.[name]) {
|
|
||||||
output.warn({
|
|
||||||
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 Nx 21, migrations inside `generators` will be treated as Nx Devkit migrations and therefore may not run correctly if they are using Angular Devkit.',
|
|
||||||
'If the migration should be run with Angular Devkit, please place the migration inside `schematics` instead.',
|
|
||||||
"Please open an issue on the plugin's repository if you believe this is an error.",
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Currently, if the cli property exists we listen to it. If its nx, its not an ng cli migration.
|
|
||||||
// If the property is not set, we will fall back to our intuition.
|
|
||||||
return entry.cli ? entry.cli !== 'nx' : !shouldBeNx && shouldBeNg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getNgCompatLayer = (() => {
|
const getNgCompatLayer = (() => {
|
||||||
|
|||||||
@ -14,7 +14,6 @@ export async function repair(
|
|||||||
if (!skip) {
|
if (!skip) {
|
||||||
agg.push({
|
agg.push({
|
||||||
package: 'nx',
|
package: 'nx',
|
||||||
cli: 'nx',
|
|
||||||
name,
|
name,
|
||||||
description: migration.description,
|
description: migration.description,
|
||||||
version: migration.version,
|
version: migration.version,
|
||||||
|
|||||||
@ -69,7 +69,6 @@ export type PackageJsonUpdates = {
|
|||||||
export interface MigrationsJsonEntry {
|
export interface MigrationsJsonEntry {
|
||||||
version: string;
|
version: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
cli?: string;
|
|
||||||
implementation?: string;
|
implementation?: string;
|
||||||
factory?: string;
|
factory?: string;
|
||||||
requires?: Record<string, string>;
|
requires?: Record<string, string>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user