@nx/detox 19.5.7 → 19.6.0-beta.1
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.
- package/generators.json +5 -0
- package/package.json +7 -7
- package/src/generators/application/files/app/.detoxrc.json.template +3 -3
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +7 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.js +79 -0
- package/src/generators/convert-to-inferred/lib/post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/lib/post-target-transformer.js +34 -0
- package/src/generators/convert-to-inferred/lib/process-build-options.d.ts +3 -0
- package/src/generators/convert-to-inferred/lib/process-build-options.js +27 -0
- package/src/generators/convert-to-inferred/lib/process-test-options.d.ts +3 -0
- package/src/generators/convert-to-inferred/lib/process-test-options.js +65 -0
- package/src/generators/convert-to-inferred/schema.json +19 -0
package/generators.json
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"aliases": ["app"],
|
|
16
16
|
"x-type": "application",
|
|
17
17
|
"description": "Create a Detox application."
|
|
18
|
+
},
|
|
19
|
+
"convert-to-inferred": {
|
|
20
|
+
"factory": "./src/generators/convert-to-inferred/convert-to-inferred",
|
|
21
|
+
"schema": "./src/generators/convert-to-inferred/schema.json",
|
|
22
|
+
"description": "Convert existing Detox project(s) using `@nx/detox:*` executors to use `@nx/detox/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target."
|
|
18
23
|
}
|
|
19
24
|
}
|
|
20
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/detox",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.6.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Detox contains executors and generators for allowing your workspace to use the powerful Detox integration testing capabilities.",
|
|
6
6
|
"keywords": [
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"main": "./index",
|
|
28
28
|
"types": "index.d.ts",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@nx/devkit": "19.
|
|
31
|
-
"@nx/jest": "19.
|
|
32
|
-
"@nx/js": "19.
|
|
33
|
-
"@nx/eslint": "19.
|
|
34
|
-
"@nx/react": "19.
|
|
30
|
+
"@nx/devkit": "19.6.0-beta.1",
|
|
31
|
+
"@nx/jest": "19.6.0-beta.1",
|
|
32
|
+
"@nx/js": "19.6.0-beta.1",
|
|
33
|
+
"@nx/eslint": "19.6.0-beta.1",
|
|
34
|
+
"@nx/react": "19.6.0-beta.1",
|
|
35
35
|
"tslib": "^2.3.0",
|
|
36
|
-
"@nrwl/detox": "19.
|
|
36
|
+
"@nrwl/detox": "19.6.0-beta.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"detox": "^20.9.0"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"apps": {
|
|
12
12
|
"ios.debug": {
|
|
13
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
|
+
"build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
|
|
15
15
|
"binaryPath": "<%= offsetFromRoot %><%= appRoot %>/ios/build/Build/Products/Debug-iphonesimulator/<%= appClassName %>.app"
|
|
16
16
|
},
|
|
17
17
|
"ios.release": {
|
|
18
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
|
|
19
|
+
"build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
|
|
20
20
|
"binaryPath": "<%= offsetFromRoot %><%= appRoot %>/ios/build/Build/Products/Release-iphonesimulator/<%= appClassName %>.app"
|
|
21
21
|
},
|
|
22
22
|
<% if (framework === 'expo') { %>
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"simulator": {
|
|
49
49
|
"type": "ios.simulator",
|
|
50
50
|
"device": {
|
|
51
|
-
"type": "iPhone
|
|
51
|
+
"type": "iPhone 15 Plus"
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"emulator": {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToInferred = convertToInferred;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const aggregate_log_util_1 = require("@nx/devkit/src/generators/plugin-migrations/aggregate-log-util");
|
|
6
|
+
const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
|
|
7
|
+
const plugin_1 = require("../../plugins/plugin");
|
|
8
|
+
const process_build_options_1 = require("./lib/process-build-options");
|
|
9
|
+
const post_target_transformer_1 = require("./lib/post-target-transformer");
|
|
10
|
+
const process_test_options_1 = require("./lib/process-test-options");
|
|
11
|
+
async function convertToInferred(tree, options) {
|
|
12
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
13
|
+
const migrationLogs = new aggregate_log_util_1.AggregatedLog();
|
|
14
|
+
const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPluginV1)(tree, projectGraph, '@nx/detox/plugin', plugin_1.createNodes, {
|
|
15
|
+
buildTargetName: 'build',
|
|
16
|
+
startTargetName: 'start',
|
|
17
|
+
testTargetName: 'test',
|
|
18
|
+
}, [
|
|
19
|
+
{
|
|
20
|
+
executors: ['@nx/detox:build'],
|
|
21
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs, process_build_options_1.processBuildOptions),
|
|
22
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
23
|
+
buildTargetName: targetName, // We should use "build" instead of "build-ios" or "build-android". We'll handle this later.
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
executors: ['@nx/detox:test'],
|
|
28
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs, process_test_options_1.processTestOptions),
|
|
29
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
30
|
+
testTargetName: targetName, // We should use "test" instead of "test-ios" or "test-android". We'll handle this later.
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
], options.project);
|
|
34
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
35
|
+
const detoxPlugins = nxJson.plugins?.filter((p) => typeof p !== 'string' && p.plugin === '@nx/detox/plugin');
|
|
36
|
+
// These were either `build-ios`, `test-ios`, etc., and we need to set them back to their generic names.
|
|
37
|
+
// The per-project targets will call these with additional `--args` passed to maintain the same
|
|
38
|
+
// behavior as previous executor-based targets.
|
|
39
|
+
for (const p of detoxPlugins) {
|
|
40
|
+
if (typeof p === 'string')
|
|
41
|
+
continue;
|
|
42
|
+
p.options['buildTargetName'] = 'build';
|
|
43
|
+
p.options['testTargetName'] = 'test';
|
|
44
|
+
}
|
|
45
|
+
// Inform the users that the inferred targets are platform-agnostic, and they can remove the old targets if unnecessary.
|
|
46
|
+
for (const [project] of migratedProjects) {
|
|
47
|
+
migrationLogs.addLog({
|
|
48
|
+
project,
|
|
49
|
+
executorName: '@nx/detox:build',
|
|
50
|
+
log: `The "build-android" target was migrated to use "nx run ${project}:build", which is platform-agnostic. If you no longer need this target, you can remove it.`,
|
|
51
|
+
});
|
|
52
|
+
migrationLogs.addLog({
|
|
53
|
+
project,
|
|
54
|
+
executorName: '@nx/detox:test',
|
|
55
|
+
log: `The "test-android" target was migrated to use "nx run ${project}:test", which is platform-agnostic. If you no longer need this target, you can remove it.`,
|
|
56
|
+
});
|
|
57
|
+
migrationLogs.addLog({
|
|
58
|
+
project,
|
|
59
|
+
executorName: '@nx/detox:build',
|
|
60
|
+
log: `The "build-ios" target was migrated to use "nx run ${project}:build", which is platform-agnostic. If you no longer need this target, you can remove it.`,
|
|
61
|
+
});
|
|
62
|
+
migrationLogs.addLog({
|
|
63
|
+
project,
|
|
64
|
+
executorName: '@nx/detox:test',
|
|
65
|
+
log: `The "test-ios" target was migrated to use "nx run ${project}:test", which is platform-agnostic. If you no longer need this target, you can remove it.`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
69
|
+
if (migratedProjects.size === 0) {
|
|
70
|
+
throw new Error('Could not find any targets to migrate.');
|
|
71
|
+
}
|
|
72
|
+
if (!options.skipFormat) {
|
|
73
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
74
|
+
}
|
|
75
|
+
return () => {
|
|
76
|
+
migrationLogs.flushLogs();
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
exports.default = convertToInferred;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
|
|
3
|
+
export declare function postTargetTransformer(migrationLogs: AggregatedLog, processOptions: (tree: Tree, options: any, projectName: string, projectRoot: string, target: TargetConfiguration | undefined, migrationLogs: AggregatedLog) => void): (target: TargetConfiguration, tree: Tree, projectDetails: {
|
|
4
|
+
projectName: string;
|
|
5
|
+
root: string;
|
|
6
|
+
}, inferredTargetConfiguration: TargetConfiguration) => TargetConfiguration<any>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postTargetTransformer = postTargetTransformer;
|
|
4
|
+
const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
|
|
5
|
+
function postTargetTransformer(migrationLogs, processOptions) {
|
|
6
|
+
return (target, tree, projectDetails, inferredTargetConfiguration) => {
|
|
7
|
+
if (target.options) {
|
|
8
|
+
processOptions(tree, target.options, projectDetails.projectName, projectDetails.root, target, migrationLogs);
|
|
9
|
+
}
|
|
10
|
+
if (target.configurations) {
|
|
11
|
+
for (const configurationName in target.configurations) {
|
|
12
|
+
const configuration = target.configurations[configurationName];
|
|
13
|
+
processOptions(tree, configuration, projectDetails.projectName, projectDetails.root, undefined, migrationLogs);
|
|
14
|
+
}
|
|
15
|
+
if (Object.keys(target.configurations).length === 0) {
|
|
16
|
+
if ('defaultConfiguration' in target) {
|
|
17
|
+
delete target.defaultConfiguration;
|
|
18
|
+
}
|
|
19
|
+
delete target.configurations;
|
|
20
|
+
}
|
|
21
|
+
if ('defaultConfiguration' in target &&
|
|
22
|
+
!target.configurations[target.defaultConfiguration]) {
|
|
23
|
+
delete target.defaultConfiguration;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target.outputs) {
|
|
27
|
+
(0, plugin_migration_utils_1.processTargetOutputs)(target, [], inferredTargetConfiguration, {
|
|
28
|
+
projectName: projectDetails.projectName,
|
|
29
|
+
projectRoot: projectDetails.root,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type TargetConfiguration, type Tree } from '@nx/devkit';
|
|
2
|
+
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
|
|
3
|
+
export declare function processBuildOptions(_tree: Tree, options: any, projectName: string, _projectRoot: string, target: TargetConfiguration | undefined, _migrationLogs: AggregatedLog): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processBuildOptions = processBuildOptions;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function processBuildOptions(_tree, options, projectName, _projectRoot, target, _migrationLogs) {
|
|
6
|
+
const args = [];
|
|
7
|
+
if ('detoxConfiguration' in options) {
|
|
8
|
+
// Need to wrap in --args since --configuration/-c is swallowed by Nx CLI.
|
|
9
|
+
args.push(`--args="-c ${options.detoxConfiguration}"`);
|
|
10
|
+
delete options.detoxConfiguration;
|
|
11
|
+
}
|
|
12
|
+
for (const key of Object.keys(options)) {
|
|
13
|
+
let value = options[key];
|
|
14
|
+
if (typeof value === 'boolean') {
|
|
15
|
+
if (value)
|
|
16
|
+
args.push(`--${(0, devkit_1.names)(key).fileName}`);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
args.push(`--${(0, devkit_1.names)(key).fileName}`, value);
|
|
20
|
+
}
|
|
21
|
+
delete options[key];
|
|
22
|
+
}
|
|
23
|
+
if (target) {
|
|
24
|
+
target.command = `nx run ${projectName}:build`;
|
|
25
|
+
}
|
|
26
|
+
options.args = args;
|
|
27
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type TargetConfiguration, type Tree } from '@nx/devkit';
|
|
2
|
+
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
|
|
3
|
+
export declare function processTestOptions(_tree: Tree, options: any, projectName: string, _projectRoot: string, target: TargetConfiguration | undefined, migrationLogs: AggregatedLog): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processTestOptions = processTestOptions;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function processTestOptions(_tree, options, projectName, _projectRoot, target, migrationLogs) {
|
|
6
|
+
const args = [];
|
|
7
|
+
if ('detoxConfiguration' in options) {
|
|
8
|
+
// Need to wrap in --args since --configuration/-c is swallowed by Nx CLI.
|
|
9
|
+
args.push(`--args="-c ${options.detoxConfiguration}"`);
|
|
10
|
+
delete options.detoxConfiguration;
|
|
11
|
+
}
|
|
12
|
+
if ('deviceBootArgs' in options) {
|
|
13
|
+
args.push(`--device-boot-args="${options.deviceBootArgs}"`); // the value must be specified after an equal sign (=) and inside quotes: https://wix.github.io/Detox/docs/cli/test
|
|
14
|
+
delete options.deviceBootArgs;
|
|
15
|
+
}
|
|
16
|
+
if ('appLaunchArgs' in options) {
|
|
17
|
+
args.push(`--app-launch-args="${options.appLaunchArgs}"`); // the value must be specified after an equal sign (=) and inside quotes: https://wix.github.io/Detox/docs/cli/test
|
|
18
|
+
delete options.appLaunchArgs;
|
|
19
|
+
}
|
|
20
|
+
if ('color' in options) {
|
|
21
|
+
// detox only accepts --no-color, not --color
|
|
22
|
+
if (!options.color)
|
|
23
|
+
args.push('--no-color');
|
|
24
|
+
delete options.color;
|
|
25
|
+
}
|
|
26
|
+
if ('buildTarget' in options) {
|
|
27
|
+
migrationLogs.addLog({
|
|
28
|
+
project: projectName,
|
|
29
|
+
executorName: '@nx/expo:test',
|
|
30
|
+
log: 'Unable to migrate `buildTarget` for Detox test. Use "nx run <project>:run-ios" or "nx run <project>:run-android", and pass "--reuse" option when running tests.',
|
|
31
|
+
});
|
|
32
|
+
delete options.buildTarget;
|
|
33
|
+
}
|
|
34
|
+
const deprecatedOptions = [
|
|
35
|
+
'runnerConfig',
|
|
36
|
+
'recordTimeline',
|
|
37
|
+
'workers',
|
|
38
|
+
'deviceLaunchArgs',
|
|
39
|
+
];
|
|
40
|
+
for (const key of deprecatedOptions) {
|
|
41
|
+
if (!(key in options))
|
|
42
|
+
continue;
|
|
43
|
+
migrationLogs.addLog({
|
|
44
|
+
project: projectName,
|
|
45
|
+
executorName: '@nx/expo:test',
|
|
46
|
+
log: `Option "${key}" is not migrated since it was removed in Detox 20.`,
|
|
47
|
+
});
|
|
48
|
+
delete options[key];
|
|
49
|
+
}
|
|
50
|
+
for (const key of Object.keys(options)) {
|
|
51
|
+
let value = options[key];
|
|
52
|
+
if (typeof value === 'boolean') {
|
|
53
|
+
if (value)
|
|
54
|
+
args.push(`--${(0, devkit_1.names)(key).fileName}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
args.push(`--${(0, devkit_1.names)(key).fileName}`, value);
|
|
58
|
+
}
|
|
59
|
+
delete options[key];
|
|
60
|
+
}
|
|
61
|
+
if (target) {
|
|
62
|
+
target.command = `nx run ${projectName}:test`;
|
|
63
|
+
}
|
|
64
|
+
options.args = args;
|
|
65
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxDetoxConvertToInferred",
|
|
4
|
+
"description": "Convert existing Detox project(s) using `@nx/detox:*` executors to use `@nx/detox/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
|
|
5
|
+
"title": "Convert Detox project from executor to plugin",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The project to convert from using the `@nx/detox:*` executors to use `@nx/detox/plugin`.",
|
|
11
|
+
"x-priority": "important"
|
|
12
|
+
},
|
|
13
|
+
"skipFormat": {
|
|
14
|
+
"type": "boolean",
|
|
15
|
+
"description": "Whether to format files at the end of the migration.",
|
|
16
|
+
"default": false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|