Skip to content

Commit e8ae843

Browse files
corasanmrousavy
andauthored
refactor: migrate to monorepo setup (#7)
* refactor: move files to `package` directory and setup monorepo * refactor: android example build * fix: ci jobs * fix: lint error and turbo build error * fix: typecheck script * fix iOS build in CI --------- Co-authored-by: Marc Rousavy <me@mrousavy.com>
1 parent 68947b2 commit e8ae843

File tree

95 files changed

+3364
-12805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3364
-12805
lines changed

.github/actions/setup/action.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
name: Setup
2-
description: Setup Node.js and install dependencies
2+
description: Setup Bun and install dependencies
33

44
runs:
55
using: composite
66
steps:
7-
- name: Setup Node.js
8-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
7+
- name: Setup Bun
8+
uses: oven-sh/setup-bun@v2
99
with:
10-
node-version-file: .nvmrc
10+
bun-version-file: package.json
1111

1212
- name: Restore dependencies
13-
id: yarn-cache
13+
id: bun-cache
1414
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
1515
with:
1616
path: |
1717
**/node_modules
18-
.yarn/install-state.gz
19-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
18+
~/.bun/install/cache
19+
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
2020
restore-keys: |
21-
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
22-
${{ runner.os }}-yarn-
21+
${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
22+
${{ runner.os }}-bun-
2323
2424
- name: Install dependencies
25-
if: steps.yarn-cache.outputs.cache-hit != 'true'
26-
run: yarn install --immutable
25+
if: steps.bun-cache.outputs.cache-hit != 'true'
26+
run: bun install --frozen-lockfile
2727
shell: bash
2828

2929
- name: Cache dependencies
30-
if: steps.yarn-cache.outputs.cache-hit != 'true'
30+
if: steps.bun-cache.outputs.cache-hit != 'true'
3131
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3232
with:
3333
path: |
3434
**/node_modules
35-
.yarn/install-state.gz
36-
key: ${{ steps.yarn-cache.outputs.cache-primary-key }}
35+
~/.bun/install/cache
36+
key: ${{ steps.bun-cache.outputs.cache-primary-key }}

.github/workflows/ci.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
uses: ./.github/actions/setup
2222

2323
- name: Lint files
24-
run: yarn lint
24+
run: bun lint
2525

2626
- name: Typecheck files
27-
run: yarn typecheck
27+
run: bun typecheck
2828

2929
test:
3030
runs-on: ubuntu-latest
@@ -36,7 +36,7 @@ jobs:
3636
uses: ./.github/actions/setup
3737

3838
- name: Run unit tests
39-
run: yarn test --maxWorkers=2 --coverage
39+
run: bun test --maxWorkers=2 --coverage
4040

4141
build-library:
4242
runs-on: ubuntu-latest
@@ -48,7 +48,7 @@ jobs:
4848
uses: ./.github/actions/setup
4949

5050
- name: Build package
51-
run: yarn prepare
51+
run: bun prepare
5252

5353
build-android:
5454
runs-on: ubuntu-latest
@@ -62,19 +62,19 @@ jobs:
6262
uses: ./.github/actions/setup
6363

6464
- name: Generate nitrogen code
65-
run: yarn nitrogen
65+
run: bun nitrogen
6666

6767
- name: Cache turborepo for Android
6868
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
6969
with:
7070
path: ${{ env.TURBO_CACHE_DIR }}
71-
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
71+
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('bun.lock') }}
7272
restore-keys: |
7373
${{ runner.os }}-turborepo-android-
7474
7575
- name: Check turborepo cache for Android
7676
run: |
77-
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")
77+
TURBO_CACHE_STATUS=$(node -p "($(bun turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
7878
7979
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
8080
echo "turbo_cache_hit=1" >> $GITHUB_ENV
@@ -107,12 +107,12 @@ jobs:
107107
env:
108108
JAVA_OPTS: "-XX:MaxHeapSize=6g"
109109
run: |
110-
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
110+
bun turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
111111
112112
build-ios:
113113
runs-on: macos-latest
114114
env:
115-
XCODE_VERSION: 16.2
115+
XCODE_VERSION: 16.4
116116
TURBO_CACHE_DIR: .turbo/ios
117117
steps:
118118
- name: Checkout
@@ -122,19 +122,19 @@ jobs:
122122
uses: ./.github/actions/setup
123123

124124
- name: Generate nitrogen code
125-
run: yarn nitrogen
125+
run: bun nitrogen
126126

127127
- name: Cache turborepo for iOS
128128
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
129129
with:
130130
path: ${{ env.TURBO_CACHE_DIR }}
131-
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
131+
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('bun.lock') }}
132132
restore-keys: |
133133
${{ runner.os }}-turborepo-ios-
134134
135135
- name: Check turborepo cache for iOS
136136
run: |
137-
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")
137+
TURBO_CACHE_STATUS=$(node -p "($(bun turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
138138
139139
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
140140
echo "turbo_cache_hit=1" >> $GITHUB_ENV
@@ -156,4 +156,4 @@ jobs:
156156
157157
- name: Build example for iOS
158158
run: |
159-
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
159+
bun turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

.watchmanconfig

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ We want this community to be friendly and respectful to each other. Please follo
66

77
## Development workflow
88

9-
This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
9+
This project is a monorepo managed using [Bun workspaces](https://bun.sh/docs/install/workspaces). It contains the following packages:
1010

11-
- The library package in the root directory.
11+
- The library package in the `package/` directory.
1212
- An example app in the `example/` directory.
1313

14-
To get started with the project, make sure you have the correct version of [Node.js](https://nodejs.org/) installed. See the [`.nvmrc`](./.nvmrc) file for the version used in this project.
14+
To get started with the project, make sure you have [Bun](https://bun.sh/) installed. You can install it using:
1515

16-
Run `yarn` in the root directory to install the required dependencies for each package:
16+
```sh
17+
curl -fsSL https://bun.sh/install | bash
18+
```
19+
20+
Run `bun install` in the root directory to install the required dependencies for each package:
1721

1822
```sh
19-
yarn
23+
bun install
2024
```
2125

22-
> Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development without manually migrating.
26+
> Since the project relies on Bun workspaces, you cannot use [`npm`](https://github.com/npm/cli) or [`yarn`](https://yarnpkg.com/) for development without manually migrating.
2327
2428
This project uses Nitro Modules. If you're not familiar with how Nitro works, make sure to check the [Nitro Modules Docs](https://nitro.margelo.com/).
2529

@@ -33,7 +37,7 @@ Run **Nitrogen** in following cases:
3337
To invoke **Nitrogen**, use the following command:
3438

3539
```sh
36-
yarn nitrogen
40+
bun nitrogen
3741
```
3842

3943
The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
@@ -49,19 +53,19 @@ You can use various commands from the root directory to work with the project.
4953
To start the packager:
5054

5155
```sh
52-
yarn example start
56+
bun example start
5357
```
5458

5559
To run the example app on Android:
5660

5761
```sh
58-
yarn example android
62+
bun example android
5963
```
6064

6165
To run the example app on iOS:
6266

6367
```sh
64-
yarn example ios
68+
bun example ios
6569
```
6670

6771
To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:
@@ -75,20 +79,20 @@ Note the `"fabric":true` and `"concurrentRoot":true` properties.
7579
Make sure your code passes TypeScript and ESLint. Run the following to verify:
7680

7781
```sh
78-
yarn typecheck
79-
yarn lint
82+
bun typecheck
83+
bun lint
8084
```
8185

8286
To fix formatting errors, run the following:
8387

8488
```sh
85-
yarn lint --fix
89+
bun lint --fix
8690
```
8791

8892
Remember to add tests for your change if possible. Run the unit tests by:
8993

9094
```sh
91-
yarn test
95+
bun test
9296
```
9397

9498
### Commit message convention
@@ -119,20 +123,20 @@ We use [release-it](https://github.com/release-it/release-it) to make it easier
119123
To publish new versions, run the following:
120124

121125
```sh
122-
yarn release
126+
bun release
123127
```
124128

125129
### Scripts
126130

127131
The `package.json` file contains various scripts for common tasks:
128132

129-
- `yarn`: setup project by installing dependencies.
130-
- `yarn typecheck`: type-check files with TypeScript.
131-
- `yarn lint`: lint files with ESLint.
132-
- `yarn test`: run unit tests with Jest.
133-
- `yarn example start`: start the Metro server for the example app.
134-
- `yarn example android`: run the example app on Android.
135-
- `yarn example ios`: run the example app on iOS.
133+
- `bun install`: setup project by installing dependencies.
134+
- `bun typecheck`: type-check files with TypeScript.
135+
- `bun lint`: lint files with ESLint.
136+
- `bun test`: run unit tests with Jest.
137+
- `bun example start`: start the Metro server for the example app.
138+
- `bun example android`: run the example app on Android.
139+
- `bun example ios`: run the example app on iOS.
136140

137141
### Sending a pull request
138142

0 commit comments

Comments
 (0)