Skip to content

Commit

Permalink
fix: bump release type by dependent if inherit
Browse files Browse the repository at this point in the history
  • Loading branch information
gavmck committed May 15, 2024
1 parent bd08b14 commit d7a11c0
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/updateDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import getManifest from "./getManifest.js";
import { getHighestVersion, getLatestVersion } from "./utils.js";
import { getTags } from "./git.js";
import { logger } from "./logger.js";
import { release } from "os";

const { debug } = logger.withScope("msr:updateDeps");

Expand Down Expand Up @@ -163,23 +164,30 @@ const resolveReleaseType = (pkg, bumpStrategy = "override", releaseStrategy = "p
// 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'];
const depIndex = dependentReleaseType ? types.indexOf(dependentReleaseType) : 4;
const pkgIndex = pkg._nextType? types.indexOf(pkg._nextType) : 4;

if (releaseStrategy === "inherit" && dependentReleaseType && depIndex >= pkgIndex) {
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

0 comments on commit d7a11c0

Please sign in to comment.