Skip to content

Commit 068f0bc

Browse files
committed
Add react native, fix commands
1 parent 3fc4790 commit 068f0bc

84 files changed

Lines changed: 6611 additions & 660 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,62 @@ testem.log
3737
# System Files
3838
.DS_Store
3939
Thumbs.db
40+
41+
# React Native
42+
43+
## Xcode
44+
45+
**/ios/**/build/
46+
**/ios/**/*.pbxuser
47+
!default.pbxuser
48+
*.mode1v3
49+
!default.mode1v3
50+
*.mode2v3
51+
!default.mode2v3
52+
*.perspectivev3
53+
!default.perspectivev3
54+
xcuserdata
55+
*.xccheckout
56+
*.moved-aside
57+
DerivedData
58+
*.hmap
59+
*.ipa
60+
*.xcuserstate
61+
62+
## Android
63+
64+
**/android/**/build/
65+
**/android/**/.gradle
66+
**/android/**/local.properties
67+
**/android/**/*.iml
68+
69+
## BUCK
70+
71+
buck-out/
72+
\.buckd/
73+
*.keystore
74+
!debug.keystore
75+
76+
## fastlane
77+
#
78+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
79+
# screenshots whenever they are needed.
80+
# For more information about the recommended setup visit:
81+
# https://docs.fastlane.tools/best-practices/source-control/
82+
#
83+
*/fastlane/report.xml
84+
*/fastlane/Preview.html
85+
*/fastlane/screenshots
86+
87+
## Bundle artifact
88+
*.jsbundle
89+
90+
## CocoaPods
91+
**/ios/Pods/
92+
/
93+
94+
## Nested node_modules
95+
96+
node_modules/
97+
98+
apps/mobile-e2e/artifacts

Notes.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
- The first thing we did is - npx create-nx-workspace@latest with an empty setup
2+
3+
### Setup React Application - Dashboard
4+
5+
- Add react plugin : `yarn add -D @nrwl/react`
6+
- Create react application : `yarn nx g @nrwl/react:application dash --js` (With None as CSS Preset)
7+
- Run Dashboard `yarn nx serve dash`
8+
- Add styles.css with @tailwind annotations
9+
- Add tailwind.config.js inside dash
10+
- Add postcss.config.js at root
11+
- Edit project.json add tailwind command to compile minified version
12+
- To build this: `yarn nx build dash`
13+
14+
### Setup Nextjs Application - Landing
15+
16+
- Add plugin: `yarn add @nrwl/next --dev`
17+
- Create application: `yarn nx g @nrwl/next:app land --js`
18+
- Run Dashboard `yarn nx serve land`
19+
- Add styles.css with @tailwind annotations
20+
- Add tailwind.config.js inside land
21+
- Export `yarn nx export land`
22+
23+
24+
### Helpers
25+
26+
- To remove an application `npx nx g @nrwl/workspace:remove <app-name>`
27+
28+
### Setup React Native Mobile Application - Landing
29+
30+
31+
https://github.com/nrwl/nx-react-native
32+
33+
`yarn nx g @nrwl/react-native:app mobile --js`
34+
35+
36+
Bundler: `yarn nx start mobile`
37+
38+
Android: `yarn nx run-android mobile`
39+
40+
iOS: `yarn nx run-ios mobile --install`

apps/dash/project.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"sourceRoot": "apps/dash/src",
44
"projectType": "application",
55
"targets": {
6-
"build": {
6+
"build-with-tw": {
77
"executor": "@nrwl/workspace:run-commands",
88
"outputs": [],
99
"options": {
10-
"command": "NODE_ENV=production npx tailwindcss-cli@latest build -i ./apps/dash/src/styles.css -c ./apps/dash/tailwind.config.js -o ./apps/dash/src/tailwind.css --minify && npx nx build-app dash --prod"
10+
"command": "NODE_ENV=production npx tailwindcss-cli@latest build -i ./apps/dash/src/styles.css -c ./apps/dash/tailwind.config.js -o ./apps/dash/src/tailwind.css --minify && npx nx build dash --prod"
1111
}
1212
},
13-
"build-app": {
13+
"build": {
1414
"executor": "@nrwl/web:build",
1515
"outputs": ["{options.outputPath}"],
1616
"defaultConfiguration": "production",

apps/mobile-e2e/.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
[
4+
"@nrwl/react/babel",
5+
{
6+
"runtime": "automatic"
7+
}
8+
]
9+
],
10+
"plugins": []
11+
}

apps/mobile-e2e/.detoxrc.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"testRunner": "jest",
3+
"runnerConfig": "jest.config.json",
4+
"apps": {
5+
"ios.debug": {
6+
"type": "ios.app",
7+
"build": "cd ../mobile/ios && xcodebuild -workspace Mobile.xcworkspace -scheme Mobile -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12' -derivedDataPath ./build -quiet",
8+
"binaryPath": "../mobile/ios/build/Build/Products/Debug-iphonesimulator/Mobile.app"
9+
},
10+
"ios.release": {
11+
"type": "ios.app",
12+
"build": "cd ../mobile/ios && xcodebuild -workspace Mobile.xcworkspace -scheme Mobile -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12' -derivedDataPath ./build -quiet",
13+
"binaryPath": "../mobile/ios/build/Build/Products/Release-iphonesimulator/Mobile.app"
14+
},
15+
"android.debug": {
16+
"type": "android.apk",
17+
"build": "cd ../mobile/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug",
18+
"binaryPath": "../mobile/android/app/build/outputs/apk/debug/app-debug.apk"
19+
},
20+
"android.release": {
21+
"type": "android.apk",
22+
"build": "cd ../mobile/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release",
23+
"binaryPath": "../mobile/android/app/build/outputs/apk/release/app-release.apk"
24+
}
25+
},
26+
"devices": {
27+
"simulator": {
28+
"type": "ios.simulator",
29+
"device": {
30+
"type": "iPhone 12"
31+
}
32+
},
33+
"emulator": {
34+
"type": "android.emulator",
35+
"device": {
36+
"avdName": "Pixel_4a_API_30"
37+
}
38+
}
39+
},
40+
"configurations": {
41+
"ios.sim.release": {
42+
"device": "simulator",
43+
"app": "ios.release"
44+
},
45+
"ios.sim.debug": {
46+
"device": "simulator",
47+
"app": "ios.debug"
48+
},
49+
"android.emu.release": {
50+
"device": "emulator",
51+
"app": "android.release"
52+
},
53+
"android.emu.debug": {
54+
"device": "emulator",
55+
"app": "android.debug"
56+
}
57+
}
58+
}

apps/mobile-e2e/.eslintrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

apps/mobile-e2e/environment.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const {
2+
DetoxCircusEnvironment,
3+
SpecReporter,
4+
WorkerAssignReporter,
5+
} = require('detox/runners/jest-circus');
6+
7+
class CustomDetoxEnvironment extends DetoxCircusEnvironment {
8+
constructor(config, context) {
9+
super(config, context);
10+
11+
// Can be safely removed, if you are content with the default value (=300000ms)
12+
this.initTimeout = 300000;
13+
14+
// This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
15+
// This is strictly optional.
16+
this.registerListeners({
17+
SpecReporter,
18+
WorkerAssignReporter,
19+
});
20+
}
21+
}
22+
23+
module.exports = CustomDetoxEnvironment;

apps/mobile-e2e/jest.config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"preset": "../../jest.preset",
3+
"testEnvironment": "./environment",
4+
"testRunner": "jest-circus/runner",
5+
"testTimeout": 120000,
6+
"reporters": ["detox/runners/jest/streamlineReporter"],
7+
"setupFilesAfterEnv": ["<rootDir>/test-setup.ts"],
8+
"transform": {
9+
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nrwl/react/plugins/jest",
10+
"^.+\\.[tj]sx?$": "babel-jest"
11+
}
12+
}

apps/mobile-e2e/project.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"root": "apps/mobile-e2e",
3+
"sourceRoot": "apps/mobile-e2e/src",
4+
"projectType": "application",
5+
"targets": {
6+
"build-ios": {
7+
"executor": "@nrwl/detox:build",
8+
"options": {
9+
"detoxConfiguration": "ios.sim.debug"
10+
},
11+
"configurations": {
12+
"production": {
13+
"detoxConfiguration": "ios.sim.release"
14+
}
15+
}
16+
},
17+
"test-ios": {
18+
"executor": "@nrwl/detox:test",
19+
"options": {
20+
"detoxConfiguration": "ios.sim.debug"
21+
},
22+
"configurations": {
23+
"production": {
24+
"detoxConfiguration": "ios.sim.release"
25+
}
26+
}
27+
},
28+
"build-android": {
29+
"executor": "@nrwl/detox:build",
30+
"options": {
31+
"detoxConfiguration": "android.emu.debug"
32+
},
33+
"configurations": {
34+
"production": {
35+
"detoxConfiguration": "android.emu.release"
36+
}
37+
}
38+
},
39+
"test-android": {
40+
"executor": "@nrwl/detox:test",
41+
"options": {
42+
"detoxConfiguration": "android.emu.debug"
43+
},
44+
"configurations": {
45+
"production": {
46+
"detoxConfiguration": "android.emu.release"
47+
}
48+
}
49+
},
50+
"lint": {
51+
"executor": "@nrwl/linter:eslint",
52+
"outputs": ["{options.outputFile}"],
53+
"options": {
54+
"lintFilePatterns": ["apps/mobile-e2e/**/*.{ts,tsx,js,jsx}"]
55+
}
56+
}
57+
},
58+
"tags": [],
59+
"implicitDependencies": ["mobile"]
60+
}

apps/mobile-e2e/src/app.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { device, element, by, expect } from 'detox';
2+
describe('Mobile', () => {
3+
beforeEach(async () => {
4+
await device.reloadReactNative();
5+
});
6+
it('should display welcome message', async () => {
7+
await expect(element(by.id('heading'))).toHaveText('Welcome to Mobile');
8+
});
9+
it('should open nx link', async () => {
10+
await expect(element(by.id('nx-link'))).toBeVisible();
11+
element(by.id('nx-link')).tap();
12+
});
13+
});

0 commit comments

Comments
 (0)