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,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Platform = void 0;
4
- var Platform;
5
- (function (Platform) {
6
- Platform[Platform["iOS"] = 2] = "iOS";
7
- Platform[Platform["Android"] = 4] = "Android";
8
- })(Platform = exports.Platform || (exports.Platform = {}));
9
- //# sourceMappingURL=Platform.ds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Platform.ds.js","sourceRoot":"","sources":["../src/Platform.ds.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,qCAAY,CAAA;IACZ,6CAAgB,CAAA;AAClB,CAAC,EAHW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAGnB","sourcesContent":["export enum Platform {\n iOS = 1 << 1,\n Android = 1 << 2,\n}\n"]}
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=ProjectFile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProjectFile.js","sourceRoot":"","sources":["../src/ProjectFile.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -1,6 +0,0 @@
1
- import { Definitions } from 'dot';
2
- export default class TemplateEvaluator {
3
- private definitions;
4
- constructor(definitions: Definitions);
5
- compileFileAsync(path: string): Promise<void>;
6
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- const dot_1 = require("dot");
23
- const fs = __importStar(require("fs-extra"));
24
- class TemplateEvaluator {
25
- constructor(definitions) {
26
- this.definitions = definitions;
27
- }
28
- async compileFileAsync(path) {
29
- const fileContent = await fs.readFile(path, 'utf-8');
30
- const templateFn = dot_1.template(fileContent, {
31
- strip: false,
32
- });
33
- await fs.writeFile(path, templateFn(this.definitions));
34
- }
35
- }
36
- exports.default = TemplateEvaluator;
37
- //# sourceMappingURL=TemplateParser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplateParser.js","sourceRoot":"","sources":["../src/TemplateParser.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,3 +0,0 @@
1
- import { CommanderStatic } from 'commander';
2
- declare const _default: (program: CommanderStatic) => void;
3
- export default _default;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- async function createProjectAsync() {
4
- console.log('cos');
5
- }
6
- exports.default = (program) => {
7
- program
8
- .command('create-project')
9
- .option('--configuration [string]', 'Project configuration')
10
- .action(createProjectAsync);
11
- };
12
- //# sourceMappingURL=create-project.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-project.js","sourceRoot":"","sources":["../../src/commands/create-project.ts"],"names":[],"mappings":";;AAEA,KAAK,UAAU,kBAAkB;IAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC;AAED,kBAAe,CAAC,OAAwB,EAAE,EAAE;IAC1C,OAAO;SACJ,OAAO,CAAC,gBAAgB,CAAC;SACzB,MAAM,CAAC,0BAA0B,EAAE,uBAAuB,CAAC;SAC3D,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import { CommanderStatic } from 'commander';\n\nasync function createProjectAsync() {\n console.log('cos');\n}\n\nexport default (program: CommanderStatic) => {\n program\n .command('create-project')\n .option('--configuration [string]', 'Project configuration')\n .action(createProjectAsync);\n};\n"]}
@@ -1,13 +0,0 @@
1
- import { Definitions } from 'dot';
2
- import { Dependency, DetoxTest } from '../Config';
3
- import { ProjectFile } from '../TemplateFile';
4
- import PresetTemplate from './PresetTemplate';
5
- export default class DetoxPreset extends PresetTemplate {
6
- getDependencies(): Dependency[];
7
- getDefinitions(): Definitions;
8
- getTemplateFiles(): {
9
- [path: string]: ProjectFile;
10
- };
11
- build(projectPath: string, test: DetoxTest): Promise<void>;
12
- run(projectPath: string, test: DetoxTest): Promise<void>;
13
- }
@@ -1,79 +0,0 @@
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 BundlerController_1 = __importDefault(require("../BundlerController"));
8
- const Platform_1 = require("../Platform");
9
- const TemplateFile_1 = require("../TemplateFile");
10
- const Utils_1 = require("../Utils");
11
- const PresetTemplate_1 = __importDefault(require("./PresetTemplate"));
12
- class DetoxPreset extends PresetTemplate_1.default {
13
- getDependencies() {
14
- return [
15
- ...super.getDependencies(),
16
- {
17
- name: 'detox',
18
- path: '19.1.0',
19
- },
20
- ];
21
- }
22
- getDefinitions() {
23
- return {
24
- ...super.getDefinitions(),
25
- appEntryPoint: this.config.appEntryPoint,
26
- };
27
- }
28
- getTemplateFiles() {
29
- var _a, _b;
30
- const tff = new TemplateFile_1.TemplateFilesFactory('detox');
31
- const additionalFiles = (_a = this.config.additionalFiles) === null || _a === void 0 ? void 0 : _a.reduce((reducer, file) => ({
32
- ...reducer,
33
- [file]: new TemplateFile_1.UserFile(this.userFilePath(file)),
34
- }), {});
35
- if ((_b = this.config.android) === null || _b === void 0 ? void 0 : _b.detoxTestFile) {
36
- additionalFiles['android/app/src/androidTest/java/com/testrunner/DetoxTest.java'] =
37
- new TemplateFile_1.UserFile(this.userFilePath(this.config.android.detoxTestFile), Platform_1.Platform.Android);
38
- }
39
- return {
40
- ...super.getTemplateFiles(),
41
- 'android/build.gradle': tff.androidFile(),
42
- 'android/app/build.gradle': tff.androidFile(),
43
- 'android/app/src/androidTest/java/com/testrunner/DetoxTest.java': tff.androidFile(),
44
- 'index.js': tff.file(true),
45
- [this.config.detoxConfigFile]: new TemplateFile_1.UserFile(this.userFilePath(this.config.detoxConfigFile), Platform_1.Platform.Both, true),
46
- ...additionalFiles,
47
- };
48
- }
49
- async build(projectPath, test) {
50
- for (const conf of test.configurations) {
51
- await spawn_async_1.default('yarn', ['detox', 'build', '-c', conf], {
52
- cwd: projectPath,
53
- stdio: 'inherit',
54
- });
55
- }
56
- }
57
- async run(projectPath, test) {
58
- let bundler;
59
- try {
60
- bundler = new BundlerController_1.default(projectPath);
61
- if (test.shouldRunBundler) {
62
- await bundler.start();
63
- }
64
- for (const conf of test.configurations) {
65
- await spawn_async_1.default('yarn', ['detox', 'test', '-c', conf, '--ci', '--headless', '--gpu', 'swiftshader_indirect'], {
66
- cwd: projectPath,
67
- stdio: 'inherit',
68
- });
69
- await Utils_1.killVirtualDevicesAsync(this.platform);
70
- }
71
- }
72
- finally {
73
- // If bundler wasn't started is noop.
74
- await (bundler === null || bundler === void 0 ? void 0 : bundler.stop());
75
- }
76
- }
77
- }
78
- exports.default = DetoxPreset;
79
- //# sourceMappingURL=DetoxTemplate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DetoxTemplate.js","sourceRoot":"","sources":["../../src/presets/DetoxTemplate.ts"],"names":[],"mappings":";;;;;AAAA,oEAA2C;AAG3C,6EAAqD;AAErD,0CAAuC;AACvC,kDAA8E;AAC9E,oCAAmD;AACnD,sEAA8C;AAE9C,MAAqB,WAAY,SAAQ,wBAAc;IAC5C,eAAe;QACtB,OAAO;YACL,GAAG,KAAK,CAAC,eAAe,EAAE;YAC1B;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;aACf;SACF,CAAC;IACJ,CAAC;IAEQ,cAAc;QACrB,OAAO;YACL,GAAG,KAAK,CAAC,cAAc,EAAE;YACzB,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;SACzC,CAAC;IACJ,CAAC;IACQ,gBAAgB;;QACvB,MAAM,GAAG,GAAG,IAAI,mCAAoB,CAAC,OAAO,CAAC,CAAC;QAE9C,MAAM,eAAe,GAAoC,MAAA,IAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,MAAM,CAC1F,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YAClB,GAAG,OAAO;YACV,CAAC,IAAI,CAAC,EAAE,IAAI,uBAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SAC9C,CAAC,EACF,EAAE,CACH,CAAC;QAEF,IAAI,MAAA,IAAI,CAAC,MAAM,CAAC,OAAO,0CAAE,aAAa,EAAE;YACtC,eAAe,CAAC,gEAAgE,CAAC;gBAC/E,IAAI,uBAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,mBAAQ,CAAC,OAAO,CAAC,CAAC;SACxF;QAED,OAAO;YACL,GAAG,KAAK,CAAC,gBAAg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C,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC9C;SACF;gBAAS;YACR,qCAAqC;YACrC,MAAM,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EAAE,CAAA,CAAC;SACvB;IACH,CAAC;CACF;AAnFD,8BAmFC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { Definitions } from 'dot';\n\nimport BundlerController from '../BundlerController';\nimport { Dependency, DetoxTest } from '../Config';\nimport { Platform } from '../Platform';\nimport { ProjectFile, TemplateFilesFactory, UserFile } from '../TemplateFile';\nimport { killVirtualDevicesAsync } from '../Utils';\nimport PresetTemplate from './PresetTemplate';\n\nexport default class DetoxPreset extends PresetTemplate {\n override getDependencies(): Dependency[] {\n return [\n ...super.getDependencies(),\n {\n name: 'detox',\n path: '19.1.0',\n },\n ];\n }\n\n override getDefinitions(): Definitions {\n return {\n ...super.getDefinitions(),\n appEntryPoint: this.config.appEntryPoint,\n };\n }\n override 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 ...super.getTemplateFiles(),\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 'index.js': tff.file(true),\n [this.config.detoxConfigFile]: new UserFile(\n this.userFilePath(this.config.detoxConfigFile),\n Platform.Both,\n true\n ),\n ...additionalFiles,\n };\n }\n\n override 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 override 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"]}
@@ -1,25 +0,0 @@
1
- import { Definitions } from 'dot';
2
- import { Application, Dependency, Test } from '../Config';
3
- import { Platform } from '../Platform';
4
- import { ProjectFile } from '../TemplateFile';
5
- export default class PresetTemplate {
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
- createApplicationAsync(projectPath: string): Promise<void>;
12
- protected getDefinitions(): Definitions;
13
- protected getDependencies(): Dependency[];
14
- protected getDevDependencies(): Dependency[];
15
- protected build(projectPath: string, test: Test): Promise<void>;
16
- protected run(projectPath: string, test: Test): Promise<void>;
17
- protected getTemplateFiles(): {
18
- [path: string]: ProjectFile;
19
- };
20
- protected userFilePath(relativePath: string): string;
21
- private resolveDependencies;
22
- private copyFilesAsync;
23
- private evaluateFiles;
24
- private resolvePath;
25
- }
@@ -1,147 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
26
- const fs = __importStar(require("fs-extra"));
27
- const path_1 = require("path");
28
- const Paths_1 = require("../Paths");
29
- const Platform_1 = require("../Platform");
30
- const TemplateEvaluator_1 = __importDefault(require("../TemplateEvaluator"));
31
- const TemplateFile_1 = require("../TemplateFile");
32
- const Utils_1 = require("../Utils");
33
- class PresetTemplate {
34
- constructor(config, name, platform, configFilePath) {
35
- this.config = config;
36
- this.name = name;
37
- this.platform = platform;
38
- this.configFilePath = configFilePath;
39
- }
40
- async createApplicationAsync(projectPath) {
41
- if (!fs.existsSync(projectPath)) {
42
- await fs.mkdir(projectPath, { recursive: true });
43
- }
44
- const templateFiles = Object.fromEntries(Object.entries(this.getTemplateFiles()).filter(([_, info]) => (info.platform & this.platform) > 0));
45
- await this.copyFilesAsync(projectPath, templateFiles);
46
- await this.evaluateFiles(projectPath, templateFiles);
47
- Utils_1.yarnInstall(projectPath);
48
- if ((this.platform & Platform_1.Platform.iOS) > 0) {
49
- await spawn_async_1.default('yarn', [
50
- '--silent',
51
- 'run',
52
- 'xcodegen',
53
- '--quiet',
54
- '--spec',
55
- path_1.join(projectPath, 'ios', 'project.yml'),
56
- ], {
57
- cwd: Paths_1.SelfPath,
58
- stdio: 'inherit',
59
- });
60
- await spawn_async_1.default('pod', ['install'], { cwd: path_1.join(projectPath, 'ios'), stdio: 'inherit' });
61
- }
62
- }
63
- getDefinitions() {
64
- return {
65
- ...this.config,
66
- name: this.name,
67
- dependencies: this.getDependencies(),
68
- devDependencies: this.getDevDependencies(),
69
- };
70
- }
71
- getDependencies() {
72
- return this.resolveDependencies();
73
- }
74
- getDevDependencies() {
75
- return [];
76
- }
77
- async build(projectPath, test) { }
78
- async run(projectPath, test) { }
79
- getTemplateFiles() {
80
- var _a, _b, _c, _d;
81
- const tff = new TemplateFile_1.TemplateFilesFactory('basic');
82
- const overrides = {};
83
- if ((_a = this.config.android) === null || _a === void 0 ? void 0 : _a.mainActivity) {
84
- overrides['android/app/src/main/java/com/testrunner/MainActivity.java'] = new TemplateFile_1.UserFile(this.userFilePath(this.config.android.mainActivity), Platform_1.Platform.Android);
85
- }
86
- if ((_b = this.config.android) === null || _b === void 0 ? void 0 : _b.mainApplication) {
87
- overrides['android/app/src/main/java/com/testrunner/MainApplication.java'] = new TemplateFile_1.UserFile(this.userFilePath(this.config.android.mainApplication), Platform_1.Platform.Android);
88
- }
89
- if ((_c = this.config.ios) === null || _c === void 0 ? void 0 : _c.appDelegateHeader) {
90
- overrides['ios/src/AppDelegate.h'] = new TemplateFile_1.UserFile(this.userFilePath(this.config.ios.appDelegateHeader), Platform_1.Platform.iOS);
91
- }
92
- if ((_d = this.config.ios) === null || _d === void 0 ? void 0 : _d.appDelegate) {
93
- overrides['ios/src/AppDelegate.m'] = new TemplateFile_1.UserFile(this.userFilePath(this.config.ios.appDelegate), Platform_1.Platform.iOS);
94
- }
95
- return {
96
- 'babel.config.js': tff.file(),
97
- 'tsconfig.json': tff.file(),
98
- 'package.json': tff.file(true),
99
- 'android/build.gradle': tff.androidFile(),
100
- 'android/gradle.properties': tff.androidFile(),
101
- 'android/gradlew': tff.androidFile(),
102
- 'android/gradlew.bat': tff.androidFile(),
103
- 'android/settings.gradle': tff.androidFile(true),
104
- 'android/gradle/': tff.androidFile(),
105
- 'android/app/build_defs.bzl': tff.androidFile(),
106
- 'android/app/build.gradle': tff.androidFile(),
107
- 'android/app/debug.keystore': tff.androidFile(),
108
- 'android/app/proguard-rules.pro': tff.androidFile(),
109
- 'android/app/src/main/java/com/testrunner/MainActivity.java': tff.androidFile(),
110
- 'android/app/src/main/java/com/testrunner/MainApplication.java': tff.androidFile(),
111
- 'android/app/src/main/AndroidManifest.xml': tff.androidFile(true),
112
- 'android/app/src/main/res/': tff.androidFile(),
113
- 'ios/src/Images.xcassets': tff.iosFile(),
114
- 'ios/src/AppDelegate.h': tff.iosFile(),
115
- 'ios/src/AppDelegate.m': tff.iosFile(),
116
- 'ios/src/Info.plist': tff.iosFile(true),
117
- 'ios/src/LaunchScreen.storyboard': tff.iosFile(true),
118
- 'ios/src/main.m': tff.iosFile(),
119
- 'ios/project.yml': tff.iosFile(true),
120
- 'ios/Podfile': tff.iosFile(true),
121
- 'ios/src/dummy.swift': tff.iosFile(),
122
- ...overrides,
123
- };
124
- }
125
- userFilePath(relativePath) {
126
- return path_1.join(this.configFilePath, '..', relativePath);
127
- }
128
- resolveDependencies() {
129
- var _a, _b;
130
- return ((_b = (_a = this.config.dependencies) === null || _a === void 0 ? void 0 : _a.map(dependency => ({
131
- ...dependency,
132
- path: this.resolvePath(dependency.path),
133
- }))) !== null && _b !== void 0 ? _b : []);
134
- }
135
- async copyFilesAsync(projectPath, files) {
136
- await Promise.all(Object.entries(files).map(([path, file]) => file.copy(projectPath, path)));
137
- }
138
- async evaluateFiles(projectPath, files) {
139
- const templateEvaluator = new TemplateEvaluator_1.default(this.getDefinitions());
140
- await Promise.all(Object.entries(files).map(([path, file]) => file.evaluate(projectPath, path, templateEvaluator)));
141
- }
142
- resolvePath(relativePath) {
143
- return 'file://' + fs.realpathSync(path_1.join(this.configFilePath, '..', relativePath));
144
- }
145
- }
146
- exports.default = PresetTemplate;
147
- //# sourceMappingURL=PresetTemplate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PresetTemplate.js","sourceRoot":"","sources":["../../src/presets/PresetTemplate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAA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AEO,KAAK,CAAC,aAAa,CAAC,WAAmB,EAAE,KAAsC;QACrF,MAAM,iBAAiB,GAAG,IAAI,2BAAiB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CACzC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,iBAAiB,CAAC,CACpD,CACF,CAAC;IACJ,CAAC;IAEO,WAAW,CAAC,YAAoB;QACtC,OAAO,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,WAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IACpF,CAAC;CACF;AA9JD,iCA8JC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { Definitions } from 'dot';\nimport * as fs from 'fs-extra';\nimport { join } from 'path';\n\nimport { Application, Dependency, Test } from '../Config';\nimport { SelfPath } from '../Paths';\nimport { Platform } from '../Platform';\nimport TemplateEvaluator from '../TemplateEvaluator';\nimport { ProjectFile, TemplateFilesFactory, UserFile } from '../TemplateFile';\nimport { yarnInstall } from '../Utils';\n\nexport default class PresetTemplate {\n constructor(\n protected config: Application,\n protected name: string,\n protected platform: Platform,\n protected configFilePath: string\n ) {}\n\n async createApplicationAsync(projectPath: string) {\n if (!fs.existsSync(projectPath)) {\n await fs.mkdir(projectPath, { recursive: true });\n }\n\n const templateFiles = Object.fromEntries(\n Object.entries(this.getTemplateFiles()).filter(\n ([_, info]) => (info.platform & this.platform) > 0\n )\n );\n\n await this.copyFilesAsync(projectPath, templateFiles);\n await this.evaluateFiles(projectPath, templateFiles);\n\n yarnInstall(projectPath);\n\n if ((this.platform & Platform.iOS) > 0) {\n await spawnAsync(\n 'yarn',\n [\n '--silent',\n 'run',\n 'xcodegen',\n '--quiet',\n '--spec',\n join(projectPath, 'ios', 'project.yml'),\n ],\n {\n cwd: SelfPath,\n stdio: 'inherit',\n }\n );\n\n await spawnAsync('pod', ['install'], { cwd: join(projectPath, 'ios'), stdio: 'inherit' });\n }\n }\n\n protected getDefinitions(): Definitions {\n return {\n ...this.config,\n name: this.name,\n dependencies: this.getDependencies(),\n devDependencies: this.getDevDependencies(),\n };\n }\n\n protected getDependencies(): Dependency[] {\n return this.resolveDependencies();\n }\n\n protected getDevDependencies(): Dependency[] {\n return [];\n }\n\n protected async build(projectPath: string, test: Test) {}\n\n protected async run(projectPath: string, test: Test) {}\n\n protected getTemplateFiles(): { [path: string]: ProjectFile } {\n const tff = new TemplateFilesFactory('basic');\n\n const overrides: { [path: string]: ProjectFile } = {};\n if (this.config.android?.mainActivity) {\n overrides['android/app/src/main/java/com/testrunner/MainActivity.java'] = new UserFile(\n this.userFilePath(this.config.android.mainActivity),\n Platform.Android\n );\n }\n\n if (this.config.android?.mainApplication) {\n overrides['android/app/src/main/java/com/testrunner/MainApplication.java'] = new UserFile(\n this.userFilePath(this.config.android.mainApplication),\n Platform.Android\n );\n }\n\n if (this.config.ios?.appDelegateHeader) {\n overrides['ios/src/AppDelegate.h'] = new UserFile(\n this.userFilePath(this.config.ios.appDelegateHeader),\n Platform.iOS\n );\n }\n\n if (this.config.ios?.appDelegate) {\n overrides['ios/src/AppDelegate.m'] = new UserFile(\n this.userFilePath(this.config.ios.appDelegate),\n Platform.iOS\n );\n }\n\n return {\n 'babel.config.js': tff.file(),\n 'tsconfig.json': tff.file(),\n 'package.json': tff.file(true),\n 'android/build.gradle': tff.androidFile(),\n 'android/gradle.properties': tff.androidFile(),\n 'android/gradlew': tff.androidFile(),\n 'android/gradlew.bat': tff.androidFile(),\n 'android/settings.gradle': tff.androidFile(true),\n 'android/gradle/': tff.androidFile(),\n 'android/app/build_defs.bzl': tff.androidFile(),\n 'android/app/build.gradle': tff.androidFile(),\n 'android/app/debug.keystore': tff.androidFile(),\n 'android/app/proguard-rules.pro': tff.androidFile(),\n 'android/app/src/main/java/com/testrunner/MainActivity.java': tff.androidFile(),\n 'android/app/src/main/java/com/testrunner/MainApplication.java': tff.androidFile(),\n 'android/app/src/main/AndroidManifest.xml': tff.androidFile(true),\n 'android/app/src/main/res/': tff.androidFile(),\n 'ios/src/Images.xcassets': tff.iosFile(),\n 'ios/src/AppDelegate.h': tff.iosFile(),\n 'ios/src/AppDelegate.m': tff.iosFile(),\n 'ios/src/Info.plist': tff.iosFile(true),\n 'ios/src/LaunchScreen.storyboard': tff.iosFile(true),\n 'ios/src/main.m': tff.iosFile(),\n 'ios/project.yml': tff.iosFile(true),\n 'ios/Podfile': tff.iosFile(true),\n 'ios/src/dummy.swift': tff.iosFile(),\n ...overrides,\n };\n }\n\n protected userFilePath(relativePath: string): string {\n return join(this.configFilePath, '..', relativePath);\n }\n\n private resolveDependencies(): Dependency[] {\n return (\n this.config.dependencies?.map(dependency => ({\n ...dependency,\n path: this.resolvePath(dependency.path),\n })) ?? []\n );\n }\n\n private 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 private 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 private resolvePath(relativePath: string): string {\n return 'file://' + fs.realpathSync(join(this.configFilePath, '..', relativePath));\n }\n}\n"]}
@@ -1,94 +0,0 @@
1
- import spawnAsync from '@expo/spawn-async';
2
- import { Definitions } from 'dot';
3
-
4
- import BundlerController from '../BundlerController';
5
- import { Dependency, DetoxTest } from '../Config';
6
- import { Platform } from '../Platform';
7
- import { ProjectFile, TemplateFilesFactory, UserFile } from '../TemplateFile';
8
- import { killVirtualDevicesAsync } from '../Utils';
9
- import PresetTemplate from './PresetTemplate';
10
-
11
- export default class DetoxPreset extends PresetTemplate {
12
- override getDependencies(): Dependency[] {
13
- return [
14
- ...super.getDependencies(),
15
- {
16
- name: 'detox',
17
- path: '19.1.0',
18
- },
19
- ];
20
- }
21
-
22
- override getDefinitions(): Definitions {
23
- return {
24
- ...super.getDefinitions(),
25
- appEntryPoint: this.config.appEntryPoint,
26
- };
27
- }
28
- override getTemplateFiles(): { [path: string]: ProjectFile } {
29
- const tff = new TemplateFilesFactory('detox');
30
-
31
- const additionalFiles: { [path: string]: ProjectFile } = this.config.additionalFiles?.reduce(
32
- (reducer, file) => ({
33
- ...reducer,
34
- [file]: new UserFile(this.userFilePath(file)),
35
- }),
36
- {}
37
- );
38
-
39
- if (this.config.android?.detoxTestFile) {
40
- additionalFiles['android/app/src/androidTest/java/com/testrunner/DetoxTest.java'] =
41
- new UserFile(this.userFilePath(this.config.android.detoxTestFile), Platform.Android);
42
- }
43
-
44
- return {
45
- ...super.getTemplateFiles(),
46
- 'android/build.gradle': tff.androidFile(),
47
- 'android/app/build.gradle': tff.androidFile(),
48
- 'android/app/src/androidTest/java/com/testrunner/DetoxTest.java': tff.androidFile(),
49
- 'index.js': tff.file(true),
50
- [this.config.detoxConfigFile]: new UserFile(
51
- this.userFilePath(this.config.detoxConfigFile),
52
- Platform.Both,
53
- true
54
- ),
55
- ...additionalFiles,
56
- };
57
- }
58
-
59
- override async build(projectPath: string, test: DetoxTest): Promise<void> {
60
- for (const conf of test.configurations) {
61
- await spawnAsync('yarn', ['detox', 'build', '-c', conf], {
62
- cwd: projectPath,
63
- stdio: 'inherit',
64
- });
65
- }
66
- }
67
-
68
- override async run(projectPath: string, test: DetoxTest): Promise<void> {
69
- let bundler: BundlerController | undefined;
70
- try {
71
- bundler = new BundlerController(projectPath);
72
-
73
- if (test.shouldRunBundler) {
74
- await bundler.start();
75
- }
76
-
77
- for (const conf of test.configurations) {
78
- await spawnAsync(
79
- 'yarn',
80
- ['detox', 'test', '-c', conf, '--ci', '--headless', '--gpu', 'swiftshader_indirect'],
81
- {
82
- cwd: projectPath,
83
- stdio: 'inherit',
84
- }
85
- );
86
-
87
- await killVirtualDevicesAsync(this.platform);
88
- }
89
- } finally {
90
- // If bundler wasn't started is noop.
91
- await bundler?.stop();
92
- }
93
- }
94
- }