expo-test-runner 0.0.9 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/.eslintrc.js +2 -28
  2. package/build/BundlerController.js +7 -8
  3. package/build/BundlerController.js.map +1 -1
  4. package/build/ConfigReader.js +1 -1
  5. package/build/ConfigReader.js.map +1 -1
  6. package/build/Paths.js +1 -1
  7. package/build/Paths.js.map +1 -1
  8. package/build/TemplateEvaluator.js +6 -2
  9. package/build/TemplateEvaluator.js.map +1 -1
  10. package/build/TemplateFile.js +9 -5
  11. package/build/TemplateFile.js.map +1 -1
  12. package/build/TemplateProject.d.ts +25 -0
  13. package/build/TemplateProject.js +168 -0
  14. package/build/TemplateProject.js.map +1 -0
  15. package/build/Utils.js +4 -4
  16. package/build/Utils.js.map +1 -1
  17. package/build/commands/CreateProject.js +3 -3
  18. package/build/commands/CreateProject.js.map +1 -1
  19. package/build/commands/RunTest.js +8 -4
  20. package/build/commands/RunTest.js.map +1 -1
  21. package/build/index.js +1 -1
  22. package/build/index.js.map +1 -1
  23. package/build/registerCommand.js +6 -3
  24. package/build/registerCommand.js.map +1 -1
  25. package/package.json +26 -21
  26. package/src/BundlerController.ts +2 -2
  27. package/src/TemplateProject.ts +209 -0
  28. package/src/Utils.ts +2 -2
  29. package/src/commands/CreateProject.ts +2 -2
  30. package/src/commands/RunTest.ts +2 -2
  31. package/src/index.ts +1 -1
  32. package/src/registerCommand.ts +1 -1
  33. package/templates/detox/android/app/build.gradle +202 -24
  34. package/templates/detox/android/app/src/androidTest/java/com/testrunner/DetoxTest.java +79 -18
  35. package/templates/detox/android/app/src/main/java/com/testrunner/MainApplication.java +129 -0
  36. package/templates/detox/android/build.gradle +34 -17
  37. package/templates/detox/ios/devcliente2e/main.m +31 -0
  38. package/tsconfig.json +1 -1
  39. package/.prettierrc +0 -10
  40. package/build/Platform.ds.d.ts +0 -4
  41. package/build/Platform.ds.js +0 -9
  42. package/build/Platform.ds.js.map +0 -1
  43. package/build/ProjectFile.d.ts +0 -0
  44. package/build/ProjectFile.js +0 -2
  45. package/build/ProjectFile.js.map +0 -1
  46. package/build/TemplateParser.d.ts +0 -6
  47. package/build/TemplateParser.js +0 -37
  48. package/build/TemplateParser.js.map +0 -1
  49. package/build/commands/create-project.d.ts +0 -3
  50. package/build/commands/create-project.js +0 -12
  51. package/build/commands/create-project.js.map +0 -1
  52. package/build/presets/DetoxTemplate.d.ts +0 -13
  53. package/build/presets/DetoxTemplate.js +0 -79
  54. package/build/presets/DetoxTemplate.js.map +0 -1
  55. package/build/presets/PresetTemplate.d.ts +0 -25
  56. package/build/presets/PresetTemplate.js +0 -147
  57. package/build/presets/PresetTemplate.js.map +0 -1
  58. package/src/presets/DetoxTemplate.ts +0 -94
  59. package/src/presets/PresetTemplate.ts +0 -171
  60. package/templates/basic/android/app/BUCK +0 -55
  61. package/templates/basic/android/app/build.gradle +0 -188
  62. package/templates/basic/android/app/build_defs.bzl +0 -19
  63. package/templates/basic/android/app/debug.keystore +0 -0
  64. package/templates/basic/android/app/proguard-rules.pro +0 -10
  65. package/templates/basic/android/app/src/main/AndroidManifest.xml +0 -16
  66. package/templates/basic/android/app/src/main/java/com/testrunner/MainActivity.java +0 -28
  67. package/templates/basic/android/app/src/main/java/com/testrunner/MainApplication.java +0 -57
  68. package/templates/basic/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  69. package/templates/basic/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  70. package/templates/basic/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  71. package/templates/basic/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  72. package/templates/basic/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  73. package/templates/basic/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  74. package/templates/basic/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  75. package/templates/basic/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  76. package/templates/basic/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  77. package/templates/basic/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  78. package/templates/basic/android/app/src/main/res/values/styles.xml +0 -14
  79. package/templates/basic/android/build.gradle +0 -38
  80. package/templates/basic/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  81. package/templates/basic/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  82. package/templates/basic/android/gradle.properties +0 -26
  83. package/templates/basic/android/gradlew +0 -183
  84. package/templates/basic/android/gradlew.bat +0 -103
  85. package/templates/basic/android/settings.gradle +0 -10
  86. package/templates/basic/babel.config.js +0 -6
  87. package/templates/basic/ios/Podfile +0 -37
  88. package/templates/basic/ios/project.yml +0 -10
  89. package/templates/basic/ios/src/AppDelegate.h +0 -9
  90. package/templates/basic/ios/src/AppDelegate.m +0 -62
  91. package/templates/basic/ios/src/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
  92. package/templates/basic/ios/src/Images.xcassets/Contents.json +0 -6
  93. package/templates/basic/ios/src/Info.plist +0 -55
  94. package/templates/basic/ios/src/LaunchScreen.storyboard +0 -47
  95. package/templates/basic/ios/src/dummy.swift +0 -0
  96. package/templates/basic/ios/src/main.m +0 -9
  97. package/templates/basic/package.json +0 -37
  98. package/templates/basic/tsconfig.json +0 -6
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -45,7 +49,6 @@ function registerCommand(commander, commandName, fn) {
45
49
  .option('--platform <platform>', 'Platform for which the project should be created. Available options: `ios`, `android`, `both`.')
46
50
  .option('-p, --path <string>', 'Location where the test app will be created.')
47
51
  .action(async (providedOptions) => {
48
- var _a;
49
52
  if (providedOptions.platform) {
50
53
  providedOptions.platform = mapPlatform(providedOptions.platform);
51
54
  }
@@ -54,7 +57,7 @@ function registerCommand(commander, commandName, fn) {
54
57
  }
55
58
  // clean temp folder if the path wasn't provided.
56
59
  providedOptions.shouldBeCleaned = !providedOptions.path;
57
- providedOptions.path = (_a = providedOptions.path) !== null && _a !== void 0 ? _a : tempy.directory();
60
+ providedOptions.path = providedOptions.path ?? tempy.directory();
58
61
  providedOptions.configFile = ConfigReader_1.default.getFilePath(providedOptions.configFile);
59
62
  const options = providedOptions;
60
63
  const configReader = new ConfigReader_1.default(options.configFile);
@@ -1 +1 @@
1
- {"version":3,"file":"registerCommand.js","sourceRoot":"","sources":["../src/registerCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA+B;AAG/B,kEAA0C;AAC1C,yCAAsC;AAStC,SAAS,WAAW,CAAC,QAAgB;IACnC,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,OAAO,mBAAQ,CAAC,OAAO,CAAC;KACzB;SAAM,IAAI,QAAQ,KAAK,KAAK,EAAE;QAC7B,OAAO,mBAAQ,CAAC,GAAG,CAAC;KACrB;SAAM,IAAI,QAAQ,KAAK,MAAM,EAAE;QAC9B,OAAO,mBAAQ,CAAC,IAAI,CAAC;KACtB;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,eAAe,CAC7B,SAA0B,EAC1B,WAAmB,EACnB,EAA0D;IAE1D,OAAO,SAAS;SACb,OAAO,CAAC,WAAW,CAAC;SACpB,MAAM,CAAC,qBAAqB,EAAE,0BAA0B,CAAC;SACzD,MAAM,CACL,uBAAuB,EACvB,gGAAgG,CACjG;SACA,MAAM,CAAC,qBAAqB,EAAE,8CAA8C,CAAC;SAC7E,MAAM,CAAC,KAAK,EAAC,eAAe,EAAC,EAAE;;QAC9B,IAAI,eAAe,CAAC,QAAQ,EAAE;YAC5B,eAAe,CAAC,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;SAClE;aAAM;YACL,eAAe,CAAC,QAAQ,GAAG,mBAAQ,CAAC,IAAI,CAAC;SAC1C;QAED,iDAAiD;QACjD,eAAe,CAAC,eAAe,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC;QACxD,eAAe,CAAC,IAAI,GAAG,MAAA,eAAe,CAAC,IAAI,mCAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QAEjE,eAAe,CAAC,UAAU,GAAG,sBAAY,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAElF,MAAM,OAAO,GAAG,eAA8B,CAAC;QAC/C,MAAM,YAAY,GAAG,IAAI,sBAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE1D,IAAI;YACF,MAAM,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;SAClD;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AApCD,0CAoCC","sourcesContent":["import { CommanderStatic } from 'commander';\nimport * as tempy from 'tempy';\n\nimport { Config } from './Config';\nimport ConfigReader from './ConfigReader';\nimport { Platform } from './Platform';\n\nexport interface DefaultOptions {\n configFile: string;\n platform: Platform;\n path: string;\n shouldBeCleaned: boolean;\n}\n\nfunction mapPlatform(platform: string): Platform {\n if (platform === 'android') {\n return Platform.Android;\n } else if (platform === 'ios') {\n return Platform.iOS;\n } else if (platform === 'both') {\n return Platform.Both;\n }\n\n throw new Error(`Unknown platform: ${platform}`);\n}\n\nexport function registerCommand<OptionsType extends DefaultOptions>(\n commander: CommanderStatic,\n commandName: string,\n fn: (config: Config, options: OptionsType) => Promise<any>\n) {\n return commander\n .command(commandName)\n .option('-c, --config <path>', 'Path to the config file.')\n .option(\n '--platform <platform>',\n 'Platform for which the project should be created. Available options: `ios`, `android`, `both`.'\n )\n .option('-p, --path <string>', 'Location where the test app will be created.')\n .action(async providedOptions => {\n if (providedOptions.platform) {\n providedOptions.platform = mapPlatform(providedOptions.platform);\n } else {\n providedOptions.platform = Platform.Both;\n }\n\n // clean temp folder if the path wasn't provided.\n providedOptions.shouldBeCleaned = !providedOptions.path;\n providedOptions.path = providedOptions.path ?? tempy.directory();\n\n providedOptions.configFile = ConfigReader.getFilePath(providedOptions.configFile);\n\n const options = providedOptions as OptionsType;\n const configReader = new ConfigReader(options.configFile);\n\n try {\n await fn(configReader.readConfigFile(), options);\n } catch (e) {\n console.error(e);\n process.exit(1);\n }\n });\n}\n"]}
1
+ {"version":3,"file":"registerCommand.js","sourceRoot":"","sources":["../src/registerCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA+B;AAG/B,kEAA0C;AAC1C,yCAAsC;AAStC,SAAS,WAAW,CAAC,QAAgB;IACnC,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,OAAO,mBAAQ,CAAC,OAAO,CAAC;KACzB;SAAM,IAAI,QAAQ,KAAK,KAAK,EAAE;QAC7B,OAAO,mBAAQ,CAAC,GAAG,CAAC;KACrB;SAAM,IAAI,QAAQ,KAAK,MAAM,EAAE;QAC9B,OAAO,mBAAQ,CAAC,IAAI,CAAC;KACtB;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,eAAe,CAC7B,SAA0B,EAC1B,WAAmB,EACnB,EAA0D;IAE1D,OAAO,SAAS;SACb,OAAO,CAAC,WAAW,CAAC;SACpB,MAAM,CAAC,qBAAqB,EAAE,0BAA0B,CAAC;SACzD,MAAM,CACL,uBAAuB,EACvB,gGAAgG,CACjG;SACA,MAAM,CAAC,qBAAqB,EAAE,8CAA8C,CAAC;SAC7E,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE;QAChC,IAAI,eAAe,CAAC,QAAQ,EAAE;YAC5B,eAAe,CAAC,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;SAClE;aAAM;YACL,eAAe,CAAC,QAAQ,GAAG,mBAAQ,CAAC,IAAI,CAAC;SAC1C;QAED,iDAAiD;QACjD,eAAe,CAAC,eAAe,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC;QACxD,eAAe,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QAEjE,eAAe,CAAC,UAAU,GAAG,sBAAY,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAElF,MAAM,OAAO,GAAG,eAA8B,CAAC;QAC/C,MAAM,YAAY,GAAG,IAAI,sBAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE1D,IAAI;YACF,MAAM,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;SAClD;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AApCD,0CAoCC","sourcesContent":["import { CommanderStatic } from 'commander';\nimport * as tempy from 'tempy';\n\nimport { Config } from './Config';\nimport ConfigReader from './ConfigReader';\nimport { Platform } from './Platform';\n\nexport interface DefaultOptions {\n configFile: string;\n platform: Platform;\n path: string;\n shouldBeCleaned: boolean;\n}\n\nfunction mapPlatform(platform: string): Platform {\n if (platform === 'android') {\n return Platform.Android;\n } else if (platform === 'ios') {\n return Platform.iOS;\n } else if (platform === 'both') {\n return Platform.Both;\n }\n\n throw new Error(`Unknown platform: ${platform}`);\n}\n\nexport function registerCommand<OptionsType extends DefaultOptions>(\n commander: CommanderStatic,\n commandName: string,\n fn: (config: Config, options: OptionsType) => Promise<any>\n) {\n return commander\n .command(commandName)\n .option('-c, --config <path>', 'Path to the config file.')\n .option(\n '--platform <platform>',\n 'Platform for which the project should be created. Available options: `ios`, `android`, `both`.'\n )\n .option('-p, --path <string>', 'Location where the test app will be created.')\n .action(async (providedOptions) => {\n if (providedOptions.platform) {\n providedOptions.platform = mapPlatform(providedOptions.platform);\n } else {\n providedOptions.platform = Platform.Both;\n }\n\n // clean temp folder if the path wasn't provided.\n providedOptions.shouldBeCleaned = !providedOptions.path;\n providedOptions.path = providedOptions.path ?? tempy.directory();\n\n providedOptions.configFile = ConfigReader.getFilePath(providedOptions.configFile);\n\n const options = providedOptions as OptionsType;\n const configReader = new ConfigReader(options.configFile);\n\n try {\n await fn(configReader.readConfigFile(), options);\n } catch (e) {\n console.error(e);\n process.exit(1);\n }\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-test-runner",
3
- "version": "0.0.9",
3
+ "version": "0.0.12",
4
4
  "description": "Script that enchants test experience.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -10,36 +10,41 @@
10
10
  "expo-test-runner": "bin/expo-test-runner.js"
11
11
  },
12
12
  "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/expo/expo-test-runner.git"
15
- },
13
+ "type": "git",
14
+ "url": "git+https://github.com/expo/expo-test-runner.git"
15
+ },
16
16
  "bugs": {
17
- "url": "https://github.com/expo/expo-test-runner/issues"
18
- },
19
- "homepage": "https://github.com/expo/expo-test-runner#readme",
17
+ "url": "https://github.com/expo/expo-test-runner/issues"
18
+ },
19
+ "homepage": "https://github.com/expo/expo-test-runner#readme",
20
20
  "scripts": {
21
- "build": "tsc --watch --preserveWatchOutput"
21
+ "build": "expo-module build",
22
+ "clean": "expo-module clean",
23
+ "lint": "expo-module lint",
24
+ "test": "expo-module test",
25
+ "prepare": "expo-module prepare",
26
+ "prepublishOnly": "expo-module prepublishOnly",
27
+ "expo-module": "expo-module"
22
28
  },
23
29
  "devDependencies": {
24
30
  "@babel/core": "^7.9.0",
25
- "@tsconfig/node12": "^1.0.7",
31
+ "@tsconfig/node14": "^1.0.3",
26
32
  "@types/fs-extra": "^9.0.1",
27
- "@types/node": "^12",
28
- "eslint": "^7.25.0",
29
- "eslint-config-universe": "^5.0.0",
30
- "prettier": "^2.2.1",
31
- "typescript": "^4.2.4",
32
- "@types/node-fetch": "^2.5.12"
33
+ "@types/node": "^16.18.11",
34
+ "@types/node-fetch": "^2.5.12",
35
+ "eslint-config-universe": "^11.1.0",
36
+ "expo-module-scripts": "^3.0.0",
37
+ "typescript": "^4.9.4"
33
38
  },
34
39
  "dependencies": {
35
40
  "@babel/runtime": "7.9.0",
36
- "dot": "^2.0.0-beta.1",
37
41
  "@expo/spawn-async": "^1.5.0",
42
+ "chalk": "^4.1.2",
38
43
  "commander": "^7.2.0",
44
+ "dot": "^2.0.0-beta.1",
39
45
  "fs-extra": "^10.0.0",
40
- "@expo/xcodegen": "2.18.0-patch.1",
41
- "chalk": "^4.1.2",
42
- "tempy": "^0.7.1",
43
- "node-fetch": "^2.6.1"
44
- }
46
+ "node-fetch": "^2.6.1",
47
+ "tempy": "^0.7.1"
48
+ },
49
+ "gitHead": "1f8a6a09570fd451378565ca34933018ce48454e"
45
50
  }
@@ -29,7 +29,7 @@ export default class BundlerController {
29
29
  const interval = setInterval(() => {
30
30
  try {
31
31
  process.kill(pid, 0);
32
- } catch (e) {
32
+ } catch {
33
33
  clearInterval(interval);
34
34
  // the process does not exists anymore
35
35
  resolve();
@@ -55,7 +55,7 @@ export default class BundlerController {
55
55
  if (bundlerStatus.status === 200) {
56
56
  return;
57
57
  }
58
- } catch (ignore) {}
58
+ } catch {}
59
59
 
60
60
  await delay(500);
61
61
  }
@@ -0,0 +1,209 @@
1
+ import spawnAsync from '@expo/spawn-async';
2
+ import { Definitions } from 'dot';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+
6
+ import BundlerController from './BundlerController';
7
+ import { Application, DetoxTest } from './Config';
8
+ import { Platform } from './Platform';
9
+ import TemplateEvaluator from './TemplateEvaluator';
10
+ import { ProjectFile, TemplateFilesFactory, UserFile } from './TemplateFile';
11
+ import { killVirtualDevicesAsync } from './Utils';
12
+
13
+ export default class TemplateProject {
14
+ constructor(
15
+ protected config: Application,
16
+ protected name: string,
17
+ protected platform: Platform,
18
+ protected configFilePath: string
19
+ ) {}
20
+
21
+ getDefinitions(): Definitions {
22
+ return {
23
+ name: 'devcliente2e',
24
+ appEntryPoint: 'e2e/app/App',
25
+ };
26
+ }
27
+
28
+ async createApplicationAsync(projectPath: string) {
29
+ // TODO: this assumes there is a parent folder
30
+ const parentFolder = path.resolve(projectPath, '..');
31
+ if (!fs.existsSync(parentFolder)) {
32
+ fs.mkdirSync(parentFolder, { recursive: true });
33
+ }
34
+
35
+ const appName = 'dev-client-e2e';
36
+ await spawnAsync('yarn', ['create', 'expo-app', appName], {
37
+ stdio: 'inherit',
38
+ cwd: parentFolder,
39
+ });
40
+ fs.renameSync(path.join(parentFolder, appName), projectPath);
41
+
42
+ const repoRoot = path.resolve(this.configFilePath, '..', '..', '..');
43
+ const localCliBin = path.join(repoRoot, 'packages/@expo/cli/build/bin/cli');
44
+ await spawnAsync(localCliBin, ['install', 'detox', 'jest'], {
45
+ stdio: 'inherit',
46
+ cwd: projectPath,
47
+ });
48
+
49
+ // add local dependencies
50
+ let packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf-8'));
51
+ packageJson = {
52
+ ...packageJson,
53
+ dependencies: {
54
+ ...packageJson.dependencies,
55
+ 'expo-dev-client': `file:${repoRoot}/packages/expo-dev-client`,
56
+ 'expo-dev-menu-interface': `file:${repoRoot}/packages/expo-dev-menu-interface`,
57
+ 'expo-status-bar': `file:${repoRoot}/packages/expo-status-bar`,
58
+ expo: `file:${repoRoot}/packages/expo`,
59
+ 'jest-circus': packageJson.dependencies.jest,
60
+ },
61
+ resolutions: {
62
+ ...packageJson.resolutions,
63
+ 'expo-application': `file:${repoRoot}/packages/expo-application`,
64
+ 'expo-asset': `file:${repoRoot}/packages/expo-asset`,
65
+ 'expo-constants': `file:${repoRoot}/packages/expo-constants`,
66
+ 'expo-dev-launcher': `file:${repoRoot}/packages/expo-dev-launcher`,
67
+ 'expo-dev-menu': `file:${repoRoot}/packages/expo-dev-menu`,
68
+ 'expo-error-recovery': `file:${repoRoot}/packages/expo-error-recovery`,
69
+ 'expo-file-system': `file:${repoRoot}/packages/expo-file-system`,
70
+ 'expo-font': `file:${repoRoot}/packages/expo-font`,
71
+ 'expo-keep-awake': `file:${repoRoot}/packages/expo-keep-awake`,
72
+ 'expo-manifests': `file:${repoRoot}/packages/expo-manifests`,
73
+ 'expo-modules-autolinking': `file:${repoRoot}/packages/expo-modules-autolinking`,
74
+ 'expo-modules-core': `file:${repoRoot}/packages/expo-modules-core`,
75
+ 'expo-updates-interface': `file:${repoRoot}/packages/expo-updates-interface`,
76
+ },
77
+ };
78
+ fs.writeFileSync(
79
+ path.join(projectPath, 'package.json'),
80
+ JSON.stringify(packageJson, null, 2),
81
+ 'utf-8'
82
+ );
83
+
84
+ // configure app.json
85
+ let appJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'app.json'), 'utf-8'));
86
+ appJson = {
87
+ ...appJson,
88
+ expo: {
89
+ ...appJson.expo,
90
+ android: { ...appJson.android, package: 'com.testrunner' },
91
+ ios: { ...appJson.ios, bundleIdentifier: 'com.testrunner' },
92
+ },
93
+ };
94
+ fs.writeFileSync(path.join(projectPath, 'app.json'), JSON.stringify(appJson, null, 2), 'utf-8');
95
+
96
+ // pack local template and prebuild
97
+ const localTemplatePath = path.join(repoRoot, 'templates', 'expo-template-bare-minimum');
98
+ await spawnAsync('npm', ['pack', '--pack-destination', projectPath], {
99
+ cwd: localTemplatePath,
100
+ stdio: 'inherit',
101
+ });
102
+ const templateVersion = require(path.join(localTemplatePath, 'package.json')).version;
103
+
104
+ await spawnAsync(
105
+ localCliBin,
106
+ ['prebuild', '--template', `expo-template-bare-minimum-${templateVersion}.tgz`],
107
+ {
108
+ stdio: 'inherit',
109
+ cwd: projectPath,
110
+ }
111
+ );
112
+
113
+ const templateFiles = this.getTemplateFiles();
114
+ await this.copyFilesAsync(projectPath, templateFiles);
115
+ await this.evaluateFiles(projectPath, templateFiles);
116
+
117
+ // workaround for instrumented unit test files not compiling in this
118
+ // configuration (ignored in .npmignore)
119
+ await spawnAsync('rm', ['-rf', 'node_modules/expo-dev-client/android/src/androidTest'], {
120
+ stdio: 'inherit',
121
+ cwd: projectPath,
122
+ });
123
+ }
124
+
125
+ getTemplateFiles(): { [path: string]: ProjectFile } {
126
+ const tff = new TemplateFilesFactory('detox');
127
+
128
+ const additionalFiles: { [path: string]: ProjectFile } = this.config.additionalFiles?.reduce(
129
+ (reducer, file) => ({
130
+ ...reducer,
131
+ [file]: new UserFile(this.userFilePath(file)),
132
+ }),
133
+ {}
134
+ );
135
+
136
+ if (this.config.android?.detoxTestFile) {
137
+ additionalFiles['android/app/src/androidTest/java/com/testrunner/DetoxTest.java'] =
138
+ new UserFile(this.userFilePath(this.config.android.detoxTestFile), Platform.Android);
139
+ }
140
+
141
+ return {
142
+ 'android/build.gradle': tff.androidFile(),
143
+ 'android/app/build.gradle': tff.androidFile(),
144
+ 'android/app/src/androidTest/java/com/testrunner/DetoxTest.java': tff.androidFile(),
145
+ 'android/app/src/main/java/com/testrunner/MainApplication.java': tff.androidFile(),
146
+ 'index.js': tff.file(true),
147
+ 'ios/devcliente2e/main.m': tff.iosFile(),
148
+ [this.config.detoxConfigFile]: new UserFile(
149
+ this.userFilePath(this.config.detoxConfigFile),
150
+ Platform.Both,
151
+ true
152
+ ),
153
+ ...additionalFiles,
154
+ };
155
+ }
156
+
157
+ protected userFilePath(relativePath: string): string {
158
+ return path.join(this.configFilePath, '..', relativePath);
159
+ }
160
+
161
+ protected async copyFilesAsync(projectPath: string, files: { [path: string]: ProjectFile }) {
162
+ await Promise.all(Object.entries(files).map(([path, file]) => file.copy(projectPath, path)));
163
+ }
164
+
165
+ protected async evaluateFiles(projectPath: string, files: { [path: string]: ProjectFile }) {
166
+ const templateEvaluator = new TemplateEvaluator(this.getDefinitions());
167
+ await Promise.all(
168
+ Object.entries(files).map(([path, file]) =>
169
+ file.evaluate(projectPath, path, templateEvaluator)
170
+ )
171
+ );
172
+ }
173
+
174
+ async build(projectPath: string, test: DetoxTest): Promise<void> {
175
+ for (const conf of test.configurations) {
176
+ await spawnAsync('yarn', ['detox', 'build', '-c', conf], {
177
+ cwd: projectPath,
178
+ stdio: 'inherit',
179
+ });
180
+ }
181
+ }
182
+
183
+ async run(projectPath: string, test: DetoxTest): Promise<void> {
184
+ let bundler: BundlerController | undefined;
185
+ try {
186
+ bundler = new BundlerController(projectPath);
187
+
188
+ if (test.shouldRunBundler) {
189
+ await bundler.start();
190
+ }
191
+
192
+ for (const conf of test.configurations) {
193
+ await spawnAsync(
194
+ 'yarn',
195
+ ['detox', 'test', '-c', conf, '--ci', '--headless', '--gpu', 'swiftshader_indirect'],
196
+ {
197
+ cwd: projectPath,
198
+ stdio: 'inherit',
199
+ }
200
+ );
201
+
202
+ await killVirtualDevicesAsync(this.platform);
203
+ }
204
+ } finally {
205
+ // If bundler wasn't started is noop.
206
+ await bundler?.stop();
207
+ }
208
+ }
209
+ }
package/src/Utils.ts CHANGED
@@ -7,8 +7,8 @@ export function yarnInstall(path: string) {
7
7
  spawnSync('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });
8
8
  }
9
9
 
10
- export const delay: (ms: number) => Promise<void> = ms =>
11
- new Promise(resolve => setTimeout(resolve, ms));
10
+ export const delay: (ms: number) => Promise<void> = (ms) =>
11
+ new Promise((resolve) => setTimeout(resolve, ms));
12
12
 
13
13
  export async function killEmulatorAsync(): Promise<void> {
14
14
  try {
@@ -2,7 +2,7 @@ import chalk from 'chalk';
2
2
  import { CommanderStatic } from 'commander';
3
3
 
4
4
  import { Config } from '../Config';
5
- import DetoxPreset from '../presets/DetoxTemplate';
5
+ import TemplateProject from '../TemplateProject';
6
6
  import { DefaultOptions, registerCommand } from '../registerCommand';
7
7
 
8
8
  interface CreateProjectOptions extends DefaultOptions {
@@ -14,7 +14,7 @@ async function createProjectAsync(config: Config, options: CreateProjectOptions)
14
14
 
15
15
  if (app.preset === 'detox') {
16
16
  console.log(`Using ${chalk.green('detox')} preset.`);
17
- const preset = new DetoxPreset(app, options.app, options.platform, options.configFile);
17
+ const preset = new TemplateProject(app, options.app, options.platform, options.configFile);
18
18
 
19
19
  console.log(`Creating test app in ${chalk.green(options.path)}.`);
20
20
  await preset.createApplicationAsync(options.path);
@@ -3,7 +3,7 @@ import { CommanderStatic } from 'commander';
3
3
  import * as fs from 'fs-extra';
4
4
 
5
5
  import { Application, Config } from '../Config';
6
- import DetoxPreset from '../presets/DetoxTemplate';
6
+ import TemplateProject from '../TemplateProject';
7
7
  import { DefaultOptions, registerCommand } from '../registerCommand';
8
8
 
9
9
  interface RunTestOptions extends DefaultOptions {
@@ -30,7 +30,7 @@ async function runTestAsync(config: Config, options: RunTestOptions) {
30
30
 
31
31
  if (app.preset === 'detox') {
32
32
  console.log(`Using ${chalk.green('detox')} preset.`);
33
- const preset = new DetoxPreset(app, appName, options.platform, options.configFile);
33
+ const preset = new TemplateProject(app, appName, options.platform, options.configFile);
34
34
 
35
35
  console.log(`Creating test app in ${chalk.green(options.path)}.`);
36
36
  await preset.createApplicationAsync(options.path);
package/src/index.ts CHANGED
@@ -4,6 +4,6 @@ import CreateProject from './commands/CreateProject';
4
4
  import RunTest from './commands/RunTest';
5
5
 
6
6
  const program = commander.version('0.0.1');
7
- [CreateProject, RunTest].forEach(command => command(program));
7
+ [CreateProject, RunTest].forEach((command) => command(program));
8
8
 
9
9
  program.parse(process.argv);
@@ -37,7 +37,7 @@ export function registerCommand<OptionsType extends DefaultOptions>(
37
37
  'Platform for which the project should be created. Available options: `ios`, `android`, `both`.'
38
38
  )
39
39
  .option('-p, --path <string>', 'Location where the test app will be created.')
40
- .action(async providedOptions => {
40
+ .action(async (providedOptions) => {
41
41
  if (providedOptions.platform) {
42
42
  providedOptions.platform = mapPlatform(providedOptions.platform);
43
43
  } else {