Browse Source

updating scripts

Daniel Zlotin 7 years ago
parent
commit
c57c9b451d

+ 8
- 3
.travis.yml View File

@@ -25,15 +25,20 @@ before_cache:
25 25
   - rm -rf $HOME/.gradle/caches/*/plugin-resolution/
26 26
 
27 27
 install:
28
+  - set -e
29
+  # node
28 30
   - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
29 31
   - export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
30 32
   - nvm install $NODE_VERSION
31 33
   - nvm use $NODE_VERSION
32
-  - nvm ls
33
-  - gem install xcpretty
34
+  # yarn
34 35
   - curl -o- -L https://yarnpkg.com/install.sh | bash
35 36
   - yarn config set cache-folder $YARN_CACHE
36
-
37
+  # android sdk
38
+  - node ./scripts/installAndroidSdk.js
39
+  # fbsimctl
40
+  - brew tap facebook/fb && brew install fbsimctl
41
+  - set +e
37 42
 
38 43
 script:
39 44
   - set -e

+ 0
- 14
scripts/fixRN38.js View File

@@ -1,14 +0,0 @@
1
-const _ = require('lodash');
2
-const shellUtils = require('shell-utils');
3
-const fs = require('fs');
4
-
5
-function run() {
6
-  console.log('fixing RCTJSStackFrame.m to not break analysis'); //eslint-disable-line
7
-
8
-  const path = `${process.cwd()}/node_modules/react-native/React/Base/RCTJSStackFrame.h`;
9
-  const lines = String(fs.readFileSync(path)).split('\n');
10
-  lines[24] = '+ (NSArray<RCTJSStackFrame *> *)stackFramesWithDictionaries:(NSArray *)dicts;';
11
-  fs.writeFileSync(path, lines.join('\n'));
12
-}
13
-
14
-run();

+ 0
- 17
scripts/ignoreReactWarnings.rb View File

@@ -1,17 +0,0 @@
1
-#!/usr/bin/env ruby
2
-
3
-require 'pathname'
4
-
5
-$LOAD_PATH.unshift(__dir__ + "/../node_modules/detox/scripts/Xcodeproj/lib")
6
-$LOAD_PATH.unshift(__dir__ + "/../node_modules/detox/scripts/Nanaimo/lib")
7
-
8
-require 'xcodeproj'
9
-
10
-project = Xcodeproj::Project.open(__dir__ + "/../node_modules/react-native/React/React.xcodeproj")
11
-
12
-warning_flags = ['-Wno-shorten-64-to-32','-Wno-unused-parameter','-Wno-unreachable-code','-Wno-deprecated-declarations','-Wno-extra-tokens','-Wno-unused-variable','-Wno-incompatible-pointer-types','-Wno-conditional-uninitialized','-Wno-undeclared-selector','-Wno-objc-protocol-property-synthesis']
13
-
14
-project.build_configuration_list['Debug'].build_settings['WARNING_CFLAGS'] = warning_flags
15
-project.build_configuration_list['Release'].build_settings['WARNING_CFLAGS'] = warning_flags
16
-
17
-raise "Error: Unable to save Xcode project" unless project.save()

+ 13
- 0
scripts/installAndroidSdk.js View File

@@ -0,0 +1,13 @@
1
+const exec = require('shell-utils').exec;
2
+
3
+run();
4
+
5
+function run() {
6
+  console.log(`Downloading Android SDK`); //eslint-disable-line
7
+  // fix for https://code.google.com/p/android/issues/detail?id=223424
8
+  exec.execSync(`mkdir -p ~/.android`);
9
+  exec.execSync(`curl --location https://dl.google.com/android/android-sdk_r24.4.1-macosx.zip | tar -x -z -C $HOME`);
10
+  console.log(`Copying Android licenses`); //eslint-disable-line
11
+  exec.execSync(`mkdir -p "${ANDROID_HOME}"/licenses`);
12
+  exec.execSync(`cp "${__dirname}"/android-sdk-licenses/* "${ANDROID_HOME}"/licenses`);
13
+}

+ 12
- 12
scripts/release.js View File

@@ -1,5 +1,5 @@
1 1
 /*eslint-disable no-console*/
2
-const shellUtils = require('shell-utils');
2
+const exec = require('shell-utils').exec;
3 3
 const p = require('path');
4 4
 const semver = require('semver');
5 5
 
@@ -22,30 +22,30 @@ function validateEnv() {
22 22
 }
23 23
 
24 24
 function setupGit() {
25
-  shellUtils.exec.execSyncSilent(`git config --global push.default simple`);
26
-  shellUtils.exec.execSyncSilent(`git config --global user.email "${process.env.GIT_EMAIL}"`);
27
-  shellUtils.exec.execSyncSilent(`git config --global user.name "${process.env.GIT_USER}"`);
28
-  const remoteUrl = new RegExp(`https?://(\\S+)`).exec(shellUtils.exec.execSyncRead(`git remote -v`))[1];
29
-  shellUtils.exec.execSyncSilent(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
30
-  shellUtils.exec.execSync(`git checkout master`);
25
+  exec.execSyncSilent(`git config --global push.default simple`);
26
+  exec.execSyncSilent(`git config --global user.email "${process.env.GIT_EMAIL}"`);
27
+  exec.execSyncSilent(`git config --global user.name "${process.env.GIT_USER}"`);
28
+  const remoteUrl = new RegExp(`https?://(\\S+)`).exec(exec.execSyncRead(`git remote -v`))[1];
29
+  exec.execSyncSilent(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
30
+  exec.execSync(`git checkout master`);
31 31
 }
32 32
 
33 33
 function calcNewVersion() {
34
-  const nextTaggedVersion = shellUtils.exec.execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
34
+  const nextTaggedVersion = exec.execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
35 35
   console.log(`next tagged version is: ${nextTaggedVersion}`);
36 36
   return semver.inc(nextTaggedVersion, 'prerelease');
37 37
 }
38 38
 
39 39
 function copyNpmRc() {
40 40
   const npmrcPath = p.resolve(`${__dirname}/.npmrc`);
41
-  shellUtils.exec.execSync(`cp -Rf ${npmrcPath} .`);
41
+  exec.execSync(`cp -Rf ${npmrcPath} .`);
42 42
 }
43 43
 
44 44
 function tagAndPublish(newVersion) {
45 45
   console.log(`new version is: ${newVersion}`);
46
-  shellUtils.exec.execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
47
-  shellUtils.exec.execSyncSilent(`git push deploy --tags`);
48
-  shellUtils.exec.execSync(`npm publish --tag next`);
46
+  exec.execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
47
+  exec.execSyncSilent(`git push deploy --tags`);
48
+  exec.execSync(`npm publish --tag next`);
49 49
 }
50 50
 
51 51
 function run() {

+ 5
- 5
scripts/test.all.js View File

@@ -1,10 +1,10 @@
1
-const shellUtils = require('shell-utils');
1
+const exec = require('shell-utils').exec;
2 2
 
3 3
 function run() {
4
-  shellUtils.exec.execSync(`yarn run test-js`);
5
-  shellUtils.exec.execSync(`yarn run test-unit-android && yarn run test-unit-ios`);
6
-  shellUtils.exec.exec(`yarn run test-e2e-android`);
7
-  shellUtils.exec.exec(`yarn run test-e2e-ios`);
4
+  exec.execSync(`yarn run test-js`);
5
+  exec.execSync(`yarn run test-unit-android && yarn run test-unit-ios`);
6
+  exec.exec(`yarn run test-e2e-android`);
7
+  exec.exec(`yarn run test-e2e-ios`);
8 8
 }
9 9
 
10 10
 run();

+ 13
- 28
scripts/test.e2e.ios.js View File

@@ -1,39 +1,31 @@
1 1
 const _ = require('lodash');
2
-const shellUtils = require('shell-utils');
2
+const exec = require('shell-utils').exec;
3 3
 
4 4
 const release = _.includes(process.argv, 'release');
5 5
 
6 6
 function buildProjForDetox() {
7 7
   const scheme = release ? `playground_release` : `playground`;
8 8
 
9
-  const cmd = `RCT_NO_LAUNCH_PACKAGER=true
10
-          cd ./playground/ios && xcodebuild
9
+  const cmd = `cd ./playground/ios && xcodebuild
11 10
             -scheme ${scheme}
12 11
             ${release ? 'clean build' : 'build'}
13 12
             -project playground.xcodeproj
14 13
             -sdk iphonesimulator
15 14
             -derivedDataPath ./DerivedData/playground`;
16 15
 
17
-  if (isInstalled(`xcpretty`)) {
18
-    shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
16
+  if (exec.which(`xcpretty`)) {
17
+    exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
19 18
   } else {
20
-    shellUtils.exec.execSync(`${cmd}`);
21
-  }
22
-}
23
-function isInstalled(what) {
24
-  try {
25
-    return shellUtils.exec.execSyncRead(`which ${what}`);
26
-  } catch (e) {
27
-    return false;
19
+    exec.execSync(`${cmd}`);
28 20
   }
29 21
 }
30 22
 
31 23
 function e2e() { //eslint-disable-line
32 24
   try {
33
-    shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
25
+    exec.execSyncSilent(`watchman watch-del-all || true`);
34 26
     const detoxAppBuildPath = `playground/ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
35 27
 
36
-    shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
28
+    exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
37 29
                               BABEL_ENV=test
38 30
                               ./node_modules/mocha/bin/mocha e2e
39 31
                                 --timeout ${2 * 60 * 1000}
@@ -41,24 +33,17 @@ function e2e() { //eslint-disable-line
41 33
                                 --bail`);
42 34
   } finally {
43 35
     if (process.env.CI) {
44
-      shellUtils.exec.kill(`Simulator`);
45
-      shellUtils.exec.kill(`CoreSimulator`);
46
-      shellUtils.exec.execSync(`sleep 5`);
36
+      exec.kill(`Simulator`);
37
+      exec.kill(`CoreSimulator`);
38
+      exec.execSync(`sleep 5`);
47 39
     }
48 40
   }
49 41
 }
50 42
 
51
-function installFbsimctlIfNeeded() {
52
-  if (!isInstalled(`fbsimctl`)) {
53
-    console.log(`installing fbsimctl...`); //eslint-disable-line
54
-    shellUtils.exec.execSyncSilent(`brew tap facebook/fb && brew install fbsimctl`);
55
-  }
56
-}
57
-
58 43
 function run() {
59
-  shellUtils.exec.execSync(`./scripts/ignoreReactWarnings.rb`);
60
-  shellUtils.exec.execSync(`node ./scripts/fixRN38.js`);
61
-  installFbsimctlIfNeeded();
44
+  if (!exec.which(`fbsimctl`)) {
45
+    throw new Error(`fbsimctl must be installed: "brew tap facebook/fb && brew install fbsimctl"`);
46
+  }
62 47
   buildProjForDetox();
63 48
   e2e();
64 49
 }

+ 1
- 5
scripts/test.unit.android.js View File

@@ -1,10 +1,6 @@
1 1
 const exec = require('shell-utils').exec;
2
+run();
2 3
 
3 4
 function run() {
4
-  if (process.env.CI) {
5
-    exec.execSync(`./scripts/installAndroidSDK.sh`);
6
-  }
7 5
   exec.execSync(`cd lib/android && ./gradlew clean testDebugUnitTest`);
8 6
 }
9
-
10
-run();

+ 7
- 17
scripts/test.unit.ios.js View File

@@ -1,32 +1,22 @@
1
-const shellUtils = require('shell-utils');
1
+const exec = require('shell-utils').exec;
2 2
 
3
-function runWithXcprettyIfPossible(cmd) {
4
-  if (hasXcpretty()) {
5
-    shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
3
+function runWithXcpretty(cmd) {
4
+  if (exec.which(`xcpretty`)) {
5
+    exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
6 6
   } else {
7
-    shellUtils.exec.execSync(`${cmd}`);
8
-  }
9
-}
10
-
11
-function hasXcpretty() {
12
-  try {
13
-    return shellUtils.exec.execSyncRead(`which xcpretty`);
14
-  } catch (e) {
15
-    return false;
7
+    exec.execSync(`${cmd}`);
16 8
   }
17 9
 }
18 10
 
19 11
 function run() {
20
-  shellUtils.exec.execSync(`./scripts/ignoreReactWarnings.rb`);
21
-  shellUtils.exec.execSync(`node ./scripts/fixRN38.js`);
22
-  runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
12
+  runWithXcpretty(`RCT_NO_LAUNCH_PACKAGER=true
23 13
           cd ./playground/ios && xcodebuild
24 14
             build build-for-testing
25 15
             -scheme "playground"
26 16
             -project playground.xcodeproj
27 17
             -sdk iphonesimulator
28 18
             -configuration Debug`);
29
-  runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
19
+  runWithXcpretty(`RCT_NO_LAUNCH_PACKAGER=true
30 20
           cd ./playground/ios && xcodebuild
31 21
             test-without-building
32 22
             -scheme "playground"

+ 2
- 2
yarn.lock View File

@@ -4124,8 +4124,8 @@ shell-quote@1.6.1:
4124 4124
     jsonify "~0.0.0"
4125 4125
 
4126 4126
 shell-utils@1.x.x:
4127
-  version "1.0.1"
4128
-  resolved "https://registry.yarnpkg.com/shell-utils/-/shell-utils-1.0.1.tgz#f65f40d05999c49569c0928355e9ede15ad2ce07"
4127
+  version "1.0.2"
4128
+  resolved "https://registry.yarnpkg.com/shell-utils/-/shell-utils-1.0.2.tgz#20b38d7d3f80deaeaeca364204da4e007bc4f59d"
4129 4129
   dependencies:
4130 4130
     lodash "4.x.x"
4131 4131