Skip to content

Commit

Permalink
chore: migrate npx react-native init (#6628)
Browse files Browse the repository at this point in the history
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

<!-- Explain the motivation for this PR. Include "Fixes #<number>" if
applicable. -->

Migrating deprecated `npx react-native init` command to `npx
@react-native-community/cli init` as mentioned
[here](#6533 (review))

---------

Co-authored-by: Tomasz Żelawski <[email protected]>
  • Loading branch information
coado and tjzel committed Dec 13, 2024
1 parent 0780288 commit cc05d2a
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 40 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/V8-reanimated-build-check-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ jobs:
java-version: '17'
- name:
Setup Yarn
# Sometimes `npx react-native init` fails due to dependency mismatches or other
# rather vague errors. This is a workaround for that.
# Sometimes `npx @react-native-community/cli init` fails at random.
# Pre-installing it with Yarn seems to improve stability.
run: corepack enable && yarn init
- name: Install React Native
run: yarn add react-native
- name: Install React Native CLI
run: yarn add @react-native-community/cli
- name: Create app
run: |
yarn react-native init ${{ env.APP_NAME }} --version ${{env.LATEST_SUPPORTED_RN_VERSION_IN_V8}} --skip-install --pm yarn --skip-install --install-pods false --skip-git-init
- name: Setup Yarn Modern
run: yarn rnc-cli init ${{ env.APP_NAME }} --version ${{env.LATEST_SUPPORTED_RN_VERSION_IN_V8}} --skip-install --pm yarn --install-pods false --skip-git-init
- name: Setup Yarn Modern in app
working-directory: ${{ env.APP_NAME }}
run: touch yarn.lock && yarn set version berry && yarn config set nodeLinker node-modules
run: |
touch yarn.lock
yarn set version berry
yarn config set nodeLinker node-modules
- name: Install dependencies
working-directory: ${{ env.APP_NAME }}
run: yarn install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-ios-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
- name: Build app
working-directory: ${{ matrix.working-directory }}
run: npx react-native run-ios --no-packager
run: yarn react-native run-ios --no-packager
2 changes: 1 addition & 1 deletion .github/workflows/expo-devclient-build-check-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Build app (iOS)
working-directory: ${{ env.APP_NAME }}
if: ${{ matrix.platform == 'iOS' }}
run: npx react-native run-ios --simulator='iPhone 14' --terminal='Terminal'
run: yarn react-native run-ios --terminal='Terminal'
- name: Build app (Android)
working-directory: ${{ env.APP_NAME }}/android
if: ${{ matrix.platform == 'Android' }}
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/monorepo-app-reanimated-build-check-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ jobs:
# TODO: Put Monorepo template into a separate repo/package
run: echo '{"name":"rnos-monorepo-tester","version":"1.0.0","license":"MIT","private":true,"workspaces":{"packages":["RootApp","packages/PackageApp", "AppA", "AppB"],"nohoist":["**/react","**/react-dom","**/react-native","**/react-native/**","**/react-native-codegen","**/react-native-dev-menu"]}}' > package.json
- name: Install dependencies
working-directory: monorepo
run: yarn install
- name: Install React Native CLI
working-directory: monorepo
run: yarn add -W @react-native-community/cli
- name: Create RootApp
working-directory: monorepo
# TODO: Revise if we want to hardcode 0.73 here.
run: npx [email protected] init RootApp --skip-install --version 0.73
run: yarn rnc-cli init RootApp --skip-install --pm yarn --install-pods false --skip-git-init
- name: Create PackageApp
working-directory: monorepo/packages
# TODO: Revise if we want to hardcode 0.73 here.
run: npx [email protected] init PackageApp --skip-install --version 0.73
run: yarn rnc-cli init PackageApp --skip-install --pm yarn --install-pods false --skip-git-init

- name: Install dependencies for RootApp
working-directory: monorepo/RootApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
cancel-in-progress: true
steps:
- name: Setup Yarn
# Sometimes `npx react-native init` fails due to dependency mismatches or other
# rather vague errors. This is a workaround for that.
# Sometimes `npx @react-native-community/cli init` fails at random.
# Pre-installing it with Yarn seems to improve stability.
run: corepack enable && yarn init
- name: Set up JDK 18
if: ${{ matrix.platform == 'Android' }}
Expand All @@ -41,14 +41,16 @@ jobs:
if npm view react-native dist-tags | grep -q 'next:' ; then
echo "REACT_NATIVE_TAG=next" >> $GITHUB_ENV
fi
- name: Install React Native
run: yarn add react-native@${{ env.REACT_NATIVE_TAG }}
- name: Install React Native CLI
run: yarn add @react-native-community/cli
- name: Create app
run: |
yarn react-native init ${{ env.APP_NAME }} --version ${{ env.REACT_NATIVE_TAG }} --pm yarn --skip-install --install-pods false --skip-git-init
- name: Setup Yarn Modern
run: yarn rnc-cli init ${{ env.APP_NAME }} --version ${{ env.REACT_NATIVE_TAG }} --pm yarn --skip-install --install-pods false --skip-git-init
- name: Setup Yarn Modern in app
working-directory: ${{ env.APP_NAME }}
run: touch yarn.lock && yarn set version berry
run: |
touch yarn.lock
yarn set version berry
yarn config set nodeLinker node-modules
- name: Install Reanimated
working-directory: ${{ env.APP_NAME }}
run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}"
Expand All @@ -67,7 +69,7 @@ jobs:
- name: Build app (iOS)
if: ${{ matrix.platform == 'iOS' }}
working-directory: ${{ env.APP_NAME }}
run: yarn react-native run-ios --simulator='iPhone 14'
run: yarn react-native run-ios --terminal='Terminal'
- name: Build app (Android)
if: ${{ matrix.platform == 'Android' }}
working-directory: ${{ env.APP_NAME }}/android
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/reanimated-compatibility-check-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- name:
Setup Yarn
# Sometimes `npx @react-native-community/cli init` fails at random.
# Pre-installing it with Yarn seems to improve stability.
run: corepack enable && yarn init
- name: Install React Native CLI
run: yarn add @react-native-community/cli
- name: Create app
run: |
npx react-native@latest init ${{env.APP_NAME}} --version ${{ matrix.react-native.version }} --skip-install --pm yarn --skip-install --install-pods 0 --skip-git-init
- name: Setup Yarn Modern
run: yarn rnc-cli init ${{env.APP_NAME}} --version ${{ matrix.react-native.version }} --skip-install --pm yarn --install-pods 0 --skip-git-init
- name: Setup Yarn Modern in app
# For convenience, sometimes there are vague issues with RN CLI and Yarn Legacy on the runner.
working-directory: ${{ env.APP_NAME }}
run: corepack enable && yarn set version berry
run: |
touch yarn.lock
yarn set version berry
yarn config set nodeLinker node-modules
- name: Install Reanimated
working-directory: ${{ env.APP_NAME }}
run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,37 @@ jobs:
concurrency:
group: ios-static-framework-${{ matrix.react-native-architecture }}-${{ github.ref }}
cancel-in-progress: true
env:
APP_NAME: app
steps:
- name: Create React Native app
run: npx react-native init app
- name: Setup Yarn
# Sometimes `npx @react-native-community/cli init` fails at random.
# Pre-installing it with Yarn seems to improve stability.
run: corepack enable && yarn init
- name: Install React Native
run: yarn add @react-native-community/cli
- name: Create app
run: yarn rnc-cli init ${{ env.APP_NAME }} --skip-install --pm yarn --install-pods false --skip-git-init
- name: Setup Yarn Modern in app
working-directory: ${{ env.APP_NAME }}
run: |
touch yarn.lock
yarn set version berry
yarn config set nodeLinker node-modules
- name: Install dependencies
working-directory: ${{ env.APP_NAME }}
run: yarn install
- name: Install Reanimated
working-directory: app
working-directory: ${{ env.APP_NAME }}
run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}"
- name: Install Paper Pods
if: ${{ matrix.react-native-architecture == 'Paper' }}
working-directory: app/ios
working-directory: ${{env.APP_NAME}}/ios
run: export USE_FRAMEWORKS=static NO_FLIPPER=1 && bundle install && bundle exec pod install
- name: Install Fabric Pods
if: ${{ matrix.react-native-architecture == 'Fabric' }}
working-directory: app/ios
run: export USE_FRAMEWORKS=static NO_FLIPPER=1 RCT_NEW_ARCH_ENABLED=1 && bundle install && bundle exec pod install
working-directory: ${{env.APP_NAME}}/ios
run: export USE_FRAMEWORKS=static NO_FLIPPER=1 RCT_NEW_ARCH_ENABLED=1 && bundle install && bundle exec pod update
- name: Build app
working-directory: app
run: npx react-native run-ios --no-packager
working-directory: ${{env.APP_NAME}}/ios
run: xcodebuild -workspace ${{env.APP_NAME}}.xcworkspace -scheme ${{env.APP_NAME}} -configuration Debug -destination 'generic/platform=iOS Simulator' build | xcpretty
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ jobs:
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Yarn
# Sometimes `npx react-native init` fails due to dependency mismatches or other
# rather vague errors. This is a workaround for that.
- name:
Setup Yarn
# Sometimes `npx @react-native-community/cli init` fails at random.
# Pre-installing it with Yarn seems to improve stability.
run: corepack enable && yarn init --yes
- name: Install React Native
run: yarn add @react-native-community/cli
- name: Create app
run: yarn rnc-cli init ${{ env.APP_NAME }} --pm yarn --skip-install --install-pods false --skip-git-init
- name: Setup Yarn Modern
- name: Setup Yarn Modern in app
working-directory: ${{ env.APP_NAME }}
run: touch yarn.lock && yarn set version berry
run: |
touch yarn.lock
yarn set version berry
yarn config set nodeLinker node-modules
- name: Install dependencies
working-directory: ${{ env.APP_NAME }}
run: yarn
Expand Down

0 comments on commit cc05d2a

Please sign in to comment.