Skip to content

Commit

Permalink
fix: limit breaking change dependent detection to peer dependencies (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptodev-2s authored Mar 4, 2025
1 parent 3125ca3 commit 920bb92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 228 deletions.
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

0 comments on commit 920bb92

Please sign in to comment.