Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit breaking change dependent detection to peer dependencies #170

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 0 additions & 222 deletions src/release-specification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,116 +602,6 @@ Your release spec could not be processed due to the following issues:
});
});

it('throws if there are any packages in the release with a major version bump using the word "major", but any of their dependents defined as "dependencies" are not listed in the release', async () => {
await withSandbox(async (sandbox) => {
const project = buildMockProject({
workspacePackages: {
a: buildMockPackage('a', {
hasChangesSinceLatestRelease: true,
}),
b: buildMockPackage('b', {
hasChangesSinceLatestRelease: true,
validatedManifest: {
dependencies: {
a: '1.0.0',
},
},
}),
},
});
const releaseSpecificationPath = path.join(
sandbox.directoryPath,
'release-spec',
);
await fs.promises.writeFile(
releaseSpecificationPath,
YAML.stringify({
packages: {
a: 'major',
},
}),
);

await expect(
validateReleaseSpecification(project, releaseSpecificationPath),
).rejects.toThrow(
`
Your release spec could not be processed due to the following issues:

* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.

- b

Consider including them in the release spec so that they are compatible with the new 'a' version.

If you are ABSOLUTELY SURE these packages are safe to omit, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:

packages:
b: intentionally-skip

The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.

${releaseSpecificationPath}
`.trim(),
);
});
});

it('throws if there are any packages in the release with a major version bump using a literal version, but any of their dependents defined as "dependencies" are not listed in the release', async () => {
await withSandbox(async (sandbox) => {
const project = buildMockProject({
workspacePackages: {
a: buildMockPackage('a', '2.1.4', {
hasChangesSinceLatestRelease: true,
}),
b: buildMockPackage('b', {
hasChangesSinceLatestRelease: true,
validatedManifest: {
dependencies: {
a: '2.1.4',
},
},
}),
},
});
const releaseSpecificationPath = path.join(
sandbox.directoryPath,
'release-spec',
);
await fs.promises.writeFile(
releaseSpecificationPath,
YAML.stringify({
packages: {
a: '3.0.0',
},
}),
);

await expect(
validateReleaseSpecification(project, releaseSpecificationPath),
).rejects.toThrow(
`
Your release spec could not be processed due to the following issues:

* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.

- b

Consider including them in the release spec so that they are compatible with the new 'a' version.

If you are ABSOLUTELY SURE these packages are safe to omit, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:

packages:
b: intentionally-skip

The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.

${releaseSpecificationPath}
`.trim(),
);
});
});

it('throws if there are any packages in the release with a major version bump using the word "major", but any of their dependents defined as "peerDependencies" are not listed in the release', async () => {
await withSandbox(async (sandbox) => {
const project = buildMockProject({
Expand Down Expand Up @@ -816,118 +706,6 @@ Your release spec could not be processed due to the following issues:

The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.

${releaseSpecificationPath}
`.trim(),
);
});
});

it('throws if there are any packages in the release with a major version bump using the word "major", but their dependents via "dependencies" have their version specified as null in the release spec', async () => {
await withSandbox(async (sandbox) => {
const project = buildMockProject({
workspacePackages: {
a: buildMockPackage('a', {
hasChangesSinceLatestRelease: true,
}),
b: buildMockPackage('b', {
hasChangesSinceLatestRelease: true,
validatedManifest: {
dependencies: {
a: '1.0.0',
},
},
}),
},
});
const releaseSpecificationPath = path.join(
sandbox.directoryPath,
'release-spec',
);
await fs.promises.writeFile(
releaseSpecificationPath,
YAML.stringify({
packages: {
a: 'major',
b: null,
},
}),
);

await expect(
validateReleaseSpecification(project, releaseSpecificationPath),
).rejects.toThrow(
`
Your release spec could not be processed due to the following issues:

* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.

- b

Consider including them in the release spec so that they are compatible with the new 'a' version.

If you are ABSOLUTELY SURE these packages are safe to omit, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:

packages:
b: intentionally-skip

The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.

${releaseSpecificationPath}
`.trim(),
);
});
});

it('throws if there are any packages in the release with a major version bump using a literal version, but their dependents via "dependencies" have their version specified as null in the release spec', async () => {
await withSandbox(async (sandbox) => {
const project = buildMockProject({
workspacePackages: {
a: buildMockPackage('a', '2.1.4', {
hasChangesSinceLatestRelease: true,
}),
b: buildMockPackage('b', {
hasChangesSinceLatestRelease: true,
validatedManifest: {
dependencies: {
a: '2.1.4',
},
},
}),
},
});
const releaseSpecificationPath = path.join(
sandbox.directoryPath,
'release-spec',
);
await fs.promises.writeFile(
releaseSpecificationPath,
YAML.stringify({
packages: {
a: '3.0.0',
b: null,
},
}),
);

await expect(
validateReleaseSpecification(project, releaseSpecificationPath),
).rejects.toThrow(
`
Your release spec could not be processed due to the following issues:

* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.

- b

Consider including them in the release spec so that they are compatible with the new 'a' version.

If you are ABSOLUTELY SURE these packages are safe to omit, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:

packages:
b: intentionally-skip

The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.

${releaseSpecificationPath}
`.trim(),
);
Expand Down
8 changes: 2 additions & 6 deletions src/release-specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,8 @@ export async function validateReleaseSpecification(
(possibleDependentName) => {
const possibleDependent =
project.workspacePackages[possibleDependentName];
const { dependencies, peerDependencies } =
possibleDependent.validatedManifest;
return (
hasProperty(dependencies, changedPackageName) ||
hasProperty(peerDependencies, changedPackageName)
);
const { peerDependencies } = possibleDependent.validatedManifest;
return hasProperty(peerDependencies, changedPackageName);
},
);
const changedDependentNames = dependentNames.filter(
Expand Down
Loading