Skip to content

Commit fc87440

Browse files
committed
fix: add support for react native 0.71
1 parent 1a67482 commit fc87440

File tree

9 files changed

+135
-142
lines changed

9 files changed

+135
-142
lines changed

.github/workflows/build-templates.yml

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,9 @@ jobs:
9191
run: |
9292
yarn workspace create-react-native-library prepare
9393
94-
- name: Configure environment
94+
- name: Get working directory
9595
run: |
96-
echo "work_dir=tmp-${{ matrix.type }}-${{ matrix.language }}" >> $GITHUB_ENV
97-
98-
# Build Android for only some matrices to skip redundant builds
99-
if [[ ${{ matrix.os }} == ubuntu ]]; then
100-
if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then
101-
echo "build_android=1" >> $GITHUB_ENV
102-
fi
103-
fi
104-
105-
# Build iOS for only some matrices to skip redundant builds
106-
if [[ ${{ matrix.os }} == macos ]]; then
107-
if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then
108-
echo "build_ios=1" >> $GITHUB_ENV
109-
fi
110-
fi
96+
echo "work_dir=${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }}" >> $GITHUB_ENV
11197
11298
- name: Create library
11399
run: |
@@ -120,6 +106,7 @@ jobs:
120106
--repo-url https://test.test \
121107
--type ${{ matrix.type }} \
122108
--languages ${{ matrix.language }} \
109+
--react-native-version 0.71.0-rc.3 \
123110
--turborepo
124111
125112
- name: Cache dependencies of library
@@ -149,68 +136,71 @@ jobs:
149136
restore-keys: |
150137
${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-
151138
139+
- name: Get build target
140+
working-directory: ${{ env.work_dir }}
141+
run: |
142+
# Build Android for only some matrices to skip redundant builds
143+
if [[ ${{ matrix.os }} == ubuntu ]]; then
144+
if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then
145+
echo "android_build=1" >> $GITHUB_ENV
146+
fi
147+
fi
148+
149+
# Build iOS for only some matrices to skip redundant builds
150+
if [[ ${{ matrix.os }} == macos ]]; then
151+
if [[ ${{ matrix.type }} == view-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then
152+
echo "ios_build=1" >> $GITHUB_ENV
153+
fi
154+
fi
155+
152156
- name: Lint library
153-
if: matrix.os == 'ubuntu'
154157
working-directory: ${{ env.work_dir }}
155158
run: |
156159
yarn lint
157160
158161
- name: Typecheck library
159-
if: matrix.os == 'ubuntu'
160162
working-directory: ${{ env.work_dir }}
161163
run: |
162-
yarn typescript
164+
yarn typecheck
163165
164166
- name: Test library
165-
if: matrix.os == 'ubuntu'
166167
working-directory: ${{ env.work_dir }}
167168
run: |
168169
yarn test
169170
170171
- name: Install JDK
171-
if: env.build_android == 1
172+
if: env.android_build == 1
172173
uses: actions/setup-java@v3
173174
with:
174175
distribution: 'zulu'
175176
java-version: '11'
176177

177-
- name: Install NDK
178-
if: env.build_android == 1
179-
uses: nttld/setup-ndk@v1
180-
with:
181-
ndk-version: r21d
182-
local-cache: true
183-
184-
- name: Finalize Android NDK & SDK
185-
if: env.build_android == 1
178+
- name: Finalize Android SDK
179+
if: env.android_build == 1
186180
run: |
187-
echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV
188181
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
189182
190183
- name: Cache Gradle
191-
if: env.build_android == 1
184+
if: env.android_build == 1
192185
uses: actions/cache@v3
193186
with:
194187
path: |
195188
~/.gradle/wrapper
196189
~/.gradle/caches
197190
key: ${{ runner.os }}-gradle-${{ hashFiles(format('{0}/example/android/gradle/wrapper/gradle-wrapper.properties', env.work_dir)) }}
198191

199-
- name: Cache android libraries
200-
if: env.build_android == 1
201-
uses: actions/cache@v3
202-
with:
203-
path: ${{ env.work_dir }}/example/android/app/build/react-ndk
204-
key: ${{ runner.os }}-react-ndk-${{ hashFiles(format('{0}/example/node_modules/react-native/package.json', env.work_dir)) }}
205-
206192
- name: Build example (Android)
207-
if: env.build_android == 1
193+
if: env.android_build == 1
208194
working-directory: ${{ env.work_dir }}
209195
run: |
210196
yarn turbo run build:android --cache-dir=".turbo/cache"
211197
198+
- name: Cache iOS build
199+
if: env.ios_build == 1
200+
uses: mikehardy/buildcache-action@v1
201+
212202
- name: Cache cocoapods
213-
if: env.build_ios == 1
203+
if: env.ios_build == 1
214204
id: library-cocoapods-cache
215205
uses: actions/cache@v3
216206
with:
@@ -222,15 +212,15 @@ jobs:
222212
${{ runner.os }}-library-cocoapods-${{ env.work_dir }}-
223213
224214
- name: Install cocoapods
225-
if: steps.library-cocoapods-cache.outputs.cache-hit != 'true' && env.build_ios == 1
215+
if: steps.library-cocoapods-cache.outputs.cache-hit != 'true' && env.ios_build == 1
226216
working-directory: ${{ env.work_dir }}
227217
run: |
228218
yarn example pods
229219
env:
230220
NO_FLIPPER: 1
231221

232222
- name: Cache iOS build artifacts
233-
if: env.build_ios == 1
223+
if: env.ios_build == 1
234224
uses: actions/cache@v3
235225
with:
236226
path: |
@@ -240,7 +230,7 @@ jobs:
240230
${{ runner.os }}-library-xcode-derived-data-${{ env.work_dir }}-
241231
242232
- name: Build example (iOS)
243-
if: env.build_ios == 1
233+
if: env.ios_build == 1
244234
working-directory: ${{ env.work_dir }}
245235
run: |
246236
yarn turbo run build:ios --cache-dir=".turbo/cache"

.github/workflows/check-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
run: yarn lint
1717

1818
- name: Typecheck
19-
run: yarn typescript
19+
run: yarn typecheck
2020

2121
- name: Build packages
2222
run: yarn lerna run prepare

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ To test the CLI locally, you can point to the `bin/bob` executable:
355355
Before sending a pull request, make sure your code passes TypeScript and ESLint. Run the following to verify:
356356

357357
```sh
358-
yarn typescript
358+
yarn typecheck
359359
yarn lint
360360
```
361361

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"packageManager": "^[email protected]",
1616
"scripts": {
1717
"lint": "eslint \"**/*.{js,ts,tsx}\"",
18-
"typescript": "tsc --noEmit",
19-
"watch": "concurrently 'yarn typescript --watch' 'lerna run --parallel prepare -- --watch'"
18+
"typecheck": "tsc --noEmit",
19+
"watch": "concurrently 'yarn typecheck --watch' 'lerna run --parallel prepare -- --watch'"
2020
},
2121
"devDependencies": {
2222
"@arkweid/lefthook": "^0.7.7",

packages/create-react-native-library/src/utils/generateExampleApp.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,25 @@ const FILES_TO_DELETE = [
1111
'.gitignore',
1212
'.prettierrc.js',
1313
'App.js',
14+
'App.tsx',
1415
'index.js',
16+
'tsconfig.json',
1517
];
1618

1719
const PACKAGES_TO_REMOVE = [
1820
'@react-native-community/eslint-config',
21+
'@tsconfig/react-native',
22+
'@types/jest',
23+
'@types/react',
24+
'@types/react-test-renderer',
25+
'@typescript-eslint/eslint-plugin',
26+
'@typescript-eslint/parser',
1927
'babel-jest',
2028
'eslint',
2129
'jest',
30+
'prettier',
2231
'react-test-renderer',
32+
'typescript',
2333
];
2434

2535
const PACKAGES_TO_ADD = {

packages/create-react-native-library/templates/common/$.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
run: yarn lint
1717

1818
- name: Typecheck files
19-
run: yarn typescript
19+
run: yarn typecheck
2020

2121
test:
2222
runs-on: ubuntu-latest

packages/create-react-native-library/templates/common/$package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
],
2929
"scripts": {
3030
"test": "jest",
31-
"typescript": "tsc --noEmit",
31+
"typecheck": "tsc --noEmit",
3232
"lint": "eslint \"**/*.{js,ts,tsx}\"",
3333
"prepare": "bob build",
3434
"release": "release-it",
3535
"example": "yarn --cwd example",
3636
<% if (example === 'native' && turborepo) { -%>
3737
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
38-
"build:ios": "cd example/ios && xcodebuild -workspace <%- project.name %>Example.xcworkspace -configuration Debug -scheme <%- project.name %>Example -destination 'generic/platform=iOS' CODE_SIGN_IDENTITY='' CODE_SIGNING_REQUIRED=NO",
38+
"build:ios": "cd example/ios && xcodebuild -workspace <%- project.name %>Example.xcworkspace -scheme <%- project.name %>Example -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf GCC_OPTIMIZATION_LEVEL=fast GCC_PRECOMPILE_PREFIX_HEADER=YES GCC_UNROLL_LOOPS=YES COMPILER_INDEX_STORE_ENABLE=NO",
3939
<% } -%>
4040
<% if (example === 'native') { -%>
4141
"bootstrap": "yarn example && yarn install && yarn example pods",

packages/create-react-native-library/templates/common/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ yarn example web
7878
Make sure your code passes TypeScript and ESLint. Run the following to verify:
7979

8080
```sh
81-
yarn typescript
81+
yarn typecheck
8282
yarn lint
8383
```
8484

@@ -137,7 +137,7 @@ yarn release
137137
The `package.json` file contains various scripts for common tasks:
138138

139139
- `yarn bootstrap`: setup project by installing all dependencies and pods.
140-
- `yarn typescript`: type-check files with TypeScript.
140+
- `yarn typecheck`: type-check files with TypeScript.
141141
- `yarn lint`: lint files with ESLint.
142142
- `yarn test`: run unit tests with Jest.
143143
- `yarn example start`: start the Metro server for the example app.

0 commit comments

Comments
 (0)