fix(angular): handle projects without name in angular cli adapter (#15089)
This commit is contained in:
parent
a1a1cdaf4a
commit
2011e29dc3
@ -226,25 +226,30 @@ export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
|||||||
concatMap((arg) => {
|
concatMap((arg) => {
|
||||||
const graph = arg[0] as any;
|
const graph = arg[0] as any;
|
||||||
const ret = (arg[1] || { projects: {} }) as any;
|
const ret = (arg[1] || { projects: {} }) as any;
|
||||||
const projectJsonReads = [] as Observable<any>[];
|
const projectJsonReads: Observable<
|
||||||
|
[string, ProjectConfiguration & { version: string }]
|
||||||
|
>[] = [];
|
||||||
for (let projectName of Object.keys(graph.nodes)) {
|
for (let projectName of Object.keys(graph.nodes)) {
|
||||||
if (!ret.projects[projectName]) {
|
if (!ret.projects[projectName]) {
|
||||||
projectJsonReads.push(
|
projectJsonReads.push(
|
||||||
this.readExistingProjectJson(
|
zip(
|
||||||
join(graph.nodes[projectName].data.root, 'project.json')
|
of(projectName),
|
||||||
|
this.readExistingProjectJson(
|
||||||
|
join(graph.nodes[projectName].data.root, 'project.json')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return zip(...projectJsonReads).pipe(
|
return zip(...projectJsonReads).pipe(
|
||||||
map((projectJsons) => {
|
map((reads) => {
|
||||||
projectJsons
|
reads
|
||||||
.filter((p) => p !== null)
|
.filter(([, p]) => p !== null)
|
||||||
.forEach((p) => {
|
.forEach(([projectName, project]) => {
|
||||||
delete p.version;
|
delete project.version;
|
||||||
ret.projects[p.name] = {
|
ret.projects[projectName] = {
|
||||||
...p,
|
...project,
|
||||||
root: graph.nodes[p.name].data.root,
|
root: graph.nodes[projectName].data.root,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -290,9 +295,11 @@ export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
|||||||
if (existingConfig.projects[projectName]) {
|
if (existingConfig.projects[projectName]) {
|
||||||
const updatedContent = this.mergeProjectConfiguration(
|
const updatedContent = this.mergeProjectConfiguration(
|
||||||
existingConfig.projects[projectName],
|
existingConfig.projects[projectName],
|
||||||
projects[projectName]
|
projects[projectName],
|
||||||
|
projectName
|
||||||
);
|
);
|
||||||
if (updatedContent) {
|
if (updatedContent) {
|
||||||
|
delete updatedContent.root;
|
||||||
allObservables.push(
|
allObservables.push(
|
||||||
super.write(
|
super.write(
|
||||||
path as any,
|
path as any,
|
||||||
@ -338,7 +345,8 @@ export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
|||||||
|
|
||||||
mergeProjectConfiguration(
|
mergeProjectConfiguration(
|
||||||
existing: ProjectConfiguration,
|
existing: ProjectConfiguration,
|
||||||
updated: ProjectConfiguration
|
updated: ProjectConfiguration,
|
||||||
|
projectName: string
|
||||||
) {
|
) {
|
||||||
const res = { ...existing };
|
const res = { ...existing };
|
||||||
|
|
||||||
@ -353,6 +361,10 @@ export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!res.name) {
|
||||||
|
res.name = updated.name || projectName;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
return modified ? res : null;
|
return modified ? res : null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user