fix(release): ensure versionData is always populated even when no bumps (#30866)

This commit is contained in:
James Henry 2025-04-25 17:13:37 +04:00 committed by GitHub
parent 73077fec66
commit c0426c1b35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 70 additions and 0 deletions

View File

@ -1673,4 +1673,65 @@ describe('ReleaseGroupProcessor', () => {
);
});
});
describe('versionData', () => {
it('should populate versionData even when projects are not versioned', async () => {
const {
nxReleaseConfig,
projectGraph,
releaseGroups,
releaseGroupToFilteredProjects,
filters,
} = await createNxReleaseConfigAndPopulateWorkspace(
tree,
`
__default__ ({ "projectsRelationship": "independent" }):
- libtest1@4.5.0 [js]
- my-nest-app@1.0.0 [js]
`,
{
version: {
conventionalCommits: true,
},
},
mockResolveCurrentVersion
);
const processor = new ReleaseGroupProcessor(
tree,
projectGraph,
nxReleaseConfig,
releaseGroups,
releaseGroupToFilteredProjects,
{
dryRun: false,
verbose: false,
firstRelease: false,
preid: undefined,
filters,
}
);
await processor.init();
mockDeriveSpecifierFromConventionalCommits.mockImplementation(
() => 'none'
);
await processor.processGroups();
expect(processor.getVersionData()).toMatchInlineSnapshot(`
{
"libtest1": {
"currentVersion": "4.5.0",
"dependentProjects": [],
"newVersion": null,
},
"my-nest-app": {
"currentVersion": "1.0.0",
"dependentProjects": [],
"newVersion": null,
},
}
`);
});
});
});

View File

@ -360,6 +360,15 @@ export class ReleaseGroupProcessor {
);
this.cachedCurrentVersions.set(projectName, currentVersion);
}
// Ensure that there is an entry in versionData for each project being processed, even if they don't end up being bumped
for (const projectName of this.allProjectsToProcess) {
this.versionData.set(projectName, {
currentVersion: this.getCurrentCachedVersionForProject(projectName),
newVersion: null,
dependentProjects: this.getOriginalDependentProjects(projectName),
});
}
}
// Build the dependency relationships between groups