浏览代码

updating scripts

Daniel Zlotin 8 年前
父节点
当前提交
c57c9b451d
共有 10 个文件被更改,包括 61 次插入103 次删除
  1. 8
    3
      .travis.yml
  2. 0
    14
      scripts/fixRN38.js
  3. 0
    17
      scripts/ignoreReactWarnings.rb
  4. 13
    0
      scripts/installAndroidSdk.js
  5. 12
    12
      scripts/release.js
  6. 5
    5
      scripts/test.all.js
  7. 13
    28
      scripts/test.e2e.ios.js
  8. 1
    5
      scripts/test.unit.android.js
  9. 7
    17
      scripts/test.unit.ios.js
  10. 2
    2
      yarn.lock

+ 8
- 3
.travis.yml 查看文件

25
   - rm -rf $HOME/.gradle/caches/*/plugin-resolution/
25
   - rm -rf $HOME/.gradle/caches/*/plugin-resolution/
26
 
26
 
27
 install:
27
 install:
28
+  - set -e
29
+  # node
28
   - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
30
   - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
29
   - export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
31
   - export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
30
   - nvm install $NODE_VERSION
32
   - nvm install $NODE_VERSION
31
   - nvm use $NODE_VERSION
33
   - nvm use $NODE_VERSION
32
-  - nvm ls
33
-  - gem install xcpretty
34
+  # yarn
34
   - curl -o- -L https://yarnpkg.com/install.sh | bash
35
   - curl -o- -L https://yarnpkg.com/install.sh | bash
35
   - yarn config set cache-folder $YARN_CACHE
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
 script:
43
 script:
39
   - set -e
44
   - set -e

+ 0
- 14
scripts/fixRN38.js 查看文件

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 查看文件

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 查看文件

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 查看文件

1
 /*eslint-disable no-console*/
1
 /*eslint-disable no-console*/
2
-const shellUtils = require('shell-utils');
2
+const exec = require('shell-utils').exec;
3
 const p = require('path');
3
 const p = require('path');
4
 const semver = require('semver');
4
 const semver = require('semver');
5
 
5
 
22
 }
22
 }
23
 
23
 
24
 function setupGit() {
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
 function calcNewVersion() {
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
   console.log(`next tagged version is: ${nextTaggedVersion}`);
35
   console.log(`next tagged version is: ${nextTaggedVersion}`);
36
   return semver.inc(nextTaggedVersion, 'prerelease');
36
   return semver.inc(nextTaggedVersion, 'prerelease');
37
 }
37
 }
38
 
38
 
39
 function copyNpmRc() {
39
 function copyNpmRc() {
40
   const npmrcPath = p.resolve(`${__dirname}/.npmrc`);
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
 function tagAndPublish(newVersion) {
44
 function tagAndPublish(newVersion) {
45
   console.log(`new version is: ${newVersion}`);
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
 function run() {
51
 function run() {

+ 5
- 5
scripts/test.all.js 查看文件

1
-const shellUtils = require('shell-utils');
1
+const exec = require('shell-utils').exec;
2
 
2
 
3
 function run() {
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
 run();
10
 run();

+ 13
- 28
scripts/test.e2e.ios.js 查看文件

1
 const _ = require('lodash');
1
 const _ = require('lodash');
2
-const shellUtils = require('shell-utils');
2
+const exec = require('shell-utils').exec;
3
 
3
 
4
 const release = _.includes(process.argv, 'release');
4
 const release = _.includes(process.argv, 'release');
5
 
5
 
6
 function buildProjForDetox() {
6
 function buildProjForDetox() {
7
   const scheme = release ? `playground_release` : `playground`;
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
             -scheme ${scheme}
10
             -scheme ${scheme}
12
             ${release ? 'clean build' : 'build'}
11
             ${release ? 'clean build' : 'build'}
13
             -project playground.xcodeproj
12
             -project playground.xcodeproj
14
             -sdk iphonesimulator
13
             -sdk iphonesimulator
15
             -derivedDataPath ./DerivedData/playground`;
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
   } else {
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
 function e2e() { //eslint-disable-line
23
 function e2e() { //eslint-disable-line
32
   try {
24
   try {
33
-    shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
25
+    exec.execSyncSilent(`watchman watch-del-all || true`);
34
     const detoxAppBuildPath = `playground/ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
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
                               BABEL_ENV=test
29
                               BABEL_ENV=test
38
                               ./node_modules/mocha/bin/mocha e2e
30
                               ./node_modules/mocha/bin/mocha e2e
39
                                 --timeout ${2 * 60 * 1000}
31
                                 --timeout ${2 * 60 * 1000}
41
                                 --bail`);
33
                                 --bail`);
42
   } finally {
34
   } finally {
43
     if (process.env.CI) {
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
 function run() {
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
   buildProjForDetox();
47
   buildProjForDetox();
63
   e2e();
48
   e2e();
64
 }
49
 }

+ 1
- 5
scripts/test.unit.android.js 查看文件

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

+ 7
- 17
scripts/test.unit.ios.js 查看文件

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
   } else {
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
 function run() {
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
           cd ./playground/ios && xcodebuild
13
           cd ./playground/ios && xcodebuild
24
             build build-for-testing
14
             build build-for-testing
25
             -scheme "playground"
15
             -scheme "playground"
26
             -project playground.xcodeproj
16
             -project playground.xcodeproj
27
             -sdk iphonesimulator
17
             -sdk iphonesimulator
28
             -configuration Debug`);
18
             -configuration Debug`);
29
-  runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
19
+  runWithXcpretty(`RCT_NO_LAUNCH_PACKAGER=true
30
           cd ./playground/ios && xcodebuild
20
           cd ./playground/ios && xcodebuild
31
             test-without-building
21
             test-without-building
32
             -scheme "playground"
22
             -scheme "playground"

+ 2
- 2
yarn.lock 查看文件

4124
     jsonify "~0.0.0"
4124
     jsonify "~0.0.0"
4125
 
4125
 
4126
 shell-utils@1.x.x:
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
   dependencies:
4129
   dependencies:
4130
     lodash "4.x.x"
4130
     lodash "4.x.x"
4131
 
4131