Browse Source

update scripts

Daniel Zlotin 7 years ago
parent
commit
ebda7d422a
4 changed files with 27 additions and 68 deletions
  1. 11
    15
      playground/scripts/e2e.ios.js
  2. 4
    4
      playground/scripts/postinstall.js
  3. 0
    25
      scripts/exec.js
  4. 12
    24
      scripts/release.js

+ 11
- 15
playground/scripts/e2e.ios.js View File

@@ -1,5 +1,5 @@
1 1
 const _ = require('lodash');
2
-const exec = require('./exec');
2
+const shellUtils = require('shell-utils');
3 3
 const fs = require('fs');
4 4
 
5 5
 const release = _.includes(process.argv, 'release');
@@ -15,7 +15,7 @@ function buildProjForDetox() {
15 15
   const scheme = release ? `playground_release_Detox` : `playground_Detox`;
16 16
   const args = release ? '' : `GCC_PREPROCESSOR_DEFINITIONS="DEBUG=1 RCT_DEBUG=1 RCT_DEV=1 RCT_NSASSERT=1"`;
17 17
 
18
-  exec.exec(`RCT_NO_LAUNCH_PACKAGER=true \
18
+  shellUtils.exec.execSync(`RCT_NO_LAUNCH_PACKAGER=true \
19 19
           cd ios && xcodebuild \
20 20
             -scheme ${scheme} build \
21 21
             -project playground.xcodeproj \
@@ -26,26 +26,22 @@ function buildProjForDetox() {
26 26
 
27 27
 function e2e() {
28 28
   try {
29
-    kill(`detox-server`);
30
-    exec.execAsync(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
29
+    shellUtils.exec.kill(`detox-server`);
30
+    shellUtils.exec.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
31 31
     const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}_Detox-iphonesimulator/playground.app`;
32
-    exec.exec(`detoxAppBuildPath="${detoxAppBuildPath}" BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --compilers js:babel-register`);
32
+    shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}" BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --compilers js:babel-register`);
33 33
   } finally {
34
-    kill(`detox-server`);
34
+    shellUtils.exec.kill(`detox-server`);
35 35
     if (release) {
36
-      kill(`Simulator`);
37
-      kill(`CoreSimulator`);
36
+      shellUtils.exec.kill(`Simulator`);
37
+      shellUtils.exec.kill(`CoreSimulator`);
38 38
     }
39
-    exec.exec(`cat ./detox-server.log`);
40
-    exec.exec(`rm -f ./detox-server.log`);
41
-    exec.exec(`sleep 5`);
39
+    shellUtils.exec.execSync(`cat ./detox-server.log`);
40
+    shellUtils.exec.execSync(`rm -f ./detox-server.log`);
41
+    shellUtils.exec.execSync(`sleep 5`);
42 42
   }
43 43
 }
44 44
 
45
-function kill(process) {
46
-  exec.execSilent(`pkill -f "${process}"`);
47
-}
48
-
49 45
 function run() {
50 46
   hackReactXcodeScript();
51 47
   buildProjForDetox();

+ 4
- 4
playground/scripts/postinstall.js View File

@@ -1,5 +1,5 @@
1
-const cp = require('child_process');
1
+const shellUtils = require('shell-utils');
2 2
 
3
-cp.execSync(`rm yarn.lock`);
4
-cp.execSync(`rm -rf node_modules/react-native-navigation/node_modules`);
5
-cp.execSync(`rm -rf node_modules/react-native-navigation/playground`);
3
+shellUtils.exec.execSync(`rm yarn.lock`);
4
+shellUtils.exec.execSync(`rm -rf node_modules/react-native-navigation/node_modules`);
5
+shellUtils.exec.execSync(`rm -rf node_modules/react-native-navigation/playground`);

+ 0
- 25
scripts/exec.js View File

@@ -1,25 +0,0 @@
1
-const cp = require('child_process');
2
-
3
-function exec(cmd) {
4
-  cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
5
-}
6
-
7
-function execSilent(cmd) {
8
-  cp.execSync(`${cmd} || true`, {stdio: ['ignore', 'ignore', 'ignore']});
9
-}
10
-
11
-function execRead(cmd) {
12
-  return String(cp.execSync(cmd, {stdio: ['pipe', 'pipe', 'pipe']})).trim();
13
-}
14
-
15
-function execAsync(cmd) {
16
-  cp.exec(cmd);
17
-}
18
-
19
-module.exports = {
20
-  exec,
21
-  execSilent,
22
-  execRead,
23
-  execAsync
24
-};
25
-

+ 12
- 24
scripts/release.js View File

@@ -1,19 +1,7 @@
1
-const cp = require('child_process');
1
+const shellUtils = require('shell-utils');
2 2
 const p = require('path');
3 3
 const semver = require('semver');
4 4
 
5
-function execSync(cmd) {
6
-  cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
7
-}
8
-
9
-function execSyncRead(cmd) {
10
-  return String(cp.execSync(cmd, {stdio: ['inherit', 'pipe', 'inherit']})).trim();
11
-}
12
-
13
-function execSyncSilently(cmd) {
14
-  cp.execSync(cmd, {stdio: ['ignore', 'ignore', 'ignore']});
15
-}
16
-
17 5
 function validateEnv() {
18 6
   if (!process.env.CI || !process.env.TRAVIS) {
19 7
     throw new Error(`releasing is only available from Travis CI`);
@@ -33,30 +21,30 @@ function validateEnv() {
33 21
 }
34 22
 
35 23
 function setupGit() {
36
-  execSyncSilently(`git config --global push.default simple`);
37
-  execSyncSilently(`git config --global user.email "${process.env.GIT_EMAIL}"`);
38
-  execSyncSilently(`git config --global user.name "${process.env.GIT_USER}"`);
39
-  const remoteUrl = new RegExp(`https?://(\\S+)`).exec(execSyncRead(`git remote -v`))[1];
40
-  execSyncSilently(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
41
-  execSync(`git checkout master`);
24
+  shellUtils.exec.execSyncSilent(`git config --global push.default simple`);
25
+  shellUtils.exec.execSyncSilent(`git config --global user.email "${process.env.GIT_EMAIL}"`);
26
+  shellUtils.exec.execSyncSilent(`git config --global user.name "${process.env.GIT_USER}"`);
27
+  const remoteUrl = new RegExp(`https?://(\\S+)`).exec(shellUtils.exec.execSyncRead(`git remote -v`))[1];
28
+  shellUtils.exec.execSyncSilent(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
29
+  shellUtils.exec.execSync(`git checkout master`);
42 30
 }
43 31
 
44 32
 function calcNewVersion() {
45
-  const nextTaggedVersion = execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
33
+  const nextTaggedVersion = shellUtils.exec.execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
46 34
   console.log(`next tagged version is: ${nextTaggedVersion}`);
47 35
   return semver.inc(nextTaggedVersion, 'prerelease');
48 36
 }
49 37
 
50 38
 function copyNpmRc() {
51 39
   const npmrcPath = p.resolve(`${__dirname}/.npmrc`);
52
-  execSync(`cp -rf ${npmrcPath} .`);
40
+  shellUtils.exec.execSync(`cp -rf ${npmrcPath} .`);
53 41
 }
54 42
 
55 43
 function tagAndPublish(newVersion) {
56 44
   console.log(`new version is: ${newVersion}`);
57
-  execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
58
-  execSyncSilently(`git push deploy --tags`);
59
-  execSync(`npm publish --tag next`);
45
+  shellUtils.exec.execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
46
+  shellUtils.exec.execSyncSilent(`git push deploy --tags`);
47
+  shellUtils.exec.execSync(`npm publish --tag next`);
60 48
 }
61 49
 
62 50
 function run() {