feat: move examples to ./apps (#2507)

# Summary

Due to the large number of example apps in the repository, I decided to
change the structure and move all applications into an "apps" folder to
maintain a clear structure.
This commit is contained in:
Jakub Grzywacz
2024-10-25 16:12:23 +02:00
committed by GitHub
parent a1be06cbfd
commit b3b175a7fb
450 changed files with 153 additions and 1344 deletions

View File

@@ -1,9 +1,9 @@
**/node_modules/ **/node_modules/
example/examples/ apps/**/node_modules/
example/android/ apps/**/android/
example/ios/ apps/**/ios/
example/windows/ apps/**/windows/
macos-example/macos/ apps/**/macos/
screenshots/ screenshots/
android/ android/
apple/ apple/

View File

@@ -6,10 +6,10 @@ on:
- 'android/**' - 'android/**'
- 'src/fabric/**' - 'src/fabric/**'
- 'package.json' - 'package.json'
- 'example/android/**' - 'apps/example/android/**'
- 'example/package.json' - 'apps/example/package.json'
- 'fabric-example/android/**' - 'apps/fabric-example/android/**'
- 'fabric-example/package.json' - 'apps/fabric-example/package.json'
push: push:
branches: branches:
- main - main
@@ -48,12 +48,12 @@ jobs:
- name: Get app node_modules cache - name: Get app node_modules cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ${{ matrix.working-directory }}/node_modules path: apps/${{ matrix.working-directory }}/node_modules
key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/yarn.lock', matrix.working-directory)) }} key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/yarn.lock', matrix.working-directory)) }}
restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}- restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-
- name: Install app node_modules - name: Install app node_modules
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
- name: Get build cache - name: Get build cache
@@ -67,5 +67,5 @@ jobs:
${{ runner.os }}-gradle-${{matrix.working-directory}}- ${{ runner.os }}-gradle-${{matrix.working-directory}}-
- name: Build app - name: Build app
working-directory: ${{ matrix.working-directory }}/android working-directory: apps/${{ matrix.working-directory }}/android
run: ./gradlew assembleDebug --build-cache --console=plain -PreactNativeArchitectures=arm64-v8a run: ./gradlew assembleDebug --build-cache --console=plain -PreactNativeArchitectures=arm64-v8a

View File

@@ -3,8 +3,7 @@ on:
pull_request: pull_request:
paths: paths:
- .github/workflows/e2e-android.yml - .github/workflows/e2e-android.yml
- apps/examples/** - apps/example/**
- example/**
- android/** - android/**
- src/** - src/**
- e2e/** - e2e/**
@@ -81,7 +80,7 @@ jobs:
timeout-minutes: 10 timeout-minutes: 10
- name: Reverse TCP - name: Reverse TCP
working-directory: ${{ env.WORKING_DIRECTORY }} working-directory: apps/${{ env.WORKING_DIRECTORY }}
run: adb devices | grep '\t' | awk '{print $1}' | sed 's/\\s//g' | xargs -I {} adb -s {} reverse tcp:8081 tcp:8081 run: adb devices | grep '\t' | awk '{print $1}' | sed 's/\\s//g' | xargs -I {} adb -s {} reverse tcp:8081 tcp:8081
- name: Install root node dependencies - name: Install root node dependencies
@@ -89,18 +88,18 @@ jobs:
- name: Install example app node dependencies - name: Install example app node dependencies
run: yarn run: yarn
working-directory: ${{ env.WORKING_DIRECTORY }} working-directory: apps/${{ env.WORKING_DIRECTORY }}
- name: Build Android app - name: Build Android app
working-directory: ${{ env.WORKING_DIRECTORY }}/android working-directory: apps/${{ env.WORKING_DIRECTORY }}/android
run: ./gradlew assembleDebug run: ./gradlew assembleDebug
- name: Start Metro server - name: Start Metro server
working-directory: ${{ env.WORKING_DIRECTORY }} working-directory: apps/${{ env.WORKING_DIRECTORY }}
run: E2E=true yarn start &> output.log & run: E2E=true yarn start &> output.log &
- name: Install APK - name: Install APK
run: adb install -r ${{ env.WORKING_DIRECTORY }}/android/app/build/outputs/apk/debug/app-debug.apk run: adb install -r apps/${{ env.WORKING_DIRECTORY }}/android/app/build/outputs/apk/debug/app-debug.apk
- name: Launch APK - name: Launch APK
run: 'while ! (adb shell monkey -p com.example 1 | grep -q "Events injected: 1"); do sleep 1; echo "Retrying due to errors in previous run..."; done' run: 'while ! (adb shell monkey -p com.example 1 | grep -q "Events injected: 1"); do sleep 1; echo "Retrying due to errors in previous run..."; done'

View File

@@ -3,7 +3,7 @@ on:
pull_request: pull_request:
paths: paths:
- .github/workflows/ios-e2e.yml - .github/workflows/ios-e2e.yml
- apps/examples/** - apps/common/example/**
- apple/** - apple/**
- src/** - src/**
- e2e/** - e2e/**
@@ -45,40 +45,40 @@ jobs:
- name: Get app node_modules cache - name: Get app node_modules cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ${{ matrix.working-directory }}/node_modules path: apps/${{ matrix.working-directory }}/node_modules
key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/yarn.lock', matrix.working-directory)) }} key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/yarn.lock', matrix.working-directory)) }}
restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}- restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-
- name: Install app node_modules - name: Install app node_modules
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
- name: Get Pods cache - name: Get Pods cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ${{ matrix.working-directory }}/ios/Pods path: apps/${{ matrix.working-directory }}/ios/Pods
key: ${{ runner.os }}-pods-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/ios/Podfile.lock', matrix.working-directory)) }} key: ${{ runner.os }}-pods-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/ios/Podfile.lock', matrix.working-directory)) }}
restore-keys: | restore-keys: |
${{ runner.os }}-pods-${{ matrix.working-directory }}- ${{ runner.os }}-pods-${{ matrix.working-directory }}-
- name: Install Pods - name: Install Pods
working-directory: ${{ matrix.working-directory }}/ios working-directory: apps/${{ matrix.working-directory }}/ios
run: bundle install && bundle exec pod install run: bundle install && bundle exec pod install
- name: Get build artifacts cache - name: Get build artifacts cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ~/Library/Developer/Xcode/DerivedData path: ~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/ios/Podfile.lock', matrix.working-directory)) }} key: ${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/ios/Podfile.lock', matrix.working-directory)) }}
restore-keys: | restore-keys: |
${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}- ${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}-
- name: Start Metro server - name: Start Metro server
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: E2E=true yarn start &> output.log & run: E2E=true yarn start &> output.log &
- name: Build app - name: Build app
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: E2E=true npx react-native@latest run-ios --simulator="${{ env.DEVICE }}" --mode Debug --verbose run: E2E=true npx react-native@latest run-ios --simulator="${{ env.DEVICE }}" --mode Debug --verbose
- name: Run e2e Tests - name: Run e2e Tests

View File

@@ -7,10 +7,10 @@ on:
- apple/** - apple/**
- src/fabric/** - src/fabric/**
- package.json - package.json
- example/package.json - apps/example/package.json
- example/ios/** - apps/example/ios/**
- fabric-example/package.json - apps/fabric-example/package.json
- fabric-example/ios/** - apps/fabric-example/ios/**
push: push:
branches: branches:
- main - main
@@ -48,34 +48,34 @@ jobs:
- name: Get app node_modules cache - name: Get app node_modules cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ${{ matrix.working-directory }}/node_modules path: apps/${{ matrix.working-directory }}/node_modules
key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/yarn.lock', matrix.working-directory)) }} key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/yarn.lock', matrix.working-directory)) }}
restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}- restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-
- name: Install app node_modules - name: Install app node_modules
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
- name: Get Pods cache - name: Get Pods cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ${{ matrix.working-directory }}/ios/Pods path: apps/${{ matrix.working-directory }}/ios/Pods
key: ${{ runner.os }}-pods-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/ios/Podfile.lock', matrix.working-directory)) }} key: ${{ runner.os }}-pods-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/ios/Podfile.lock', matrix.working-directory)) }}
restore-keys: | restore-keys: |
${{ runner.os }}-pods-${{ matrix.working-directory }}- ${{ runner.os }}-pods-${{ matrix.working-directory }}-
- name: Install Pods - name: Install Pods
working-directory: ${{ matrix.working-directory }}/ios working-directory: apps/${{ matrix.working-directory }}/ios
run: bundle install && bundle exec pod install run: bundle install && bundle exec pod install
- name: Get build artifacts cache - name: Get build artifacts cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ~/Library/Developer/Xcode/DerivedData path: ~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/ios/Podfile.lock', matrix.working-directory)) }} key: ${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/ios/Podfile.lock', matrix.working-directory)) }}
restore-keys: | restore-keys: |
${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}- ${{ runner.os }}-ios-derived-data-${{ matrix.working-directory }}-
- name: Build app - name: Build app
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: npx react-native run-ios --simulator="iPhone 15 Pro" --mode Debug --verbose --no-packager run: npx react-native run-ios --simulator="iPhone 15 Pro" --mode Debug --verbose --no-packager

View File

@@ -7,10 +7,10 @@ on:
- apple/** - apple/**
- src/fabric/** - src/fabric/**
- package.json - package.json
- paper-macos-example/package.json - apps/paper-macos-example/package.json
- paper-macos-example/ios/** - apps/paper-macos-example/ios/**
- fabric-macos-example/package.json - apps/fabric-macos-example/package.json
- fabric-macos-example/ios/** - apps/fabric-macos-example/ios/**
push: push:
branches: branches:
- main - main
@@ -48,32 +48,32 @@ jobs:
- name: Get app node_modules cache - name: Get app node_modules cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ${{ matrix.working-directory }}/node_modules path: apps/${{ matrix.working-directory }}/node_modules
key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/yarn.lock', matrix.working-directory)) }} key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/yarn.lock', matrix.working-directory)) }}
restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}- restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-
- name: Install app node_modules - name: Install app node_modules
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
- name: Get Pods cache - name: Get Pods cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ${{ matrix.working-directory }}/macos/Pods path: apps/${{ matrix.working-directory }}/macos/Pods
key: ${{ runner.os }}-pods-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/macos/Podfile.lock', matrix.working-directory)) }} key: ${{ runner.os }}-pods-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/macos/Podfile.lock', matrix.working-directory)) }}
restore-keys: | restore-keys: |
${{ runner.os }}-pods-${{ matrix.working-directory }}- ${{ runner.os }}-pods-${{ matrix.working-directory }}-
- name: Install Pods - name: Install Pods
working-directory: ${{ matrix.working-directory }}/macos working-directory: apps/${{ matrix.working-directory }}/macos
run: bundle install && bundle exec pod install run: bundle install && bundle exec pod install
- name: Get build artifacts cache - name: Get build artifacts cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ~/Library/Developer/Xcode/DerivedData path: ~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-macos-derived-data-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/macos/Podfile.lock', matrix.working-directory)) }} key: ${{ runner.os }}-macos-derived-data-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/macos/Podfile.lock', matrix.working-directory)) }}
- name: Build app - name: Build app
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: yarn macos run: yarn macos

View File

@@ -6,10 +6,10 @@ on:
- 'windows/**' - 'windows/**'
- 'src/fabric/**' - 'src/fabric/**'
- 'package.json' - 'package.json'
- 'paper-windows-example/windows/**' - 'apps/paper-windows-example/windows/**'
- 'paper-windows-example/package.json' - 'apps/paper-windows-example/package.json'
- 'fabric-windows-example/windows/**' - 'apps/fabric-windows-example/windows/**'
- 'fabric-windows-example/package.json' - 'apps/fabric-windows-example/package.json'
push: push:
branches: branches:
- main - main
@@ -49,14 +49,14 @@ jobs:
- name: Restore app node_modules from cache - name: Restore app node_modules from cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ${{ matrix.working-directory }}/node_modules path: apps/${{ matrix.working-directory }}/node_modules
key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/yarn.lock', matrix.working-directory)) }} key: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-${{ hashFiles(format('apps/{0}/yarn.lock', matrix.working-directory)) }}
restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}- restore-keys: ${{ runner.os }}-node-modules-${{ matrix.working-directory }}-
- name: Install app node_modules - name: Install app node_modules
working-directory: ${{ matrix.working-directory }} working-directory: apps/${{ matrix.working-directory }}
run: yarn --frozen-lockfile run: yarn --frozen-lockfile
- name: Build app - name: Build app
working-directory: ${{ matrix.working-directory }}/windows working-directory: apps/${{ matrix.working-directory }}/windows
run: npx react-native run-windows --logging --no-packager --no-deploy --no-autolink run: npx react-native run-windows --logging --no-packager --no-deploy --no-autolink

1
.gitignore vendored
View File

@@ -51,5 +51,6 @@ experimental/
# VS Code # VS Code
.vscode/ .vscode/
# E2E reports
jest-html-reporters-attach/ jest-html-reporters-attach/
report.html report.html

View File

@@ -1,2 +1,2 @@
screenshots/ screenshots/
idl/ apps/

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@@ -10,21 +10,20 @@ import {createStackNavigator} from '@react-navigation/stack';
import React from 'react'; import React from 'react';
import {ActivityIndicator, Platform, View} from 'react-native'; import {ActivityIndicator, Platform, View} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler'; import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {allScreens, allScreensKeys} from './src'; import {ListScreen} from './ListScreen';
import {ListScreen} from './src/ListScreen'; import * as E2e from './e2e/index.macos';
import * as E2e from './src/e2e'; import {examples} from './examples';
import {examples} from './src/examples'; import * as FilterImage from './examples/FilterImage';
import * as FilterImage from './src/examples/FilterImage'; import * as Filters from './examples/Filters';
import * as Filters from './src/examples/Filters'; import {commonStyles} from './utils/commonStyles';
import {commonStyles} from './src/utils/commonStyles'; import composeComponents from './utils/composeComponent';
import composeComponents from './src/utils/composeComponent';
import { import {
Example, Example,
Examples, Examples,
NavigationProp, NavigationProp,
RootStackParamList, RootStackParamList,
} from './src/utils/types'; } from './utils/types';
import {usePersistNavigation} from './src/utils/usePersistNavigation'; import {usePersistNavigation} from './utils/usePersistNavigation';
export default function App() { export default function App() {
const {isReady, initialState, persistNavigationState} = const {isReady, initialState, persistNavigationState} =
@@ -91,3 +90,11 @@ const Stack =
Platform.OS === 'macos' Platform.OS === 'macos'
? createStackNavigator<RootStackParamList>() ? createStackNavigator<RootStackParamList>()
: createNativeStackNavigator<RootStackParamList>(); : createNativeStackNavigator<RootStackParamList>();
const allScreens = {
...examples,
...Filters.samples,
...FilterImage.samples,
};
const allScreensKeys = Object.keys(allScreens) as (keyof typeof allScreens)[];

3
apps/common/index.tsx Normal file
View File

@@ -0,0 +1,3 @@
import App from './example';
export default App;

View File

@@ -73,7 +73,7 @@ const PNGImageFromFile = () => {
opacity="1" opacity="1"
width={100} width={100}
height={100} height={100}
href={require('../assets/arrow.png')} href={require('./assets/arrow.png')}
onLoad={e => onLoad={e =>
console.log(`${Platform.OS} load png image from file`, e.nativeEvent) console.log(`${Platform.OS} load png image from file`, e.nativeEvent)
} }
@@ -107,7 +107,7 @@ const JPEGImageFromFile = () => {
opacity="1" opacity="1"
width={'100%'} width={'100%'}
height={'100%'} height={'100%'}
href={require('../assets/earth.jpg')} href={require('./assets/earth.jpg')}
onLoad={e => onLoad={e =>
console.log(`${Platform.OS} load JPEG image from file`, e.nativeEvent) console.log(`${Platform.OS} load JPEG image from file`, e.nativeEvent)
} }

View File

@@ -9,7 +9,7 @@ import {
LocalSvg, LocalSvg,
} from 'react-native-svg/css'; } from 'react-native-svg/css';
const asset = require('../assets/ruby.svg'); const asset = require('./assets/ruby.svg');
const normalUri = const normalUri =
'https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg'; 'https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg';
const uriWithCss = 'http://thenewcode.com/assets/svg/accessibility.svg'; const uriWithCss = 'http://thenewcode.com/assets/svg/accessibility.svg';

Some files were not shown because too many files have changed in this diff Show More