Skip to content

Commit b2a45ff

Browse files
committed
feat: upgrade template and repo to Yarn 3
1 parent 1902e5f commit b2a45ff

File tree

24 files changed

+12209
-6807
lines changed

24 files changed

+12209
-6807
lines changed

.github/actions/setup/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ runs:
1515
with:
1616
path: |
1717
**/node_modules
18+
.yarn/install-state.gz
1819
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
1920
restore-keys: |
2021
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
2122
${{ runner.os }}-yarn-
2223
2324
- name: Install dependencies
2425
if: steps.yarn-cache.outputs.cache-hit != 'true'
25-
run: yarn install --frozen-lockfile
26+
run: yarn install --immutable
2627
shell: bash

.github/workflows/build-templates.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ jobs:
129129
if: steps.library-yarn-cache.outputs.cache-hit != 'true'
130130
working-directory: ${{ env.work_dir }}
131131
run: |
132-
yarn install --cwd example
133-
yarn install
132+
touch yarn.lock # Without this Yarn will fail due to the parent directory being a Yarn workspace
133+
yarn install --no-immutable
134+
env:
135+
POD_INSTALL: 0
134136

135137
- name: Get build target
136138
working-directory: ${{ env.work_dir }}
@@ -163,8 +165,8 @@ jobs:
163165
if: env.android_build == 1 || env.ios_build == 1
164166
working-directory: ${{ env.work_dir }}
165167
run: |
166-
TURBO_CACHE_STATUS_ANDROID=$(node -p "($(yarn --silent turbo run build:android --cache-dir=".turbo/cache" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
167-
TURBO_CACHE_STATUS_IOS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir=".turbo/cache" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
168+
TURBO_CACHE_STATUS_ANDROID=$(node -p "($(yarn turbo run build:android --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
169+
TURBO_CACHE_STATUS_IOS=$(node -p "($(yarn turbo run build:ios --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
168170
169171
if [[ $TURBO_CACHE_STATUS_ANDROID == "HIT" ]]; then
170172
echo "turbo_cache_hit_android=1" >> $GITHUB_ENV
@@ -227,7 +229,7 @@ jobs:
227229
if: env.android_build == 1
228230
working-directory: ${{ env.work_dir }}
229231
run: |
230-
yarn turbo run build:android --cache-dir=".turbo/cache"
232+
yarn turbo run build:android --cache-dir=".turbo"
231233
232234
- name: Cache cocoapods
233235
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
@@ -254,4 +256,4 @@ jobs:
254256
if: env.ios_build == 1
255257
working-directory: ${{ env.work_dir }}
256258
run: |
257-
yarn turbo run build:ios --cache-dir=".turbo/cache"
259+
yarn turbo run build:ios --cache-dir=".turbo"

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ build/Release
4141
node_modules/
4242
jspm_packages/
4343

44+
# Yarn
45+
.yarn/*
46+
!.yarn/patches
47+
!.yarn/plugins
48+
!.yarn/releases
49+
!.yarn/sdks
50+
!.yarn/versions
51+
4452
# Typescript v1 declaration files
4553
typings/
4654

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 541 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-3.6.1.cjs

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
nodeLinker: node-modules
2+
3+
plugins:
4+
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
5+
spec: "@yarnpkg/plugin-workspace-tools"
6+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
7+
spec: "@yarnpkg/plugin-interactive-tools"
8+
9+
yarnPath: .yarn/releases/yarn-3.6.1.cjs

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"type": "git",
1010
"url": "git+https://github.com/react-navigation/react-navigation.git"
1111
},
12+
"packageManager": "[email protected]",
1213
"engines": {
13-
"node": ">= 16.0.0"
14+
"node": ">= 18.0.0"
1415
},
15-
"packageManager": "^[email protected]",
1616
"scripts": {
1717
"lint": "eslint \"**/*.{js,ts,tsx}\"",
1818
"typecheck": "tsc --noEmit",

packages/create-react-native-library/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
},
2525
"homepage": "https://github.com/callstack/react-native-builder-bob/blob/main/README.md",
2626
"main": "lib/index.js",
27-
"bin": {
28-
"create-react-native-library": "bin/create-react-native-library"
29-
},
27+
"bin": "bin/create-react-native-library",
3028
"files": [
3129
"lib",
3230
"templates"

packages/create-react-native-library/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import generateExampleApp from './utils/generateExampleApp';
1313

1414
const FALLBACK_BOB_VERSION = '0.20.0';
1515

16-
const BINARIES = /(gradlew|\.(jar|keystore|png|jpg|gif))$/;
16+
const BINARIES = [
17+
/(gradlew|\.(jar|keystore|png|jpg|gif))$/,
18+
/\$\.yarn(?![a-z])/,
19+
];
1720

1821
const COMMON_FILES = path.resolve(__dirname, '../templates/common');
1922
const JS_FILES = path.resolve(__dirname, '../templates/js-library');
@@ -596,7 +599,7 @@ async function create(argv: yargs.Arguments<any>) {
596599

597600
if (stats.isDirectory()) {
598601
await copyDir(file, target);
599-
} else if (!file.match(BINARIES)) {
602+
} else if (!BINARIES.some((r) => r.test(file))) {
600603
const content = await fs.readFile(file, 'utf8');
601604

602605
await fs.writeFile(target, ejs.render(content, options));
@@ -627,6 +630,7 @@ async function create(argv: yargs.Arguments<any>) {
627630
await generateExampleApp({
628631
type: example,
629632
dest: folder,
633+
slug: options.project.slug,
630634
projectName: options.project.name,
631635
arch,
632636
reactNativeVersion,

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,25 @@ const PACKAGES_TO_ADD_WEB_DEV = {
4747
'babel-loader': '^8.1.0',
4848
};
4949

50+
const SCRIPTS_TO_ADD = {
51+
'pods': 'pod-install --quiet',
52+
'build:android':
53+
'cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a',
54+
'build:ios':
55+
'cd ios && xcodebuild -workspace TestLibExample.xcworkspace -scheme TestLibExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO',
56+
};
57+
5058
export default async function generateExampleApp({
5159
type,
5260
dest,
61+
slug,
5362
projectName,
5463
arch,
5564
reactNativeVersion = 'latest',
5665
}: {
5766
type: 'expo' | 'native';
5867
dest: string;
68+
slug: string;
5969
projectName: string;
6070
arch: 'new' | 'mixed' | 'legacy';
6171
reactNativeVersion?: string;
@@ -110,6 +120,8 @@ export default async function generateExampleApp({
110120
await fs.readFile(path.join(directory, 'package.json'), 'utf8')
111121
);
112122

123+
pkg.name = `${slug}-example`;
124+
113125
// Remove Jest config for now
114126
delete pkg.jest;
115127

@@ -119,7 +131,7 @@ export default async function generateExampleApp({
119131
delete scripts.lint;
120132

121133
if (type === 'native') {
122-
scripts.pods = 'pod-install --quiet';
134+
Object.assign(scripts, SCRIPTS_TO_ADD);
123135
}
124136

125137
PACKAGES_TO_REMOVE.forEach((name) => {

packages/create-react-native-library/templates/common/$.github/actions/setup/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ runs:
1515
with:
1616
path: |
1717
**/node_modules
18+
.yarn/install-state.gz
1819
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
1920
restore-keys: |
2021
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
2122
${{ runner.os }}-yarn-
2223
2324
- name: Install dependencies
2425
if: steps.yarn-cache.outputs.cache-hit != 'true'
25-
run: |
26-
yarn install --cwd example --frozen-lockfile
27-
yarn install --frozen-lockfile
26+
run: yarn install --immutable
2827
shell: bash

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
7070
- name: Check turborepo cache for Android
7171
run: |
72-
TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
72+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
7373
7474
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
7575
echo "turbo_cache_hit=1" >> $GITHUB_ENV
@@ -123,7 +123,7 @@ jobs:
123123
124124
- name: Check turborepo cache for iOS
125125
run: |
126-
TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
126+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
127127
128128
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
129129
echo "turbo_cache_hit=1" >> $GITHUB_ENV

packages/create-react-native-library/templates/common/$.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ buck-out/
6060
android/app/libs
6161
android/keystores/debug.keystore
6262

63+
# Yarn
64+
.yarn/*
65+
!.yarn/patches
66+
!.yarn/plugins
67+
!.yarn/releases
68+
!.yarn/sdks
69+
!.yarn/versions
70+
6371
# Expo
6472
.expo/
6573

0 commit comments

Comments
 (0)