1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var SEMVER;
|
4 | (function (SEMVER) {
|
5 | SEMVER["major"] = "major";
|
6 | SEMVER["premajor"] = "premajor";
|
7 | SEMVER["minor"] = "minor";
|
8 | SEMVER["preminor"] = "preminor";
|
9 | SEMVER["patch"] = "patch";
|
10 | SEMVER["prepatch"] = "prepatch";
|
11 | SEMVER["noVersion"] = "";
|
12 | })(SEMVER || (SEMVER = {}));
|
13 | exports.preVersionMap = new Map([
|
14 | [SEMVER.major, SEMVER.premajor],
|
15 | [SEMVER.minor, SEMVER.preminor],
|
16 | [SEMVER.patch, SEMVER.prepatch],
|
17 | ]);
|
18 | exports.default = SEMVER;
|
19 |
|
20 | function getHigherSemverTag(left, right) {
|
21 | if (left === SEMVER.major || right === SEMVER.major) {
|
22 | return SEMVER.major;
|
23 | }
|
24 | if (left === SEMVER.minor || right === SEMVER.minor) {
|
25 | return SEMVER.minor;
|
26 | }
|
27 | return SEMVER.patch;
|
28 | }
|
29 | exports.getHigherSemverTag = getHigherSemverTag;
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | function calculateSemVerBump(labels, labelMap, { onlyPublishWithReleaseLabel } = {}) {
|
36 | const labelSet = new Set();
|
37 | const skipReleaseLabels = labelMap.get("skip") || [];
|
38 | labels.forEach((pr, index) => {
|
39 |
|
40 | if (pr.length === 0 && index === 0) {
|
41 | labelSet.add(SEMVER.patch);
|
42 | }
|
43 | pr.forEach((label) => {
|
44 | const userLabel = [...labelMap.entries()].find((pair) => pair[1].includes(label));
|
45 | if (userLabel) {
|
46 | labelSet.add(userLabel[0]);
|
47 | }
|
48 | });
|
49 | });
|
50 | const lastMergedCommitLabels = labels[0] || [];
|
51 | const releaseLabels = labelMap.get("release") || [];
|
52 | const skipRelease = onlyPublishWithReleaseLabel
|
53 | ? !lastMergedCommitLabels.some((label) => releaseLabels.includes(label))
|
54 | : lastMergedCommitLabels.some((label) => skipReleaseLabels.includes(label));
|
55 |
|
56 | const onlyNoReleaseLabels = [...labelSet].reduce((condition, releaseType) => condition && (releaseType === "none" || releaseType === "skip"), true);
|
57 | if (labelSet.size > 0 && onlyNoReleaseLabels) {
|
58 | return SEMVER.noVersion;
|
59 | }
|
60 | const version = [...labelSet].reduce(getHigherSemverTag, SEMVER.patch);
|
61 | if (skipRelease) {
|
62 | return SEMVER.noVersion;
|
63 | }
|
64 | return version;
|
65 | }
|
66 | exports.calculateSemVerBump = calculateSemVerBump;
|
67 |
|
\ | No newline at end of file |