react-native-navigation的迁移库

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. const _ = require('lodash');
  2. const shellUtils = require('shell-utils');
  3. const fs = require('fs');
  4. const release = _.includes(process.argv, 'release');
  5. function buildProjForDetox() {
  6. const scheme = release ? `playground_release` : `playground`;
  7. shellUtils.exec.execSync(`echo 'travis_fold:start:xcodebuild'`);
  8. const cmd = `RCT_NO_LAUNCH_PACKAGER=true
  9. cd ios && xcodebuild
  10. -scheme ${scheme}
  11. ${release ? 'clean build' : 'build'}
  12. -project playground.xcodeproj
  13. -sdk iphonesimulator
  14. -derivedDataPath ./DerivedData/playground`;
  15. if (hasXcpretty()) {
  16. shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
  17. } else {
  18. shellUtils.exec.execSync(`${cmd}`);
  19. }
  20. shellUtils.exec.execSync(`echo 'travis_fold:end:xcodebuild'`);
  21. }
  22. function hasXcpretty() {
  23. try {
  24. return shellUtils.exec.execSyncRead(`which xcpretty`);
  25. } catch (e) {
  26. return false;
  27. }
  28. }
  29. function e2e() { //eslint-disable-line
  30. try {
  31. shellUtils.exec.execSync(`echo 'travis_fold:start:detox-ios'`);
  32. shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
  33. shellUtils.exec.kill(`detox-server`);
  34. shellUtils.exec.exec(`./node_modules/.bin/detox-server`);
  35. const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
  36. shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  37. BABEL_ENV=test
  38. ./node_modules/mocha/bin/mocha e2e
  39. --timeout ${10 * 60 * 1000}
  40. --recursive
  41. --compilers js:babel-register`);
  42. } finally {
  43. shellUtils.exec.kill(`detox-server`);
  44. if (process.env.CI) {
  45. shellUtils.exec.kill(`Simulator`);
  46. shellUtils.exec.kill(`CoreSimulator`);
  47. shellUtils.exec.execSync(`sleep 5`);
  48. }
  49. shellUtils.exec.execSync(`echo 'travis_fold:end:detox-ios'`);
  50. }
  51. }
  52. function run() {
  53. buildProjForDetox();
  54. if (process.env.TRAVIS) {
  55. console.warn('skipping e2e temporarily due to fbsimctl is currently broken'); //eslint-disable-line
  56. }
  57. e2e();
  58. }
  59. run();