Daniel Zlotin 7 years ago
parent
commit
82df2e4082
5 changed files with 49 additions and 15 deletions
  1. 4
    3
      docs/docs/CONTRIBUTING.md
  2. 18
    11
      package.json
  3. 1
    1
      scripts/test-js.js
  4. 23
    0
      tsconfig.json
  5. 3
    0
      wallaby.js

+ 4
- 3
docs/docs/CONTRIBUTING.md View File

@@ -92,8 +92,9 @@ No PR will be accepted without adequate test coverage.
92 92
 | `lib` | The project itself composed of: |
93 93
 | `lib/android` | android sources and unit tests |
94 94
 | `lib/ios` | iOS sources and unit tests |
95
-| `lib/src` | javascript sources and unit tests |
96
-| `lib/src/index.js` | the entry point for `import Navigation from 'react-native-navigation'` |
95
+| `lib/src` | TypeScript sources and unit tests |
96
+| `lib/dist` | compiled javascript sources and unit tests |
97
+| `lib/dist/index.js` | the entry point for `import Navigation from 'react-native-navigation'` |
97 98
 | `e2e` | [detox](https://github.com/wix/detox) iOS e2e tests (in the future, once detox supports it, we will have android e2e here as well) |
98 99
 | `AndroidE2E` | Android e2e tests using native uiautomator (until detox for android is ready) |
99 100
 | `playground` | The end-user project all e2e tests run against. Contains its own `src`, `android` and `ios`. Does not have its own package.json, depends on the local `<root>/lib` in order not to go through npm. |
@@ -105,13 +106,13 @@ No PR will be accepted without adequate test coverage.
105 106
 | Command | Description |
106 107
 | ------- | ----------- |
107 108
 | `npm install` | installs dependencies |
109
+| `npm run build` | compiles TypeScript sources `./lib/src` into javascript `./lib/dist` |
108 110
 | `npm run clean` | cleans all build directories, stops packager, fixes flakiness by removing watchman cache, etc. |
109 111
 | `npm run start` | starts the react-native packager for local debugging |
110 112
 | `npm run xcode` | for convenience, opens xcode in this project |
111 113
 | `npm run install-android`  |  builds playground debug/release version and installs on running android devices/emulators. <br> **Options:** `-- --release` |
112 114
 | `npm run uninstall-android` | uninstalls playground from running android devices/simulators |
113 115
 | `npm run test-js` | runs javascript tests and coverage report |
114
-| `npm run test-watch` | runs javascript tests in watch mode (can also use the provided wallaby config) |
115 116
 | `npm run test-unit-ios` | runs ios unit tests in debug/release <br> **Options:** `-- --release` |
116 117
 | `npm run test-unit-android` | runs android unit tests in debug/release <br> **Options:** `-- --release` |
117 118
 | `npm run test-e2e-ios` | runs the ios e2e suite (with detox) in debug/release <br> **Options:** `-- --release`|

+ 18
- 11
package.json View File

@@ -23,23 +23,25 @@
23 23
     "type": "git",
24 24
     "url": "https://github.com/wix/react-native-navigation.git"
25 25
   },
26
-  "main": "lib/src/index.js",
26
+  "main": "lib/dist/index.js",
27 27
   "scripts": {
28
-    "build": ":",
28
+    "build": "rm -rf ./lib/dist && tsc",
29 29
     "xcode": "open playground/ios/playground.xcodeproj",
30 30
     "install-android": "node ./scripts/install-android.js",
31 31
     "uninstall-android": "cd playground/android && ./gradlew uninstallAll",
32 32
     "clean": "node ./scripts/clean.js",
33
+    "prestart": "npm run build",
33 34
     "start": "node ./scripts/start.js",
35
+    "pretest-js": "npm run build",
34 36
     "test-js": "node ./scripts/test-js.js",
35 37
     "test-unit-android": "node ./scripts/test.unit.android.js",
36 38
     "test-unit-ios": "node ./scripts/test.unit.ios.js",
39
+    "pretest-e2e-android": "npm run build",
37 40
     "test-e2e-android": "node ./scripts/test.e2e.android.js",
41
+    "pretest-e2e-ios": "npm run build",
38 42
     "test-e2e-ios": "node ./scripts/test.e2e.ios.js",
39 43
     "test-all": "node ./scripts/test.all.js",
40
-    "test-watch": "jest --coverage --watch",
41
-    "release": "node ./scripts/release.js",
42
-    "gen-doc": "node ./scripts/generate-js-doc.js"
44
+    "release": "node ./scripts/release.js"
43 45
   },
44 46
   "peerDependencies": {
45 47
     "react": "*",
@@ -66,7 +68,12 @@
66 68
     "remx": "2.x.x",
67 69
     "semver": "5.x.x",
68 70
     "shell-utils": "1.x.x",
69
-    "xo": "0.18.x"
71
+    "xo": "0.18.x",
72
+    "typescript": "2.x.x",
73
+    "@types/react": "16.0.0",
74
+    "@types/react-native": "0.49.x",
75
+    "@types/jest": "22.x.x",
76
+    "@types/prop-types": "15.x.x"
70 77
   },
71 78
   "babel": {
72 79
     "env": {
@@ -81,15 +88,15 @@
81 88
     "preset": "react-native",
82 89
     "roots": [
83 90
       "<rootDir>/node_modules/",
84
-      "<rootDir>/lib/src/",
91
+      "<rootDir>/lib/dist/",
85 92
       "<rootDir>/integration/"
86 93
     ],
87 94
     "collectCoverageFrom": [
88
-      "lib/src/**/*.js",
95
+      "lib/dist/**/*.js",
89 96
       "integration/**/*.js",
90
-      "!lib/src/index.js",
91
-      "!lib/src/Navigation.js",
92
-      "!lib/src/adapters/**/*"
97
+      "!lib/dist/index.js",
98
+      "!lib/dist/Navigation.js",
99
+      "!lib/dist/adapters/**/*"
93 100
     ],
94 101
     "resetMocks": true,
95 102
     "resetModules": true,

+ 1
- 1
scripts/test-js.js View File

@@ -4,7 +4,7 @@ const _ = require('lodash');
4 4
 const fix = _.includes(process.argv, '--fix') ? '--fix' : '';
5 5
 
6 6
 const dirs = [
7
-  'lib/src',
7
+  'lib/dist',
8 8
   'integration',
9 9
   'e2e',
10 10
   'scripts',

+ 23
- 0
tsconfig.json View File

@@ -0,0 +1,23 @@
1
+{
2
+  "compilerOptions": {
3
+    "outDir": "./lib/dist",
4
+    "allowJs": true,
5
+    "target": "esnext",
6
+    "moduleResolution": "node",
7
+    "module": "commonjs",
8
+    "jsx": "preserve",
9
+    "noEmitOnError": true,
10
+    "noImplicitReturns": true,
11
+    "noFallthroughCasesInSwitch": true,
12
+    "alwaysStrict": true,
13
+    "strictNullChecks": true,
14
+    "types": [
15
+      "react",
16
+      "react-native",
17
+      "jest"
18
+    ]
19
+  },
20
+  "include": [
21
+    "./lib/src/**/*"
22
+  ]
23
+}

+ 3
- 0
wallaby.js View File

@@ -12,13 +12,16 @@ module.exports = function (wallaby) {
12 12
     files: [
13 13
       'package.json',
14 14
       'lib/src/**/*.js',
15
+      'lib/src/**/*.ts',
15 16
       '!lib/src/**/*.test.js',
17
+      '!lib/src/**/*.test.ts',
16 18
       'integration/**/*.js',
17 19
       '!integration/**/*.test.js'
18 20
     ],
19 21
 
20 22
     tests: [
21 23
       'lib/src/**/*.test.js',
24
+      'lib/src/**/*.test.ts',
22 25
       'integration/**/*.test.js'
23 26
     ],
24 27