Skip to content

Commit

Permalink
Merge branch 'master' into fix/changelog-notify-if-disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj committed Jan 26, 2024
2 parents ca7ebfd + bf6f78f commit 864e991
Show file tree
Hide file tree
Showing 18 changed files with 251 additions and 374 deletions.
53 changes: 41 additions & 12 deletions e2e/release/src/independent-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ describe('nx release - independent projects', () => {

pkg3 = uniq('my-pkg-3');
runCLI(`generate @nx/workspace:npm-package ${pkg3}`);
updateJson(`${pkg3}/package.json`, (json) => {
json.private = true;
return json;
});

/**
* Update pkg2 to depend on pkg3.
Expand Down Expand Up @@ -210,9 +206,6 @@ describe('nx release - independent projects', () => {
+ "version": "999.9.9-package.3",
"scripts": {
}
+
"dependencies": {
- "@proj/{project-name}": "0.0.0"
Expand Down Expand Up @@ -429,7 +422,7 @@ describe('nx release - independent projects', () => {
release: {
projectsRelationship: 'independent',
changelog: {
projectChangelogs: {}, // enable project changelogs with default options
projectChangelogs: true, // enable project changelogs with default options
workspaceChangelog: false, // disable workspace changelog
},
},
Expand Down Expand Up @@ -751,7 +744,25 @@ describe('nx release - independent projects', () => {
> nx run {project-name}:nx-release-publish
Skipped package "@proj/{project-name}" from project "{project-name}", because it has \`"private": true\` in {project-name}/package.json
📦 @proj/{project-name}@999.9.9-version-git-operations-test.3
=== Tarball Contents ===
XXXB CHANGELOG.md
XXB index.js
XXXB package.json
XXB project.json
=== Tarball Details ===
name: @proj/{project-name}
version: 999.9.9-version-git-operations-test.3
filename: proj-{project-name}-999.9.9-version-git-operations-test.3.tgz
package size: XXXB
unpacked size: XXXB
shasum: {SHASUM}
integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
total files: 4
Would publish to http://localhost:4873 with tag "latest", but [dry-run] was set
Expand Down Expand Up @@ -842,7 +853,25 @@ describe('nx release - independent projects', () => {
> nx run {project-name}:nx-release-publish
Skipped package "@proj/{project-name}" from project "{project-name}", because it has \`"private": true\` in {project-name}/package.json
📦 @proj/{project-name}@999.9.9-version-git-operations-test.3
=== Tarball Contents ===
XXXB CHANGELOG.md
XXB index.js
XXXB package.json
XXB project.json
=== Tarball Details ===
name: @proj/{project-name}
version: 999.9.9-version-git-operations-test.3
filename: proj-{project-name}-999.9.9-version-git-operations-test.3.tgz
package size: XXXB
unpacked size: XXXB
shasum: {SHASUM}
integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
total files: 4
Would publish to http://localhost:4873 with tag "latest", but [dry-run] was set
Expand All @@ -867,7 +896,7 @@ describe('nx release - independent projects', () => {
},
},
changelog: {
projectChangelogs: {},
projectChangelogs: true,
},
},
};
Expand Down Expand Up @@ -925,7 +954,7 @@ describe('nx release - independent projects', () => {
},
},
changelog: {
projectChangelogs: {},
projectChangelogs: true,
},
},
};
Expand Down
17 changes: 6 additions & 11 deletions e2e/release/src/private-js-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,23 @@ describe('nx release - private JS packages', () => {
`);

const privatePkgPublishOutput = runCLI(`release publish -p ${privatePkg}`);
const privatePkgPublishOutput = runCLI(`release publish -p ${privatePkg}`, {
silenceError: true,
});
expect(privatePkgPublishOutput).toMatchInlineSnapshot(`
> NX Your filter "{private-project-name}" matched the following projects:
- {private-project-name}
> NX Running target nx-release-publish for project {private-project-name}:
> NX Based on your config, the following projects were matched for publishing but do not have the "nx-release-publish" target specified:
- {private-project-name}
There are a few possible reasons for this: (1) The projects may be private (2) You may not have an appropriate plugin (such as \`@nx/js\`) installed which adds the target automatically to public projects (3) You intended to configure the target manually, or exclude those projects via config in nx.json
> nx run {private-project-name}:nx-release-publish
Skipped package "@proj/{private-project-name}" from project "{private-project-name}", because it has \`"private": true\` in {private-project-name}/package.json
> NX Successfully ran target nx-release-publish for project {private-project-name}
Pass --verbose to see the stacktrace.
`);
Expand Down
10 changes: 6 additions & 4 deletions packages/nx/src/command-line/release/command-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,12 @@ const publishCommand: CommandModule<NxReleaseArgs, PublishOptions> = {
description:
'A one-time password for publishing to a registry that requires 2FA',
}),
handler: (args) =>
import('./publish').then((m) =>
m.releasePublishCLIHandler(coerceParallelOption(withOverrides(args, 2)))
),
handler: async (args) => {
const status = await (
await import('./publish')
).releasePublishCLIHandler(coerceParallelOption(withOverrides(args, 2)));
process.exit(status);
},
};

function coerceParallelOption(args: any) {
Expand Down
148 changes: 0 additions & 148 deletions packages/nx/src/command-line/release/config/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2116,80 +2116,6 @@ describe('createNxReleaseConfig()', () => {
}
`);
});

it('should return an error if any matched projects do not have the required target specified', async () => {
const res = await createNxReleaseConfig(
{
...projectGraph,
nodes: {
...projectGraph.nodes,
'project-without-target': {
name: 'project-without-target',
type: 'lib',
data: {
root: 'libs/project-without-target',
targets: {},
} as any,
},
},
},
{
groups: {
'group-1': {
projects: '*', // using string form to ensure that is supported in addition to array form
},
},
},
'nx-release-publish'
);
expect(res).toMatchInlineSnapshot(`
{
"error": {
"code": "PROJECTS_MISSING_TARGET",
"data": {
"projects": [
"project-without-target",
],
"targetName": "nx-release-publish",
},
},
"nxReleaseConfig": null,
}
`);

const res2 = await createNxReleaseConfig(
{
...projectGraph,
nodes: {
...projectGraph.nodes,
'another-project-without-target': {
name: 'another-project-without-target',
type: 'lib',
data: {
root: 'libs/another-project-without-target',
targets: {},
} as any,
},
},
},
{},
'nx-release-publish'
);
expect(res2).toMatchInlineSnapshot(`
{
"error": {
"code": "PROJECTS_MISSING_TARGET",
"data": {
"projects": [
"another-project-without-target",
],
"targetName": "nx-release-publish",
},
},
"nxReleaseConfig": null,
}
`);
});
});

describe('user config -> mixed top level and granular git', () => {
Expand Down Expand Up @@ -2321,80 +2247,6 @@ describe('createNxReleaseConfig()', () => {
`);
});

it('should return an error if any matched projects do not have the required target specified', async () => {
const res = await createNxReleaseConfig(
{
...projectGraph,
nodes: {
...projectGraph.nodes,
'project-without-target': {
name: 'project-without-target',
type: 'lib',
data: {
root: 'libs/project-without-target',
targets: {},
} as any,
},
},
},
{
groups: {
'group-1': {
projects: '*', // using string form to ensure that is supported in addition to array form
},
},
},
'nx-release-publish'
);
expect(res).toMatchInlineSnapshot(`
{
"error": {
"code": "PROJECTS_MISSING_TARGET",
"data": {
"projects": [
"project-without-target",
],
"targetName": "nx-release-publish",
},
},
"nxReleaseConfig": null,
}
`);

const res2 = await createNxReleaseConfig(
{
...projectGraph,
nodes: {
...projectGraph.nodes,
'another-project-without-target': {
name: 'another-project-without-target',
type: 'lib',
data: {
root: 'libs/another-project-without-target',
targets: {},
} as any,
},
},
},
{},
'nx-release-publish'
);
expect(res2).toMatchInlineSnapshot(`
{
"error": {
"code": "PROJECTS_MISSING_TARGET",
"data": {
"projects": [
"another-project-without-target",
],
"targetName": "nx-release-publish",
},
},
"nxReleaseConfig": null,
}
`);
});

it("should return an error if a group's releaseTagPattern has no {version} placeholder", async () => {
const res = await createNxReleaseConfig(projectGraph, {
groups: {
Expand Down
Loading

0 comments on commit 864e991

Please sign in to comment.