@@ -48,48 +48,76 @@ async function update() {
4848
4949 await writeFileAsync ( './package.json' , JSON . stringify ( nextPackageJson , null , 2 ) + '\n' ) ;
5050 await install ( ) ;
51-
5251 await build ( ) ;
5352
5453 const [ indexDtsDiff , indexFlowDiff ] = [
55- await spawnAsync ( 'git' , '--no-pager' , 'diff' , '--color' , TYPESCRIPT_FILENAME ) ,
56- await spawnAsync ( 'git' , '--no-pager' , 'diff' , '--color' , FLOW_FILENAME ) ,
54+ await spawnAsync ( 'git' , '--no-pager' , 'diff' , TYPESCRIPT_FILENAME ) ,
55+ await spawnAsync ( 'git' , '--no-pager' , 'diff' , FLOW_FILENAME ) ,
5756 ] ;
5857
5958 if ( indexDtsDiff !== '' || indexFlowDiff !== '' ) {
6059 console . info ( "Changes detected! Here's the diff:" ) ;
6160 console . info ( indexDtsDiff ) ;
6261 console . info ( indexFlowDiff ) ;
6362
64- const doPrepare = await questionAsync ( 'Do you want to prepare a release for this? (y/n) ' ) ;
65-
66- if ( doPrepare === 'y' ) {
63+ if ( process . argv . includes ( '--auto' ) ) {
6764 await spawnAsync ( 'git' , 'commit' , '-am' , 'Bump MDN' ) ;
65+ await spawnAsync ( 'git' , 'push' , 'origin' , 'HEAD' ) ;
66+
67+ let body = 'Automated update of types based on the latest MDN data:' ;
6868
69- const [ major , minor , patch ] = nextPackageJson . version . split ( '.' ) ;
70- const version = `${ major } . ${ minor } . ${ Number ( patch ) + 1 } ` ;
71- const tag = `v ${ version } ` ;
69+ if ( currentMdnDataVersion !== latestMdnDataVersion ) {
70+ body + = `\n- ${ MDN_DATA } : ${ currentMdnDataVersion } → ${ latestMdnDataVersion } ` ;
71+ }
7272
73- nextPackageJson . version = version ;
73+ if ( currentMdnCompatVersion !== latestMdnCompatVersion ) {
74+ body += `\n- ${ MDN_COMPAT } : ${ currentMdnCompatVersion } → ${ latestMdnCompatVersion } ` ;
75+ }
7476
75- await writeFileAsync ( './package.json' , JSON . stringify ( nextPackageJson , null , 2 ) + '\n' ) ;
76- await spawnAsync ( 'git' , 'commit' , '-am' , tag ) ;
77- await spawnAsync ( 'git' , 'tag' , tag ) ;
77+ await spawnAsync (
78+ 'gh' ,
79+ 'pr' ,
80+ 'create' ,
81+ '-B' ,
82+ 'master' ,
83+ '-H' ,
84+ 'HEAD' ,
85+ '--title' ,
86+ '"Update types"' ,
87+ '--body' ,
88+ JSON . stringify ( body ) ,
89+ ) ;
90+ } else {
91+ const doPrepare = await questionAsync ( 'Do you want to prepare a release for this? (y/n) ' ) ;
7892
79- console . info ( `The changes are committed and tagged with: ${ tag } ` ) ;
93+ if ( doPrepare === 'y' ) {
94+ await spawnAsync ( 'git' , 'commit' , '-am' , 'Bump MDN' ) ;
8095
81- const doPush = await questionAsync ( 'Do you want to push now? (y/n) ' ) ;
96+ const [ major , minor , patch ] = nextPackageJson . version . split ( '.' ) ;
97+ const version = `${ major } .${ minor } .${ Number ( patch ) + 1 } ` ;
98+ const tag = `v${ version } ` ;
8299
83- if ( doPush === 'y' ) {
84- console . info ( 'Pushing...' ) ;
85- await spawnAsync ( 'git' , 'push' , 'origin' , 'HEAD' , '--tags' ) ;
100+ nextPackageJson . version = version ;
101+
102+ await writeFileAsync ( './package.json' , JSON . stringify ( nextPackageJson , null , 2 ) + '\n' ) ;
103+ await spawnAsync ( 'git' , 'commit' , '-am' , tag ) ;
104+ await spawnAsync ( 'git' , 'tag' , tag ) ;
105+
106+ console . info ( `The changes are committed and tagged with: ${ tag } ` ) ;
107+
108+ const doPush = await questionAsync ( 'Do you want to push now? (y/n) ' ) ;
109+
110+ if ( doPush === 'y' ) {
111+ console . info ( 'Pushing...' ) ;
112+ await spawnAsync ( 'git' , 'push' , 'origin' , 'HEAD' , '--tags' ) ;
113+ }
114+ } else {
115+ console . info ( 'Maybe next time!' ) ;
116+ console . info ( 'Resetting...' ) ;
117+ await reset ( ) ;
118+ console . info ( 'Downgrading...' ) ;
119+ await install ( true ) ;
86120 }
87- } else {
88- console . info ( 'Maybe next time!' ) ;
89- console . info ( 'Resetting...' ) ;
90- await reset ( ) ;
91- console . info ( 'Downgrading...' ) ;
92- await install ( true ) ;
93121 }
94122 } else {
95123 console . info ( 'No changes detected!' ) ;
0 commit comments