expo-test-runner 0.0.10 → 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
package/.eslintrc.js CHANGED
@@ -1,28 +1,2 @@
1
- module.exports = {
2
- root: true,
3
- extends: ['universe/node'],
4
- overrides: [
5
- {
6
- files: ['**/__tests__/*'],
7
- },
8
- ],
9
- globals: {
10
- jasmine: false,
11
- },
12
- rules: {
13
- 'no-constant-condition': ['warn', { checkLoops: false }],
14
- 'sort-imports': [
15
- 'warn',
16
- {
17
- ignoreCase: true,
18
- ignoreDeclarationSort: true,
19
- },
20
- ],
21
- 'flowtype/no-types-missing-file-annotation': 'off',
22
- },
23
- settings: {
24
- react: {
25
- version: 'detect',
26
- },
27
- },
28
- };
1
+ // @generated by expo-module-scripts
2
+ module.exports = require('expo-module-scripts/eslintrc.base.js');
@@ -11,13 +11,12 @@ class BundlerController {
11
11
  this.path = path;
12
12
  }
13
13
  async start() {
14
- const bundler = child_process_1.spawn('yarn', ['start'], { cwd: this.path, stdio: 'inherit' });
15
- await Utils_1.delay(1000);
14
+ const bundler = (0, child_process_1.spawn)('yarn', ['start'], { cwd: this.path, stdio: 'inherit' });
15
+ await (0, Utils_1.delay)(1000);
16
16
  this.ensureBundlerWasStarted();
17
17
  this.process = bundler;
18
18
  }
19
19
  async stop() {
20
- var _a;
21
20
  try {
22
21
  // Fixes:
23
22
  // Error: read EIO
@@ -31,7 +30,7 @@ class BundlerController {
31
30
  try {
32
31
  process.kill(pid, 0);
33
32
  }
34
- catch (e) {
33
+ catch {
35
34
  clearInterval(interval);
36
35
  // the process does not exists anymore
37
36
  resolve();
@@ -42,7 +41,7 @@ class BundlerController {
42
41
  }
43
42
  }, 100);
44
43
  });
45
- await killProcess((_a = this.process) === null || _a === void 0 ? void 0 : _a.pid, 2000);
44
+ await killProcess(this.process?.pid, 2000);
46
45
  }
47
46
  catch (error) {
48
47
  console.log(`Cannot kill bundler: ${error}.`);
@@ -52,13 +51,13 @@ class BundlerController {
52
51
  let retries = 10;
53
52
  while (retries-- > 0) {
54
53
  try {
55
- const bundlerStatus = await node_fetch_1.default('http://localhost:8081/status');
54
+ const bundlerStatus = await (0, node_fetch_1.default)('http://localhost:8081/status');
56
55
  if (bundlerStatus.status === 200) {
57
56
  return;
58
57
  }
59
58
  }
60
- catch (ignore) { }
61
- await Utils_1.delay(500);
59
+ catch { }
60
+ await (0, Utils_1.delay)(500);
62
61
  }
63
62
  throw new Error("Bundler isn't available.");
64
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BundlerController.js","sourceRoot":"","sources":["../src/BundlerController.ts"],"names":[],"mappings":";;;;;AAAA,iDAAoD;AACpD,4DAA+B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AC;YAEL,MAAM,WAAW,CAAC,MAAA,IAAI,CAAC,OAAO,0CAAE,GAAI,EAAE,IAAI,CAAC,CAAC;SAC7C;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,CAAC,CAAC;SAC/C;IACH,CAAC;IAEO,KAAK,CAAC,uBAAuB;QACnC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,OAAO,OAAO,EAAE,GAAG,CAAC,EAAE;YACpB,IAAI;gBACF,MAAM,aAAa,GAAG,MAAM,oBAAK,CAAC,8BAA8B,CAAC,CAAC;gBAClE,IAAI,aAAa,CAAC,MAAM,KAAK,GAAG,EAAE;oBAChC,OAAO;iBACR;aACF;YAAC,OAAO,MAAM,EAAE,GAAE;YAEnB,MAAM,aAAK,CAAC,GAAG,CAAC,CAAC;SAClB;QAED,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;CACF;AA3DD,oCA2DC","sourcesContent":["import { ChildProcess, spawn } from 'child_process';\nimport fetch from 'node-fetch';\n\nimport { delay } from './Utils';\n\nexport default class BundlerController {\n private process: ChildProcess | undefined;\n\n constructor(private path: string) {}\n\n async start() {\n const bundler = spawn('yarn', ['start'], { cwd: this.path, stdio: 'inherit' });\n await delay(1000);\n this.ensureBundlerWasStarted();\n this.process = bundler;\n }\n\n async stop() {\n try {\n // Fixes:\n // Error: read EIO\n // at TTY.onStreamRead (node:internal/stream_base_commons:211:20)\n // Emitted 'error' event on ReadStream\n const killProcess: (pid: number, timeout: number) => Promise<void> = (pid, timeout) =>\n new Promise<void>((resolve, reject) => {\n const signal = 'SIGTERM';\n process.kill(pid, signal);\n let count = 0;\n const interval = setInterval(() => {\n try {\n process.kill(pid, 0);\n } catch (e) {\n clearInterval(interval);\n // the process does not exists anymore\n resolve();\n }\n if ((count += 100) > timeout) {\n clearInterval(interval);\n reject(new Error('Timeout process kill'));\n }\n }, 100);\n });\n\n await killProcess(this.process?.pid!, 2000);\n } catch (error) {\n console.log(`Cannot kill bundler: ${error}.`);\n }\n }\n\n private async ensureBundlerWasStarted() {\n let retries = 10;\n while (retries-- > 0) {\n try {\n const bundlerStatus = await fetch('http://localhost:8081/status');\n if (bundlerStatus.status === 200) {\n return;\n }\n } catch (ignore) {}\n\n await delay(500);\n }\n\n throw new Error(\"Bundler isn't available.\");\n }\n}\n"]}
1
+ {"version":3,"file":"BundlerController.js","sourceRoot":"","sources":["../src/BundlerController.ts"],"names":[],"mappings":";;;;;AAAA,iDAAoD;AACpD,4DAA+B;AAE/B,mCAAgC;AAEhC,MAAqB,iBAAiB;IAGpC,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEpC,KAAK,CAAC,KAAK;QACT,MAAM,OAAO,GAAG,IAAA,qBAAK,EAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/E,MAAM,IAAA,aAAK,EAAC,IAAI,CAAC,CAAC;QAClB,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI;YACF,SAAS;YACT,kBAAkB;YAClB,iEAAiE;YACjE,sCAAsC;YACtC,MAAM,WAAW,GAAoD,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CACpF,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACpC,MAAM,MAAM,GAAG,SAAS,CAAC;gBACzB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBAC1B,IAAI,KAAK,GAAG,CAAC,CAAC;gBACd,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;oBAChC,IAAI;wBACF,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;qBACtB;oBAAC,MAAM;wBACN,aAAa,CAAC,QAAQ,CAAC,CAAC;wBACxB,sCAAsC;wBACtC,OAAO,EAAE,CAAC;qBACX;oBACD,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,OAAO,EAAE;wBAC5B,aAAa,CAAC,QAAQ,CAAC,CAAC;wBACxB,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;qBAC3C;gBACH,CAAC,EAAE,GAAG,CAAC,CAAC;YACV,CAAC,CAAC,CAAC;YAEL,MAAM,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,GAAI,EAAE,IAAI,CAAC,CAAC;SAC7C;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,CAAC,CAAC;SAC/C;IACH,CAAC;IAEO,KAAK,CAAC,uBAAuB;QACnC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,OAAO,OAAO,EAAE,GAAG,CAAC,EAAE;YACpB,IAAI;gBACF,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAK,EAAC,8BAA8B,CAAC,CAAC;gBAClE,IAAI,aAAa,CAAC,MAAM,KAAK,GAAG,EAAE;oBAChC,OAAO;iBACR;aACF;YAAC,MAAM,GAAE;YAEV,MAAM,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;SAClB;QAED,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;CACF;AA3DD,oCA2DC","sourcesContent":["import { ChildProcess, spawn } from 'child_process';\nimport fetch from 'node-fetch';\n\nimport { delay } from './Utils';\n\nexport default class BundlerController {\n private process: ChildProcess | undefined;\n\n constructor(private path: string) {}\n\n async start() {\n const bundler = spawn('yarn', ['start'], { cwd: this.path, stdio: 'inherit' });\n await delay(1000);\n this.ensureBundlerWasStarted();\n this.process = bundler;\n }\n\n async stop() {\n try {\n // Fixes:\n // Error: read EIO\n // at TTY.onStreamRead (node:internal/stream_base_commons:211:20)\n // Emitted 'error' event on ReadStream\n const killProcess: (pid: number, timeout: number) => Promise<void> = (pid, timeout) =>\n new Promise<void>((resolve, reject) => {\n const signal = 'SIGTERM';\n process.kill(pid, signal);\n let count = 0;\n const interval = setInterval(() => {\n try {\n process.kill(pid, 0);\n } catch {\n clearInterval(interval);\n // the process does not exists anymore\n resolve();\n }\n if ((count += 100) > timeout) {\n clearInterval(interval);\n reject(new Error('Timeout process kill'));\n }\n }, 100);\n });\n\n await killProcess(this.process?.pid!, 2000);\n } catch (error) {\n console.log(`Cannot kill bundler: ${error}.`);\n }\n }\n\n private async ensureBundlerWasStarted() {\n let retries = 10;\n while (retries-- > 0) {\n try {\n const bundlerStatus = await fetch('http://localhost:8081/status');\n if (bundlerStatus.status === 200) {\n return;\n }\n } catch {}\n\n await delay(500);\n }\n\n throw new Error(\"Bundler isn't available.\");\n }\n}\n"]}
@@ -9,7 +9,7 @@ class ConfigReader {
9
9
  return require(this.path);
10
10
  }
11
11
  static getFilePath(path) {
12
- return path ? path : path_1.join(process.cwd(), 'test-runner.config.js');
12
+ return path ? path : (0, path_1.join)(process.cwd(), 'test-runner.config.js');
13
13
  }
14
14
  }
15
15
  exports.default = ConfigReader;
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigReader.js","sourceRoot":"","sources":["../src/ConfigReader.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAI5B,MAAqB,YAAY;IAC/B,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEpC,cAAc;QACZ,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAW,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAwB;QACzC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;IACpE,CAAC;CACF;AAVD,+BAUC","sourcesContent":["import { join } from 'path';\n\nimport { Config } from './Config';\n\nexport default class ConfigReader {\n constructor(private path: string) {}\n\n readConfigFile(): Config {\n return require(this.path) as Config;\n }\n\n static getFilePath(path: string | undefined): string {\n return path ? path : join(process.cwd(), 'test-runner.config.js');\n }\n}\n"]}
1
+ {"version":3,"file":"ConfigReader.js","sourceRoot":"","sources":["../src/ConfigReader.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAI5B,MAAqB,YAAY;IAC/B,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEpC,cAAc;QACZ,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAW,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAwB;QACzC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;IACpE,CAAC;CACF;AAVD,+BAUC","sourcesContent":["import { join } from 'path';\n\nimport { Config } from './Config';\n\nexport default class ConfigReader {\n constructor(private path: string) {}\n\n readConfigFile(): Config {\n return require(this.path) as Config;\n }\n\n static getFilePath(path: string | undefined): string {\n return path ? path : join(process.cwd(), 'test-runner.config.js');\n }\n}\n"]}
package/build/Paths.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SelfPath = void 0;
4
4
  const path_1 = require("path");
5
- exports.SelfPath = path_1.join(__dirname, '..');
5
+ exports.SelfPath = (0, path_1.join)(__dirname, '..');
6
6
  //# sourceMappingURL=Paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paths.js","sourceRoot":"","sources":["../src/Paths.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AACf,QAAA,QAAQ,GAAG,WAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC","sourcesContent":["import { join } from 'path';\nexport const SelfPath = join(__dirname, '..');\n"]}
1
+ {"version":3,"file":"Paths.js","sourceRoot":"","sources":["../src/Paths.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AACf,QAAA,QAAQ,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC","sourcesContent":["import { join } from 'path';\nexport const SelfPath = join(__dirname, '..');\n"]}
@@ -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];
@@ -27,7 +31,7 @@ class TemplateEvaluator {
27
31
  }
28
32
  async compileFileAsync(path) {
29
33
  const fileContent = await fs.readFile(path, 'utf-8');
30
- const templateFn = dot_1.template(fileContent, {
34
+ const templateFn = (0, dot_1.template)(fileContent, {
31
35
  strip: false,
32
36
  });
33
37
  await fs.writeFile(path, templateFn(this.definitions));
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateEvaluator.js","sourceRoot":"","sources":["../src/TemplateEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4C;AAC5C,6CAA+B;AAE/B,MAAqB,iBAAiB;IACpC,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,KAAK,CAAC,gBAAgB,CAAC,IAAY;QACjC,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,cAAQ,CAAC,WAAW,EAAE;YACvC,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QAEH,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAXD,oCAWC","sourcesContent":["import { Definitions, template } from 'dot';\nimport * as fs from 'fs-extra';\n\nexport default class TemplateEvaluator {\n constructor(private definitions: Definitions) {}\n\n async compileFileAsync(path: string) {\n const fileContent = await fs.readFile(path, 'utf-8');\n const templateFn = template(fileContent, {\n strip: false,\n });\n\n await fs.writeFile(path, templateFn(this.definitions));\n }\n}\n"]}
1
+ {"version":3,"file":"TemplateEvaluator.js","sourceRoot":"","sources":["../src/TemplateEvaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4C;AAC5C,6CAA+B;AAE/B,MAAqB,iBAAiB;IACpC,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,KAAK,CAAC,gBAAgB,CAAC,IAAY;QACjC,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,IAAA,cAAQ,EAAC,WAAW,EAAE;YACvC,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QAEH,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAXD,oCAWC","sourcesContent":["import { Definitions, template } from 'dot';\nimport * as fs from 'fs-extra';\n\nexport default class TemplateEvaluator {\n constructor(private definitions: Definitions) {}\n\n async compileFileAsync(path: string) {\n const fileContent = await fs.readFile(path, 'utf-8');\n const templateFn = template(fileContent, {\n strip: false,\n });\n\n await fs.writeFile(path, templateFn(this.definitions));\n }\n}\n"]}
@@ -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];
@@ -31,13 +35,13 @@ class TemplateFile {
31
35
  this.shouldBeEvaluated = shouldBeEvaluated;
32
36
  }
33
37
  async copy(projectPath, outputPath) {
34
- return fs.copy(path_1.join(Paths_1.SelfPath, 'templates', this.template, outputPath), path_1.join(projectPath, outputPath), {
38
+ return fs.copy((0, path_1.join)(Paths_1.SelfPath, 'templates', this.template, outputPath), (0, path_1.join)(projectPath, outputPath), {
35
39
  recursive: true,
36
40
  });
37
41
  }
38
42
  async evaluate(projectPath, filePath, evaluator) {
39
43
  if (this.shouldBeEvaluated) {
40
- return evaluator.compileFileAsync(path_1.join(projectPath, filePath));
44
+ return evaluator.compileFileAsync((0, path_1.join)(projectPath, filePath));
41
45
  }
42
46
  return Promise.resolve();
43
47
  }
@@ -50,13 +54,13 @@ class UserFile {
50
54
  this.shouldBeEvaluated = shouldBeEvaluated;
51
55
  }
52
56
  copy(projectPath, outputPath) {
53
- return fs.copy(this.userFilePath, path_1.join(projectPath, outputPath), {
57
+ return fs.copy(this.userFilePath, (0, path_1.join)(projectPath, outputPath), {
54
58
  recursive: true,
55
59
  });
56
60
  }
57
61
  evaluate(projectPath, filePath, evaluator) {
58
62
  if (this.shouldBeEvaluated) {
59
- return evaluator.compileFileAsync(path_1.join(projectPath, filePath));
63
+ return evaluator.compileFileAsync((0, path_1.join)(projectPath, filePath));
60
64
  }
61
65
  return Promise.resolve();
62
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":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C,EAAE;YAC/D,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,WAAmB,EAAE,QAAgB,EAAE,SAAc;QAC5D,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,OAAO,SAAS,CAAC,gBAAgB,CAAC,WAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;SAChE;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AApBD,4BAoBC;AAED,MAAa,oBAAoB;IAC/B,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAExC,IAAI,CAAC,oBAA6B,KAAK;QACrC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC;IAED,WAAW,CAAC,oBAA6B,KAAK;QAC5C,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,CAAC,oBAA6B,KAAK;QACxC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC1E,CAAC;CACF;AAdD,oDAcC","sourcesContent":["import * as fs from 'fs-extra';\nimport { join } from 'path';\n\nimport { SelfPath } from './Paths';\nimport { Platform } from './Platform';\nimport TemplateEvaluator from './TemplateEvaluator';\n\nexport interface ProjectFile {\n platform: Platform;\n copy(projectPath: string, outputPath: string): Promise<void>;\n evaluate(projectPath: string, filePath: string, evaluator: TemplateEvaluator): Promise<void>;\n}\n\nexport class TemplateFile implements ProjectFile {\n constructor(\n public template: string,\n public platform: Platform = Platform.Both,\n public shouldBeEvaluated: boolean = false\n ) {}\n\n async copy(projectPath: string, outputPath: string): Promise<void> {\n return fs.copy(\n join(SelfPath, 'templates', this.template, outputPath),\n join(projectPath, outputPath),\n {\n recursive: true,\n }\n );\n }\n\n async evaluate(\n projectPath: string,\n filePath: string,\n evaluator: TemplateEvaluator\n ): Promise<void> {\n if (this.shouldBeEvaluated) {\n return evaluator.compileFileAsync(join(projectPath, filePath));\n }\n\n return Promise.resolve();\n }\n}\n\nexport class UserFile implements ProjectFile {\n constructor(\n public userFilePath: string,\n public platform: Platform = Platform.Both,\n public shouldBeEvaluated: boolean = false\n ) {}\n\n copy(projectPath: string, outputPath: string): Promise<void> {\n return fs.copy(this.userFilePath, join(projectPath, outputPath), {\n recursive: true,\n });\n }\n\n evaluate(projectPath: string, filePath: string, evaluator: any): Promise<void> {\n if (this.shouldBeEvaluated) {\n return evaluator.compileFileAsync(join(projectPath, filePath));\n }\n\n return Promise.resolve();\n }\n}\n\nexport class TemplateFilesFactory {\n constructor(private template: string) {}\n\n file(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.Both, shouldBeEvaluated);\n }\n\n androidFile(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.Android, shouldBeEvaluated);\n }\n\n iosFile(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.iOS, shouldBeEvaluated);\n }\n}\n"]}
1
+ {"version":3,"file":"TemplateFile.js","sourceRoot":"","sources":["../src/TemplateFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,+BAA4B;AAE5B,mCAAmC;AACnC,yCAAsC;AAStC,MAAa,YAAY;IACvB,YACS,QAAgB,EAChB,WAAqB,mBAAQ,CAAC,IAAI,EAClC,oBAA6B,KAAK;QAFlC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAA0B;QAClC,sBAAiB,GAAjB,iBAAiB,CAAiB;IACxC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,WAAmB,EAA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AAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAExC,IAAI,CAAC,oBAA6B,KAAK;QACrC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC;IAED,WAAW,CAAC,oBAA6B,KAAK;QAC5C,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,CAAC,oBAA6B,KAAK;QACxC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC1E,CAAC;CACF;AAdD,oDAcC","sourcesContent":["import * as fs from 'fs-extra';\nimport { join } from 'path';\n\nimport { SelfPath } from './Paths';\nimport { Platform } from './Platform';\nimport TemplateEvaluator from './TemplateEvaluator';\n\nexport interface ProjectFile {\n platform: Platform;\n copy(projectPath: string, outputPath: string): Promise<void>;\n evaluate(projectPath: string, filePath: string, evaluator: TemplateEvaluator): Promise<void>;\n}\n\nexport class TemplateFile implements ProjectFile {\n constructor(\n public template: string,\n public platform: Platform = Platform.Both,\n public shouldBeEvaluated: boolean = false\n ) {}\n\n async copy(projectPath: string, outputPath: string): Promise<void> {\n return fs.copy(\n join(SelfPath, 'templates', this.template, outputPath),\n join(projectPath, outputPath),\n {\n recursive: true,\n }\n );\n }\n\n async evaluate(\n projectPath: string,\n filePath: string,\n evaluator: TemplateEvaluator\n ): Promise<void> {\n if (this.shouldBeEvaluated) {\n return evaluator.compileFileAsync(join(projectPath, filePath));\n }\n\n return Promise.resolve();\n }\n}\n\nexport class UserFile implements ProjectFile {\n constructor(\n public userFilePath: string,\n public platform: Platform = Platform.Both,\n public shouldBeEvaluated: boolean = false\n ) {}\n\n copy(projectPath: string, outputPath: string): Promise<void> {\n return fs.copy(this.userFilePath, join(projectPath, outputPath), {\n recursive: true,\n });\n }\n\n evaluate(projectPath: string, filePath: string, evaluator: any): Promise<void> {\n if (this.shouldBeEvaluated) {\n return evaluator.compileFileAsync(join(projectPath, filePath));\n }\n\n return Promise.resolve();\n }\n}\n\nexport class TemplateFilesFactory {\n constructor(private template: string) {}\n\n file(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.Both, shouldBeEvaluated);\n }\n\n androidFile(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.Android, shouldBeEvaluated);\n }\n\n iosFile(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.iOS, shouldBeEvaluated);\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { Definitions } from 'dot';
2
+ import { Application, DetoxTest } from './Config';
3
+ import { Platform } from './Platform';
4
+ import { ProjectFile } from './TemplateFile';
5
+ export default class TemplateProject {
6
+ protected config: Application;
7
+ protected name: string;
8
+ protected platform: Platform;
9
+ protected configFilePath: string;
10
+ constructor(config: Application, name: string, platform: Platform, configFilePath: string);
11
+ getDefinitions(): Definitions;
12
+ createApplicationAsync(projectPath: string): Promise<void>;
13
+ getTemplateFiles(): {
14
+ [path: string]: ProjectFile;
15
+ };
16
+ protected userFilePath(relativePath: string): string;
17
+ protected copyFilesAsync(projectPath: string, files: {
18
+ [path: string]: ProjectFile;
19
+ }): Promise<void>;
20
+ protected evaluateFiles(projectPath: string, files: {
21
+ [path: string]: ProjectFile;
22
+ }): Promise<void>;
23
+ build(projectPath: string, test: DetoxTest): Promise<void>;
24
+ run(projectPath: string, test: DetoxTest): Promise<void>;
25
+ }
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const BundlerController_1 = __importDefault(require("./BundlerController"));
10
+ const Platform_1 = require("./Platform");
11
+ const TemplateEvaluator_1 = __importDefault(require("./TemplateEvaluator"));
12
+ const TemplateFile_1 = require("./TemplateFile");
13
+ const Utils_1 = require("./Utils");
14
+ class TemplateProject {
15
+ constructor(config, name, platform, configFilePath) {
16
+ this.config = config;
17
+ this.name = name;
18
+ this.platform = platform;
19
+ this.configFilePath = configFilePath;
20
+ }
21
+ getDefinitions() {
22
+ return {
23
+ name: 'devcliente2e',
24
+ appEntryPoint: 'e2e/app/App',
25
+ };
26
+ }
27
+ async createApplicationAsync(projectPath) {
28
+ // TODO: this assumes there is a parent folder
29
+ const parentFolder = path_1.default.resolve(projectPath, '..');
30
+ if (!fs_1.default.existsSync(parentFolder)) {
31
+ fs_1.default.mkdirSync(parentFolder, { recursive: true });
32
+ }
33
+ const appName = 'dev-client-e2e';
34
+ await (0, spawn_async_1.default)('yarn', ['create', 'expo-app', appName], {
35
+ stdio: 'inherit',
36
+ cwd: parentFolder,
37
+ });
38
+ fs_1.default.renameSync(path_1.default.join(parentFolder, appName), projectPath);
39
+ const repoRoot = path_1.default.resolve(this.configFilePath, '..', '..', '..');
40
+ const localCliBin = path_1.default.join(repoRoot, 'packages/@expo/cli/build/bin/cli');
41
+ await (0, spawn_async_1.default)(localCliBin, ['install', 'detox', 'jest'], {
42
+ stdio: 'inherit',
43
+ cwd: projectPath,
44
+ });
45
+ // add local dependencies
46
+ let packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(projectPath, 'package.json'), 'utf-8'));
47
+ packageJson = {
48
+ ...packageJson,
49
+ dependencies: {
50
+ ...packageJson.dependencies,
51
+ 'expo-dev-client': `file:${repoRoot}/packages/expo-dev-client`,
52
+ 'expo-dev-menu-interface': `file:${repoRoot}/packages/expo-dev-menu-interface`,
53
+ 'expo-status-bar': `file:${repoRoot}/packages/expo-status-bar`,
54
+ expo: `file:${repoRoot}/packages/expo`,
55
+ 'jest-circus': packageJson.dependencies.jest,
56
+ },
57
+ resolutions: {
58
+ ...packageJson.resolutions,
59
+ 'expo-application': `file:${repoRoot}/packages/expo-application`,
60
+ 'expo-asset': `file:${repoRoot}/packages/expo-asset`,
61
+ 'expo-constants': `file:${repoRoot}/packages/expo-constants`,
62
+ 'expo-dev-launcher': `file:${repoRoot}/packages/expo-dev-launcher`,
63
+ 'expo-dev-menu': `file:${repoRoot}/packages/expo-dev-menu`,
64
+ 'expo-error-recovery': `file:${repoRoot}/packages/expo-error-recovery`,
65
+ 'expo-file-system': `file:${repoRoot}/packages/expo-file-system`,
66
+ 'expo-font': `file:${repoRoot}/packages/expo-font`,
67
+ 'expo-keep-awake': `file:${repoRoot}/packages/expo-keep-awake`,
68
+ 'expo-manifests': `file:${repoRoot}/packages/expo-manifests`,
69
+ 'expo-modules-autolinking': `file:${repoRoot}/packages/expo-modules-autolinking`,
70
+ 'expo-modules-core': `file:${repoRoot}/packages/expo-modules-core`,
71
+ 'expo-updates-interface': `file:${repoRoot}/packages/expo-updates-interface`,
72
+ },
73
+ };
74
+ fs_1.default.writeFileSync(path_1.default.join(projectPath, 'package.json'), JSON.stringify(packageJson, null, 2), 'utf-8');
75
+ // configure app.json
76
+ let appJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(projectPath, 'app.json'), 'utf-8'));
77
+ appJson = {
78
+ ...appJson,
79
+ expo: {
80
+ ...appJson.expo,
81
+ android: { ...appJson.android, package: 'com.testrunner' },
82
+ ios: { ...appJson.ios, bundleIdentifier: 'com.testrunner' },
83
+ },
84
+ };
85
+ fs_1.default.writeFileSync(path_1.default.join(projectPath, 'app.json'), JSON.stringify(appJson, null, 2), 'utf-8');
86
+ // pack local template and prebuild
87
+ const localTemplatePath = path_1.default.join(repoRoot, 'templates', 'expo-template-bare-minimum');
88
+ await (0, spawn_async_1.default)('npm', ['pack', '--pack-destination', projectPath], {
89
+ cwd: localTemplatePath,
90
+ stdio: 'inherit',
91
+ });
92
+ const templateVersion = require(path_1.default.join(localTemplatePath, 'package.json')).version;
93
+ await (0, spawn_async_1.default)(localCliBin, ['prebuild', '--template', `expo-template-bare-minimum-${templateVersion}.tgz`], {
94
+ stdio: 'inherit',
95
+ cwd: projectPath,
96
+ });
97
+ const templateFiles = this.getTemplateFiles();
98
+ await this.copyFilesAsync(projectPath, templateFiles);
99
+ await this.evaluateFiles(projectPath, templateFiles);
100
+ // workaround for instrumented unit test files not compiling in this
101
+ // configuration (ignored in .npmignore)
102
+ await (0, spawn_async_1.default)('rm', ['-rf', 'node_modules/expo-dev-client/android/src/androidTest'], {
103
+ stdio: 'inherit',
104
+ cwd: projectPath,
105
+ });
106
+ }
107
+ getTemplateFiles() {
108
+ const tff = new TemplateFile_1.TemplateFilesFactory('detox');
109
+ const additionalFiles = this.config.additionalFiles?.reduce((reducer, file) => ({
110
+ ...reducer,
111
+ [file]: new TemplateFile_1.UserFile(this.userFilePath(file)),
112
+ }), {});
113
+ if (this.config.android?.detoxTestFile) {
114
+ additionalFiles['android/app/src/androidTest/java/com/testrunner/DetoxTest.java'] =
115
+ new TemplateFile_1.UserFile(this.userFilePath(this.config.android.detoxTestFile), Platform_1.Platform.Android);
116
+ }
117
+ return {
118
+ 'android/build.gradle': tff.androidFile(),
119
+ 'android/app/build.gradle': tff.androidFile(),
120
+ 'android/app/src/androidTest/java/com/testrunner/DetoxTest.java': tff.androidFile(),
121
+ 'android/app/src/main/java/com/testrunner/MainApplication.java': tff.androidFile(),
122
+ 'index.js': tff.file(true),
123
+ 'ios/devcliente2e/main.m': tff.iosFile(),
124
+ [this.config.detoxConfigFile]: new TemplateFile_1.UserFile(this.userFilePath(this.config.detoxConfigFile), Platform_1.Platform.Both, true),
125
+ ...additionalFiles,
126
+ };
127
+ }
128
+ userFilePath(relativePath) {
129
+ return path_1.default.join(this.configFilePath, '..', relativePath);
130
+ }
131
+ async copyFilesAsync(projectPath, files) {
132
+ await Promise.all(Object.entries(files).map(([path, file]) => file.copy(projectPath, path)));
133
+ }
134
+ async evaluateFiles(projectPath, files) {
135
+ const templateEvaluator = new TemplateEvaluator_1.default(this.getDefinitions());
136
+ await Promise.all(Object.entries(files).map(([path, file]) => file.evaluate(projectPath, path, templateEvaluator)));
137
+ }
138
+ async build(projectPath, test) {
139
+ for (const conf of test.configurations) {
140
+ await (0, spawn_async_1.default)('yarn', ['detox', 'build', '-c', conf], {
141
+ cwd: projectPath,
142
+ stdio: 'inherit',
143
+ });
144
+ }
145
+ }
146
+ async run(projectPath, test) {
147
+ let bundler;
148
+ try {
149
+ bundler = new BundlerController_1.default(projectPath);
150
+ if (test.shouldRunBundler) {
151
+ await bundler.start();
152
+ }
153
+ for (const conf of test.configurations) {
154
+ await (0, spawn_async_1.default)('yarn', ['detox', 'test', '-c', conf, '--ci', '--headless', '--gpu', 'swiftshader_indirect'], {
155
+ cwd: projectPath,
156
+ stdio: 'inherit',
157
+ });
158
+ await (0, Utils_1.killVirtualDevicesAsync)(this.platform);
159
+ }
160
+ }
161
+ finally {
162
+ // If bundler wasn't started is noop.
163
+ await bundler?.stop();
164
+ }
165
+ }
166
+ }
167
+ exports.default = TemplateProject;
168
+ //# sourceMappingURL=TemplateProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateProject.js","sourceRoot":"","sources":["../src/TemplateProject.ts"],"names":[],"mappings":";;;;;AAAA,oEAA2C;AAE3C,4CAAoB;AACpB,gDAAwB;AAExB,4EAAoD;AAEpD,yCAAsC;AACtC,4EAAoD;AACpD,iDAA6E;AAC7E,mCAAkD;AAElD,MAAqB,eAAe;IAClC,YACY,MAAmB,EACnB,IAAY,EACZ,QAAkB,EAClB,cAAsB;QAHtB,WAAM,GAAN,MAAM,CAAa;QACnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAU;QAClB,mBAAc,GAAd,cAAc,CAAQ;IAC/B,CAAC;IAEJ,cAAc;QACZ,OAAO;YACL,IAAI,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BACzB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;aACvB;YAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE;gBACtC,MAAM,IAAA,qBAAU,EACd,MAAM,EACN,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,sBAAsB,CAAC,EACpF;oBACE,GAAG,EAAE,WAAW;oBAChB,KAAK,EAAE,SAAS;iBACjB,CACF,CAAC;gBAEF,MAAM,IAAA,+BAAuB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC9C;SACF;gBAAS;YACR,qCAAqC;YACrC,MAAM,OAAO,EAAE,IAAI,EAAE,CAAC;SACvB;IACH,CAAC;CACF;AApMD,kCAoMC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { Definitions } from 'dot';\nimport fs from 'fs';\nimport path from 'path';\n\nimport BundlerController from './BundlerController';\nimport { Application, DetoxTest } from './Config';\nimport { Platform } from './Platform';\nimport TemplateEvaluator from './TemplateEvaluator';\nimport { ProjectFile, TemplateFilesFactory, UserFile } from './TemplateFile';\nimport { killVirtualDevicesAsync } from './Utils';\n\nexport default class TemplateProject {\n constructor(\n protected config: Application,\n protected name: string,\n protected platform: Platform,\n protected configFilePath: string\n ) {}\n\n getDefinitions(): Definitions {\n return {\n name: 'devcliente2e',\n appEntryPoint: 'e2e/app/App',\n };\n }\n\n async createApplicationAsync(projectPath: string) {\n // TODO: this assumes there is a parent folder\n const parentFolder = path.resolve(projectPath, '..');\n if (!fs.existsSync(parentFolder)) {\n fs.mkdirSync(parentFolder, { recursive: true });\n }\n\n const appName = 'dev-client-e2e';\n await spawnAsync('yarn', ['create', 'expo-app', appName], {\n stdio: 'inherit',\n cwd: parentFolder,\n });\n fs.renameSync(path.join(parentFolder, appName), projectPath);\n\n const repoRoot = path.resolve(this.configFilePath, '..', '..', '..');\n const localCliBin = path.join(repoRoot, 'packages/@expo/cli/build/bin/cli');\n await spawnAsync(localCliBin, ['install', 'detox', 'jest'], {\n stdio: 'inherit',\n cwd: projectPath,\n });\n\n // add local dependencies\n let packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf-8'));\n packageJson = {\n ...packageJson,\n dependencies: {\n ...packageJson.dependencies,\n 'expo-dev-client': `file:${repoRoot}/packages/expo-dev-client`,\n 'expo-dev-menu-interface': `file:${repoRoot}/packages/expo-dev-menu-interface`,\n 'expo-status-bar': `file:${repoRoot}/packages/expo-status-bar`,\n expo: `file:${repoRoot}/packages/expo`,\n 'jest-circus': packageJson.dependencies.jest,\n },\n resolutions: {\n ...packageJson.resolutions,\n 'expo-application': `file:${repoRoot}/packages/expo-application`,\n 'expo-asset': `file:${repoRoot}/packages/expo-asset`,\n 'expo-constants': `file:${repoRoot}/packages/expo-constants`,\n 'expo-dev-launcher': `file:${repoRoot}/packages/expo-dev-launcher`,\n 'expo-dev-menu': `file:${repoRoot}/packages/expo-dev-menu`,\n 'expo-error-recovery': `file:${repoRoot}/packages/expo-error-recovery`,\n 'expo-file-system': `file:${repoRoot}/packages/expo-file-system`,\n 'expo-font': `file:${repoRoot}/packages/expo-font`,\n 'expo-keep-awake': `file:${repoRoot}/packages/expo-keep-awake`,\n 'expo-manifests': `file:${repoRoot}/packages/expo-manifests`,\n 'expo-modules-autolinking': `file:${repoRoot}/packages/expo-modules-autolinking`,\n 'expo-modules-core': `file:${repoRoot}/packages/expo-modules-core`,\n 'expo-updates-interface': `file:${repoRoot}/packages/expo-updates-interface`,\n },\n };\n fs.writeFileSync(\n path.join(projectPath, 'package.json'),\n JSON.stringify(packageJson, null, 2),\n 'utf-8'\n );\n\n // configure app.json\n let appJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'app.json'), 'utf-8'));\n appJson = {\n ...appJson,\n expo: {\n ...appJson.expo,\n android: { ...appJson.android, package: 'com.testrunner' },\n ios: { ...appJson.ios, bundleIdentifier: 'com.testrunner' },\n },\n };\n fs.writeFileSync(path.join(projectPath, 'app.json'), JSON.stringify(appJson, null, 2), 'utf-8');\n\n // pack local template and prebuild\n const localTemplatePath = path.join(repoRoot, 'templates', 'expo-template-bare-minimum');\n await spawnAsync('npm', ['pack', '--pack-destination', projectPath], {\n cwd: localTemplatePath,\n stdio: 'inherit',\n });\n const templateVersion = require(path.join(localTemplatePath, 'package.json')).version;\n\n await spawnAsync(\n localCliBin,\n ['prebuild', '--template', `expo-template-bare-minimum-${templateVersion}.tgz`],\n {\n stdio: 'inherit',\n cwd: projectPath,\n }\n );\n\n const templateFiles = this.getTemplateFiles();\n await this.copyFilesAsync(projectPath, templateFiles);\n await this.evaluateFiles(projectPath, templateFiles);\n\n // workaround for instrumented unit test files not compiling in this\n // configuration (ignored in .npmignore)\n await spawnAsync('rm', ['-rf', 'node_modules/expo-dev-client/android/src/androidTest'], {\n stdio: 'inherit',\n cwd: projectPath,\n });\n }\n\n getTemplateFiles(): { [path: string]: ProjectFile } {\n const tff = new TemplateFilesFactory('detox');\n\n const additionalFiles: { [path: string]: ProjectFile } = this.config.additionalFiles?.reduce(\n (reducer, file) => ({\n ...reducer,\n [file]: new UserFile(this.userFilePath(file)),\n }),\n {}\n );\n\n if (this.config.android?.detoxTestFile) {\n additionalFiles['android/app/src/androidTest/java/com/testrunner/DetoxTest.java'] =\n new UserFile(this.userFilePath(this.config.android.detoxTestFile), Platform.Android);\n }\n\n return {\n 'android/build.gradle': tff.androidFile(),\n 'android/app/build.gradle': tff.androidFile(),\n 'android/app/src/androidTest/java/com/testrunner/DetoxTest.java': tff.androidFile(),\n 'android/app/src/main/java/com/testrunner/MainApplication.java': tff.androidFile(),\n 'index.js': tff.file(true),\n 'ios/devcliente2e/main.m': tff.iosFile(),\n [this.config.detoxConfigFile]: new UserFile(\n this.userFilePath(this.config.detoxConfigFile),\n Platform.Both,\n true\n ),\n ...additionalFiles,\n };\n }\n\n protected userFilePath(relativePath: string): string {\n return path.join(this.configFilePath, '..', relativePath);\n }\n\n protected async copyFilesAsync(projectPath: string, files: { [path: string]: ProjectFile }) {\n await Promise.all(Object.entries(files).map(([path, file]) => file.copy(projectPath, path)));\n }\n\n protected async evaluateFiles(projectPath: string, files: { [path: string]: ProjectFile }) {\n const templateEvaluator = new TemplateEvaluator(this.getDefinitions());\n await Promise.all(\n Object.entries(files).map(([path, file]) =>\n file.evaluate(projectPath, path, templateEvaluator)\n )\n );\n }\n\n async build(projectPath: string, test: DetoxTest): Promise<void> {\n for (const conf of test.configurations) {\n await spawnAsync('yarn', ['detox', 'build', '-c', conf], {\n cwd: projectPath,\n stdio: 'inherit',\n });\n }\n }\n\n async run(projectPath: string, test: DetoxTest): Promise<void> {\n let bundler: BundlerController | undefined;\n try {\n bundler = new BundlerController(projectPath);\n\n if (test.shouldRunBundler) {\n await bundler.start();\n }\n\n for (const conf of test.configurations) {\n await spawnAsync(\n 'yarn',\n ['detox', 'test', '-c', conf, '--ci', '--headless', '--gpu', 'swiftshader_indirect'],\n {\n cwd: projectPath,\n stdio: 'inherit',\n }\n );\n\n await killVirtualDevicesAsync(this.platform);\n }\n } finally {\n // If bundler wasn't started is noop.\n await bundler?.stop();\n }\n }\n}\n"]}
package/build/Utils.js CHANGED
@@ -8,15 +8,15 @@ const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
8
8
  const child_process_1 = require("child_process");
9
9
  const Platform_1 = require("./Platform");
10
10
  function yarnInstall(path) {
11
- child_process_1.spawnSync('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });
11
+ (0, child_process_1.spawnSync)('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });
12
12
  }
13
13
  exports.yarnInstall = yarnInstall;
14
- const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
14
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
15
15
  exports.delay = delay;
16
16
  async function killEmulatorAsync() {
17
17
  try {
18
18
  console.log('Trying to kill emulator...');
19
- await spawn_async_1.default('adb', ['-s', 'emulator-5554', 'emu', 'kill'], { stdio: 'inherit' });
19
+ await (0, spawn_async_1.default)('adb', ['-s', 'emulator-5554', 'emu', 'kill'], { stdio: 'inherit' });
20
20
  console.log('Emulator was killed.');
21
21
  }
22
22
  catch (e) {
@@ -28,7 +28,7 @@ exports.killEmulatorAsync = killEmulatorAsync;
28
28
  async function killSimulatorAsync() {
29
29
  try {
30
30
  console.log('Trying to kill simulator...');
31
- await spawn_async_1.default('xcrun', ['simctl', 'shutdown', 'all'], { stdio: 'inherit' });
31
+ await (0, spawn_async_1.default)('xcrun', ['simctl', 'shutdown', 'all'], { stdio: 'inherit' });
32
32
  console.log('Simulator was killed.');
33
33
  }
34
34
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAC3C,iDAA0C;AAE1C,yCAAsC;AAEtC,SAAgB,WAAW,CAAC,IAAY;IACtC,yBAAS,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,kCAEC;AAEM,MAAM,KAAK,GAAkC,EAAE,CAAC,EAAE,CACvD,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AADrC,QAAA,KAAK,SACgC;AAE3C,KAAK,UAAU,iBAAiB;IACrC,IAAI;QACF,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,MAAM,qBAAU,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;KACrC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAChB;AACH,CAAC;AATD,8CASC;AAEM,KAAK,UAAU,kBAAkB;IACtC,IAAI;QACF,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,MAAM,qBAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/E,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;KACtC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAChB;AACH,CAAC;AATD,gDASC;AAEM,KAAK,UAAU,uBAAuB,CAAC,QAAkB;IAC9D,IAAI,CAAC,QAAQ,GAAG,mBAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACrC,MAAM,iBAAiB,EAAE,CAAC;KAC3B;IAED,IAAI,CAAC,QAAQ,GAAG,mBAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACjC,MAAM,kBAAkB,EAAE,CAAC;KAC5B;AACH,CAAC;AARD,0DAQC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { spawnSync } from 'child_process';\n\nimport { Platform } from './Platform';\n\nexport function yarnInstall(path: string) {\n spawnSync('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });\n}\n\nexport const delay: (ms: number) => Promise<void> = ms =>\n new Promise(resolve => setTimeout(resolve, ms));\n\nexport async function killEmulatorAsync(): Promise<void> {\n try {\n console.log('Trying to kill emulator...');\n await spawnAsync('adb', ['-s', 'emulator-5554', 'emu', 'kill'], { stdio: 'inherit' });\n console.log('Emulator was killed.');\n } catch (e) {\n console.log(\"Couldn't kill emulator\");\n console.log(e);\n }\n}\n\nexport async function killSimulatorAsync(): Promise<void> {\n try {\n console.log('Trying to kill simulator...');\n await spawnAsync('xcrun', ['simctl', 'shutdown', 'all'], { stdio: 'inherit' });\n console.log('Simulator was killed.');\n } catch (e) {\n console.log(\"Couldn't kill simulator.\");\n console.log(e);\n }\n}\n\nexport async function killVirtualDevicesAsync(platform: Platform): Promise<void> {\n if ((platform & Platform.Android) > 0) {\n await killEmulatorAsync();\n }\n\n if ((platform & Platform.iOS) > 0) {\n await killSimulatorAsync();\n }\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAC3C,iDAA0C;AAE1C,yCAAsC;AAEtC,SAAgB,WAAW,CAAC,IAAY;IACtC,IAAA,yBAAS,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,kCAEC;AAEM,MAAM,KAAK,GAAkC,CAAC,EAAE,EAAE,EAAE,CACzD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AADvC,QAAA,KAAK,SACkC;AAE7C,KAAK,UAAU,iBAAiB;IACrC,IAAI;QACF,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,MAAM,IAAA,qBAAU,EAAC,KAAK,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;KACrC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAChB;AACH,CAAC;AATD,8CASC;AAEM,KAAK,UAAU,kBAAkB;IACtC,IAAI;QACF,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/E,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;KACtC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAChB;AACH,CAAC;AATD,gDASC;AAEM,KAAK,UAAU,uBAAuB,CAAC,QAAkB;IAC9D,IAAI,CAAC,QAAQ,GAAG,mBAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACrC,MAAM,iBAAiB,EAAE,CAAC;KAC3B;IAED,IAAI,CAAC,QAAQ,GAAG,mBAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACjC,MAAM,kBAAkB,EAAE,CAAC;KAC5B;AACH,CAAC;AARD,0DAQC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { spawnSync } from 'child_process';\n\nimport { Platform } from './Platform';\n\nexport function yarnInstall(path: string) {\n spawnSync('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });\n}\n\nexport const delay: (ms: number) => Promise<void> = (ms) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\nexport async function killEmulatorAsync(): Promise<void> {\n try {\n console.log('Trying to kill emulator...');\n await spawnAsync('adb', ['-s', 'emulator-5554', 'emu', 'kill'], { stdio: 'inherit' });\n console.log('Emulator was killed.');\n } catch (e) {\n console.log(\"Couldn't kill emulator\");\n console.log(e);\n }\n}\n\nexport async function killSimulatorAsync(): Promise<void> {\n try {\n console.log('Trying to kill simulator...');\n await spawnAsync('xcrun', ['simctl', 'shutdown', 'all'], { stdio: 'inherit' });\n console.log('Simulator was killed.');\n } catch (e) {\n console.log(\"Couldn't kill simulator.\");\n console.log(e);\n }\n}\n\nexport async function killVirtualDevicesAsync(platform: Platform): Promise<void> {\n if ((platform & Platform.Android) > 0) {\n await killEmulatorAsync();\n }\n\n if ((platform & Platform.iOS) > 0) {\n await killSimulatorAsync();\n }\n}\n"]}
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const chalk_1 = __importDefault(require("chalk"));
7
- const DetoxTemplate_1 = __importDefault(require("../presets/DetoxTemplate"));
7
+ const TemplateProject_1 = __importDefault(require("../TemplateProject"));
8
8
  const registerCommand_1 = require("../registerCommand");
9
9
  async function createProjectAsync(config, options) {
10
10
  const app = config.applications[options.app];
11
11
  if (app.preset === 'detox') {
12
12
  console.log(`Using ${chalk_1.default.green('detox')} preset.`);
13
- const preset = new DetoxTemplate_1.default(app, options.app, options.platform, options.configFile);
13
+ const preset = new TemplateProject_1.default(app, options.app, options.platform, options.configFile);
14
14
  console.log(`Creating test app in ${chalk_1.default.green(options.path)}.`);
15
15
  await preset.createApplicationAsync(options.path);
16
16
  }
@@ -19,6 +19,6 @@ async function createProjectAsync(config, options) {
19
19
  }
20
20
  }
21
21
  exports.default = (program) => {
22
- registerCommand_1.registerCommand(program, 'create-project', createProjectAsync).option('-a, --app [string]', 'Name of the application to create.');
22
+ (0, registerCommand_1.registerCommand)(program, 'create-project', createProjectAsync).option('-a, --app [string]', 'Name of the application to create.');
23
23
  };
24
24
  //# sourceMappingURL=CreateProject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CreateProject.js","sourceRoot":"","sources":["../../src/commands/CreateProject.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAI1B,6EAAmD;AACnD,wDAAqE;AAMrE,KAAK,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAA6B;IAC7E,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,uBAAW,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAEvF,OAAO,CAAC,GAAG,CAAC,wBAAwB,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACnD;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClD;AACH,CAAC;AAED,kBAAe,CAAC,OAAwB,EAAE,EAAE;IAC1C,iCAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,MAAM,CACnE,oBAAoB,EACpB,oCAAoC,CACrC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { CommanderStatic } from 'commander';\n\nimport { Config } from '../Config';\nimport DetoxPreset from '../presets/DetoxTemplate';\nimport { DefaultOptions, registerCommand } from '../registerCommand';\n\ninterface CreateProjectOptions extends DefaultOptions {\n app: string;\n}\n\nasync function createProjectAsync(config: Config, options: CreateProjectOptions) {\n const app = config.applications[options.app];\n\n if (app.preset === 'detox') {\n console.log(`Using ${chalk.green('detox')} preset.`);\n const preset = new DetoxPreset(app, options.app, options.platform, options.configFile);\n\n console.log(`Creating test app in ${chalk.green(options.path)}.`);\n await preset.createApplicationAsync(options.path);\n } else {\n throw new Error(`Unknown preset: ${app.preset}`);\n }\n}\n\nexport default (program: CommanderStatic) => {\n registerCommand(program, 'create-project', createProjectAsync).option(\n '-a, --app [string]',\n 'Name of the application to create.'\n );\n};\n"]}
1
+ {"version":3,"file":"CreateProject.js","sourceRoot":"","sources":["../../src/commands/CreateProject.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAI1B,yEAAiD;AACjD,wDAAqE;AAMrE,KAAK,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAA6B;IAC7E,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,yBAAe,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE3F,OAAO,CAAC,GAAG,CAAC,wBAAwB,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACnD;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClD;AACH,CAAC;AAED,kBAAe,CAAC,OAAwB,EAAE,EAAE;IAC1C,IAAA,iCAAe,EAAC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,MAAM,CACnE,oBAAoB,EACpB,oCAAoC,CACrC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { CommanderStatic } from 'commander';\n\nimport { Config } from '../Config';\nimport TemplateProject from '../TemplateProject';\nimport { DefaultOptions, registerCommand } from '../registerCommand';\n\ninterface CreateProjectOptions extends DefaultOptions {\n app: string;\n}\n\nasync function createProjectAsync(config: Config, options: CreateProjectOptions) {\n const app = config.applications[options.app];\n\n if (app.preset === 'detox') {\n console.log(`Using ${chalk.green('detox')} preset.`);\n const preset = new TemplateProject(app, options.app, options.platform, options.configFile);\n\n console.log(`Creating test app in ${chalk.green(options.path)}.`);\n await preset.createApplicationAsync(options.path);\n } else {\n throw new Error(`Unknown preset: ${app.preset}`);\n }\n}\n\nexport default (program: CommanderStatic) => {\n registerCommand(program, 'create-project', createProjectAsync).option(\n '-a, --app [string]',\n 'Name of the application to create.'\n );\n};\n"]}
@@ -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];
@@ -24,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
28
  Object.defineProperty(exports, "__esModule", { value: true });
25
29
  const chalk_1 = __importDefault(require("chalk"));
26
30
  const fs = __importStar(require("fs-extra"));
27
- const DetoxTemplate_1 = __importDefault(require("../presets/DetoxTemplate"));
31
+ const TemplateProject_1 = __importDefault(require("../TemplateProject"));
28
32
  const registerCommand_1 = require("../registerCommand");
29
33
  function findTest(config, test) {
30
34
  for (const appName in config.applications) {
@@ -42,7 +46,7 @@ async function runTestAsync(config, options) {
42
46
  const test = app.tests[options.test];
43
47
  if (app.preset === 'detox') {
44
48
  console.log(`Using ${chalk_1.default.green('detox')} preset.`);
45
- const preset = new DetoxTemplate_1.default(app, appName, options.platform, options.configFile);
49
+ const preset = new TemplateProject_1.default(app, appName, options.platform, options.configFile);
46
50
  console.log(`Creating test app in ${chalk_1.default.green(options.path)}.`);
47
51
  await preset.createApplicationAsync(options.path);
48
52
  console.log(`Building app.`);
@@ -59,6 +63,6 @@ async function runTestAsync(config, options) {
59
63
  }
60
64
  }
61
65
  exports.default = (program) => {
62
- registerCommand_1.registerCommand(program, 'run-test', runTestAsync).option('-t, --test [string]', 'Name of the test case to run.');
66
+ (0, registerCommand_1.registerCommand)(program, 'run-test', runTestAsync).option('-t, --test [string]', 'Name of the test case to run.');
63
67
  };
64
68
  //# sourceMappingURL=RunTest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RunTest.js","sourceRoot":"","sources":["../../src/commands/RunTest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,6CAA+B;AAG/B,6EAAmD;AACnD,wDAAqE;AAMrE,SAAS,QAAQ,CAAC,MAAc,EAAE,IAAY;IAC5C,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,YAAY,EAAE;QACzC,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEzC,KAAK,MAAM,QAAQ,IAAI,GAAG,CAAC,KAAK,EAAE;YAChC,IAAI,IAAI,KAAK,QAAQ,EAAE;gBACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;aACvB;SACF;KACF;IAED,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,MAAc,EAAE,OAAuB;IACjE,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,uBAAW,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAEnF,OAAO,CAAC,GAAG,CAAC,wBAAwB,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAElD,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEvC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC9B,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAErC,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACzB,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC/B;KACF;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClD;AACH,CAAC;AAED,kBAAe,CAAC,OAAwB,EAAE,EAAE;IAC1C,iCAAe,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,MAAM,CACvD,qBAAqB,EACrB,+BAA+B,CAChC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { CommanderStatic } from 'commander';\nimport * as fs from 'fs-extra';\n\nimport { Application, Config } from '../Config';\nimport DetoxPreset from '../presets/DetoxTemplate';\nimport { DefaultOptions, registerCommand } from '../registerCommand';\n\ninterface RunTestOptions extends DefaultOptions {\n test: string;\n}\n\nfunction findTest(config: Config, test: string): [string, Application] {\n for (const appName in config.applications) {\n const app = config.applications[appName];\n\n for (const testName in app.tests) {\n if (test === testName) {\n return [appName, app];\n }\n }\n }\n\n throw new Error(`Couldn't find test: ${test}`);\n}\n\nasync function runTestAsync(config: Config, options: RunTestOptions) {\n const [appName, app] = findTest(config, options.test);\n const test = app.tests[options.test];\n\n if (app.preset === 'detox') {\n console.log(`Using ${chalk.green('detox')} preset.`);\n const preset = new DetoxPreset(app, appName, options.platform, options.configFile);\n\n console.log(`Creating test app in ${chalk.green(options.path)}.`);\n await preset.createApplicationAsync(options.path);\n\n console.log(`Building app.`);\n await preset.build(options.path, test);\n\n console.log(`Running tests.`);\n await preset.run(options.path, test);\n\n if (options.shouldBeCleaned) {\n console.log(`Cleaning.`);\n await fs.remove(options.path);\n }\n } else {\n throw new Error(`Unknown preset: ${app.preset}`);\n }\n}\n\nexport default (program: CommanderStatic) => {\n registerCommand(program, 'run-test', runTestAsync).option(\n '-t, --test [string]',\n 'Name of the test case to run.'\n );\n};\n"]}
1
+ {"version":3,"file":"RunTest.js","sourceRoot":"","sources":["../../src/commands/RunTest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,6CAA+B;AAG/B,yEAAiD;AACjD,wDAAqE;AAMrE,SAAS,QAAQ,CAAC,MAAc,EAAE,IAAY;IAC5C,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,YAAY,EAAE;QACzC,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEzC,KAAK,MAAM,QAAQ,IAAI,GAAG,CAAC,KAAK,EAAE;YAChC,IAAI,IAAI,KAAK,QAAQ,EAAE;gBACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;aACvB;SACF;KACF;IAED,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,KAAK,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EAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,MAAM,CACvD,qBAAqB,EACrB,+BAA+B,CAChC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { CommanderStatic } from 'commander';\nimport * as fs from 'fs-extra';\n\nimport { Application, Config } from '../Config';\nimport TemplateProject from '../TemplateProject';\nimport { DefaultOptions, registerCommand } from '../registerCommand';\n\ninterface RunTestOptions extends DefaultOptions {\n test: string;\n}\n\nfunction findTest(config: Config, test: string): [string, Application] {\n for (const appName in config.applications) {\n const app = config.applications[appName];\n\n for (const testName in app.tests) {\n if (test === testName) {\n return [appName, app];\n }\n }\n }\n\n throw new Error(`Couldn't find test: ${test}`);\n}\n\nasync function runTestAsync(config: Config, options: RunTestOptions) {\n const [appName, app] = findTest(config, options.test);\n const test = app.tests[options.test];\n\n if (app.preset === 'detox') {\n console.log(`Using ${chalk.green('detox')} preset.`);\n const preset = new TemplateProject(app, appName, options.platform, options.configFile);\n\n console.log(`Creating test app in ${chalk.green(options.path)}.`);\n await preset.createApplicationAsync(options.path);\n\n console.log(`Building app.`);\n await preset.build(options.path, test);\n\n console.log(`Running tests.`);\n await preset.run(options.path, test);\n\n if (options.shouldBeCleaned) {\n console.log(`Cleaning.`);\n await fs.remove(options.path);\n }\n } else {\n throw new Error(`Unknown preset: ${app.preset}`);\n }\n}\n\nexport default (program: CommanderStatic) => {\n registerCommand(program, 'run-test', runTestAsync).option(\n '-t, --test [string]',\n 'Name of the test case to run.'\n );\n};\n"]}
package/build/index.js CHANGED
@@ -7,6 +7,6 @@ const commander_1 = __importDefault(require("commander"));
7
7
  const CreateProject_1 = __importDefault(require("./commands/CreateProject"));
8
8
  const RunTest_1 = __importDefault(require("./commands/RunTest"));
9
9
  const program = commander_1.default.version('0.0.1');
10
- [CreateProject_1.default, RunTest_1.default].forEach(command => command(program));
10
+ [CreateProject_1.default, RunTest_1.default].forEach((command) => command(program));
11
11
  program.parse(process.argv);
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,6EAAqD;AACrD,iEAAyC;AAEzC,MAAM,OAAO,GAAG,mBAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC,uBAAa,EAAE,iBAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAE9D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import commander from 'commander';\n\nimport CreateProject from './commands/CreateProject';\nimport RunTest from './commands/RunTest';\n\nconst program = commander.version('0.0.1');\n[CreateProject, RunTest].forEach(command => command(program));\n\nprogram.parse(process.argv);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,6EAAqD;AACrD,iEAAyC;AAEzC,MAAM,OAAO,GAAG,mBAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC,uBAAa,EAAE,iBAAO,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAEhE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import commander from 'commander';\n\nimport CreateProject from './commands/CreateProject';\nimport RunTest from './commands/RunTest';\n\nconst program = commander.version('0.0.1');\n[CreateProject, RunTest].forEach((command) => command(program));\n\nprogram.parse(process.argv);\n"]}