Skip to content

Commit 91059d9

Browse files
committed
feat: upgrade template and repo to Yarn 3
1 parent 2a92f26 commit 91059d9

File tree

24 files changed

+12861
-6804
lines changed

24 files changed

+12861
-6804
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: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
--author-url https://test.test \
113113
--repo-url https://test.test \
114114
--type ${{ matrix.type }} \
115-
--languages ${{ matrix.language }} \
115+
--languages ${{ matrix.language }}
116116
117117
- name: Cache dependencies of library
118118
id: library-yarn-cache
@@ -129,8 +129,11 @@ 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+
rm -f example/yarn.lock # Workaround for cached yarn.lock from older version
134+
yarn install --no-immutable
135+
env:
136+
POD_INSTALL: 0
134137

135138
- name: Get build target
136139
working-directory: ${{ env.work_dir }}
@@ -163,8 +166,8 @@ jobs:
163166
if: env.android_build == 1 || env.ios_build == 1
164167
working-directory: ${{ env.work_dir }}
165168
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")
169+
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")
170+
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")
168171
169172
if [[ $TURBO_CACHE_STATUS_ANDROID == "HIT" ]]; then
170173
echo "turbo_cache_hit_android=1" >> $GITHUB_ENV
@@ -227,7 +230,7 @@ jobs:
227230
if: env.android_build == 1
228231
working-directory: ${{ env.work_dir }}
229232
run: |
230-
yarn turbo run build:android --cache-dir=".turbo/cache"
233+
yarn turbo run build:android --cache-dir=".turbo"
231234
232235
- name: Cache cocoapods
233236
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
@@ -246,12 +249,12 @@ jobs:
246249
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true'
247250
working-directory: ${{ env.work_dir }}
248251
run: |
249-
yarn example pods
252+
yarn pod-install example/ios
250253
env:
251254
NO_FLIPPER: 1
252255

253256
- name: Build example (iOS)
254257
if: env.ios_build == 1
255258
working-directory: ${{ env.work_dir }}
256259
run: |
257-
yarn turbo run build:ios --cache-dir=".turbo/cache"
260+
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: 1 addition & 1 deletion
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": {
1314
"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 { spawn } from './utils/spawn';
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');
@@ -573,7 +576,7 @@ async function create(argv: yargs.Arguments<any>) {
573576

574577
if (stats.isDirectory()) {
575578
await copyDir(file, target);
576-
} else if (!file.match(BINARIES)) {
579+
} else if (!BINARIES.some((r) => r.test(file))) {
577580
const content = await fs.readFile(file, 'utf8');
578581

579582
await fs.writeFile(target, ejs.render(content, options));
@@ -604,6 +607,7 @@ async function create(argv: yargs.Arguments<any>) {
604607
await generateExampleApp({
605608
type: example,
606609
dest: folder,
610+
slug: options.project.slug,
607611
projectName: options.project.name,
608612
arch,
609613
reactNativeVersion,

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ const PACKAGES_TO_ADD_WEB_DEV = {
5050
export default async function generateExampleApp({
5151
type,
5252
dest,
53+
slug,
5354
projectName,
5455
arch,
5556
reactNativeVersion = 'latest',
5657
}: {
5758
type: 'expo' | 'native';
5859
dest: string;
60+
slug: string;
5961
projectName: string;
6062
arch: 'new' | 'mixed' | 'legacy';
6163
reactNativeVersion?: string;
@@ -93,6 +95,8 @@ export default async function generateExampleApp({
9395
await fs.readFile(path.join(directory, 'package.json'), 'utf8')
9496
);
9597

98+
pkg.name = `${slug}-example`;
99+
96100
// Remove Jest config for now
97101
delete pkg.jest;
98102

@@ -101,8 +105,14 @@ export default async function generateExampleApp({
101105
delete scripts.test;
102106
delete scripts.lint;
103107

108+
const SCRIPTS_TO_ADD = {
109+
'build:android':
110+
'cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a',
111+
'build:ios': `cd ios && xcodebuild -workspace ${projectName}Example.xcworkspace -scheme ${projectName}Example -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`,
112+
};
113+
104114
if (type === 'native') {
105-
scripts.pods = 'pod-install --quiet';
115+
Object.assign(scripts, SCRIPTS_TO_ADD);
106116
}
107117

108118
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: 3 additions & 3 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
@@ -143,7 +143,7 @@ jobs:
143143
- name: Install cocoapods
144144
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
145145
run: |
146-
yarn example pods
146+
yarn pod-install example/ios
147147
env:
148148
NO_FLIPPER: 1
149149

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)