fix(angular): write config correctly when using the angular cli adapter (#15133)
This commit is contained in:
parent
f8d49951b5
commit
61e28c63c3
@ -203,6 +203,8 @@ async function runSchematic(
|
|||||||
return { status: 0, loggingQueue: record.loggingQueue };
|
return { status: 0, loggingQueue: record.loggingQueue };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AngularProjectConfiguration = ProjectConfiguration & { prefix?: string };
|
||||||
|
|
||||||
export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
||||||
constructor(private root: string) {
|
constructor(private root: string) {
|
||||||
super(new NodeJsSyncHost(), normalize(root));
|
super(new NodeJsSyncHost(), normalize(root));
|
||||||
@ -344,27 +346,40 @@ export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mergeProjectConfiguration(
|
mergeProjectConfiguration(
|
||||||
existing: ProjectConfiguration,
|
existing: AngularProjectConfiguration,
|
||||||
updated: ProjectConfiguration,
|
updated: AngularProjectConfiguration,
|
||||||
projectName: string
|
projectName: string
|
||||||
) {
|
) {
|
||||||
const res = { ...existing };
|
const res: AngularProjectConfiguration = { ...existing };
|
||||||
|
|
||||||
if (!res.targets) {
|
|
||||||
res.targets = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
let modified = false;
|
let modified = false;
|
||||||
for (let target of Object.keys(updated.targets)) {
|
|
||||||
if (!res.targets[target]) {
|
function updatePropertyIfDifferent<
|
||||||
res.targets[target] = updated.targets[target];
|
T extends Exclude<keyof AngularProjectConfiguration, 'namedInputs'>
|
||||||
|
>(property: T): void {
|
||||||
|
if (typeof res[property] === 'string') {
|
||||||
|
if (res[property] !== updated[property]) {
|
||||||
|
res[property] = updated[property];
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
} else if (
|
||||||
|
JSON.stringify(res[property]) !== JSON.stringify(updated[property])
|
||||||
|
) {
|
||||||
|
res[property] = updated[property];
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!res.name) {
|
|
||||||
res.name = updated.name || projectName;
|
if (!res.name || (updated.name && res.name !== updated.name)) {
|
||||||
|
res.name ??= updated.name || projectName;
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
updatePropertyIfDifferent('projectType');
|
||||||
|
updatePropertyIfDifferent('sourceRoot');
|
||||||
|
updatePropertyIfDifferent('prefix');
|
||||||
|
updatePropertyIfDifferent('targets');
|
||||||
|
updatePropertyIfDifferent('generators');
|
||||||
|
updatePropertyIfDifferent('implicitDependencies');
|
||||||
|
updatePropertyIfDifferent('tags');
|
||||||
|
|
||||||
return modified ? res : null;
|
return modified ? res : null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user