@@ -14,6 +14,7 @@ const path = require('path');
1414const { echo, exec, exit} = require ( 'shelljs' ) ;
1515const yargs = require ( 'yargs' ) ;
1616
17+ const alignPackageVersions = require ( '../align-package-versions' ) ;
1718const {
1819 PUBLISH_PACKAGES_TAG ,
1920 GENERIC_COMMIT_MESSAGE ,
@@ -157,76 +158,80 @@ const main = async () => {
157158 . then ( ( ) => echo ( ) ) ;
158159 }
159160
160- if ( checkForGitChanges ( ) ) {
161- await inquirer
162- . prompt ( [
163- {
164- type : 'list' ,
165- name : 'commitChoice' ,
166- message : 'Do you want to submit a commit with these changes?' ,
167- choices : [
168- {
169- name : 'Yes, with generic message' ,
170- value : COMMIT_WITH_GENERIC_MESSAGE_CHOICE ,
171- } ,
172- {
173- name : 'Yes, with custom message' ,
174- value : COMMIT_WITH_CUSTOM_MESSAGE_CHOICE ,
175- } ,
176- {
177- name : 'No' ,
178- value : NO_COMMIT_CHOICE ,
179- } ,
180- ] ,
181- } ,
182- ] )
183- . then ( ( { commitChoice} ) => {
184- switch ( commitChoice ) {
185- case NO_COMMIT_CHOICE : {
186- echo ( 'Not submitting a commit, but keeping all changes' ) ;
187-
188- break ;
189- }
190-
191- case COMMIT_WITH_GENERIC_MESSAGE_CHOICE : {
192- exec ( `git commit -am "${ GENERIC_COMMIT_MESSAGE } "` , {
193- cwd : ROOT_LOCATION ,
194- silent : true ,
195- } ) ;
196-
197- break ;
198- }
199-
200- case COMMIT_WITH_CUSTOM_MESSAGE_CHOICE : {
201- // exec from shelljs currently does not support interactive input
202- // https://github.com/shelljs/shelljs/wiki/FAQ#running-interactive-programs-with-exec
203- execSync ( 'git commit -a' , { cwd : ROOT_LOCATION , stdio : 'inherit' } ) ;
204-
205- const enteredCommitMessage = exec (
206- 'git log -n 1 --format=format:%B' ,
207- {
208- cwd : ROOT_LOCATION ,
209- silent : true ,
210- } ,
211- ) . stdout . trim ( ) ;
212- const commitMessageWithTag =
213- enteredCommitMessage + `\n\n${ PUBLISH_PACKAGES_TAG } ` ;
214-
215- exec ( `git commit --amend -m "${ commitMessageWithTag } "` , {
216- cwd : ROOT_LOCATION ,
217- silent : true ,
218- } ) ;
219-
220- break ;
221- }
222-
223- default :
224- throw new Error ( '' ) ;
225- }
226- } )
227- . then ( ( ) => echo ( ) ) ;
161+ if ( ! checkForGitChanges ( ) ) {
162+ echo ( 'No changes have been made. Finishing the process...' ) ;
163+ exit ( 0 ) ;
228164 }
229165
166+ echo ( 'Aligning new versions across monorepo...' ) ;
167+ alignPackageVersions ( ) ;
168+ echo ( chalk . green ( 'Done!\n' ) ) ;
169+
170+ await inquirer
171+ . prompt ( [
172+ {
173+ type : 'list' ,
174+ name : 'commitChoice' ,
175+ message : 'Do you want to submit a commit with these changes?' ,
176+ choices : [
177+ {
178+ name : 'Yes, with generic message' ,
179+ value : COMMIT_WITH_GENERIC_MESSAGE_CHOICE ,
180+ } ,
181+ {
182+ name : 'Yes, with custom message' ,
183+ value : COMMIT_WITH_CUSTOM_MESSAGE_CHOICE ,
184+ } ,
185+ {
186+ name : 'No' ,
187+ value : NO_COMMIT_CHOICE ,
188+ } ,
189+ ] ,
190+ } ,
191+ ] )
192+ . then ( ( { commitChoice} ) => {
193+ switch ( commitChoice ) {
194+ case NO_COMMIT_CHOICE : {
195+ echo ( 'Not submitting a commit, but keeping all changes' ) ;
196+
197+ break ;
198+ }
199+
200+ case COMMIT_WITH_GENERIC_MESSAGE_CHOICE : {
201+ exec ( `git commit -am "${ GENERIC_COMMIT_MESSAGE } "` , {
202+ cwd : ROOT_LOCATION ,
203+ silent : true ,
204+ } ) ;
205+
206+ break ;
207+ }
208+
209+ case COMMIT_WITH_CUSTOM_MESSAGE_CHOICE : {
210+ // exec from shelljs currently does not support interactive input
211+ // https://github.com/shelljs/shelljs/wiki/FAQ#running-interactive-programs-with-exec
212+ execSync ( 'git commit -a' , { cwd : ROOT_LOCATION , stdio : 'inherit' } ) ;
213+
214+ const enteredCommitMessage = exec ( 'git log -n 1 --format=format:%B' , {
215+ cwd : ROOT_LOCATION ,
216+ silent : true ,
217+ } ) . stdout . trim ( ) ;
218+ const commitMessageWithTag =
219+ enteredCommitMessage + `\n\n${ PUBLISH_PACKAGES_TAG } ` ;
220+
221+ exec ( `git commit --amend -m "${ commitMessageWithTag } "` , {
222+ cwd : ROOT_LOCATION ,
223+ silent : true ,
224+ } ) ;
225+
226+ break ;
227+ }
228+
229+ default :
230+ throw new Error ( '' ) ;
231+ }
232+ } )
233+ . then ( ( ) => echo ( ) ) ;
234+
230235 echo ( chalk . green ( 'Successfully finished the process of bumping packages' ) ) ;
231236 exit ( 0 ) ;
232237} ;
0 commit comments