@nx/detox 17.3.0-beta.1 → 17.3.0-beta.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/detox",
|
|
3
|
-
"version": "17.3.0-beta.
|
|
3
|
+
"version": "17.3.0-beta.3",
|
|
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": [
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"main": "./index.js",
|
|
26
26
|
"types": "index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@nx/devkit": "17.3.0-beta.
|
|
29
|
-
"@nx/jest": "17.3.0-beta.
|
|
30
|
-
"@nx/js": "17.3.0-beta.
|
|
31
|
-
"@nx/eslint": "17.3.0-beta.
|
|
32
|
-
"@nx/react": "17.3.0-beta.
|
|
28
|
+
"@nx/devkit": "17.3.0-beta.3",
|
|
29
|
+
"@nx/jest": "17.3.0-beta.3",
|
|
30
|
+
"@nx/js": "17.3.0-beta.3",
|
|
31
|
+
"@nx/eslint": "17.3.0-beta.3",
|
|
32
|
+
"@nx/react": "17.3.0-beta.3",
|
|
33
33
|
"tslib": "^2.3.0",
|
|
34
|
-
"@nrwl/detox": "17.3.0-beta.
|
|
34
|
+
"@nrwl/detox": "17.3.0-beta.3"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"detox": "^20.9.0"
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createNodes, DetoxPluginOptions } from './src/plugins/plugin';
|
package/plugin.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = void 0;
|
|
4
|
+
var plugin_1 = require("./src/plugins/plugin");
|
|
5
|
+
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
@@ -4,11 +4,15 @@ exports.addProject = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const get_targets_1 = require("./get-targets");
|
|
6
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');
|
|
7
11
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
8
12
|
root: options.e2eProjectRoot,
|
|
9
13
|
sourceRoot: `${options.e2eProjectRoot}/src`,
|
|
10
14
|
projectType: 'application',
|
|
11
|
-
targets: {
|
|
15
|
+
targets: hasPlugin ? {} : getTargets(options),
|
|
12
16
|
tags: [],
|
|
13
17
|
implicitDependencies: [options.appProject],
|
|
14
18
|
});
|
|
@@ -10,6 +10,9 @@ async function detoxInitGenerator(host, schema) {
|
|
|
10
10
|
tasks.push(moveDependency(host));
|
|
11
11
|
tasks.push(updateDependencies(host, schema));
|
|
12
12
|
}
|
|
13
|
+
if (process.env.NX_PCV3 === 'true') {
|
|
14
|
+
addPlugin(host);
|
|
15
|
+
}
|
|
13
16
|
if (!schema.skipFormat) {
|
|
14
17
|
await (0, devkit_1.formatFiles)(host);
|
|
15
18
|
}
|
|
@@ -32,4 +35,23 @@ exports.updateDependencies = updateDependencies;
|
|
|
32
35
|
function moveDependency(host) {
|
|
33
36
|
return (0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/detox'], []);
|
|
34
37
|
}
|
|
38
|
+
function addPlugin(host) {
|
|
39
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
40
|
+
nxJson.plugins ??= [];
|
|
41
|
+
for (const plugin of nxJson.plugins) {
|
|
42
|
+
if (typeof plugin === 'string'
|
|
43
|
+
? plugin === '@nx/detox/plugin'
|
|
44
|
+
: plugin.plugin === '@nx/detox/plugin') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
nxJson.plugins.push({
|
|
49
|
+
plugin: '@nx/detox/plugin',
|
|
50
|
+
options: {
|
|
51
|
+
buildTargetName: 'build',
|
|
52
|
+
testTargetName: 'test',
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
56
|
+
}
|
|
35
57
|
exports.default = detoxInitGenerator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
2
|
+
export interface DetoxPluginOptions {
|
|
3
|
+
buildTargetName?: string;
|
|
4
|
+
testTargetName?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const createDependencies: CreateDependencies;
|
|
7
|
+
export declare const createNodes: CreateNodes<DetoxPluginOptions>;
|
|
@@ -0,0 +1,84 @@
|
|
|
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.testTargetName]: {
|
|
61
|
+
command: `detox test`,
|
|
62
|
+
options: { cwd: projectRoot },
|
|
63
|
+
cache: true,
|
|
64
|
+
inputs: getInputs(namedInputs),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return targets;
|
|
68
|
+
}
|
|
69
|
+
function getInputs(namedInputs) {
|
|
70
|
+
return [
|
|
71
|
+
...('production' in namedInputs
|
|
72
|
+
? ['default', '^production']
|
|
73
|
+
: ['default', '^default']),
|
|
74
|
+
{
|
|
75
|
+
externalDependencies: ['detox'],
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
function normalizeOptions(options) {
|
|
80
|
+
options ??= {};
|
|
81
|
+
options.buildTargetName ??= 'build';
|
|
82
|
+
options.testTargetName ??= 'test';
|
|
83
|
+
return options;
|
|
84
|
+
}
|