Skip to content

Commit 6f48e5b

Browse files
committed
chore: cleanup some scripts
1 parent eae2663 commit 6f48e5b

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

scripts/bump-package-versions.mjs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* after the latest tag of the package
2020
*/
2121

22-
import { exec, execSync } from 'child_process';
22+
import { execSync } from 'child_process';
2323
import path from 'path';
2424
import { readFileSync } from 'fs';
2525
import { globSync } from 'glob';
@@ -43,10 +43,6 @@ const getPackages = () => {
4343
});
4444
}
4545

46-
const getCommitsFrom = (commitOrTag) => {
47-
return execSync(`git log ${commitOrTag}..HEAD --oneline`, { encoding: 'utf-8' }).split('\n');
48-
}
49-
5046
const getScopedCommitsFrom = (scope, commitOrTag) => {
5147
const commits = execSync(`git log ${commitOrTag}..HEAD --oneline`, { encoding: 'utf-8' }).split('\n');
5248

@@ -60,7 +56,6 @@ const repoTags = execSync('git tag', { encoding: 'utf-8' }).split('\n');
6056
// Set the latest tag on each package
6157
repoTags.forEach((tag) => {
6258
const nameParts = tag.split('-');
63-
const version = nameParts.pop();
6459
const pkgName = `@opentelemetry/${nameParts.join('-')}`;
6560
const pkgInfo = publicPkgList.find((pkg) => pkg.name === pkgName);
6661

@@ -93,26 +88,27 @@ publicPkgList.forEach((pkgInfo) => {
9388

9489
console.log(`Bumping ${bumpType} version in ${pkgInfo.name}`);
9590
execSync(`npm version ${bumpType} --git-tag-version=false`, { cwd: pkgInfo.location });
96-
9791
} else {
9892
// NOTE: this could be one of two scenairios
9993
// - new package
10094
// - package being moved here like @opentelemetry/propagator-aws-xray-lambda
101-
console.log(pkgInfo.name, 'has no tag');
95+
console.log(`"${pkgInfo.name}" has no tag`);
10296
let isNewPkg = false;
10397
let versions;
10498
try {
10599
versions = JSON.parse(
106100
execSync(`npm info ${pkgInfo.name} --json time`, { encoding: 'utf-8' })
107101
);
108102
} catch (err) {
109-
console.log(`*********\n${err.message}\n********`)
103+
// We get an error for new a new package. Throw other type of errors
110104
isNewPkg = err.message.includes('npm ERR! 404 Not Found - GET');
105+
if (!isNewPkg) {
106+
throw err;
107+
}
111108
}
112109

113-
114110
if (isNewPkg) {
115-
console.log(pkgInfo.name, 'is not in the registry. No bump needed');
111+
console.log(`"${pkgInfo.name}" is not in the registry. No bump needed`);
116112
} else {
117113
// - assume version is the last in npm
118114
// - find the commit where it was added
@@ -122,7 +118,6 @@ publicPkgList.forEach((pkgInfo) => {
122118
const scopedCommits = getScopedCommitsFrom(pkgScope, commitSha);
123119

124120
console.log(`Package ${pkgInfo.name} was added in ${commitSha}`);
125-
126121
const isExperimental = pkgInfo.version.startsWith('0.');
127122
const bumpMinor = scopedCommits.some((cmt) => {
128123
const pattern = isExperimental ? `(${pkgScope})!:` : `feat(${pkgScope}):`
@@ -135,4 +130,4 @@ publicPkgList.forEach((pkgInfo) => {
135130
execSync(`npm version ${bumpType} --git-tag-version=false`, { cwd: pkgInfo.location });
136131
}
137132
}
138-
})
133+
});

scripts/publish-to-npm.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* Replacement for: lerna publish from-package --no-push --no-private --no-git-tag-version --no-verify-access --yes
19+
* Workflow line: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/c67a8c3e096b835e3eb91cac0642bf775ffa4350/.github/workflows/release-please.yml#L84
1920
* Ref: https://github.com/lerna/lerna/tree/main/commands/publish#bump-from-package
2021
*
2122
* Usage: node ./scripts/publish-to-npm.mjs

0 commit comments

Comments
 (0)