@@ -67,8 +67,32 @@ function markTaskAsDone(task, releaseDirPath) {
67
67
fs . writeFileSync ( taskDoneFilePath ( task , releaseDirPath ) , '' ) ;
68
68
}
69
69
70
+ function checkUserPermissionsToPublish ( ) {
71
+ const lerna = path . resolve ( rootPath , 'node_modules' , '.bin' , 'lerna' ) ;
72
+
73
+ const userPackagesAccess = JSON . parse ( execSync ( `npm access ls-packages` ) . toString ( ) . trim ( ) )
74
+ const lernaPackages = JSON . parse ( execFileSync ( lerna ,
75
+ [ 'list' , '--json' , '--no-private' , '--loglevel=error' ] ) . toString ( ) . trim ( ) ) ;
76
+
77
+ const missingAccess = [ ] ;
78
+
79
+ for ( const repo of lernaPackages ) {
80
+ if ( userPackagesAccess [ repo . name ] !== 'read-write' ) {
81
+ missingAccess . push ( repo . name ) ;
82
+ }
83
+ }
84
+
85
+ if ( missingAccess . length ) {
86
+ throw new Error (
87
+ `Required write access missing for the following packages: ${ missingAccess . join ( ', ' ) } `
88
+ ) ;
89
+ }
90
+ }
91
+
70
92
async function publish ( ) {
71
93
const segmentApiKey = requireSegmentApiKey ( ) ;
94
+ checkUserPermissionsToPublish ( ) ;
95
+
72
96
const remoteUrl = getGitRemoteUrl ( ) ;
73
97
const remoteHeadSha = getGitRemoteHeadSHA ( remoteUrl ) ;
74
98
const releaseDirPath = path . resolve ( rootPath , 'tmp' , 'releases' , remoteHeadSha ) ;
0 commit comments