@nx/detox 20.0.8 → 20.1.0-beta.0

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": "20.0.8",
3
+ "version": "20.1.0-beta.0",
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,11 +27,11 @@
27
27
  "main": "./index",
28
28
  "types": "index.d.ts",
29
29
  "dependencies": {
30
- "@nx/devkit": "20.0.8",
31
- "@nx/jest": "20.0.8",
32
- "@nx/js": "20.0.8",
33
- "@nx/eslint": "20.0.8",
34
- "@nx/react": "20.0.8",
30
+ "@nx/devkit": "20.1.0-beta.0",
31
+ "@nx/jest": "20.1.0-beta.0",
32
+ "@nx/js": "20.1.0-beta.0",
33
+ "@nx/eslint": "20.1.0-beta.0",
34
+ "@nx/react": "20.1.0-beta.0",
35
35
  "tslib": "^2.3.0"
36
36
  },
37
37
  "peerDependencies": {
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, createDependencies, DetoxPluginOptions, } from './src/plugins/plugin';
1
+ export { createNodes, createNodesV2, DetoxPluginOptions, } from './src/plugins/plugin';
package/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDependencies = exports.createNodes = void 0;
3
+ exports.createNodesV2 = exports.createNodes = void 0;
4
4
  var plugin_1 = require("./src/plugins/plugin");
5
5
  Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
- Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
6
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
@@ -11,7 +11,7 @@ const process_test_options_1 = require("./lib/process-test-options");
11
11
  async function convertToInferred(tree, options) {
12
12
  const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
13
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, {
14
+ const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/detox/plugin', plugin_1.createNodesV2, {
15
15
  buildTargetName: 'build',
16
16
  startTargetName: 'start',
17
17
  testTargetName: 'test',
@@ -1,8 +1,8 @@
1
- import { CreateDependencies, CreateNodes } from '@nx/devkit';
1
+ import { CreateNodes, CreateNodesV2 } from '@nx/devkit';
2
2
  export interface DetoxPluginOptions {
3
3
  buildTargetName?: string;
4
4
  startTargetName?: string;
5
5
  testTargetName?: string;
6
6
  }
7
- export declare const createDependencies: CreateDependencies;
7
+ export declare const createNodesV2: CreateNodesV2<DetoxPluginOptions>;
8
8
  export declare const createNodes: CreateNodes<DetoxPluginOptions>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = exports.createDependencies = void 0;
3
+ exports.createNodes = exports.createNodesV2 = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const path_1 = require("path");
6
6
  const js_1 = require("@nx/js");
@@ -8,40 +8,55 @@ const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
8
  const fs_1 = require("fs");
9
9
  const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
10
  const cache_directory_1 = require("nx/src/utils/cache-directory");
11
- const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'detox.hash');
12
- const targetsCache = readTargetsCache();
13
- function readTargetsCache() {
11
+ const devkit_internals_1 = require("nx/src/devkit-internals");
12
+ function readTargetsCache(cachePath) {
14
13
  return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
15
14
  }
16
- function writeTargetsToCache() {
17
- (0, devkit_1.writeJsonFile)(cachePath, targetsCache);
15
+ function writeTargetsToCache(cachePath, targetsCache) {
16
+ const oldCache = readTargetsCache(cachePath);
17
+ (0, devkit_1.writeJsonFile)(cachePath, {
18
+ ...oldCache,
19
+ targetsCache,
20
+ });
18
21
  }
19
- const createDependencies = () => {
20
- writeTargetsToCache();
21
- return [];
22
- };
23
- exports.createDependencies = createDependencies;
22
+ exports.createNodesV2 = [
23
+ '**/{detox.config,.detoxrc}.{json,js}',
24
+ async (configFiles, options, context) => {
25
+ const optionsHash = (0, devkit_internals_1.hashObject)(options);
26
+ const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `expo-${optionsHash}.hash`);
27
+ const targetsCache = readTargetsCache(cachePath);
28
+ try {
29
+ return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache), configFiles, options, context);
30
+ }
31
+ finally {
32
+ writeTargetsToCache(cachePath, targetsCache);
33
+ }
34
+ },
35
+ ];
24
36
  exports.createNodes = [
25
37
  '**/{detox.config,.detoxrc}.{json,js}',
26
38
  async (configFilePath, options, context) => {
27
- options = normalizeOptions(options);
28
- const projectRoot = (0, path_1.dirname)(configFilePath);
29
- // Do not create a project if project.json isn't there.
30
- const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
31
- if (!siblingFiles.includes('project.json')) {
32
- return {};
33
- }
34
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
35
- targetsCache[hash] ??= buildDetoxTargets(projectRoot, options, context);
36
- return {
37
- projects: {
38
- [projectRoot]: {
39
- targets: targetsCache[hash],
40
- },
41
- },
42
- };
39
+ const optionsHash = (0, devkit_internals_1.hashObject)(options);
40
+ const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `detox-${optionsHash}.hash`);
41
+ const targetsCache = readTargetsCache(cachePath);
42
+ const result = await createNodesInternal(configFilePath, options, context, targetsCache);
43
+ writeTargetsToCache(cachePath, targetsCache);
44
+ return result;
43
45
  },
44
46
  ];
47
+ async function createNodesInternal(configFile, options, context, targetsCache) {
48
+ options = normalizeOptions(options);
49
+ const projectRoot = (0, path_1.dirname)(configFile);
50
+ const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
51
+ targetsCache[hash] ??= buildDetoxTargets(projectRoot, options, context);
52
+ return {
53
+ projects: {
54
+ [projectRoot]: {
55
+ targets: targetsCache[hash],
56
+ },
57
+ },
58
+ };
59
+ }
45
60
  function buildDetoxTargets(projectRoot, options, context) {
46
61
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
47
62
  const targets = {