fix(core): handle symbol in migration path and infer angular material and cdk migration type correctly (#16538)
This commit is contained in:
parent
4e0df09fac
commit
85366d5cbe
@ -1543,8 +1543,12 @@ async function runNxMigration(
|
|||||||
collection: MigrationsJson,
|
collection: MigrationsJson,
|
||||||
name: string
|
name: string
|
||||||
) {
|
) {
|
||||||
const implPath = getImplementationPath(collection, collectionPath, name);
|
const { path: implPath, fnSymbol } = getImplementationPath(
|
||||||
const fn = require(implPath).default;
|
collection,
|
||||||
|
collectionPath,
|
||||||
|
name
|
||||||
|
);
|
||||||
|
const fn = require(implPath)[fnSymbol];
|
||||||
const host = new FsTree(root, false);
|
const host = new FsTree(root, false);
|
||||||
await fn(host, {});
|
await fn(host, {});
|
||||||
host.lock();
|
host.lock();
|
||||||
@ -1598,14 +1602,16 @@ function getImplementationPath(
|
|||||||
collection: MigrationsJson,
|
collection: MigrationsJson,
|
||||||
collectionPath: string,
|
collectionPath: string,
|
||||||
name: string
|
name: string
|
||||||
) {
|
): { path: string; fnSymbol: string } {
|
||||||
const g = collection.generators?.[name] || collection.schematics?.[name];
|
const g = collection.generators?.[name] || collection.schematics?.[name];
|
||||||
if (!g) {
|
if (!g) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to determine implementation path for "${collectionPath}:${name}"`
|
`Unable to determine implementation path for "${collectionPath}:${name}"`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const implRelativePath = g.implementation || g.factory;
|
const implRelativePathAndMaybeSymbol = g.implementation || g.factory;
|
||||||
|
const [implRelativePath, fnSymbol = 'default'] =
|
||||||
|
implRelativePathAndMaybeSymbol.split('#');
|
||||||
|
|
||||||
let implPath: string;
|
let implPath: string;
|
||||||
|
|
||||||
@ -1620,7 +1626,7 @@ function getImplementationPath(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return implPath;
|
return { path: implPath, fnSymbol };
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (v17): This should just become something like:
|
// TODO (v17): This should just become something like:
|
||||||
@ -1643,7 +1649,7 @@ function isAngularMigration(
|
|||||||
const shouldBeNg = !!collection.schematics?.[name];
|
const shouldBeNg = !!collection.schematics?.[name];
|
||||||
let useAngularDevkitToRunMigration = false;
|
let useAngularDevkitToRunMigration = false;
|
||||||
|
|
||||||
const implementationPath = getImplementationPath(
|
const { path: implementationPath } = getImplementationPath(
|
||||||
collection,
|
collection,
|
||||||
collectionPath,
|
collectionPath,
|
||||||
name
|
name
|
||||||
@ -1651,6 +1657,7 @@ function isAngularMigration(
|
|||||||
const implStringContents = readFileSync(implementationPath, 'utf-8');
|
const implStringContents = readFileSync(implementationPath, 'utf-8');
|
||||||
// TODO (v17): Remove this check and the cli property access - it is only here for backwards compatibility.
|
// TODO (v17): Remove this check and the cli property access - it is only here for backwards compatibility.
|
||||||
if (
|
if (
|
||||||
|
['@angular/material', '@angular/cdk'].includes(collection.name) ||
|
||||||
[
|
[
|
||||||
"import('@angular-devkit",
|
"import('@angular-devkit",
|
||||||
'import("@angular-devkit',
|
'import("@angular-devkit',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user