@nx/detox 0.0.0-pr-22179-271588f

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 (55) hide show
  1. package/.eslintrc.json +32 -0
  2. package/LICENSE +22 -0
  3. package/README.md +68 -0
  4. package/executors.json +14 -0
  5. package/generators.json +20 -0
  6. package/index.d.ts +2 -0
  7. package/index.js +7 -0
  8. package/migrations.json +130 -0
  9. package/package.json +49 -0
  10. package/plugin.d.ts +1 -0
  11. package/plugin.js +6 -0
  12. package/project.json +58 -0
  13. package/src/executors/build/build.impl.d.ts +7 -0
  14. package/src/executors/build/build.impl.js +56 -0
  15. package/src/executors/build/schema.json +23 -0
  16. package/src/executors/test/schema.json +170 -0
  17. package/src/executors/test/test.impl.d.ts +6 -0
  18. package/src/executors/test/test.impl.js +80 -0
  19. package/src/generators/application/application.d.ts +5 -0
  20. package/src/generators/application/application.js +37 -0
  21. package/src/generators/application/files/app/.babelrc.template +11 -0
  22. package/src/generators/application/files/app/.detoxrc.json.template +91 -0
  23. package/src/generators/application/files/app/jest.config.json.template +23 -0
  24. package/src/generators/application/files/app/src/app.spec.ts.template +11 -0
  25. package/src/generators/application/files/app/test-setup.ts.template +5 -0
  26. package/src/generators/application/files/app/tsconfig.e2e.json +10 -0
  27. package/src/generators/application/files/app/tsconfig.json +10 -0
  28. package/src/generators/application/lib/add-git-ignore-entry.d.ts +3 -0
  29. package/src/generators/application/lib/add-git-ignore-entry.js +15 -0
  30. package/src/generators/application/lib/add-linting.d.ts +3 -0
  31. package/src/generators/application/lib/add-linting.js +27 -0
  32. package/src/generators/application/lib/add-project.d.ts +3 -0
  33. package/src/generators/application/lib/add-project.js +48 -0
  34. package/src/generators/application/lib/create-files.d.ts +3 -0
  35. package/src/generators/application/lib/create-files.js +18 -0
  36. package/src/generators/application/lib/ensure-dependencies.d.ts +3 -0
  37. package/src/generators/application/lib/ensure-dependencies.js +18 -0
  38. package/src/generators/application/lib/get-targets.d.ts +51 -0
  39. package/src/generators/application/lib/get-targets.js +68 -0
  40. package/src/generators/application/lib/normalize-options.d.ts +11 -0
  41. package/src/generators/application/lib/normalize-options.js +32 -0
  42. package/src/generators/application/schema.json +72 -0
  43. package/src/generators/init/init.d.ts +6 -0
  44. package/src/generators/init/init.js +64 -0
  45. package/src/generators/init/schema.json +33 -0
  46. package/src/migrations/update-16-0-0/update-detoxrc-json.d.ts +10 -0
  47. package/src/migrations/update-16-0-0/update-detoxrc-json.js +66 -0
  48. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  49. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  50. package/src/migrations/update-16-1-4/update-detoxrc-json-expo.d.ts +8 -0
  51. package/src/migrations/update-16-1-4/update-detoxrc-json-expo.js +81 -0
  52. package/src/plugins/plugin.d.ts +8 -0
  53. package/src/plugins/plugin.js +89 -0
  54. package/src/utils/versions.d.ts +4 -0
  55. package/src/utils/versions.js +7 -0
@@ -0,0 +1,51 @@
1
+ export declare function reactNativeBuildTarget(platform: 'ios.sim' | 'android.emu'): {
2
+ options: {
3
+ detoxConfiguration: string;
4
+ };
5
+ configurations: {
6
+ production: {
7
+ detoxConfiguration: string;
8
+ };
9
+ };
10
+ };
11
+ export declare function expoBuildTarget(platform: 'ios.sim' | 'android.emu'): {
12
+ options: {
13
+ detoxConfiguration: string;
14
+ };
15
+ configurations: {
16
+ bare: {
17
+ detoxConfiguration: string;
18
+ };
19
+ production: {
20
+ detoxConfiguration: string;
21
+ };
22
+ };
23
+ };
24
+ export declare function reactNativeTestTarget(platform: 'ios.sim' | 'android.emu', e2eName: string): {
25
+ options: {
26
+ detoxConfiguration: string;
27
+ buildTarget: string;
28
+ };
29
+ configurations: {
30
+ production: {
31
+ detoxConfiguration: string;
32
+ buildTarget: string;
33
+ };
34
+ };
35
+ };
36
+ export declare function expoTestTarget(platform: 'ios.sim' | 'android.emu', e2eName: string): {
37
+ options: {
38
+ detoxConfiguration: string;
39
+ buildTarget: string;
40
+ };
41
+ configurations: {
42
+ bare: {
43
+ detoxConfiguration: string;
44
+ buildTarget: string;
45
+ };
46
+ production: {
47
+ detoxConfiguration: string;
48
+ buildTarget: string;
49
+ };
50
+ };
51
+ };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expoTestTarget = exports.reactNativeTestTarget = exports.expoBuildTarget = exports.reactNativeBuildTarget = void 0;
4
+ function reactNativeBuildTarget(platform) {
5
+ return {
6
+ options: {
7
+ detoxConfiguration: `${platform}.debug`,
8
+ },
9
+ configurations: {
10
+ production: {
11
+ detoxConfiguration: `${platform}.release`,
12
+ },
13
+ },
14
+ };
15
+ }
16
+ exports.reactNativeBuildTarget = reactNativeBuildTarget;
17
+ function expoBuildTarget(platform) {
18
+ return {
19
+ options: {
20
+ detoxConfiguration: `${platform}.local`,
21
+ },
22
+ configurations: {
23
+ bare: {
24
+ detoxConfiguration: `${platform}.debug`,
25
+ },
26
+ production: {
27
+ detoxConfiguration: `${platform}.release`,
28
+ },
29
+ },
30
+ };
31
+ }
32
+ exports.expoBuildTarget = expoBuildTarget;
33
+ function reactNativeTestTarget(platform, e2eName) {
34
+ const buildPlatform = platform === 'ios.sim' ? 'ios' : 'android';
35
+ return {
36
+ options: {
37
+ detoxConfiguration: `${platform}.debug`,
38
+ buildTarget: `${e2eName}:build-${buildPlatform}`,
39
+ },
40
+ configurations: {
41
+ production: {
42
+ detoxConfiguration: `${platform}.release`,
43
+ buildTarget: `${e2eName}:build-${buildPlatform}:production`,
44
+ },
45
+ },
46
+ };
47
+ }
48
+ exports.reactNativeTestTarget = reactNativeTestTarget;
49
+ function expoTestTarget(platform, e2eName) {
50
+ const buildPlatform = platform === 'ios.sim' ? 'ios' : 'android';
51
+ return {
52
+ options: {
53
+ detoxConfiguration: `${platform}.local`,
54
+ buildTarget: `${e2eName}:build-${buildPlatform}`,
55
+ },
56
+ configurations: {
57
+ bare: {
58
+ detoxConfiguration: `${platform}.debug`,
59
+ buildTarget: `${e2eName}:build-${buildPlatform}:bare`,
60
+ },
61
+ production: {
62
+ detoxConfiguration: `${platform}.release`,
63
+ buildTarget: `${e2eName}:build-${buildPlatform}:production`,
64
+ },
65
+ },
66
+ };
67
+ }
68
+ exports.expoTestTarget = expoTestTarget;
@@ -0,0 +1,11 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Schema } from '../schema';
3
+ export interface NormalizedSchema extends Schema {
4
+ appFileName: string;
5
+ appClassName: string;
6
+ appExpoName: string;
7
+ appRoot: string;
8
+ e2eProjectName: string;
9
+ e2eProjectRoot: string;
10
+ }
11
+ export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ async function normalizeOptions(host, options) {
7
+ const { projectName: e2eProjectName, projectRoot: e2eProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
+ name: options.e2eName,
9
+ projectType: 'application',
10
+ directory: options.e2eDirectory,
11
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
12
+ callingGenerator: '@nx/detox:application',
13
+ });
14
+ const nxJson = (0, devkit_1.readNxJson)(host);
15
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
16
+ nxJson.useInferencePlugins !== false;
17
+ options.addPlugin ??= addPlugin;
18
+ const { fileName: appFileName, className: appClassName } = (0, devkit_1.names)(options.appName || options.appProject);
19
+ const { root: appRoot } = (0, devkit_1.readProjectConfiguration)(host, (0, devkit_1.names)(options.appProject).fileName);
20
+ return {
21
+ ...options,
22
+ appFileName,
23
+ appClassName,
24
+ appDisplayName: options.appDisplayName || appClassName,
25
+ appExpoName: options.appDisplayName?.replace(/\s/g, '') || appClassName,
26
+ appRoot,
27
+ e2eName: e2eProjectName,
28
+ e2eProjectName,
29
+ e2eProjectRoot,
30
+ };
31
+ }
32
+ exports.normalizeOptions = normalizeOptions;
@@ -0,0 +1,72 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "title": "Create Detox Configuration for the workspace",
4
+ "description": "Create Detox Configuration for the workspace.",
5
+ "type": "object",
6
+ "properties": {
7
+ "appProject": {
8
+ "type": "string",
9
+ "description": "Name of the frontend project to be tested.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ },
13
+ "x-prompt": "What is the name of the frontend project to test?"
14
+ },
15
+ "e2eName": {
16
+ "type": "string",
17
+ "description": "Name of the E2E Project.",
18
+ "$default": {
19
+ "$source": "argv",
20
+ "index": 0
21
+ },
22
+ "x-prompt": "What name would you like to use for the E2E project?",
23
+ "pattern": "^[a-zA-Z][^:]*$"
24
+ },
25
+ "appName": {
26
+ "type": "string",
27
+ "description": "Name of the app to be tested if different from appProject"
28
+ },
29
+ "appDisplayName": {
30
+ "type": "string",
31
+ "description": "Display name of the app to be tested if different from appProject"
32
+ },
33
+ "framework": {
34
+ "type": "string",
35
+ "description": "App framework to test",
36
+ "enum": ["react-native", "expo"],
37
+ "x-prompt": "What app framework should detox test?"
38
+ },
39
+ "e2eDirectory": {
40
+ "type": "string",
41
+ "description": "A directory where the project is placed relative to apps directory."
42
+ },
43
+ "projectNameAndRootFormat": {
44
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
45
+ "type": "string",
46
+ "enum": ["as-provided", "derived"]
47
+ },
48
+ "linter": {
49
+ "description": "The tool to use for running lint checks.",
50
+ "type": "string",
51
+ "enum": ["eslint", "none"],
52
+ "default": "eslint"
53
+ },
54
+ "js": {
55
+ "description": "Generate JavaScript files rather than TypeScript files.",
56
+ "type": "boolean",
57
+ "default": false
58
+ },
59
+ "skipFormat": {
60
+ "description": "Skip formatting files.",
61
+ "type": "boolean",
62
+ "default": false,
63
+ "x-priority": "internal"
64
+ },
65
+ "setParserOptionsProject": {
66
+ "type": "boolean",
67
+ "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
68
+ "default": false
69
+ }
70
+ },
71
+ "required": ["e2eName", "appProject", "framework"]
72
+ }
@@ -0,0 +1,6 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { Schema } from './schema';
3
+ export declare function detoxInitGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function detoxInitGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
5
+ export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
6
+ export default detoxInitGenerator;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateDependencies = exports.detoxInitGeneratorInternal = exports.detoxInitGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
6
+ const plugin_1 = require("../../plugins/plugin");
7
+ const versions_1 = require("../../utils/versions");
8
+ function detoxInitGenerator(host, schema) {
9
+ return detoxInitGeneratorInternal(host, { addPlugin: false, ...schema });
10
+ }
11
+ exports.detoxInitGenerator = detoxInitGenerator;
12
+ async function detoxInitGeneratorInternal(host, schema) {
13
+ const tasks = [];
14
+ const nxJson = (0, devkit_1.readNxJson)(host);
15
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
16
+ nxJson.useInferencePlugins !== false;
17
+ schema.addPlugin ??= addPluginDefault;
18
+ if (!schema.skipPackageJson) {
19
+ tasks.push(moveDependency(host));
20
+ tasks.push(updateDependencies(host, schema));
21
+ }
22
+ if (schema.addPlugin) {
23
+ addPlugin(host);
24
+ }
25
+ if (schema.updatePackageScripts) {
26
+ await (0, update_package_scripts_1.updatePackageScripts)(host, plugin_1.createNodes);
27
+ }
28
+ if (!schema.skipFormat) {
29
+ await (0, devkit_1.formatFiles)(host);
30
+ }
31
+ return (0, devkit_1.runTasksInSerial)(...tasks);
32
+ }
33
+ exports.detoxInitGeneratorInternal = detoxInitGeneratorInternal;
34
+ function updateDependencies(host, schema) {
35
+ return (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
36
+ '@nx/detox': versions_1.nxVersion,
37
+ detox: versions_1.detoxVersion,
38
+ }, undefined, schema.keepExistingVersions);
39
+ }
40
+ exports.updateDependencies = updateDependencies;
41
+ function moveDependency(host) {
42
+ return (0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/detox'], []);
43
+ }
44
+ function addPlugin(host) {
45
+ const nxJson = (0, devkit_1.readNxJson)(host);
46
+ nxJson.plugins ??= [];
47
+ for (const plugin of nxJson.plugins) {
48
+ if (typeof plugin === 'string'
49
+ ? plugin === '@nx/detox/plugin'
50
+ : plugin.plugin === '@nx/detox/plugin') {
51
+ return;
52
+ }
53
+ }
54
+ nxJson.plugins.push({
55
+ plugin: '@nx/detox/plugin',
56
+ options: {
57
+ buildTargetName: 'build',
58
+ startTargetName: 'start',
59
+ testTargetName: 'test',
60
+ },
61
+ });
62
+ (0, devkit_1.updateNxJson)(host, nxJson);
63
+ }
64
+ exports.default = detoxInitGenerator;
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "title": "Add Detox Schematics",
4
+ "description": "Add Detox Schematics.",
5
+ "type": "object",
6
+ "properties": {
7
+ "skipFormat": {
8
+ "description": "Skip formatting files.",
9
+ "type": "boolean",
10
+ "default": false,
11
+ "x-priority": "internal"
12
+ },
13
+ "skipPackageJson": {
14
+ "type": "boolean",
15
+ "default": false,
16
+ "description": "Do not add dependencies to `package.json`.",
17
+ "x-priority": "internal"
18
+ },
19
+ "keepExistingVersions": {
20
+ "type": "boolean",
21
+ "x-priority": "internal",
22
+ "description": "Keep existing dependencies versions",
23
+ "default": false
24
+ },
25
+ "updatePackageScripts": {
26
+ "type": "boolean",
27
+ "x-priority": "internal",
28
+ "description": "Update `package.json` scripts with inferred targets",
29
+ "default": false
30
+ }
31
+ },
32
+ "required": []
33
+ }
@@ -0,0 +1,10 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Update .detoxrc.json under detox project:
4
+ * - remove deprecated keys: testRunner
5
+ * - update keys: runnerConfig
6
+ * Update jest.config.json under detox project:
7
+ * - remove key: transform
8
+ * - add key: rootDir, testMatch, reporter, globalSetup, globalTeardown, verbose
9
+ */
10
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ /**
5
+ * Update .detoxrc.json under detox project:
6
+ * - remove deprecated keys: testRunner
7
+ * - update keys: runnerConfig
8
+ * Update jest.config.json under detox project:
9
+ * - remove key: transform
10
+ * - add key: rootDir, testMatch, reporter, globalSetup, globalTeardown, verbose
11
+ */
12
+ async function update(tree) {
13
+ const projects = (0, devkit_1.getProjects)(tree);
14
+ projects.forEach((project) => {
15
+ if (project.targets?.['test-ios']?.executor !== '@nx/detox:test')
16
+ return;
17
+ updateDetoxrcJson(tree, project);
18
+ updateJestConfigJson(tree, project);
19
+ });
20
+ await (0, devkit_1.formatFiles)(tree);
21
+ }
22
+ exports.default = update;
23
+ function updateDetoxrcJson(host, project) {
24
+ const detoxConfigPath = `${project.root}/.detoxrc.json`;
25
+ if (!host.exists(detoxConfigPath))
26
+ return;
27
+ (0, devkit_1.updateJson)(host, detoxConfigPath, (json) => {
28
+ json.testRunner = {
29
+ args: {
30
+ $0: 'jest',
31
+ config: './jest.config.json',
32
+ },
33
+ jest: {
34
+ setupTimeout: 120000,
35
+ },
36
+ };
37
+ if (json.runnerConfig) {
38
+ delete json.runnerConfig;
39
+ }
40
+ return json;
41
+ });
42
+ }
43
+ function updateJestConfigJson(host, project) {
44
+ const jestConfigPath = `${project.root}/jest.config.json`;
45
+ if (!host.exists(jestConfigPath))
46
+ return;
47
+ (0, devkit_1.updateJson)(host, jestConfigPath, (json) => {
48
+ if (json.transform) {
49
+ delete json.transform;
50
+ }
51
+ if (!json.rootDir) {
52
+ json.rootDir = '.';
53
+ }
54
+ if (!json.testMatch) {
55
+ json.testMatch = [
56
+ '<rootDir>/src/**/*.test.ts?(x)',
57
+ '<rootDir>/src/**/*.spec.ts?(x)',
58
+ ];
59
+ }
60
+ json.reporter = ['detox/runners/jest/reporter'];
61
+ json.globalSetup = 'detox/runners/jest/globalSetup';
62
+ json.globalTeardown = 'detox/runners/jest/globalTeardown';
63
+ json.verbose = true;
64
+ return json;
65
+ });
66
+ }
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function replacePackage(tree: Tree): Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
5
+ async function replacePackage(tree) {
6
+ (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/detox', '@nx/detox');
7
+ await (0, devkit_1.formatFiles)(tree);
8
+ }
9
+ exports.default = replacePackage;
@@ -0,0 +1,8 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Update .detoxrc.json under detox project for expo:
4
+ * - fix the eas build command
5
+ * - fix the local build command
6
+ * - update project.json targets
7
+ */
8
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ /**
5
+ * Update .detoxrc.json under detox project for expo:
6
+ * - fix the eas build command
7
+ * - fix the local build command
8
+ * - update project.json targets
9
+ */
10
+ async function update(tree) {
11
+ const projects = (0, devkit_1.getProjects)(tree);
12
+ projects.forEach((project) => {
13
+ if (project.targets?.['test-ios']?.executor !== '@nx/detox:test')
14
+ return;
15
+ updateDetoxrcJson(tree, project);
16
+ updateProjectJson(tree, project);
17
+ });
18
+ await (0, devkit_1.formatFiles)(tree);
19
+ }
20
+ exports.default = update;
21
+ function updateDetoxrcJson(host, project) {
22
+ const detoxConfigPath = `${project.root}/.detoxrc.json`;
23
+ const projectName = project.name?.endsWith('-e2e')
24
+ ? project.name.substring(0, project.name.indexOf('-e2e'))
25
+ : project.name;
26
+ const appRoot = (0, devkit_1.getProjects)(host).get(projectName)?.root;
27
+ const appName = (0, devkit_1.names)(projectName).className;
28
+ const offset = (0, devkit_1.offsetFromRoot)(project.root);
29
+ const exec = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(host.root)).exec;
30
+ if (!host.exists(detoxConfigPath))
31
+ return;
32
+ (0, devkit_1.updateJson)(host, detoxConfigPath, (json) => {
33
+ if (json.apps?.['ios.eas']) {
34
+ json.apps['ios.eas'].build = `${exec} nx run ${projectName}:download --platform ios --distribution simulator --output=${offset}${appRoot}/dist/`;
35
+ }
36
+ if (json.apps?.['android.eas']) {
37
+ json.apps['android.eas'].build = `${exec} nx run ${projectName}:download --platform android --distribution simulator --output=${offset}${appRoot}/dist/`;
38
+ json.apps['android.eas'].type = 'android.apk';
39
+ }
40
+ if (json.apps?.['ios.local']) {
41
+ json.apps['ios.local'].build = `${exec} nx run ${projectName}:build --platform ios --profile preview --wait --local --no-interactive --output=${offset}${appRoot}/dist/${appName}.tar.gz`;
42
+ }
43
+ if (json.apps?.['android.local']) {
44
+ json.apps['android.local'].build = `${exec} nx run ${projectName}:build --platform android --profile preview --wait --local --no-interactive --output=${offset}${appRoot}/dist/${appName}.apk`;
45
+ json.apps['android.local'].type = 'android.apk';
46
+ }
47
+ return json;
48
+ });
49
+ }
50
+ function updateProjectJson(host, project) {
51
+ if (project.targets?.['test-ios']?.options?.detoxConfiguration == 'ios.sim.eas') {
52
+ project.targets['build-ios'].options.detoxConfiguration = 'ios.sim.eas';
53
+ }
54
+ if (project.targets?.['test-android']?.options?.detoxConfiguration ==
55
+ 'android.sim.eas') {
56
+ project.targets['build-android'].options.detoxConfiguration =
57
+ 'android.sim.eas';
58
+ project.targets['test-android'] = {
59
+ executor: '@nx/detox:test',
60
+ options: {
61
+ detoxConfiguration: 'android.sim.eas',
62
+ buildTarget: `${project.name}:build-android`,
63
+ },
64
+ configurations: {
65
+ local: {
66
+ detoxConfiguration: 'android.emu.local',
67
+ buildTarget: `${project.name}:build-android:local`,
68
+ },
69
+ bare: {
70
+ detoxConfiguration: 'android.emu.debug',
71
+ buildTarget: `${project.name}:build-android:bare`,
72
+ },
73
+ production: {
74
+ detoxConfiguration: 'android.emu.release',
75
+ buildTarget: `${project.name}:build-android:production`,
76
+ },
77
+ },
78
+ };
79
+ }
80
+ (0, devkit_1.updateProjectConfiguration)(host, project.name, project);
81
+ }
@@ -0,0 +1,8 @@
1
+ import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
+ export interface DetoxPluginOptions {
3
+ buildTargetName?: string;
4
+ startTargetName?: string;
5
+ testTargetName?: string;
6
+ }
7
+ export declare const createDependencies: CreateDependencies;
8
+ export declare const createNodes: CreateNodes<DetoxPluginOptions>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = exports.createDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const js_1 = require("@nx/js");
7
+ const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
+ const fs_1 = require("fs");
9
+ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
11
+ const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'detox.hash');
12
+ const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
13
+ const calculatedTargets = {};
14
+ function readTargetsCache() {
15
+ return (0, devkit_1.readJsonFile)(cachePath);
16
+ }
17
+ function writeTargetsToCache(targets) {
18
+ (0, devkit_1.writeJsonFile)(cachePath, targets);
19
+ }
20
+ const createDependencies = () => {
21
+ writeTargetsToCache(calculatedTargets);
22
+ return [];
23
+ };
24
+ exports.createDependencies = createDependencies;
25
+ exports.createNodes = [
26
+ '**/{detox.config,.detoxrc}.{json,js}',
27
+ (configFilePath, options, context) => {
28
+ options = normalizeOptions(options);
29
+ const projectRoot = (0, path_1.dirname)(configFilePath);
30
+ // Do not create a project if project.json isn't there.
31
+ const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
32
+ if (!siblingFiles.includes('project.json')) {
33
+ return {};
34
+ }
35
+ const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
36
+ (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
37
+ ]);
38
+ const targets = targetsCache[hash]
39
+ ? targetsCache[hash]
40
+ : buildDetoxTargets(projectRoot, options, context);
41
+ calculatedTargets[hash] = targets;
42
+ return {
43
+ projects: {
44
+ [projectRoot]: {
45
+ targets,
46
+ },
47
+ },
48
+ };
49
+ },
50
+ ];
51
+ function buildDetoxTargets(projectRoot, options, context) {
52
+ const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
53
+ const targets = {
54
+ [options.buildTargetName]: {
55
+ command: `detox build`,
56
+ options: { cwd: projectRoot },
57
+ cache: true,
58
+ inputs: getInputs(namedInputs),
59
+ },
60
+ [options.startTargetName]: {
61
+ command: `detox start`,
62
+ options: { cwd: projectRoot },
63
+ },
64
+ [options.testTargetName]: {
65
+ command: `detox test`,
66
+ options: { cwd: projectRoot },
67
+ cache: true,
68
+ inputs: getInputs(namedInputs),
69
+ },
70
+ };
71
+ return targets;
72
+ }
73
+ function getInputs(namedInputs) {
74
+ return [
75
+ ...('production' in namedInputs
76
+ ? ['default', '^production']
77
+ : ['default', '^default']),
78
+ {
79
+ externalDependencies: ['detox'],
80
+ },
81
+ ];
82
+ }
83
+ function normalizeOptions(options) {
84
+ options ??= {};
85
+ options.buildTargetName ??= 'build';
86
+ options.startTargetName ??= 'start';
87
+ options.testTargetName ??= 'test';
88
+ return options;
89
+ }
@@ -0,0 +1,4 @@
1
+ export declare const nxVersion: any;
2
+ export declare const detoxVersion = "~20.18.1";
3
+ export declare const testingLibraryJestDom = "~6.4.2";
4
+ export declare const configPluginsDetoxVersion = "~7.0.0";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configPluginsDetoxVersion = exports.testingLibraryJestDom = exports.detoxVersion = exports.nxVersion = void 0;
4
+ exports.nxVersion = require('../../package.json').version;
5
+ exports.detoxVersion = '~20.18.1';
6
+ exports.testingLibraryJestDom = '~6.4.2';
7
+ exports.configPluginsDetoxVersion = '~7.0.0'; // only required for expo