Skip to content

Commit

Permalink
fix(release): default to only publishing libs when no config is defin…
Browse files Browse the repository at this point in the history
…ed (nrwl#20315)
  • Loading branch information
fahslaj authored Nov 22, 2023
1 parent d1a213f commit d2b444c
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
87 changes: 87 additions & 0 deletions packages/nx/src/command-line/release/config/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
7 changes: 6 additions & 1 deletion packages/nx/src/command-line/release/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ export async function createNxReleaseConfig(
const rootVersionWithoutGit = { ...rootVersionConfig };
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'] =
userConfig.groups && Object.keys(userConfig.groups).length
? ensureProjectsConfigIsArray(userConfig.groups)
Expand Down

0 comments on commit d2b444c

Please sign in to comment.