-
-
Notifications
You must be signed in to change notification settings - Fork 5
Compel users to release packages with breaking changes alongside their dependents #101
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
Merged
cryptodev-2s
merged 11 commits into
main
from
feature/compel-users-to-release-dependents
Oct 17, 2023
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
33d8a21
Compel users to release packages with breaking changes alongside thei…
cryptodev-2s 83d6867
fix: combine checks on 1 iteration
cryptodev-2s 9dafef3
Merge remote-tracking branch 'origin/main' into feature/compel-users-…
cryptodev-2s 57beec0
Add more unit tests
cryptodev-2s 29afc3e
Fix remove useless code change
cryptodev-2s 25ec632
Add unit tests for literal version upgrade
cryptodev-2s beeddbf
Refactor dependent package lookup
cryptodev-2s d9739cd
Use validatedManifest
cryptodev-2s d89a104
Update test scenario wording
cryptodev-2s 389df9b
Fix real case dependents lookup
cryptodev-2s 8bf5ce2
Fix changed package var naming
cryptodev-2s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||
import fs, { WriteStream } from 'fs'; | ||||||||||
import YAML from 'yaml'; | ||||||||||
import { diff } from 'semver'; | ||||||||||
import { Editor } from './editor'; | ||||||||||
import { readFile } from './fs'; | ||||||||||
import { | ||||||||||
|
@@ -241,10 +242,8 @@ export async function validateReleaseSpecification( | |||||||||
}); | ||||||||||
} | ||||||||||
|
||||||||||
Object.keys(unvalidatedReleaseSpecification.packages).forEach( | ||||||||||
(packageName, index) => { | ||||||||||
const versionSpecifierOrDirective = | ||||||||||
unvalidatedReleaseSpecification.packages[packageName]; | ||||||||||
Object.entries(unvalidatedReleaseSpecification.packages).forEach( | ||||||||||
([packageName, versionSpecifierOrDirective], index) => { | ||||||||||
const lineNumber = indexOfFirstUsableLine + index + 2; | ||||||||||
const pkg = project.workspacePackages[packageName]; | ||||||||||
|
||||||||||
|
@@ -301,6 +300,72 @@ export async function validateReleaseSpecification( | |||||||||
}); | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
// Check to compel users to release packages with breaking changes alongside their dependents | ||||||||||
if ( | ||||||||||
versionSpecifierOrDirective === 'major' || | ||||||||||
(isValidSemver(versionSpecifierOrDirective) && | ||||||||||
diff( | ||||||||||
pkg.validatedManifest.version, | ||||||||||
cryptodev-2s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
versionSpecifierOrDirective as string, | ||||||||||
cryptodev-2s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
) === 'major') | ||||||||||
) { | ||||||||||
const missingDependents = Object.values( | ||||||||||
project.workspacePackages, | ||||||||||
).filter((dependent) => { | ||||||||||
const { dependencies, peerDependencies } = | ||||||||||
cryptodev-2s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
dependent.unvalidatedManifest; | ||||||||||
const isDependent = | ||||||||||
(dependencies && hasProperty(dependencies, packageName)) || | ||||||||||
(peerDependencies && hasProperty(peerDependencies, packageName)); | ||||||||||
|
||||||||||
if (!isDependent) { | ||||||||||
return false; | ||||||||||
} | ||||||||||
|
||||||||||
const dependentVersionSpecifierOrDirective = | ||||||||||
unvalidatedReleaseSpecification.packages[ | ||||||||||
dependent.validatedManifest.name | ||||||||||
]; | ||||||||||
|
||||||||||
return ( | ||||||||||
dependentVersionSpecifierOrDirective === SKIP_PACKAGE_DIRECTIVE || | ||||||||||
(dependentVersionSpecifierOrDirective !== | ||||||||||
INTENTIONALLY_SKIP_PACKAGE_DIRECTIVE && | ||||||||||
!hasProperty( | ||||||||||
IncrementableVersionParts, | ||||||||||
dependentVersionSpecifierOrDirective, | ||||||||||
) && | ||||||||||
!isValidSemver(dependentVersionSpecifierOrDirective)) | ||||||||||
); | ||||||||||
}); | ||||||||||
cryptodev-2s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
if (missingDependents.length > 0) { | ||||||||||
errors.push({ | ||||||||||
message: [ | ||||||||||
`The following packages, which depend on released package ${packageName}, are missing.`, | ||||||||||
cryptodev-2s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
missingDependents | ||||||||||
.map((dependent) => ` - ${dependent.validatedManifest.name}`) | ||||||||||
.join('\n'), | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the changes above, you should have names of packages again instead of whole package objects, so you should be able to simplify this to:
Suggested change
|
||||||||||
` Consider including them in the release spec so that they are compatible with the new '${packageName}' version.`, | ||||||||||
` If you are ABSOLUTELY SURE that this won't occur, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:`, | ||||||||||
cryptodev-2s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
YAML.stringify({ | ||||||||||
packages: missingDependents.reduce((object, dependent) => { | ||||||||||
return { | ||||||||||
...object, | ||||||||||
[dependent.validatedManifest.name]: | ||||||||||
INTENTIONALLY_SKIP_PACKAGE_DIRECTIVE, | ||||||||||
}; | ||||||||||
}, {}), | ||||||||||
}) | ||||||||||
.trim() | ||||||||||
.split('\n') | ||||||||||
.map((line) => ` ${line}`) | ||||||||||
.join('\n'), | ||||||||||
].join('\n\n'), | ||||||||||
}); | ||||||||||
} | ||||||||||
} | ||||||||||
}, | ||||||||||
); | ||||||||||
|
||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.