Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Web support integrated in RN 0.63 (#162)
Browse files Browse the repository at this point in the history
* Configure react-native-web in project

* Configured projects with all 3 platforms

They almost look a like now. However still on more remaining issue is `fbt`.

* Removed react-app-rewired and added craco

* Fixed tests with correct fbtEnum path

There was a space at the first of the path strings

* More options to tsconfig

* Fixed fbt for android

* Refactor codes applying new eslint rules

* Upgrade typescript to < 4.1 and > 3.9

Affected by the peer dep

* Configured eslint rules

* More lint fixes

* Fixed false positiy eslint config upgrading package

* Mocked @react-navigation/stack

* Updated snapshots

* Updated packages

* Added v5 tag for dooboo-cli@5 compatibility

Refer to hyochan/dooboo-cli#75

* TS config isolatedModules => false

eveningkid/denodb#146

* More lint fixes in root files

* Set isolatedModules to true for in tsconfig

* Generated fbts

* Added `withScreen` util instead of wrapping whole screen

* Remove i18n root which is moved to utils

* Updated [ThemeProvider] and changed theme controls

* Patch on new themeing and media queries

* Updated button text color

* Enable PWA Support (#163)

* Updated packages and eslint config

* Removed empty spaces in .gitignore

* Removed generated i18n files from git

* Update packages

* Upgrade android sdk version to 29

* Circleci android sdk 29 image

Co-authored-by: Donghyeon Kim <[email protected]>
  • Loading branch information
hyochan and 0916dhkim authored Jan 31, 2021
1 parent 0583407 commit 1b9632a
Show file tree
Hide file tree
Showing 74 changed files with 8,174 additions and 2,168 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
android:
working_directory: ~/dooboo
docker:
- image: circleci/android:api-28-node8-alpha
- image: circleci/android:api-29-node
steps:
- checkout:
path: ~/dooboo
Expand Down
Empty file added .dooboo/v5
Empty file.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/assets
src/utils/i18n
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
root: true,
extends: '@dooboo/eslint-config',
rules: {
'eslint-comments/no-unlimited-disable': 0,
'eslint-comments/no-unused-disable': 0,
},
};
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ local.properties
*.iml

# node.js
#

dist/
node_modules/
npm-debug.log
yarn-error.log

# eslint
.eslintcache

# BUCK
buck-out/
\.buckd/
Expand Down Expand Up @@ -64,6 +67,6 @@ package-lock.json
ios/Pods/

# fbt
i18n/fbt/.enum_manifest.json
i18n/fbt/.source_strings.json
i18n/fbt/.src_manifest.json
src/utils/i18n/fbt/.enum_manifest.json
src/utils/i18n/fbt/.source_strings.json
src/utils/i18n/fbt/.src_manifest.json
4 changes: 3 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ module.exports = {
trailingComma: "all",
arrowParens: "always",
singleQuote: true,
jsxSingleQuote: false
jsxSingleQuote: false,
jsxBracketSameLine: true,
bracketSpacing: false,
};
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"eslint.enable": true,
"eslint.validate": [
"javascript",
"javascriptreact",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const component = (props): React.ReactElement => {
### Localization

Previously, we used `i18n-j` to localize our app and we decided to switch to [fbt](https://github.com/facebook/fbt). If you want to understand why, you may see our blog for [Localizing react app with FBT instead of i18n](https://medium.com/dooboolab/localizing-react-app-with-fbt-instead-of-i18n-90822e0cb373).
Previously, we used `i18n-j` to localize our app and we decided to switch to [fbt](https://github.com/facebook/fbt). If you want to understand why, you may see our blog for [Localizing react app with FBT instead of src/utils/i18n](https://medium.com/dooboolab/localizing-react-app-with-fbt-instead-of-i18n-90822e0cb373).

We've defined localized strings in `assets/translations/en.json` for English and `assets/translations/ko.json` for Korean. Since the `en` is default locale setup in current project, you do not need to localize this file. However, you still should not delete this if you don't want to see missing localization warning messages when you are running jest.

Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def enableProguardInReleaseBuilds = false
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* The international variant includes ICU src/utils/i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/raw-en-rUS/localizable.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"18yDJU":"\"Go Back\"","4rqrl3":"\"Sign In\"","3fayOT":"\"Navigate\"","zcXn6":"\"Change Theme\""}
{"4rqrl3":"\"Sign In\"","3fayOT":"\"Navigate\"","zcXn6":"\"Change Theme\""}
2 changes: 1 addition & 1 deletion android/app/src/main/res/raw-ko-rKR/localizable.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"18yDJU":"\"뒤로가기\"","4rqrl3":"\"로그인\"","3fayOT":"\"화면 전환\"","zcXn6":"\"테마 변경\""}
{"4rqrl3":"\"로그인\"","3fayOT":"\"화면 전환\"","zcXn6":"\"테마 변경\""}
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

buildscript {
ext {
buildToolsVersion = "28.0.3"
buildToolsVersion = "29.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
Expand Down
16 changes: 12 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
// eslint-disable-next-line
const path = require('path');

const fbtEnumPath = path.join(
__dirname,
'src/utils/i18n/fbt/.enum_manifest.json',
);

module.exports = {
presets: [
'module:metro-react-native-babel-preset',
'@babel/preset-typescript',
],
plugins: [
'babel-plugin-fbt-runtime',
['babel-plugin-fbt', {
fbtEnumPath: path.join(__dirname, 'i18n/fbt/.enum_manifest.json'),
extraOptions: { __self: true },
},
[
'babel-plugin-fbt',
{
fbtEnumPath,
extraOptions: {__self: true},
},
],
],
};
15 changes: 15 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
babel: {
presets: ['@babel/preset-typescript'],
plugins: [
[
'babel-plugin-fbt',
{
fbtEnumManifest: require('./src/utils/i18n/fbt/.enum_manifest.json'),
extraOptions: {__self: true},
},
],
'babel-plugin-fbt-runtime',
],
},
};
5 changes: 2 additions & 3 deletions environment.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
declare module '*.svg' {
import {IconType} from './src/types';

import { IconType } from './src/types';

const content: IconType;
const content: IconType;
export default content;
}

Expand Down
1 change: 0 additions & 1 deletion i18n/fbt/translatedFbts.json

This file was deleted.

15 changes: 2 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
import { AppRegistry, YellowBox } from 'react-native';
import {App} from './src';

import App from './src/App';

/**
* React Native 0.54 warning message ignore.
*/
YellowBox.ignoreWarnings([
'Warning: componentWillMount is deprecated',
'Warning: componentWillReceiveProps is deprecated',
'Module RCTImageLoader',
]);

AppRegistry.registerComponent('dooboo', () => App);
export default App;
7 changes: 2 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { defaults: tsjPreset } = require('ts-jest/presets');
const {defaults: tsjPreset} = require('ts-jest/presets');
/* eslint-enable @typescript-eslint/no-var-requires */

module.exports = {
Expand Down Expand Up @@ -36,10 +36,7 @@ module.exports = {
'<rootDir>/test/jestSetup.ts',
],
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$',
testPathIgnorePatterns: [
'\\.snap$',
'<rootDir>/node_modules/',
],
testPathIgnorePatterns: ['\\.snap$', '<rootDir>/node_modules/'],
/* eslint-disable */
transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|react-navigation|@react-navigation/.*|@dooboo-ui)',
Expand Down
83 changes: 51 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,88 +7,107 @@
"postinstall": "npx jetify",
"scripts": {
"postinstall": "yarn fbt:all",
"dev": "node node_modules/react-native/local-cli/cli.js start",
"dev": "react-native start",
"tsc": "tsc",
"watch": "tsc -w",
"start": "npm run dev",
"codecov": "codecov",
"upgrade": "react-native-git-upgrade && npm install --save react-native",
"upgrade:major": "react-native upgrade",
"test": "jest",
"test": "jest --runInBand",
"start:packager": "node_modules/react-native/packager/packager.sh",
"start:reset": "node node_modules/react-native/local-cli/cli.js start --reset-cache",
"android": "node node_modules/react-native/local-cli/cli.js run-android",
"start:reset": "react-native start --reset-cache",
"web": "craco start",
"build": "craco build",
"reset": "watchman watch-del-all; rm -rf /tmp/metro-bundler-cache-*; rm -rf ./android/build; rm -rf ./android/.gradle; rm -rf ./android/app/build; rm -rf ~/Library/Developer/Xcode/DerivedData; rm -rf /tmp/haste-map-react-native-packager-*; rm -rf ./ios/build; jest --clearCache; cd ios; pod install --repo-update; cd ..; npx jetify; cd android; ./gradlew clean; cd ..; react-native start --reset-cache",
"android": "react-native run-android",
"android:shake": "adb shell input keyevent 82",
"android:log": "adb logcat '*:S' ReactNative:V ReactNativeJS:V",
"android:apk": "cd android && ./gradlew assembleRelease",
"android:release": "node node_modules/react-native/local-cli/cli.js run-android --variant=release",
"ios": "node node_modules/react-native/local-cli/cli.js run-ios",
"ios:release": "node node_modules/react-native/local-cli/cli.js run-ios --configuration Release",
"android:release": "react-native run-android --variant=release",
"ios": "react-native run-ios",
"ios:release": "react-native run-ios --configuration Release",
"ios:devices": "xcrun simctl list devices",
"ios:dooboolab": "node node_modules/react-native/local-cli/cli.js run-ios --device 'dooboolab'",
"ios:dooboolab-release": "node node_modules/react-native/local-cli/cli.js run-ios --configuration Release --device 'dooboolab'",
"ios:iphone5": "node node_modules/react-native/local-cli/cli.js run-ios --simulator='iPhone 5s'",
"ios:iphone7": "node node_modules/react-native/local-cli/cli.js run-ios --simulator='iPhone 7'",
"ios:dooboolab": "react-native run-ios --device 'dooboolab'",
"ios:dooboolab-release": "react-native run-ios --configuration Release --device 'dooboolab'",
"ios:iphone5": "react-native run-ios --simulator='iPhone 5s'",
"ios:iphone7": "react-native run-ios --simulator='iPhone 7'",
"ios:reset": "rm -rf ios/build/ModuleCache",
"lint": "eslint src --ext .ts,.tsx,.js,.jsx",
"build:ios": "react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ./ios",
"build:android": "react-native bundle --entry-file index.js --platform android --dev false --bundle-output android/main.jsbundle --assets-dest ./android",
"manifest": "babel-node ./node_modules/babel-plugin-fbt/bin/manifest --src src/ --enum-manifest i18n/fbt/.enum_manifest.json --src-manifest i18n/fbt/.src_manifest.json",
"collect-fbts": "babel-node ./node_modules/babel-plugin-fbt/bin/collectFBT --hash-module 'fb-tiger-hash/src/hashPhrases' --react-native-mode --manifest --options __self < i18n/fbt/.src_manifest.json > i18n/fbt/.source_strings.json",
"translate-fbts": "babel-node ./node_modules/babel-plugin-fbt/bin/translate.js --jenkins --source-strings i18n/fbt/.source_strings.json --translations assets/translations/*.json > i18n/fbt/translatedFbts.json",
"clean-fbts": "rm i18n/fbt/.enum_manifest.json i18n/fbt/.src_manifest.json i18n/fbt/.source_strings.json assets/translatedFbts.json 2&> /dev/null || exit 0",
"fbt:all": "yarn manifest && yarn collect-fbts && yarn translate-fbts",
"fbt:android": "babel-node i18n/scripts/generate-android-localizables-executor.js"
"manifest": "fbt-manifest --src src/ --enum-manifest src/utils/i18n/fbt/.enum_manifest.json --src-manifest src/utils/i18n/fbt/.src_manifest.json",
"collect-fbts": "fbt-collect --hash-module 'fb-tiger-hash/src/hashPhrases' --react-native-mode --manifest --options __self < src/utils/i18n/fbt/.src_manifest.json > src/utils/i18n/fbt/.source_strings.json",
"translate-fbts": "fbt-translate --jenkins --source-strings src/utils/i18n/fbt/.source_strings.json --translations src/assets/translations/*.json > src/utils/i18n/fbt/translatedFbts.json",
"clean-fbts": "rm src/utils/i18n/fbt/.enum_manifest.json src/utils/i18n/fbt/.src_manifest.json src/utils/i18n/fbt/.source_strings.json src/assets/translatedFbts.json 2&> /dev/null || exit 0",
"fbt:android": "babel-node src/utils/i18n/scripts/generate-android-localizables-executor.js",
"fbt:all": "yarn manifest && yarn collect-fbts && yarn translate-fbts && yarn fbt:android"
},
"dependencies": {
"@dooboo-ui/theme": "^0.0.3",
"@react-native-community/async-storage": "^1.12.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/core": "^5.14.4",
"@react-navigation/native": "^5.8.10",
"@react-navigation/stack": "^5.12.8",
"fbt": "^0.16.0",
"@react-navigation/core": "^5.15.1",
"@react-navigation/native": "^5.9.2",
"@react-navigation/stack": "^5.14.2",
"fbt": "^0.16.1",
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-gesture-handler": "^1.9.0",
"react-native-reanimated": "^1.13.2",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.16.1",
"react-native-screens": "^2.17.1",
"react-native-web": "^0.14.10",
"react-responsive": "^8.2.0",
"react-scripts": "^4.0.1",
"styled-components": "^5.2.1"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/node": "^7.12.10",
"@babel/plugin-syntax-jsx": "^7.12.1",
"@babel/preset-typescript": "^7.12.7",
"@babel/runtime": "^7.12.5",
"@dooboo/eslint-config": "^0.5.8",
"@craco/craco": "^6.1.0",
"@dooboo/eslint-config": "^0.6.19",
"@testing-library/jest-native": "^3.4.3",
"@testing-library/react-native": "^7.1.0",
"@types/jest": "^26.0.19",
"@types/jest": "^26.0.20",
"@types/react": "^17.0.0",
"@types/react-native": "^0.63.43",
"@types/react-native": "^0.63.46",
"@types/react-responsive": "^8.0.2",
"@types/react-test-renderer": "^17.0.0",
"@types/styled-components": "^5.1.7",
"@types/styled-components-react-native": "^5.1.1",
"babel-jest": "^26.6.3",
"babel-plugin-fbt": "^0.16.0",
"babel-plugin-fbt-runtime": "^0.9.12",
"babel-plugin-fbt": "^0.17.1",
"babel-plugin-fbt-runtime": "^0.9.13",
"babel-preset-react-native": "^4.0.1",
"codecov": "^3.8.1",
"eslint": "^7.16.0",
"eslint": "^7.18.0",
"fb-tiger-hash": "^0.1.6",
"fbt-generate-translations": "^0.0.4",
"jest": "^26.6.3",
"jest-fetch-mock": "^3.0.3",
"jest-styled-components": "^7.0.3",
"jetifier": "^1.6.6",
"metro-react-native-babel-preset": "^0.64.0",
"metro-react-native-babel-preset": "^0.65.0",
"prettier": "^2.2.1",
"react-dom": "^16.13.1",
"react-native-fbt": "^0.0.1",
"react-test-renderer": "16.13.1",
"shelljs": "^0.8.4",
"ts-jest": "^26.4.4",
"typescript": "4.1.3"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1b9632a

Please sign in to comment.