Skip to content

Commit 920bb92

Browse files
authored
fix: limit breaking change dependent detection to peer dependencies (#170)
1 parent 3125ca3 commit 920bb92

File tree

2 files changed

+2
-228
lines changed

2 files changed

+2
-228
lines changed

src/release-specification.test.ts

Lines changed: 0 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -602,116 +602,6 @@ Your release spec could not be processed due to the following issues:
602602
});
603603
});
604604

605-
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 () => {
606-
await withSandbox(async (sandbox) => {
607-
const project = buildMockProject({
608-
workspacePackages: {
609-
a: buildMockPackage('a', {
610-
hasChangesSinceLatestRelease: true,
611-
}),
612-
b: buildMockPackage('b', {
613-
hasChangesSinceLatestRelease: true,
614-
validatedManifest: {
615-
dependencies: {
616-
a: '1.0.0',
617-
},
618-
},
619-
}),
620-
},
621-
});
622-
const releaseSpecificationPath = path.join(
623-
sandbox.directoryPath,
624-
'release-spec',
625-
);
626-
await fs.promises.writeFile(
627-
releaseSpecificationPath,
628-
YAML.stringify({
629-
packages: {
630-
a: 'major',
631-
},
632-
}),
633-
);
634-
635-
await expect(
636-
validateReleaseSpecification(project, releaseSpecificationPath),
637-
).rejects.toThrow(
638-
`
639-
Your release spec could not be processed due to the following issues:
640-
641-
* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.
642-
643-
- b
644-
645-
Consider including them in the release spec so that they are compatible with the new 'a' version.
646-
647-
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:
648-
649-
packages:
650-
b: intentionally-skip
651-
652-
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.
653-
654-
${releaseSpecificationPath}
655-
`.trim(),
656-
);
657-
});
658-
});
659-
660-
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 () => {
661-
await withSandbox(async (sandbox) => {
662-
const project = buildMockProject({
663-
workspacePackages: {
664-
a: buildMockPackage('a', '2.1.4', {
665-
hasChangesSinceLatestRelease: true,
666-
}),
667-
b: buildMockPackage('b', {
668-
hasChangesSinceLatestRelease: true,
669-
validatedManifest: {
670-
dependencies: {
671-
a: '2.1.4',
672-
},
673-
},
674-
}),
675-
},
676-
});
677-
const releaseSpecificationPath = path.join(
678-
sandbox.directoryPath,
679-
'release-spec',
680-
);
681-
await fs.promises.writeFile(
682-
releaseSpecificationPath,
683-
YAML.stringify({
684-
packages: {
685-
a: '3.0.0',
686-
},
687-
}),
688-
);
689-
690-
await expect(
691-
validateReleaseSpecification(project, releaseSpecificationPath),
692-
).rejects.toThrow(
693-
`
694-
Your release spec could not be processed due to the following issues:
695-
696-
* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.
697-
698-
- b
699-
700-
Consider including them in the release spec so that they are compatible with the new 'a' version.
701-
702-
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:
703-
704-
packages:
705-
b: intentionally-skip
706-
707-
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.
708-
709-
${releaseSpecificationPath}
710-
`.trim(),
711-
);
712-
});
713-
});
714-
715605
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 () => {
716606
await withSandbox(async (sandbox) => {
717607
const project = buildMockProject({
@@ -816,118 +706,6 @@ Your release spec could not be processed due to the following issues:
816706
817707
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.
818708
819-
${releaseSpecificationPath}
820-
`.trim(),
821-
);
822-
});
823-
});
824-
825-
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 () => {
826-
await withSandbox(async (sandbox) => {
827-
const project = buildMockProject({
828-
workspacePackages: {
829-
a: buildMockPackage('a', {
830-
hasChangesSinceLatestRelease: true,
831-
}),
832-
b: buildMockPackage('b', {
833-
hasChangesSinceLatestRelease: true,
834-
validatedManifest: {
835-
dependencies: {
836-
a: '1.0.0',
837-
},
838-
},
839-
}),
840-
},
841-
});
842-
const releaseSpecificationPath = path.join(
843-
sandbox.directoryPath,
844-
'release-spec',
845-
);
846-
await fs.promises.writeFile(
847-
releaseSpecificationPath,
848-
YAML.stringify({
849-
packages: {
850-
a: 'major',
851-
b: null,
852-
},
853-
}),
854-
);
855-
856-
await expect(
857-
validateReleaseSpecification(project, releaseSpecificationPath),
858-
).rejects.toThrow(
859-
`
860-
Your release spec could not be processed due to the following issues:
861-
862-
* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.
863-
864-
- b
865-
866-
Consider including them in the release spec so that they are compatible with the new 'a' version.
867-
868-
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:
869-
870-
packages:
871-
b: intentionally-skip
872-
873-
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.
874-
875-
${releaseSpecificationPath}
876-
`.trim(),
877-
);
878-
});
879-
});
880-
881-
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 () => {
882-
await withSandbox(async (sandbox) => {
883-
const project = buildMockProject({
884-
workspacePackages: {
885-
a: buildMockPackage('a', '2.1.4', {
886-
hasChangesSinceLatestRelease: true,
887-
}),
888-
b: buildMockPackage('b', {
889-
hasChangesSinceLatestRelease: true,
890-
validatedManifest: {
891-
dependencies: {
892-
a: '2.1.4',
893-
},
894-
},
895-
}),
896-
},
897-
});
898-
const releaseSpecificationPath = path.join(
899-
sandbox.directoryPath,
900-
'release-spec',
901-
);
902-
await fs.promises.writeFile(
903-
releaseSpecificationPath,
904-
YAML.stringify({
905-
packages: {
906-
a: '3.0.0',
907-
b: null,
908-
},
909-
}),
910-
);
911-
912-
await expect(
913-
validateReleaseSpecification(project, releaseSpecificationPath),
914-
).rejects.toThrow(
915-
`
916-
Your release spec could not be processed due to the following issues:
917-
918-
* The following dependents of package 'a', which is being released with a major version bump, are missing from the release spec.
919-
920-
- b
921-
922-
Consider including them in the release spec so that they are compatible with the new 'a' version.
923-
924-
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:
925-
926-
packages:
927-
b: intentionally-skip
928-
929-
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.
930-
931709
${releaseSpecificationPath}
932710
`.trim(),
933711
);

src/release-specification.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,8 @@ export async function validateReleaseSpecification(
295295
(possibleDependentName) => {
296296
const possibleDependent =
297297
project.workspacePackages[possibleDependentName];
298-
const { dependencies, peerDependencies } =
299-
possibleDependent.validatedManifest;
300-
return (
301-
hasProperty(dependencies, changedPackageName) ||
302-
hasProperty(peerDependencies, changedPackageName)
303-
);
298+
const { peerDependencies } = possibleDependent.validatedManifest;
299+
return hasProperty(peerDependencies, changedPackageName);
304300
},
305301
);
306302
const changedDependentNames = dependentNames.filter(

0 commit comments

Comments
 (0)