@@ -104,14 +104,9 @@ const getVersionToUpgradeTo = async (argv, currentVersion, projectDir) => {
104104 return newVersion ;
105105} ;
106106
107- const installDeps = async ( newVersion , projectDir , patchSuccess ) => {
108- if ( ! patchSuccess ) {
109- logger . warn (
110- 'Continuing after failure. Most of the files are upgraded but you will need to deal with some conflicts manually' ,
111- ) ;
112- }
107+ const installDeps = async ( newVersion , projectDir ) => {
113108 logger . info (
114- `Installing react-native@${ newVersion } and its peer dependencies...` ,
109+ `Installing " react-native@${ newVersion } " and its peer dependencies...` ,
115110 ) ;
116111 const peerDeps = await getRNPeerDeps ( newVersion ) ;
117112 const pm = new PackageManager ( { projectDir} ) ;
@@ -170,12 +165,6 @@ const applyPatch = async (
170165 logger . log ( `${ chalk . dim ( error . stderr . trim ( ) ) } ` ) ;
171166 }
172167 logger . error ( 'Automatically applying diff failed' ) ;
173- logger . info (
174- `Here's the diff we tried to apply: ${ rnDiffPurgeUrl } /compare/version/${ currentVersion } ...version/${ newVersion } ` ,
175- ) ;
176- logger . info (
177- `You may find release notes helpful: https://github.com/facebook/react-native/releases/tag/v${ newVersion } ` ,
178- ) ;
179168 return false ;
180169 }
181170 return true ;
@@ -188,8 +177,7 @@ async function upgrade(argv: Array<string>, ctx: ContextT, args: FlagsT) {
188177 if ( args . legacy ) {
189178 return legacyUpgrade . func ( argv , ctx ) ;
190179 }
191- const rnDiffGitAddress =
192- 'https://github.com/react-native-community/rn-diff-purge.git' ;
180+ const rnDiffGitAddress = `${ rnDiffPurgeUrl } .git` ;
193181 const tmpRemote = 'tmp-rn-diff-purge' ;
194182 const tmpPatchFile = 'tmp-upgrade-rn.patch' ;
195183 const projectDir = ctx . root ;
@@ -229,9 +217,6 @@ async function upgrade(argv: Array<string>, ctx: ContextT, args: FlagsT) {
229217 await execa ( 'git' , [ 'remote' , 'add' , tmpRemote , rnDiffGitAddress ] ) ;
230218 await execa ( 'git' , [ 'fetch' , '--no-tags' , tmpRemote ] ) ;
231219 patchSuccess = await applyPatch ( currentVersion , newVersion , tmpPatchFile ) ;
232- if ( ! patchSuccess ) {
233- return ;
234- }
235220 } catch ( error ) {
236221 throw new Error ( error . stderr || error ) ;
237222 } finally {
@@ -240,15 +225,44 @@ async function upgrade(argv: Array<string>, ctx: ContextT, args: FlagsT) {
240225 } catch ( e ) {
241226 // ignore
242227 }
243- await installDeps ( newVersion , projectDir , patchSuccess ) ;
244- logger . info ( 'Running "git status" to check what changed...' ) ;
245- await execa ( 'git' , [ 'status' ] , { stdio : 'inherit' } ) ;
228+ const { stdout} = await execa ( 'git' , [ 'status' , '-s' ] ) ;
229+ if ( ! patchSuccess ) {
230+ if ( stdout ) {
231+ logger . warn (
232+ 'Continuing after failure. Most of the files are upgraded but you will need to deal with some conflicts manually' ,
233+ ) ;
234+ await installDeps ( newVersion , projectDir ) ;
235+ logger . info ( 'Running "git status" to check what changed...' ) ;
236+ await execa ( 'git' , [ 'status' ] , { stdio : 'inherit' } ) ;
237+ } else {
238+ logger . error (
239+ 'Patch failed to apply for unknown reason. Please fall back to manual way of upgrading' ,
240+ ) ;
241+ }
242+ } else {
243+ await installDeps ( newVersion , projectDir ) ;
244+ logger . info ( 'Running "git status" to check what changed...' ) ;
245+ await execa ( 'git' , [ 'status' ] , { stdio : 'inherit' } ) ;
246+ }
246247 await execa ( 'git' , [ 'remote' , 'remove' , tmpRemote ] ) ;
247248
248249 if ( ! patchSuccess ) {
249- logger . warn (
250- 'Please run "git diff" to review the conflicts and resolve them' ,
251- ) ;
250+ if ( stdout ) {
251+ logger . warn (
252+ 'Please run "git diff" to review the conflicts and resolve them' ,
253+ ) ;
254+ }
255+ logger . info ( `You may find these resources helpful:
256+ • Release notes: ${ chalk . underline . dim (
257+ `https://github.com/facebook/react-native/releases/tag/v${ newVersion } ` ,
258+ ) }
259+ • Comparison between versions: ${ chalk . underline . dim (
260+ `${ rnDiffPurgeUrl } /compare/version/${ currentVersion } ..version/${ newVersion } ` ,
261+ ) }
262+ • Git diff: ${ chalk . underline . dim (
263+ `${ rnDiffPurgeUrl } /compare/version/${ currentVersion } ..version/${ newVersion } .diff` ,
264+ ) } `) ;
265+
252266 throw new Error (
253267 'Upgrade failed. Please see the messages above for details' ,
254268 ) ;
0 commit comments