Skip to content

Commit af1531f

Browse files
committed
chore: split example apps
1 parent 77257e2 commit af1531f

43 files changed

Lines changed: 732 additions & 90 deletions

Some content is hidden

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

.github/actions/setup-react-native/action.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ runs:
1414
- name: Set up react-native@${{ inputs.version }}
1515
run: |
1616
rm example/ios/Podfile.lock
17-
rm example/macos/Podfile.lock
18-
rm example/visionos/Podfile.lock
1917
node --run set-react-version -- ${{ inputs.version }}
2018
shell: bash
2119
working-directory: packages/app

.github/workflows/build.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ jobs:
358358
uses: ./.github/actions/setup-toolchain
359359
with:
360360
platform: macos
361-
project-root: packages/app/example
361+
project-root: packages/example-macos
362362
cache-key-prefix: example
363363
xcode-developer-dir: /Applications/Xcode_16.4.app/Contents/Developer
364364
- name: Set up react-native@canary
@@ -373,7 +373,7 @@ jobs:
373373
- name: Bundle JavaScript
374374
run: |
375375
yarn build:macos
376-
working-directory: packages/app/example
376+
working-directory: packages/example-macos
377377
- name: Determine whether the macOS app needs to be built
378378
id: affected
379379
uses: ./.github/actions/affected
@@ -382,22 +382,22 @@ jobs:
382382
uses: ./.github/actions/cocoapods
383383
with:
384384
project-directory: macos
385-
working-directory: packages/app/example
385+
working-directory: packages/example-macos
386386
- name: Build
387387
if: ${{ steps.affected.outputs.macos != '' }}
388388
run: |
389-
../../../scripts/xcodebuild.sh macos/Example.xcworkspace build-for-testing
390-
working-directory: packages/app/example
389+
../../scripts/xcodebuild.sh macos/Example.xcworkspace build-for-testing
390+
working-directory: packages/example-macos
391391
- name: Test `react-native config`
392392
if: ${{ steps.affected.outputs.macos != '' }}
393393
run: |
394394
node --test test/config.test.mjs
395-
working-directory: packages/app/example
395+
working-directory: packages/example-macos
396396
- name: Test
397397
if: ${{ steps.affected.outputs.macos != '' && github.event_name != 'schedule' }}
398398
run: |
399-
../../../scripts/xcodebuild.sh macos/Example.xcworkspace test-without-building
400-
working-directory: packages/app/example
399+
../../scripts/xcodebuild.sh macos/Example.xcworkspace test-without-building
400+
working-directory: packages/example-macos
401401
timeout-minutes: 60
402402
macos-template:
403403
name: "macOS [template]"
@@ -571,14 +571,15 @@ jobs:
571571
- name: Bundle JavaScript
572572
run: |
573573
yarn build:windows
574+
working-directory: packages/example-windows
574575
- name: Generate Visual Studio solution
575576
run: |
576-
node ../windows/app.mjs --msbuildprops WindowsTargetPlatformVersion=$env:WindowsTargetPlatformVersion
577-
working-directory: packages/app/example
577+
node ../app/windows/app.mjs --msbuildprops WindowsTargetPlatformVersion=$env:WindowsTargetPlatformVersion
578+
working-directory: packages/example-windows
578579
- name: Test `react-native config`
579580
run: |
580581
node --test test/config.test.mjs
581-
working-directory: packages/app/example
582+
working-directory: packages/example-windows
582583
- name: Determine whether the Windows app needs to be built
583584
id: affected
584585
uses: ./.github/actions/affected
@@ -591,7 +592,7 @@ jobs:
591592
} else {
592593
yarn ci:windows --arch ${{ matrix.platform }}
593594
}
594-
working-directory: packages/app/example
595+
working-directory: packages/example-windows
595596
continue-on-error: true
596597
# GitHub Actions currently does not support outputs from jobs with matrices
597598
# The workaround is to upload artifacts to communicate between jobs
@@ -617,15 +618,15 @@ jobs:
617618
uses: actions/upload-artifact@v7
618619
with:
619620
name: windows-msbuild.binlog
620-
path: packages/app/example/windows/*.binlog
621+
path: packages/example-windows/windows/*.binlog
621622
retention-days: 14
622623
overwrite: true
623624
- name: Test
624625
if: ${{ steps.affected.outputs.windows != '' && matrix.platform == 'x64' && steps.build.outcome == 'success' }}
625626
run: |
626-
../../../scripts/build/MSBuild.ps1 -Configuration ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Target Build ReactAppTests.vcxproj
627-
../../../scripts/build/VSTest.ps1 ${{ matrix.platform }}\${{ matrix.configuration }}\ReactAppTests.dll
628-
working-directory: packages/app/example/windows/ReactAppTests
627+
../../../app/scripts/build/MSBuild.ps1 -Configuration ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Target Build ReactAppTests.vcxproj
628+
../../../app/scripts/build/VSTest.ps1 ${{ matrix.platform }}\${{ matrix.configuration }}\ReactAppTests.dll
629+
working-directory: packages/example-windows/windows/ReactAppTests
629630
timeout-minutes: 60
630631
windows-template:
631632
name: "Windows [template]"

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.binlog
12
*.iml
23
*.log
34
*.tgz
@@ -17,18 +18,19 @@
1718
!.yarn/patches/
1819
!.yarn/plugins/
1920
!.yarn/releases/
20-
Pods/
2121
clang-format-diff.py
2222
coverage/
2323
local.properties
24-
msbuild.binlog
2524
node_modules/
2625
!test/__fixtures__/**/node_modules/
2726
package-lock.json
28-
packages/app/android/**/build/
29-
packages/app/example/*/DerivedData/
30-
packages/app/example/*/build/
3127
packages/app/example/Screenshot-*.png
28+
packages/example-*/*/.xcode.env
29+
packages/example-*/*/DerivedData/
30+
packages/example-*/*/Pods/
31+
packages/example-*/*/build/
32+
packages/example-*/dist/*
33+
!packages/example-*/dist/.gitignore
3234
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
3335
template-example/
3436
xcuserdata/

.yarnrc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
catalog:
2+
"@babel/core": ^7.25.2
3+
"@babel/preset-env": ^7.25.3
4+
"@rnx-kit/cli": ^1.0.0
5+
"@rnx-kit/metro-config": ^2.2.3
6+
"@rnx-kit/polyfills": ^0.2.0
7+
"@rnx-kit/tsconfig": ^3.0.1
18
compressionLevel: 0
29
enableGlobalCache: false
310
enableScripts: false

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"workspaces": [
1616
".",
1717
"packages/app",
18-
"packages/app/example"
18+
"packages/app/example",
19+
"packages/example-*"
1920
],
2021
"scripts": {
2122
"format": "nx run-many --target format:c,format:js,format:swift",
@@ -24,10 +25,12 @@
2425
"lint:commit": "git log --format='%s' origin/trunk..HEAD | tail -1 | npx @rnx-kit/commitlint-lite@2.0.0",
2526
"lint:js": "oxlint $(git ls-files 'scripts/*.[cm][jt]s' 'scripts/*.[jt]s')",
2627
"release-notes": "node scripts/release-notes.mts",
28+
"rnx-align-deps": "rnx-align-deps --exclude-packages @microsoft/root,react-native-test-app",
2729
"show-affected": "node scripts/affected.mts"
2830
},
2931
"devDependencies": {
3032
"@nx/js": "^22.0.0",
33+
"@rnx-kit/align-deps": "^3.4.5",
3134
"@rnx-kit/lint-lockfile": "^0.1.0",
3235
"@rnx-kit/oxlint-config": "^1.0.3",
3336
"@swc-node/register": "^1.11.1",

packages/app/example/.gitignore

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88
.gradle/
99
.idea/
1010
.vs/
11+
.watchman-*
1112
.xcode.env
12-
Pods/
13-
build/
13+
android/app/
14+
android/build/
1415
dist/*
1516
!dist/.gitignore
17+
ios/DerivedData/
18+
ios/Pods/
19+
ios/build/
1620
local.properties
17-
msbuild.binlog
21+
macos/DerivedData/
22+
macos/Pods/
23+
macos/build/
1824
node_modules/

packages/app/example/package.json

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
},
2121
"dependencies": {
2222
"@react-native-webapis/web-storage": "^0.4.5",
23-
"react": "19.1.0",
24-
"react-native": "^0.81.0",
25-
"react-native-macos": "^0.81.1",
26-
"react-native-safe-area-context": "^5.5.2",
23+
"react": "19.1.4",
24+
"react-native": "^0.81.6",
25+
"react-native-macos": "^0.81.0",
26+
"react-native-safe-area-context": "^5.6.0",
2727
"react-native-windows": "^0.81.0"
2828
},
2929
"devDependencies": {
@@ -85,38 +85,17 @@
8585
}
8686
}
8787
],
88-
"alignDeps//disabled": {
89-
"//": "This configuration is only used for Viewfinder",
88+
"alignDeps": {
9089
"requirements": [
91-
"react-native@0.79"
90+
"react-native@0.81"
9291
],
9392
"capabilities": [
9493
"core-android",
9594
"core-ios",
9695
"core-macos",
9796
"core-windows",
98-
"animation",
9997
"babel-preset-react-native",
100-
"checkbox",
101-
"clipboard",
102-
"datetime-picker",
103-
"filesystem",
104-
"floating-action",
105-
"gestures",
106-
"html",
107-
"masked-view",
108-
"modal",
109-
"navigation/native",
110-
"navigation/stack",
111-
"netinfo",
112-
"popover",
113-
"safe-area",
114-
"screens",
115-
"shimmer",
116-
"sqlite",
117-
"storage",
118-
"svg",
119-
"webview"
98+
"safe-area"
12099
]
121100
}
122101
}

packages/app/example/test/config.test.mjs

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ import * as path from "node:path";
55
import { after, before, test } from "node:test";
66
import { URL, fileURLToPath } from "node:url";
77

8-
async function getLoadConfig() {
8+
/**
9+
* @param {string} cwd
10+
*/
11+
async function getLoadConfig(cwd) {
912
try {
10-
// @ts-expect-error `loadConfig` was not exported until 7.0.
11-
return await import("@react-native-community/cli/build/tools/config");
13+
const config = import.meta.resolve(
14+
"@react-native-community/cli/build/tools/config",
15+
cwd
16+
);
17+
return await import(config);
1218
} catch (_) {
1319
// `loadConfig` was made public in 7.0:
1420
// https://github.com/react-native-community/cli/pull/1464
15-
const { default: cli } = await import("@react-native-community/cli");
21+
const rncCli = import.meta.resolve("@react-native-community/cli", cwd);
22+
const { default: cli } = await import(rncCli);
1623
return cli.loadConfig.length === 1
17-
? // @ts-ignore The signature change of `loadConfig` was introduced in 14.0
18-
() => cli.loadConfig({}) // >=14.0
24+
? () => cli.loadConfig({}) // >=14.0
1925
: cli.loadConfig; // <14.0
2026
}
2127
}
@@ -29,9 +35,9 @@ function regexp(p) {
2935
}
3036

3137
test("react-native config", async (t) => {
32-
const loadConfig = await getLoadConfig();
33-
3438
const currentDir = process.cwd();
39+
const loadConfig = await getLoadConfig(currentDir);
40+
3541
const projectRoot = path.sep + path.join("packages", "app");
3642
const exampleRoot = path.join(projectRoot, "example");
3743
const reactNativePath = path.join(
@@ -90,6 +96,32 @@ test("react-native config", async (t) => {
9096
}
9197
);
9298

99+
await t.test(
100+
"contains macOS config",
101+
{ skip: process.platform === "win32" },
102+
() => {
103+
const sourceDir = path.join(exampleRoot, "macos");
104+
const config = loadConfig();
105+
106+
equal(typeof config, "object");
107+
match(config.root, regexp(exampleRoot));
108+
match(config.reactNativePath, regexp(reactNativePath));
109+
equal(
110+
config.dependencies["react-native-test-app"].name,
111+
"react-native-test-app"
112+
);
113+
notEqual(config.platforms.macos, undefined);
114+
match(config.project.macos.sourceDir, regexp(sourceDir));
115+
116+
if (fs.existsSync("macos/Pods")) {
117+
equal(config.project.macos.xcodeProject.name, "Example.xcworkspace");
118+
ok(config.project.macos.xcodeProject.isWorkspace);
119+
} else {
120+
equal(config.project.macos.xcodeProject, null);
121+
}
122+
}
123+
);
124+
93125
await t.test(
94126
"contains Windows config",
95127
{ skip: process.platform !== "win32" },

packages/app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@
116116
"minimatch": "^10.0.0",
117117
"oxfmt": "^0.41.0",
118118
"oxlint": "^1.51.0",
119-
"react": "19.1.0",
120-
"react-native": "^0.81.0",
121-
"react-native-macos": "^0.81.1",
119+
"react": "19.1.4",
120+
"react-native": "^0.81.6",
121+
"react-native-macos": "^0.81.0",
122122
"react-native-windows": "^0.81.0",
123123
"suggestion-bot": "^4.0.0"
124124
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)