@@ -28,25 +28,30 @@ const yargs = require('nx/node_modules/yargs');
2828 . option ( 'gitRemote' , {
2929 description : 'The name of the git remote to push the release to, defaults to origin' ,
3030 type : 'string' ,
31- default : 'origin' ,
3231 } )
3332 . parseAsync ( ) ;
34-
3533 if ( ! options . dryRun ) {
3634 if ( ! process . env . GH_TOKEN && ! process . env . GITHUB_TOKEN ) {
3735 throw new Error ( `GH_TOKEN or GITHUB_TOKEN environment variable must be set in order to run a real release` ) ;
3836 }
39- if ( options . gitRemote !== 'upstream' ) {
40- throw new Error (
41- `Expected --gitRemote to be set to "upstream" when running a real release. Add --gitRemote=upstream to the release command.`
42- ) ;
43- }
4437 }
4538
39+ if ( ! options . gitRemote ) {
40+ options . gitRemote = getRemoteFor ( 'git@github.com:ReactiveX/rxjs.git' ) ;
41+ }
42+
43+ console . log ( ) ;
44+ console . info ( `********* Release Options **********` ) ;
45+ console . info ( `version : ${ options . version ?? 'use conventional commits' } ` ) ;
46+ console . info ( `dryRun : ${ options . dryRun } ${ options . dryRun ? '😅' : '🚨🚨🚨' } ` ) ;
47+ console . info ( `verbose : ${ options . verbose } ` ) ;
48+ console . info ( `gitRemote : ${ options . gitRemote } ` ) ;
49+ console . log ( ) ;
50+
4651 // Prepare the packages for publishing
4752 execSync ( 'yarn prepare-packages' , {
4853 stdio : 'inherit' ,
49- maxBuffer : 1024 * 1000000 ,
54+ maxBuffer : 1024 * 1024 * 1024 , // 1GB
5055 } ) ;
5156
5257 const { workspaceVersion, projectsVersionData } = await releaseVersion ( {
@@ -77,3 +82,21 @@ const yargs = require('nx/node_modules/yargs');
7782 process . exit ( 1 ) ;
7883 }
7984} ) ( ) ;
85+
86+ /**
87+ * Gets the name of the git remote for the given URL, if
88+ * the remote is not found an error is thrown.
89+ * @param {string } url
90+ * @returns The name of the git remote for the given URL
91+ */
92+ function getRemoteFor ( url ) {
93+ const stdout = execSync ( 'git remote -v' ) . toString ( ) ;
94+ const lines = stdout . split ( '\n' ) ;
95+ for ( const line of lines ) {
96+ const parts = line . split ( / \s + / ) ;
97+ if ( parts . length > 1 && parts [ 1 ] === url ) {
98+ return parts [ 0 ] ;
99+ }
100+ }
101+ throw new Error ( `Could not find remote for "${ url } "` ) ;
102+ }
0 commit comments