@@ -114,56 +114,13 @@ export default async function createChangeset(
114114
115115 let pkgsLeftToGetBumpTypeFor = new Set ( packagesToRelease ) ;
116116
117- let pkgsThatShouldBeMajorBumped = ( await cli . askCheckboxPlus (
118- bold ( `Which packages should have a ${ red ( "major" ) } bump?` ) ,
119- [
120- {
121- name : "all packages" ,
122- choices : packagesToRelease . map ( pkgName => {
123- return {
124- name : pkgName ,
125- message : formatPkgNameAndVersion (
126- pkgName ,
127- pkgJsonsByName . get ( pkgName ) ! . version
128- )
129- } ;
130- } )
131- }
132- ] ,
133- x => {
134- // this removes changed packages and unchanged packages from the list
135- // of packages shown after selection
136- if ( Array . isArray ( x ) ) {
137- return x
138- . filter ( x => x !== "all packages" )
139- . map ( x => cyan ( x ) )
140- . join ( ", " ) ;
141- }
142- return x ;
143- }
144- ) ) . filter ( x => x !== "all packages" ) ;
145-
146- for ( const pkgName of pkgsThatShouldBeMajorBumped ) {
147- // for packages that are under v1, we want to make sure major releases are intended,
148- // as some repo-wide sweeping changes have mistakenly release first majors
149- // of packages.
150- let pkgJson = pkgJsonsByName . get ( pkgName ) ! ;
151-
152- let shouldReleaseFirstMajor = await confirmMajorRelease ( pkgJson ) ;
153- if ( shouldReleaseFirstMajor ) {
154- pkgsLeftToGetBumpTypeFor . delete ( pkgName ) ;
155-
156- releases . push ( { name : pkgName , type : "major" } ) ;
157- }
158- }
159-
160- if ( pkgsLeftToGetBumpTypeFor . size !== 0 ) {
161- let pkgsThatShouldBeMinorBumped = ( await cli . askCheckboxPlus (
162- bold ( `Which packages should have a ${ green ( "minor" ) } bump?` ) ,
117+ let pkgsThatShouldBeMajorBumped = (
118+ await cli . askCheckboxPlus (
119+ bold ( `Which packages should have a ${ red ( "major" ) } bump?` ) ,
163120 [
164121 {
165122 name : "all packages" ,
166- choices : [ ... pkgsLeftToGetBumpTypeFor ] . map ( pkgName => {
123+ choices : packagesToRelease . map ( pkgName => {
167124 return {
168125 name : pkgName ,
169126 message : formatPkgNameAndVersion (
@@ -185,7 +142,54 @@ export default async function createChangeset(
185142 }
186143 return x ;
187144 }
188- ) ) . filter ( x => x !== "all packages" ) ;
145+ )
146+ ) . filter ( x => x !== "all packages" ) ;
147+
148+ for ( const pkgName of pkgsThatShouldBeMajorBumped ) {
149+ // for packages that are under v1, we want to make sure major releases are intended,
150+ // as some repo-wide sweeping changes have mistakenly release first majors
151+ // of packages.
152+ let pkgJson = pkgJsonsByName . get ( pkgName ) ! ;
153+
154+ let shouldReleaseFirstMajor = await confirmMajorRelease ( pkgJson ) ;
155+ if ( shouldReleaseFirstMajor ) {
156+ pkgsLeftToGetBumpTypeFor . delete ( pkgName ) ;
157+
158+ releases . push ( { name : pkgName , type : "major" } ) ;
159+ }
160+ }
161+
162+ if ( pkgsLeftToGetBumpTypeFor . size !== 0 ) {
163+ let pkgsThatShouldBeMinorBumped = (
164+ await cli . askCheckboxPlus (
165+ bold ( `Which packages should have a ${ green ( "minor" ) } bump?` ) ,
166+ [
167+ {
168+ name : "all packages" ,
169+ choices : [ ...pkgsLeftToGetBumpTypeFor ] . map ( pkgName => {
170+ return {
171+ name : pkgName ,
172+ message : formatPkgNameAndVersion (
173+ pkgName ,
174+ pkgJsonsByName . get ( pkgName ) ! . version
175+ )
176+ } ;
177+ } )
178+ }
179+ ] ,
180+ x => {
181+ // this removes changed packages and unchanged packages from the list
182+ // of packages shown after selection
183+ if ( Array . isArray ( x ) ) {
184+ return x
185+ . filter ( x => x !== "all packages" )
186+ . map ( x => cyan ( x ) )
187+ . join ( ", " ) ;
188+ }
189+ return x ;
190+ }
191+ )
192+ ) . filter ( x => x !== "all packages" ) ;
189193
190194 for ( const pkgName of pkgsThatShouldBeMinorBumped ) {
191195 pkgsLeftToGetBumpTypeFor . delete ( pkgName ) ;
@@ -225,13 +229,27 @@ export default async function createChangeset(
225229 }
226230
227231 log (
228- "Please enter a summary for this change (this will be in the changelogs)"
232+ "Please enter a summary for this change (this will be in the changelogs). Submit empty line to open external editor "
229233 ) ;
230234
231235 let summary = await cli . askQuestion ( "Summary" ) ;
232- while ( summary . length === 0 ) {
233- error ( "A summary is required for the changelog! 😪" ) ;
234- summary = await cli . askQuestion ( "Summary" ) ;
236+ if ( summary . length === 0 ) summary = cli . askQuestionWithEditor ( "" ) ;
237+ try {
238+ while ( summary . length === 0 ) {
239+ summary = await cli . askQuestionWithEditor (
240+ "\n\n# A summary is required for the changelog! 😪"
241+ ) ;
242+ }
243+ } catch ( err ) {
244+ log (
245+ "An error happened using external editor. Please type your summary here:"
246+ ) ;
247+ summary = await cli . askQuestion ( "" ) ;
248+ while ( summary . length === 0 ) {
249+ summary = await cli . askQuestion (
250+ "\n\n# A summary is required for the changelog! 😪"
251+ ) ;
252+ }
235253 }
236254
237255 return {
0 commit comments