fix(release): default to only publishing libs when no config is defined (#20315)

This commit is contained in:
Austin Fahsl 2023-11-22 12:53:18 -07:00 committed by GitHub
parent d1a213fa4e
commit d2b444c23b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 1 deletions

View File

@ -251,6 +251,93 @@ describe('createNxReleaseConfig()', () => {
} }
`); `);
}); });
it('should filter out app and e2e projects', async () => {
projectGraph.nodes['app-1'] = {
name: 'app-1',
type: 'app',
data: {
root: 'apps/app-1',
targets: {},
} as any,
};
projectGraph.nodes['e2e-1'] = {
name: 'e2e-1',
type: 'e2e',
data: {
root: 'apps/e2e-1',
targets: {},
} as any,
};
expect(await createNxReleaseConfig(projectGraph, undefined))
.toMatchInlineSnapshot(`
{
"error": null,
"nxReleaseConfig": {
"changelog": {
"git": {
"commit": false,
"commitArgs": "",
"commitMessage": "",
"tag": false,
"tagArgs": "",
"tagMessage": "",
},
"projectChangelogs": false,
"workspaceChangelog": {
"createRelease": false,
"entryWhenNoChanges": "This was a version bump only, there were no code changes.",
"file": "{workspaceRoot}/CHANGELOG.md",
"renderOptions": {
"includeAuthors": true,
},
"renderer": "nx/changelog-renderer",
},
},
"git": {
"commit": false,
"commitArgs": "",
"commitMessage": "",
"tag": false,
"tagArgs": "",
"tagMessage": "",
},
"groups": {
"__default__": {
"changelog": false,
"projects": [
"lib-a",
"lib-b",
"nx",
],
"projectsRelationship": "fixed",
"releaseTagPattern": "v{version}",
"version": {
"generator": "@nx/js:release-version",
"generatorOptions": {},
},
},
},
"projectsRelationship": "fixed",
"releaseTagPattern": "v{version}",
"version": {
"generator": "@nx/js:release-version",
"generatorOptions": {},
"git": {
"commit": false,
"commitArgs": "",
"commitMessage": "",
"tag": false,
"tagArgs": "",
"tagMessage": "",
},
},
},
}
`);
});
}); });
describe('user specified groups', () => { describe('user specified groups', () => {

View File

@ -179,7 +179,12 @@ export async function createNxReleaseConfig(
const rootVersionWithoutGit = { ...rootVersionConfig }; const rootVersionWithoutGit = { ...rootVersionConfig };
delete rootVersionWithoutGit.git; delete rootVersionWithoutGit.git;
const allProjects = findMatchingProjects(['*'], projectGraph.nodes); const allProjects = findMatchingProjects(['*'], projectGraph.nodes).filter(
// only include libs by default when the user has no groups config,
// because the default implementation assumes npm js packages
// and these will usually be libs
(project) => projectGraph.nodes[project].type === 'lib'
);
const groups: NxReleaseConfig['groups'] = const groups: NxReleaseConfig['groups'] =
userConfig.groups && Object.keys(userConfig.groups).length userConfig.groups && Object.keys(userConfig.groups).length
? ensureProjectsConfigIsArray(userConfig.groups) ? ensureProjectsConfigIsArray(userConfig.groups)