Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import path from 'path';
import { discoverPackages } from './workspace.js';
import { getMergeBase, getVersionAtRef } from './git.js';
/**
* Detect package version changes between two refs.
*
* Uses the merge-base of (baseRef, toRef) as the comparison point so that
* detection is stable when called from a feature branch as well as from a
* post-merge HEAD on a release branch.
*
* @param {string} baseRef - Base ref to compare against (e.g. 'origin/develop', 'HEAD~1').
* @param {string} [toRef='HEAD'] - Current ref. Versions are read from the workspace
* package.json files, which represent `toRef` when run
* with a clean checkout at `toRef`.
* @returns {Array<{name: string, from: string, to: string, relativePath: string}>}
*/
export function detectBumps(baseRef, toRef = 'HEAD') {
const base = getMergeBase(baseRef, toRef) || baseRef;
const bumps = [];
for (const pkg of discoverPackages()) {
const relManifest = path.join(pkg.relativePath, 'package.json').split(path.sep).join('/');
const before = getVersionAtRef(base, relManifest);
const after = pkg.version;
if (before && before !== after) {
bumps.push({
name: pkg.name,
from: before,
to: after,
relativePath: pkg.relativePath,
});
}
}
return bumps;
}
/**
* Format detected bumps as a comma-separated tag-list compatible with
* `tag --packages` and `github --packages`.
*
* Example: "@salesforce-ux/design-system@2.264.0,@salesforce-ux/design-system-2@2.264.0"
*/
export function bumpsToTagList(bumps) {
return bumps.map((b) => `${b.name}@${b.to}`).join(',');
}
|