fix(core): fixing target groups not merging (#28280)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->
<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->
<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->
<!-- This is the behavior we have today -->
When multiple plugins touch the `project > metadata` (note NOT `project
> target > metadata`), only the last plugin to run has their
`metadata.targetGroups` data present, meaning currently `targetGroups`
is clobbering instead of merging.
<!-- This is the behavior we should expect with the changes in this PR
-->
When multiple plugins write to `metadata.targetGroups`, that data is
merged together, so data written by all plugins is present.
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
Fixes #
(cherry picked from commit 7ff387dcd2)
This commit is contained in:
committed by
FrozenPandaz
parent
2bc0755ffe
commit
88f163e9d5
@@ -965,6 +965,47 @@ describe('project-configuration-utils', () => {
|
||||
sourceMap['libs/lib-a']['metadata.targetGroups.group1.1']
|
||||
).toEqual(['dummy', 'dummy.ts']);
|
||||
});
|
||||
|
||||
it('should not clobber targetGroups', () => {
|
||||
const rootMap = new RootMapBuilder()
|
||||
.addProject({
|
||||
root: 'libs/lib-a',
|
||||
name: 'lib-a',
|
||||
metadata: {
|
||||
targetGroups: {
|
||||
group2: ['target3'],
|
||||
},
|
||||
},
|
||||
})
|
||||
.getRootMap();
|
||||
const sourceMap: ConfigurationSourceMaps = {
|
||||
'libs/lib-a': {},
|
||||
};
|
||||
|
||||
mergeProjectConfigurationIntoRootMap(
|
||||
rootMap,
|
||||
{
|
||||
root: 'libs/lib-a',
|
||||
name: 'lib-a',
|
||||
metadata: {
|
||||
technologies: ['technology'],
|
||||
targetGroups: {
|
||||
group1: ['target1', 'target2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
sourceMap,
|
||||
['dummy', 'dummy.ts']
|
||||
);
|
||||
|
||||
expect(rootMap['libs/lib-a'].metadata).toEqual({
|
||||
technologies: ['technology'],
|
||||
targetGroups: {
|
||||
group1: ['target1', 'target2'],
|
||||
group2: ['target3'],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('source map', () => {
|
||||
|
||||
@@ -252,7 +252,7 @@ export function mergeMetadata<T = ProjectMetadata | TargetMetadata>(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result[metadataKey] = value;
|
||||
result[metadataKey][key] = value[key];
|
||||
if (sourceMap) {
|
||||
sourceMap[`${baseSourceMapPath}.${metadataKey}`] =
|
||||
sourceInformation;
|
||||
|
||||
Reference in New Issue
Block a user