react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.34k stars 899 forks source link

react-native upgrade fails from 0.70 + typescript to 0.71 #1866

Closed darkbasic closed 1 year ago

darkbasic commented 1 year ago

Environment

info Fetching system and libraries information...
System:
    OS: Linux 6.2 Gentoo Linux
    CPU: (32) ppc64 POWER9, altivec supported
    Memory: 47.49 GB / 62.37 GB
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.14.2 - /tmp/yarn--1678368956695-0.18707016536137933/node
    Yarn: 1.22.19 - /tmp/yarn--1678368956695-0.18707016536137933/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
    Watchman: 2023.02.06.00 - /usr/bin/watchman
  SDKs:
    Android SDK:
      API Levels: 29, 31, 32, 33, 33
      Build Tools: 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 33.0.0, 33.0.2
      Android NDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 11.0.18 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0 
    react-native: 0.70.6 => 0.70.6 
  npmGlobalPackages:
    *react-native*: Not Found
Done in 5.08s.

Description

If you try to upgrade a project which was previously using Typescript to 0.71 (which uses ts by default) it will silently fail.

Reproducible Demo

  1. Create a react-native 0.70 app using the typescript template: npx react-native init client --template react-native-template-typescript@6.12.10
  2. Try to upgrade it: npx react-native upgrade 0.71.3
  3. See error
info Fetching diff between v0.70.6 and v0.71.3...
info Applying diff...
warn Excluding files that exist in the template, but not in your project:
  - .flowconfig
  - App.js
  - __tests__/App-test.js
error Excluding files that failed to apply the diff:
  - android/app/src/main/java/com/client/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
  - android/app/src/main/jni/CMakeLists.txt
Please make sure to check the actual changes after the upgrade command is finished.
You can find them in our Upgrade Helper web app: https://react-native-community.github.io/upgrade-helper/?from=0.70.6&to=0.71.3
error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible
error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading
info You may find these resources helpful:
• Release notes: https://github.com/facebook/react-native/releases/tag/v0.71.3
• Manual Upgrade Helper: https://react-native-community.github.io/upgrade-helper/?from=0.70.6&to=0.71.3
• Git diff: https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.70.6..0.71.3.diff
error Upgrade failed. Please see the messages above for details.
info Run CLI with --verbose flag for more details.

Verbose:

$ npx react-native upgrade 0.71.3 --verbose
info Fetching diff between v0.70.6 and v0.71.3...
info Applying diff...
warn Excluding files that exist in the template, but not in your project:
  - .flowconfig
  - App.js
  - __tests__/App-test.js
error Excluding files that failed to apply the diff:
  - android/app/src/main/java/com/client/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
  - android/app/src/main/jni/CMakeLists.txt
Please make sure to check the actual changes after the upgrade command is finished.
You can find them in our Upgrade Helper web app: https://react-native-community.github.io/upgrade-helper/?from=0.70.6&to=0.71.3
debug "git apply" failed. Error output:
Falling back to direct application...
Applied patch to '.gitignore' cleanly.
Applied patch to '.node-version' cleanly.
Applied patch to '.ruby-version' cleanly.
error: App.js: does not exist in index
Applied patch to 'Gemfile' cleanly.
error: __tests__/App-test.js: does not exist in index
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Falling back to direct application...
Applied patch to 'android/build.gradle' cleanly.
Applied patch to 'android/gradle.properties' cleanly.
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
Applied patch to 'ios/client/AppDelegate.h' cleanly.
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
error: repository lacks the necessary blob to perform 3-way merge.
Falling back to direct application...
Performing three-way merge...
Applied patch to 'tsconfig.json' with conflicts.

error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible
error Patch failed to apply for unknown reason. Please fall back to manual way of upgrading
info You may find these resources helpful:
• Release notes: https://github.com/facebook/react-native/releases/tag/v0.71.3
• Manual Upgrade Helper: https://react-native-community.github.io/upgrade-helper/?from=0.70.6&to=0.71.3
• Git diff: https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.70.6..0.71.3.diff
error Upgrade failed. Please see the messages above for details
szymonrybczak commented 1 year ago

Hey @darkbasic, I reproduced this and can confirm the issue. I will take a look. 👍

darkbasic commented 1 year ago

@szymonrybczak thanks! Feel free to take your time because I've manually upgraded the codebase, but I still wanted to report this because I think lots of people will be affected.

szymonrybczak commented 1 year ago

Hey, since the upgrade command was changed to just link to upgrade helper in https://github.com/react-native-community/cli/pull/1879 - I'm closing this issue because it's outdated.