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: bump release type by dependent if deps.release is inherit #100

Merged
merged 6 commits into from
Jul 28, 2024
Merged
Changes from 2 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
23 changes: 15 additions & 8 deletions lib/updateDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,30 @@
// NOTE This fn also updates pkg deps, so it must be invoked anyway.
const dependentReleaseType = getDependentRelease(pkg, bumpStrategy, releaseStrategy, ignore, prefix);

// Define release type for dependent package if any of its deps changes.
// `patch`, `minor`, `major` — strictly declare the release type that occurs when any dependency is updated.
// `inherit` — applies the "highest" release of updated deps to the package.
// For example, if any dep has a breaking change, `major` release will be applied to the all dependants up the chain.
// If we want to inherit the release type from the dependent package
const types = ['patch', 'minor', 'major'];

Check failure on line 171 in lib/updateDeps.js

View workflow job for this annotation

GitHub Actions / Test (Node v20, OS ubuntu-22.04)

Replace `'patch',·'minor',·'major'` with `"patch",·"minor",·"major"`
const depIndex = dependentReleaseType ? types.indexOf(dependentReleaseType) : 4;
gavmck marked this conversation as resolved.
Show resolved Hide resolved
const pkgIndex = pkg._nextType? types.indexOf(pkg._nextType) : 4;

Check failure on line 173 in lib/updateDeps.js

View workflow job for this annotation

GitHub Actions / Test (Node v20, OS ubuntu-22.04)

Insert `·`

if (releaseStrategy === "inherit" && dependentReleaseType && depIndex >= pkgIndex) {
gavmck marked this conversation as resolved.
Show resolved Hide resolved
return dependentReleaseType;
}

// Release type found by commitAnalyzer.
if (pkg._nextType) {
return pkg._nextType;
}

// No deps changed.
if (!dependentReleaseType) {
return undefined;
}

// Define release type for dependent package if any of its deps changes.
// `patch`, `minor`, `major` — strictly declare the release type that occurs when any dependency is updated.
// `inherit` — applies the "highest" release of updated deps to the package.
// For example, if any dep has a breaking change, `major` release will be applied to the all dependants up the chain.

pkg._nextType = releaseStrategy === "inherit" ? dependentReleaseType : releaseStrategy;

return pkg._nextType;
return releaseStrategy;
};

/**
Expand Down
Loading