Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
upgrade react native version
Browse files Browse the repository at this point in the history
- remove @nrwl/react being added to workspace since react native project does not have directly reference to @nrwl/react
- update nx version to 12.4.0
- remove jest.useFakeTimers in test-setup
- add migration scripts
  • Loading branch information
xiongemi committed Jun 24, 2021
1 parent 9e0c3a8 commit 9458b88
Show file tree
Hide file tree
Showing 29 changed files with 1,886 additions and 1,543 deletions.
File renamed without changes.
17 changes: 7 additions & 10 deletions e2e/react-native-e2e/jest.config.js
@@ -1,14 +1,11 @@
module.exports = {
name: 'react-native-e2e',
preset: '../../jest.config.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
},
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': 'ts-jest',
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/e2e/react-native-e2e',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
displayName: 'e2e-react-native',
testTimeout: 600000,
};
4 changes: 2 additions & 2 deletions e2e/react-native-e2e/tests/react-native.test.ts
Expand Up @@ -30,7 +30,7 @@ test('create ios and android JS bundles', async () => {
expect(() =>
checkFilesExist(`dist/apps/${appName}/android/main.bundle`)
).not.toThrow();
}, 360000);
});

test('sync npm dependencies for autolink', async () => {
const appName = uniq('my-app');
Expand Down Expand Up @@ -61,4 +61,4 @@ test('sync npm dependencies for autolink', async () => {
'react-native-safe-area-context': '*',
},
});
}, 360000);
});
10 changes: 3 additions & 7 deletions jest.config.js
@@ -1,9 +1,5 @@
const { getJestProjects } = require('@nrwl/jest');

module.exports = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest',
},
resolver: '@nrwl/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageReporters: ['html'],
projects: getJestProjects(),
};
3 changes: 3 additions & 0 deletions jest.preset.js
@@ -0,0 +1,3 @@
const nxPreset = require('@nrwl/jest/preset');

module.exports = { ...nxPreset };
28 changes: 28 additions & 0 deletions migrations.json
@@ -0,0 +1,28 @@
{
"migrations": [
{
"version": "12.4.0-beta.1",
"cli": "nx",
"description": "Add testEnvironment: 'jsdom' in web apps + libraries",
"factory": "./src/migrations/update-12-4-0/add-test-environment-for-node",
"package": "@nrwl/jest",
"name": "support-jest-27"
},
{
"version": "12.4.0-beta.1",
"cli": "nx",
"description": "Support for Jest 27 via updating ts-jest + jest-preset-angular",
"factory": "./src/migrations/update-12-4-0/update-jest-preset-angular",
"package": "@nrwl/jest",
"name": "update-ts-jest-and-jest-preset-angular"
},
{
"cli": "nx",
"version": "12.4.0-beta.0",
"description": "Remove ESLint parserOptions.project config if no rules requiring type-checking are in use",
"factory": "./src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules",
"package": "@nrwl/linter",
"name": "remove-eslint-project-config-if-no-type-checking-rules"
}
]
}
20 changes: 10 additions & 10 deletions package.json
Expand Up @@ -34,14 +34,14 @@
"@babel/plugin-transform-flow-strip-types": "^7.13.0",
"@babel/plugin-transform-object-assign": "^7.12.13",
"@babel/plugin-transform-react-jsx-source": "^7.14.2",
"@nrwl/devkit": "12.3.6",
"@nrwl/eslint-plugin-nx": "12.3.6",
"@nrwl/jest": "12.3.6",
"@nrwl/nx-plugin": "12.3.6",
"@nrwl/react": "12.3.6",
"@nrwl/tao": "12.3.6",
"@nrwl/workspace": "12.3.6",
"@types/jest": "26.0.8",
"@nrwl/devkit": "12.4.0",
"@nrwl/eslint-plugin-nx": "12.4.0",
"@nrwl/jest": "12.4.0",
"@nrwl/nx-plugin": "12.4.0",
"@nrwl/react": "12.4.0",
"@nrwl/tao": "12.4.0",
"@nrwl/workspace": "12.4.0",
"@types/jest": "26.0.23",
"@types/node": "12.12.38",
"@typescript-eslint/eslint-plugin": "2.19.2",
"@typescript-eslint/parser": "2.19.2",
Expand All @@ -51,11 +51,11 @@
"eslint": "7.14.0",
"eslint-config-prettier": "6.0.0",
"ignore": "^5.1.8",
"jest": "26.6.3",
"jest": "27.0.3",
"metro-resolver": "0.66.0",
"node-fetch": "^2.6.1",
"prettier": "2.2.1",
"ts-jest": "26.1.4",
"ts-jest": "27.0.3",
"ts-node": "9.1.1",
"tslint": "6.1.3",
"typescript": "4.0.5"
Expand Down
15 changes: 6 additions & 9 deletions packages/react-native/jest.config.js
@@ -1,14 +1,11 @@
module.exports = {
name: 'react-native',
preset: '../../jest.config.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
},
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/packages/react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html', 'json'],
globals: {
'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' },
},
displayName: 'react-native',
};
58 changes: 58 additions & 0 deletions packages/react-native/migrations.json
Expand Up @@ -9,6 +9,18 @@
"version": "11.4.0-beta.0",
"description": "Add missing libraries",
"factory": "./src/migrations/update-11-4-0/add-missing-dev-dependencies-11-4-0"
},
"add-react-native-codegen-dev-dependencies": {
"version": "12.4.0-beta.0",
"cli": "nx",
"description": "Add react-native-codegen to dev dependencies",
"factory": "./src/migrations/update-12-4-0/add-react-native-codegen-dev-dependencies"
},
"update-jest-for-react-native": {
"version": "12.4.0-beta.0",
"cli": "nx",
"description": "Update jest for react native",
"factory": "./src/migrations/update-12-4-0/update-jest-for-react-native"
}
},
"packageJsonUpdates": {
Expand Down Expand Up @@ -99,6 +111,52 @@
"alwaysAddToPackageJson": false
}
}
},
"12.4.0": {
"version": "12.4.0-beta.0",
"packages": {
"@nrwl/jest": { "version": "12.4.0", "alwaysAddToPackageJson": false },
"@nrwl/linter": {
"version": "12.4.0",
"alwaysAddToPackageJson": false
},
"react": {
"version": "17.0.2",
"alwaysAddToPackageJson": false
},
"react-native": {
"version": "0.65.0-rc.2",
"alwaysAddToPackageJson": false
},
"react-test-renderer": {
"version": "17.0.2",
"alwaysAddToPackageJson": false
},
"react-native-codegen": {
"version": "0.0.7",
"alwaysAddToPackageJson": false
},
"@types/react-native": {
"version": "0.64.10",
"alwaysAddToPackageJson": false
},
"@react-native-community/cli": {
"version": "6.0.0-rc.0",
"alwaysAddToPackageJson": false
},
"@react-native-community/cli-platform-android": {
"version": "6.0.0-rc.0",
"alwaysAddToPackageJson": false
},
"@react-native-community/cli-platform-ios": {
"version": "6.0.0-rc.0",
"alwaysAddToPackageJson": false
},
"@testing-library/react-native": {
"version": "8.0.0-rc.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
12 changes: 6 additions & 6 deletions packages/react-native/package.json
@@ -1,6 +1,6 @@
{
"name": "@nrwl/react-native",
"version": "12.3.6",
"version": "12.4.0",
"description": "React Native Plugin for Nx",
"keywords": [
"Monorepo",
Expand All @@ -25,21 +25,21 @@
"dependencies": {
"@angular-devkit/architect": "^0.1200.0",
"@angular-devkit/schematics": "^12.0.0",
"@nrwl/jest": "12.3.6",
"@nrwl/linter": "12.3.6",
"@nrwl/react": "12.3.6",
"@nrwl/jest": "12.4.0",
"@nrwl/linter": "12.4.0",
"@nrwl/react": "12.4.0",
"chalk": "^4.1.0",
"ignore": "^5.1.8",
"node-fetch": "2.6.1"
},
"peerDependencies": {
"@nrwl/workspace": "*",
"react-native": "0.64.1"
"react-native": "0.65.0-rc.2"
},
"builders": "./builders.json",
"ng-update": {
"requirements": {},
"migrations": "./migrations.json"
},
"schematics": "./collection.json"
}
}
Expand Up @@ -124,11 +124,6 @@ def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.<%= lowerCaseName %>"
minSdkVersion rootProject.ext.minSdkVersion
Expand Down
Expand Up @@ -2,25 +2,26 @@

buildscript {
ext {
buildToolsVersion = "29.0.3"
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath("com.android.tools.build:gradle:4.2.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
Expand All @@ -32,7 +33,6 @@ allprojects {
}

google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
Expand Up @@ -25,7 +25,7 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.75.1
FLIPPER_VERSION=0.93.0

# Production release must be signed
# See: https://reactnative.dev/docs/signed-apk-android
Expand Down
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Expand Up @@ -2,7 +2,7 @@ require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/@nrwl/react-native/nx_post_install'

platform :ios, '10.0'
platform :ios, '11.0'

target '<%= className %>' do
config = use_native_modules!
Expand Down

0 comments on commit 9458b88

Please sign in to comment.