fix(core): update getTouchedProjectsFromLockFile to handle deleted/moved projects correctly (#31361)
This commit is contained in:
parent
fc99ded082
commit
88c51965e6
@ -62,7 +62,7 @@ describe('getTouchedProjectsFromLockFile', () => {
|
||||
],
|
||||
graph.nodes
|
||||
);
|
||||
expect(result).toEqual([]);
|
||||
expect(result).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it(`should return all nodes when "${lockFile}" is touched`, () => {
|
||||
@ -76,7 +76,7 @@ describe('getTouchedProjectsFromLockFile', () => {
|
||||
],
|
||||
graph.nodes
|
||||
);
|
||||
expect(result).toEqual(allNodes);
|
||||
expect(result).toStrictEqual(allNodes);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -111,7 +111,7 @@ describe('getTouchedProjectsFromLockFile', () => {
|
||||
],
|
||||
graph.nodes
|
||||
);
|
||||
expect(result).toEqual([]);
|
||||
expect(result).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it(`should not return changes when whole lock file "${lockFile}" is changed`, () => {
|
||||
@ -125,7 +125,7 @@ describe('getTouchedProjectsFromLockFile', () => {
|
||||
],
|
||||
graph.nodes
|
||||
);
|
||||
expect(result).toEqual([]);
|
||||
expect(result).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it(`should return only changed projects when "${lockFile}" is touched`, () => {
|
||||
@ -163,12 +163,26 @@ describe('getTouchedProjectsFromLockFile', () => {
|
||||
rhs: '4.0.1',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: JsonDiffType.Deleted,
|
||||
path: [
|
||||
'importers',
|
||||
'apps/app-that-was-deleted',
|
||||
'devDependencies',
|
||||
'some-other-external-package',
|
||||
'version',
|
||||
],
|
||||
value: {
|
||||
lhs: '4.0.1',
|
||||
rhs: undefined,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
graph.nodes
|
||||
);
|
||||
expect(result).toEqual(['proj1', 'app1']);
|
||||
expect(result).toStrictEqual(['proj1', 'app1']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -78,10 +78,13 @@ const getProjectsNamesFromPaths = (
|
||||
projectGraphNodes: Record<string, ProjectGraphProjectNode>,
|
||||
projectPaths: string[]
|
||||
): string[] => {
|
||||
if (!projectPaths.length) {
|
||||
return [];
|
||||
}
|
||||
const lookup = new RootPathLookup(projectGraphNodes);
|
||||
return projectPaths.map((path) => {
|
||||
return lookup.findNodeNameByRoot(path);
|
||||
});
|
||||
return projectPaths
|
||||
.map((path) => lookup.findNodeNameByRoot(path))
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
class RootPathLookup {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user