1919 * after the latest tag of the package
2020 */
2121
22- import { exec , execSync } from 'child_process' ;
22+ import { execSync } from 'child_process' ;
2323import path from 'path' ;
2424import { readFileSync } from 'fs' ;
2525import { 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-
5046const 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
6157repoTags . 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+ } ) ;
0 commit comments