Procházet zdrojové kódy

Add Windows compatibility in 4 node scripts. (#6015)

Added windows compatibility to build scripts. To run the packager on windows, use: `npm run start-windows`

Co-authored-by: Guy Carmeli <guyca@users.noreply.github.com>
Maycon Mesquita před 4 roky
rodič
revize
afb5bffb49
No account linked to committer's email address
6 změnil soubory, kde provedl 53 přidání a 5 odebrání
  1. 1
    0
      docs/docs/WorkingLocally.md
  2. 3
    3
      package.json
  3. 14
    0
      scripts/build.js
  4. 14
    1
      scripts/clean.js
  5. 7
    1
      scripts/install-android.js
  6. 14
    0
      scripts/watch.js

+ 1
- 0
docs/docs/WorkingLocally.md Zobrazit soubor

@@ -55,6 +55,7 @@ No PR will be accepted without adequate test coverage.
55 55
 | `npm run build` | compiles TypeScript sources `./lib/src` into javascript `./lib/dist` |
56 56
 | `npm run clean` | cleans all build directories, stops packager, fixes flakiness by removing watchman cache, etc. |
57 57
 | `npm run start` | starts the react-native packager for local debugging |
58
+| `npm run start-windows` | starts the react-native packager for local debugging [Windows only] |
58 59
 | `npm run xcode` | for convenience, opens xcode in this project |
59 60
 | `npm run install-android`  |  builds playground debug/release version and installs on running android devices/emulators. <br> **Options:** `-- --release` |
60 61
 | `npm run uninstall-android` | uninstalls playground from running android devices/simulators |

+ 3
- 3
package.json Zobrazit soubor

@@ -19,8 +19,8 @@
19 19
   "main": "lib/dist/index.js",
20 20
   "typings": "lib/dist/index.d.ts",
21 21
   "scripts": {
22
-    "build": "rm -rf ./lib/dist && tsc",
23
-    "watch": "rm -rf ./lib/dist && tsc --watch",
22
+    "build": "node ./scripts/build",
23
+    "watch": "node ./scripts/watch",
24 24
     "xcode": "open playground/ios/playground.xcworkspace",
25 25
     "install-android": "node ./scripts/install-android",
26 26
     "uninstall-android": "cd playground/android && ./gradlew uninstallAll",
@@ -159,4 +159,4 @@
159 159
       }
160 160
     }
161 161
   }
162
-}
162
+}

+ 14
- 0
scripts/build.js Zobrazit soubor

@@ -0,0 +1,14 @@
1
+const exec = require('shell-utils').exec;
2
+
3
+const isWindows = process.platform === 'win32' ? true : false;
4
+
5
+run();
6
+
7
+function run() {
8
+    if (isWindows) {
9
+        exec.execSync(`del /F /S /Q lib\\dist`);
10
+        exec.execSync(`tsc`);
11
+    } else {
12
+        exec.execSync(`rm -rf ./lib/dist && tsc`);
13
+    }
14
+}

+ 14
- 1
scripts/clean.js Zobrazit soubor

@@ -1,6 +1,9 @@
1 1
 const exec = require('shell-utils').exec;
2 2
 
3
-run();
3
+const isWindows = process.platform === 'win32' ? true : false;
4
+
5
+if (isWindows) runWin32();
6
+else run();
4 7
 
5 8
 function run() {
6 9
   exec.killPort(8081);
@@ -14,3 +17,13 @@ function run() {
14 17
   exec.execSync(`rm -rf playground/android/app/build`);
15 18
   exec.execSync(`rm -rf lib/dist`);
16 19
 }
20
+
21
+function runWin32() {
22
+  exec.execSync(`adb reverse tcp:8081 tcp:8081 || true`);
23
+
24
+  exec.execSync('del /F /S /Q lib\\android\\build');
25
+  exec.execSync('del /F /S /Q lib\\android\\app\\build');
26
+  exec.execSync('del /F /S /Q playground\\android\\build');
27
+  exec.execSync('del /F /S /Q playground\\android\\app\\build');
28
+  exec.execSync('del /F /S /Q lib\\dist');
29
+}

+ 7
- 1
scripts/install-android.js Zobrazit soubor

@@ -3,8 +3,14 @@ const exec = require('shell-utils').exec;
3 3
 
4 4
 const release = includes(process.argv, '--release');
5 5
 
6
+const isWindows = process.platform === 'win32' ? true : false;
7
+
6 8
 run();
7 9
 
8 10
 function run() {
9
-  exec.execSync(`cd playground/android && ./gradlew ${release ? 'installRelease' : 'installDebug'}`);
11
+  if (isWindows) {
12
+  	exec.execSync(`cd playground/android && gradlew ${release ? 'installRelease' : 'installDebug'}`);
13
+  } else {
14
+  	exec.execSync(`cd playground/android && ./gradlew ${release ? 'installRelease' : 'installDebug'}`);
15
+  }
10 16
 }

+ 14
- 0
scripts/watch.js Zobrazit soubor

@@ -0,0 +1,14 @@
1
+const exec = require('shell-utils').exec;
2
+
3
+const isWindows = process.platform === 'win32' ? true : false;
4
+
5
+run();
6
+
7
+function run() {
8
+    if (isWindows) {
9
+        exec.execSync(`del /F /S /Q lib\\dist`);
10
+        exec.execSync(`tsc --watch`);
11
+    } else {
12
+        exec.execSync(`rm -rf ./lib/dist && tsc --watch`);
13
+    }
14
+}