@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,170 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "Run detox test",
5
+ "description": "Run detox test options.",
6
+ "type": "object",
7
+ "cli": "nx",
8
+ "presets": [
9
+ {
10
+ "name": "Test a Detox Configuration",
11
+ "keys": ["detoxConfiguration"]
12
+ },
13
+ {
14
+ "name": "Reuse Existing Installed App",
15
+ "keys": ["reuse"]
16
+ },
17
+ {
18
+ "name": "Set Log Level",
19
+ "keys": ["loglevel"]
20
+ }
21
+ ],
22
+ "properties": {
23
+ "detoxConfiguration": {
24
+ "type": "string",
25
+ "description": "Select a device configuration from your defined configurations, if not supplied, and there's only one configuration, detox will default to it.",
26
+ "alias": "C",
27
+ "examples": [
28
+ "ios.sim.debug",
29
+ "ios.sim.release",
30
+ "android.emu.debug",
31
+ "android.emu.release"
32
+ ]
33
+ },
34
+ "buildTarget": {
35
+ "type": "string",
36
+ "description": "Target which builds the application."
37
+ },
38
+ "configPath": {
39
+ "type": "string",
40
+ "description": "Specify Detox config file path. If not supplied, detox searches for `.detoxrc[.js]` or `detox` section in package.json.",
41
+ "alias": "cp",
42
+ "x-completion-type": "file",
43
+ "x-completion-glob": ".detoxrc?(.js)",
44
+ "x-priority": "important"
45
+ },
46
+ "loglevel": {
47
+ "type": "string",
48
+ "enum": ["fatal", "error", "warn", "info", "verbose", "trace"],
49
+ "description": "Log level: `fatal`, `error`, `warn`, `info`, `verbose`, `trace`.",
50
+ "alias": "l"
51
+ },
52
+ "retries": {
53
+ "type": "number",
54
+ "description": "[Jest Circus Only] Re-spawn the test runner for individual failing suite files until they pass, or `<N>` times at least."
55
+ },
56
+ "reuse": {
57
+ "type": "boolean",
58
+ "description": "Reuse existing installed app (do not delete + reinstall) for a faster run.",
59
+ "default": false
60
+ },
61
+ "cleanup": {
62
+ "type": "boolean",
63
+ "description": "Shutdown simulator when test is over, useful for CI scripts, to make sure detox exists cleanly with no residue",
64
+ "alias": "u"
65
+ },
66
+ "debugSynchronization": {
67
+ "type": "boolean",
68
+ "description": "Customize how long an action/expectation can take to complete before Detox starts querying the app why it is busy. By default, the app status will be printed if the action takes more than 10s to complete.",
69
+ "alias": "d"
70
+ },
71
+ "artifactsLocation": {
72
+ "type": "string",
73
+ "description": "Artifacts (logs, screenshots, etc) root directory.",
74
+ "alias": "a"
75
+ },
76
+ "recordLogs": {
77
+ "type": "string",
78
+ "enum": ["failing", "all", "none"],
79
+ "description": "Save logs during each test to artifacts directory. Pass `failing` to save logs of failing tests only."
80
+ },
81
+ "takeScreenshots": {
82
+ "type": "string",
83
+ "enum": ["manual", "failing", "all", "none"],
84
+ "description": "Save screenshots before and after each test to artifacts directory. Pass `failing` to save screenshots of failing tests only. "
85
+ },
86
+ "recordVideos": {
87
+ "type": "string",
88
+ "enum": ["failing", "all", "none"],
89
+ "description": "Save screen recordings of each test to artifacts directory. Pass `failing` to save recordings of failing tests only."
90
+ },
91
+ "recordPerformance": {
92
+ "type": "string",
93
+ "enum": ["all", "none"],
94
+ "description": "[iOS Only] Save Detox Instruments performance recordings of each test to artifacts directory."
95
+ },
96
+ "captureViewHierarchy": {
97
+ "type": "string",
98
+ "enum": ["enabled", "disabled"],
99
+ "description": "[iOS Only] Capture `*.uihierarchy` snapshots on view action errors and `device.captureViewHierarchy()` calls."
100
+ },
101
+ "jestReportSpecs": {
102
+ "type": "boolean",
103
+ "description": "[Jest Only] Whether to output logs per each running spec, in real-time. By default, disabled with multiple workers."
104
+ },
105
+ "headless": {
106
+ "type": "boolean",
107
+ "description": "Android Only] Launch Emulator in headless mode. Useful when running on CI."
108
+ },
109
+ "gpu": {
110
+ "type": "boolean",
111
+ "description": "[Android Only] Launch Emulator with the specific `-gpu [gpu mode]` parameter."
112
+ },
113
+ "keepLockFile": {
114
+ "type": "boolean",
115
+ "description": "Keep the device lock file when running Detox tests."
116
+ },
117
+ "deviceName": {
118
+ "type": "string",
119
+ "description": "Override the device name specified in a configuration. Useful for running a single build configuration on multiple devices.",
120
+ "alias": "n"
121
+ },
122
+ "deviceBootArgs": {
123
+ "type": "string",
124
+ "description": "Custom arguments to pass (through) onto the device (emulator/simulator) binary when booted."
125
+ },
126
+ "appLaunchArgs": {
127
+ "type": "number",
128
+ "description": "Custom arguments to pass (through) onto the app every time it is launched."
129
+ },
130
+ "useCustomLogger": {
131
+ "type": "boolean",
132
+ "description": "Use Detox' custom console-logging implementation, for logging Detox (non-device) logs. Disabling will fallback to Node.js / test-runner's implementation (e.g. Jest / Mocha)."
133
+ },
134
+ "forceAdbInstall": {
135
+ "type": "boolean",
136
+ "description": "Due to problems with the adb install command on Android, Detox resorts to a different scheme for install APK's. Setting true will disable that and force usage of `adb install`, instead."
137
+ },
138
+ "inspectBrk": {
139
+ "type": "boolean",
140
+ "description": "Uses node's `--inspect-brk` flag to let users debug the jest/mocha test runner"
141
+ },
142
+ "color": {
143
+ "type": "boolean",
144
+ "description": "Colors in log output"
145
+ },
146
+ "runnerConfig": {
147
+ "type": "string",
148
+ "description": "Test runner config file, defaults to `e2e/mocha.opts` for mocha and `e2e/config.json` for Jest.",
149
+ "alias": "o",
150
+ "x-deprecated": "Deprecated in Detox 20. It is default to jest.config.json. It could be specified in .detoxrc.json"
151
+ },
152
+ "recordTimeline": {
153
+ "type": "string",
154
+ "enum": ["all", "none"],
155
+ "description": "[Jest Only] Record tests and events timeline, for visual display on the `chrome://tracing` tool.",
156
+ "x-deprecated": "Deprecated in Detox 20."
157
+ },
158
+ "workers": {
159
+ "type": "number",
160
+ "description": "Specifies number of workers the test runner should spawn, requires a test runner with parallel execution support (Detox CLI currently supports Jest).",
161
+ "x-deprecated": "Deprecated in Detox 20."
162
+ },
163
+ "deviceLaunchArgs": {
164
+ "type": "string",
165
+ "description": "A list of passthrough-arguments to use when (if) devices (Android emulator / iOS simulator) are launched by Detox.",
166
+ "x-deprecated": "Deprecated in Detox 20. Use `deviceBootArgs` instead."
167
+ }
168
+ },
169
+ "required": ["detoxConfiguration"]
170
+ }
@@ -0,0 +1,6 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { DetoxTestOptions } from './schema';
3
+ export interface DetoxTestOutput {
4
+ success: boolean;
5
+ }
6
+ export default function detoxTestExecutor(options: DetoxTestOptions, context: ExecutorContext): AsyncGenerator<DetoxTestOutput>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const devkit_2 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const child_process_1 = require("child_process");
7
+ const build_impl_1 = require("../build/build.impl");
8
+ let childProcess;
9
+ async function* detoxTestExecutor(options, context) {
10
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
11
+ try {
12
+ if (!options.reuse && options.buildTarget) {
13
+ const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context);
14
+ const buildOptions = (0, devkit_1.readTargetOptions)(buildTarget, context);
15
+ await (0, build_impl_1.runCliBuild)(context.root, projectRoot, {
16
+ ...buildOptions,
17
+ detoxConfiguration: options.detoxConfiguration,
18
+ });
19
+ }
20
+ await runCliTest(context.root, projectRoot, options);
21
+ yield { success: true };
22
+ }
23
+ finally {
24
+ if (childProcess) {
25
+ childProcess.kill();
26
+ }
27
+ }
28
+ }
29
+ exports.default = detoxTestExecutor;
30
+ function runCliTest(workspaceRoot, projectRoot, options) {
31
+ return new Promise((resolve, reject) => {
32
+ childProcess = (0, child_process_1.fork)(require.resolve('detox/local-cli/cli.js'), ['test', ...createDetoxTestOptions(options)], {
33
+ cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
34
+ env: process.env,
35
+ });
36
+ // Ensure the child process is killed when the parent exits
37
+ process.on('exit', () => childProcess.kill());
38
+ process.on('SIGTERM', () => childProcess.kill());
39
+ childProcess.on('error', (err) => {
40
+ reject(err);
41
+ });
42
+ childProcess.on('exit', (code) => {
43
+ if (code === 0) {
44
+ resolve(code);
45
+ }
46
+ else {
47
+ reject(code);
48
+ }
49
+ });
50
+ });
51
+ }
52
+ const nxOptions = ['buildTarget'];
53
+ function createDetoxTestOptions(options) {
54
+ return Object.keys(options).reduce((acc, k) => {
55
+ const propertyValue = options[k];
56
+ if (nxOptions.includes(k)) {
57
+ return acc;
58
+ }
59
+ else if (k === 'detoxConfiguration') {
60
+ acc.push('--configuration', propertyValue);
61
+ }
62
+ else if (k === 'deviceBootArgs') {
63
+ acc.push(`--device-boot-args="${propertyValue}"`); // the value must be specified after an equal sign (=) and inside quotes: https://wix.github.io/Detox/docs/cli/test
64
+ }
65
+ else if (k === 'appLaunchArgs') {
66
+ acc.push(`--app-launch-args="${propertyValue}"`); // the value must be specified after an equal sign (=) and inside quotes: https://wix.github.io/Detox/docs/cli/test
67
+ }
68
+ else if (k === 'color') {
69
+ // detox only accepts --no-color, not --color
70
+ if (!propertyValue) {
71
+ acc.push('--no-color');
72
+ }
73
+ }
74
+ else {
75
+ const propertyName = (0, devkit_2.names)(k).fileName; // convert camelCase to kebab-case
76
+ acc.push(`--${propertyName}`, propertyValue);
77
+ }
78
+ return acc;
79
+ }, []);
80
+ }
@@ -0,0 +1,5 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Schema } from './schema';
3
+ export declare function detoxApplicationGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
4
+ export declare function detoxApplicationGeneratorInternal(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
5
+ export default detoxApplicationGenerator;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detoxApplicationGeneratorInternal = exports.detoxApplicationGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const init_1 = require("../init/init");
6
+ const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
7
+ const add_linting_1 = require("./lib/add-linting");
8
+ const add_project_1 = require("./lib/add-project");
9
+ const create_files_1 = require("./lib/create-files");
10
+ const normalize_options_1 = require("./lib/normalize-options");
11
+ const ensure_dependencies_1 = require("./lib/ensure-dependencies");
12
+ async function detoxApplicationGenerator(host, schema) {
13
+ return await detoxApplicationGeneratorInternal(host, {
14
+ addPlugin: false,
15
+ projectNameAndRootFormat: 'derived',
16
+ ...schema,
17
+ });
18
+ }
19
+ exports.detoxApplicationGenerator = detoxApplicationGenerator;
20
+ async function detoxApplicationGeneratorInternal(host, schema) {
21
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
22
+ const initTask = await (0, init_1.default)(host, {
23
+ ...options,
24
+ skipFormat: true,
25
+ });
26
+ (0, create_files_1.createFiles)(host, options);
27
+ (0, add_project_1.addProject)(host, options);
28
+ (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host, options);
29
+ const lintingTask = await (0, add_linting_1.addLinting)(host, options);
30
+ const depsTask = (0, ensure_dependencies_1.ensureDependencies)(host, options);
31
+ if (!options.skipFormat) {
32
+ await (0, devkit_1.formatFiles)(host);
33
+ }
34
+ return (0, devkit_1.runTasksInSerial)(initTask, lintingTask, depsTask);
35
+ }
36
+ exports.detoxApplicationGeneratorInternal = detoxApplicationGeneratorInternal;
37
+ exports.default = detoxApplicationGenerator;
@@ -0,0 +1,11 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@nx/react/babel",
5
+ {
6
+ "runtime": "automatic"
7
+ }
8
+ ]
9
+ ],
10
+ "plugins": []
11
+ }
@@ -0,0 +1,91 @@
1
+ {
2
+ "testRunner": {
3
+ "args": {
4
+ "$0": "jest",
5
+ "config": "./jest.config.json"
6
+ },
7
+ "jest": {
8
+ "setupTimeout": 120000
9
+ }
10
+ },
11
+ "apps": {
12
+ "ios.debug": {
13
+ "type": "ios.app",
14
+ "build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
15
+ "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/ios/build/Build/Products/Debug-iphonesimulator/<%= appClassName %>.app"
16
+ },
17
+ "ios.release": {
18
+ "type": "ios.app",
19
+ "build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
20
+ "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/ios/build/Build/Products/Release-iphonesimulator/<%= appClassName %>.app"
21
+ },
22
+ <% if (framework === 'expo') { %>
23
+ "ios.local": {
24
+ "type": "ios.app",
25
+ "build": "<%= exec %> nx run <%= appFileName %>:build --platform ios --profile preview --wait --local --no-interactive --output=<%= offsetFromRoot %><%= appRoot %>/dist/<%= appExpoName %>.tar.gz",
26
+ "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/dist/<%= appExpoName %>.app"
27
+ },
28
+ <% } %>
29
+ "android.debug": {
30
+ "type": "android.apk",
31
+ "build": "cd <%= offsetFromRoot %><%= appRoot %>/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug",
32
+ "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/android/app/build/outputs/apk/debug/app-debug.apk"
33
+ },
34
+ "android.release": {
35
+ "type": "android.apk",
36
+ "build": "cd <%= offsetFromRoot %><%= appRoot %>/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release",
37
+ "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/android/app/build/outputs/apk/release/app-release.apk"
38
+ },
39
+ <% if (framework === 'expo') { %>
40
+ "android.local": {
41
+ "type": "android.apk",
42
+ "build": "<%= exec %> nx run <%= appFileName %>:build --platform android --profile preview --wait --local --no-interactive --output=<%= offsetFromRoot %><%= appRoot %>/dist/<%= appExpoName %>.apk",
43
+ "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/dist/<%= appExpoName %>.apk"
44
+ },
45
+ <% } %>
46
+ },
47
+ "devices": {
48
+ "simulator": {
49
+ "type": "ios.simulator",
50
+ "device": {
51
+ "type": "iPhone 14"
52
+ }
53
+ },
54
+ "emulator": {
55
+ "type": "android.emulator",
56
+ "device": {
57
+ "avdName": "Pixel_4a_API_30"
58
+ }
59
+ }
60
+ },
61
+ "configurations": {
62
+ "ios.sim.release": {
63
+ "device": "simulator",
64
+ "app": "ios.release"
65
+ },
66
+ "ios.sim.debug": {
67
+ "device": "simulator",
68
+ "app": "ios.debug"
69
+ },
70
+ <% if (framework === 'expo') { %>
71
+ "ios.sim.local": {
72
+ "device": "simulator",
73
+ "app": "ios.local"
74
+ },
75
+ <% } %>
76
+ "android.emu.release": {
77
+ "device": "emulator",
78
+ "app": "android.release"
79
+ },
80
+ "android.emu.debug": {
81
+ "device": "emulator",
82
+ "app": "android.debug"
83
+ },
84
+ <% if (framework === 'expo') { %>
85
+ "android.emu.local": {
86
+ "device": "emulator",
87
+ "app": "android.local"
88
+ },
89
+ <% } %>
90
+ }
91
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "preset": "<%= offsetFromRoot %>jest.preset",
3
+ "rootDir": ".",
4
+ "testMatch": [
5
+ "<rootDir>/src/**/*.test.ts?(x)",
6
+ "<rootDir>/src/**/*.spec.ts?(x)"
7
+ ],
8
+ "testTimeout": 120000,
9
+ "maxWorkers": 1,
10
+ "globalSetup": "detox/runners/jest/globalSetup",
11
+ "globalTeardown": "detox/runners/jest/globalTeardown",
12
+ "reporters": ["detox/runners/jest/reporter"],
13
+ "testEnvironment": "detox/runners/jest/testEnvironment",
14
+ "verbose": true,
15
+ "setupFilesAfterEnv": ["<rootDir>/test-setup.ts"],
16
+ "transform": {
17
+ "^.+\\.(ts|js|html)$": [
18
+ "ts-jest",
19
+ { "tsconfig": "<rootDir>/tsconfig.e2e.json" }
20
+ ]
21
+ }
22
+
23
+ }
@@ -0,0 +1,11 @@
1
+ import { device, element, by, expect } from 'detox';
2
+
3
+ describe('<%= appClassName %>', () => {
4
+ beforeEach(async () => {
5
+ await device.reloadReactNative();
6
+ });
7
+
8
+ it('should display welcome message', async () => {
9
+ await expect(element(by.id('heading'))).toHaveText('Welcome <%= appDisplayName %> 👋');
10
+ });
11
+ });
@@ -0,0 +1,5 @@
1
+ import { device } from 'detox';
2
+
3
+ beforeAll(async () => {
4
+ await device.launchApp();
5
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "sourceMap": false,
5
+ "outDir": "<%= offsetFromRoot %>dist/out-tsc",
6
+ "allowJs": true,
7
+ "types": ["node", "jest", "detox"]
8
+ },
9
+ "include": ["src/**/*.ts", "src/**/*.js"]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "<%= rootTsConfigPath %>",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "./tsconfig.e2e.json"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addGitIgnoreEntry(host: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGitIgnoreEntry = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function addGitIgnoreEntry(host, options) {
6
+ if (host.exists('.gitignore')) {
7
+ let content = host.read('.gitignore', 'utf-8');
8
+ content = `${content}\n${options.e2eProjectRoot}/artifacts\n`;
9
+ host.write('.gitignore', content);
10
+ }
11
+ else {
12
+ devkit_1.logger.warn(`Couldn't find .gitignore file to update`);
13
+ }
14
+ }
15
+ exports.addGitIgnoreEntry = addGitIgnoreEntry;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addLinting = void 0;
4
+ const eslint_1 = require("@nx/eslint");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const react_1 = require("@nx/react");
7
+ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
8
+ async function addLinting(host, options) {
9
+ if (options.linter === eslint_1.Linter.None) {
10
+ return () => { };
11
+ }
12
+ const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
13
+ linter: options.linter,
14
+ project: options.e2eProjectName,
15
+ tsConfigPaths: [
16
+ (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.app.json'),
17
+ ],
18
+ skipFormat: true,
19
+ addPlugin: options.addPlugin,
20
+ });
21
+ if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
22
+ (0, eslint_file_1.addExtendsToLintConfig)(host, options.e2eProjectRoot, 'plugin:@nx/react');
23
+ }
24
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, react_1.extraEslintDependencies.dependencies, react_1.extraEslintDependencies.devDependencies);
25
+ return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
26
+ }
27
+ exports.addLinting = addLinting;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addProject(host: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const get_targets_1 = require("./get-targets");
6
+ function addProject(host, options) {
7
+ const nxJson = (0, devkit_1.readNxJson)(host);
8
+ const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
9
+ ? p === '@nx/detox/plugin'
10
+ : p.plugin === '@nx/detox/plugin');
11
+ (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
12
+ root: options.e2eProjectRoot,
13
+ sourceRoot: `${options.e2eProjectRoot}/src`,
14
+ projectType: 'application',
15
+ targets: hasPlugin ? {} : getTargets(options),
16
+ tags: [],
17
+ implicitDependencies: [options.appProject],
18
+ });
19
+ }
20
+ exports.addProject = addProject;
21
+ function getTargets(options) {
22
+ const targets = {};
23
+ targets['build-ios'] = {
24
+ executor: '@nx/detox:build',
25
+ ...(options.framework === 'react-native'
26
+ ? (0, get_targets_1.reactNativeBuildTarget)('ios.sim')
27
+ : (0, get_targets_1.expoBuildTarget)('ios.sim')),
28
+ };
29
+ targets['test-ios'] = {
30
+ executor: '@nx/detox:test',
31
+ ...(options.framework === 'react-native'
32
+ ? (0, get_targets_1.reactNativeTestTarget)('ios.sim', options.e2eProjectName)
33
+ : (0, get_targets_1.expoTestTarget)('ios.sim', options.e2eProjectName)),
34
+ };
35
+ targets['build-android'] = {
36
+ executor: '@nx/detox:build',
37
+ ...(options.framework === 'react-native'
38
+ ? (0, get_targets_1.reactNativeBuildTarget)('android.emu')
39
+ : (0, get_targets_1.expoBuildTarget)('android.emu')),
40
+ };
41
+ targets['test-android'] = {
42
+ executor: '@nx/detox:test',
43
+ ...(options.framework === 'react-native'
44
+ ? (0, get_targets_1.reactNativeTestTarget)('android.emu', options.e2eProjectName)
45
+ : (0, get_targets_1.expoTestTarget)('android.emu', options.e2eProjectName)),
46
+ };
47
+ return targets;
48
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function createFiles(host: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFiles = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const js_1 = require("@nx/js");
6
+ const path_1 = require("path");
7
+ function createFiles(host, options) {
8
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), options.e2eProjectRoot, {
9
+ ...options,
10
+ exec: (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(host.root)).exec,
11
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
12
+ rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.e2eProjectRoot),
13
+ });
14
+ if (options.js) {
15
+ (0, devkit_1.toJS)(host);
16
+ }
17
+ }
18
+ exports.createFiles = createFiles;
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { NormalizedSchema } from './normalize-options';
3
+ export declare function ensureDependencies(tree: Tree, options: NormalizedSchema): import("@nx/devkit").GeneratorCallback;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("@nx/jest/src/utils/versions");
6
+ const versions_2 = require("../../../utils/versions");
7
+ function ensureDependencies(tree, options) {
8
+ const devDependencies = {
9
+ '@testing-library/jest-dom': versions_2.testingLibraryJestDom,
10
+ '@types/node': versions_1.typesNodeVersion,
11
+ 'jest-circus': versions_1.jestVersion,
12
+ };
13
+ if (options.framework === 'expo') {
14
+ devDependencies['@config-plugins/detox'] = versions_2.configPluginsDetoxVersion;
15
+ }
16
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies);
17
+ }
18
+ exports.ensureDependencies = ensureDependencies;