Skip to content

Commit ddf5b7f

Browse files
committed
chore: update version script
1 parent d86b1f2 commit ddf5b7f

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

scripts/bump-package-versions.mjs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,27 @@ import path from 'path';
2424
import { readFileSync } from 'fs';
2525
import { globSync } from 'glob';
2626

27+
/**
28+
* @typedef {Object} PkgInfo
29+
* @property {string} version
30+
* @property {string} name
31+
* @property {string} location
32+
* @property {string} [tag]
33+
*/
34+
2735
// -- Utility functions --
2836
// TODO: move this into a common file
37+
/**
38+
* @param {string} filePath
39+
* @returns {Object}
40+
*/
2941
const readJson = (filePath) => {
3042
return JSON.parse(readFileSync(filePath));
3143
};
3244

45+
/**
46+
* @returns {PkgInfo[]}
47+
*/
3348
const getPackages = () => {
3449
const TOP = process.cwd();
3550
const pj = readJson(path.join(TOP, 'package.json'));
@@ -43,6 +58,11 @@ const getPackages = () => {
4358
});
4459
}
4560

61+
/**
62+
* @param {PkgInfo} pkgInfo
63+
* @param {string} commitOrTag
64+
* @returns
65+
*/
4666
const getPkgCommitsFrom = (pkgInfo, commitOrTag) => {
4767
const command = `git log ${commitOrTag}..HEAD --oneline ${pkgInfo.location}`;
4868
const commits = execSync(command,{ encoding: 'utf-8' }).split('\n');
@@ -51,8 +71,7 @@ const getPkgCommitsFrom = (pkgInfo, commitOrTag) => {
5171
}
5272

5373
/**
54-
*
55-
* @param {Record<string, any>} pkgInfo
74+
* @param {PkgInfo} pkgInfo
5675
* @param {string[]} commits
5776
* @returns {'major' | 'minor' | 'patch'}
5877
*/
@@ -107,15 +126,6 @@ repoTags.forEach((tag) => {
107126
// Check for commits on each package
108127
// Assumption: current version is latest on npm (so no checking it)
109128
publicPkgList.forEach((pkgInfo) => {
110-
const pkgScope = pkgInfo.name.replace('@opentelemetry/', '');
111-
112-
// if (pkgInfo.tag) {
113-
// console.log(`**** commits for ${pkgScope} from ${pkgInfo.tag} ****`)
114-
// const scopedCommits = getPkgCommitsFrom(pkgInfo, pkgInfo.tag);
115-
// console.log('bump type', getBumpType(pkgInfo, scopedCommits))
116-
// }
117-
// return
118-
119129
if (pkgInfo.tag) {
120130
const scopedCommits = getPkgCommitsFrom(pkgInfo, pkgInfo.tag);
121131

0 commit comments

Comments
 (0)