@nx/cypress 19.2.0-beta.3 → 19.2.0-beta.5

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/cypress",
3
- "version": "19.2.0-beta.3",
3
+ "version": "19.2.0-beta.5",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Cypress contains executors and generators allowing your workspace to use the powerful Cypress integration testing capabilities.",
6
6
  "repository": {
@@ -36,13 +36,13 @@
36
36
  "migrations": "./migrations.json"
37
37
  },
38
38
  "dependencies": {
39
- "@nx/devkit": "19.2.0-beta.3",
40
- "@nx/eslint": "19.2.0-beta.3",
41
- "@nx/js": "19.2.0-beta.3",
39
+ "@nx/devkit": "19.2.0-beta.5",
40
+ "@nx/eslint": "19.2.0-beta.5",
41
+ "@nx/js": "19.2.0-beta.5",
42
42
  "@phenomnomnominal/tsquery": "~5.0.1",
43
43
  "detect-port": "^1.5.1",
44
44
  "tslib": "^2.3.0",
45
- "@nrwl/cypress": "19.2.0-beta.3"
45
+ "@nrwl/cypress": "19.2.0-beta.5"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "cypress": ">= 3 < 14"
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, createDependencies } from './src/plugins/plugin';
1
+ export { createNodesV2, createNodes } 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.createNodes = exports.createNodesV2 = void 0;
4
4
  var plugin_1 = require("./src/plugins/plugin");
5
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
5
6
  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; } });
@@ -13,11 +13,11 @@ async function convertToInferred(tree, options) {
13
13
  const migratedProjectsModern = await (0, executor_to_plugin_migrator_1.migrateExecutorToPlugin)(tree, projectGraph, '@nx/cypress:cypress', '@nx/cypress/plugin', (targetName) => ({
14
14
  targetName,
15
15
  ciTargetName: 'e2e-ci',
16
- }), postTargetTransformer, plugin_1.createNodes, options.project);
16
+ }), postTargetTransformer, plugin_1.createNodesV2, options.project);
17
17
  const migratedProjectsLegacy = await (0, executor_to_plugin_migrator_1.migrateExecutorToPlugin)(tree, projectGraph, '@nrwl/cypress:cypress', '@nx/cypress/plugin', (targetName) => ({
18
18
  targetName,
19
19
  ciTargetName: 'e2e-ci',
20
- }), postTargetTransformer, plugin_1.createNodes, options.project);
20
+ }), postTargetTransformer, plugin_1.createNodesV2, options.project);
21
21
  const migratedProjects = migratedProjectsModern.size + migratedProjectsLegacy.size;
22
22
  if (migratedProjects === 0) {
23
23
  throw new Error('Could not find any targets to migrate.');
@@ -31,7 +31,7 @@ function updateDependencies(tree, options) {
31
31
  return (0, devkit_1.runTasksInSerial)(...tasks);
32
32
  }
33
33
  function addPlugin(tree, graph, updatePackageScripts) {
34
- return (0, add_plugin_1.addPlugin)(tree, graph, '@nx/cypress/plugin', plugin_1.createNodes, {
34
+ return (0, add_plugin_1.addPlugin)(tree, graph, '@nx/cypress/plugin', plugin_1.createNodesV2, {
35
35
  targetName: ['e2e', 'cypress:e2e', 'cypress-e2e'],
36
36
  openTargetName: ['open-cypress', 'cypress-open'],
37
37
  componentTestingTargetName: [
@@ -1,9 +1,13 @@
1
- import { CreateDependencies, CreateNodes } from '@nx/devkit';
1
+ import { CreateNodes, CreateNodesV2 } from '@nx/devkit';
2
2
  export interface CypressPluginOptions {
3
3
  ciTargetName?: string;
4
4
  targetName?: string;
5
5
  openTargetName?: string;
6
6
  componentTestingTargetName?: string;
7
7
  }
8
- export declare const createDependencies: CreateDependencies;
8
+ export declare const createNodesV2: CreateNodesV2<CypressPluginOptions>;
9
+ /**
10
+ * @deprecated This is replaced with {@link createNodesV2}. Update your plugin to export its own `createNodesV2` function that wraps this one instead.
11
+ * This function will change to the v2 function in Nx 20.
12
+ */
9
13
  export declare const createNodes: CreateNodes<CypressPluginOptions>;
@@ -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");
@@ -11,51 +11,64 @@ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculat
11
11
  const cache_directory_1 = require("nx/src/utils/cache-directory");
12
12
  const constants_1 = require("../utils/constants");
13
13
  const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
14
- const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'cypress.hash');
15
- const targetsCache = readTargetsCache();
16
- function readTargetsCache() {
14
+ const devkit_internals_1 = require("nx/src/devkit-internals");
15
+ function readTargetsCache(cachePath) {
17
16
  return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
18
17
  }
19
- function writeTargetsToCache() {
20
- const oldCache = readTargetsCache();
21
- (0, devkit_1.writeJsonFile)(cachePath, {
22
- ...oldCache,
23
- targetsCache,
24
- });
18
+ function writeTargetsToCache(cachePath, results) {
19
+ (0, devkit_1.writeJsonFile)(cachePath, results);
25
20
  }
26
- const createDependencies = () => {
27
- writeTargetsToCache();
28
- return [];
29
- };
30
- exports.createDependencies = createDependencies;
31
- exports.createNodes = [
32
- '**/cypress.config.{js,ts,mjs,cjs}',
33
- async (configFilePath, options, context) => {
34
- options = normalizeOptions(options);
35
- const projectRoot = (0, path_1.dirname)(configFilePath);
36
- // Do not create a project if package.json and project.json isn't there.
37
- const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
38
- if (!siblingFiles.includes('package.json') &&
39
- !siblingFiles.includes('project.json')) {
40
- return {};
21
+ const cypressConfigGlob = '**/cypress.config.{js,ts,mjs,cjs}';
22
+ exports.createNodesV2 = [
23
+ cypressConfigGlob,
24
+ async (configFiles, options, context) => {
25
+ const optionsHash = (0, devkit_internals_1.hashObject)(options);
26
+ const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, `cypress-${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);
41
33
  }
42
- const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
43
- (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
44
- ]);
45
- targetsCache[hash] ??= await buildCypressTargets(configFilePath, projectRoot, options, context);
46
- const { targets, metadata } = targetsCache[hash];
47
- const project = {
48
- projectType: 'application',
49
- targets,
50
- metadata,
51
- };
52
- return {
53
- projects: {
54
- [projectRoot]: project,
55
- },
56
- };
57
34
  },
58
35
  ];
36
+ /**
37
+ * @deprecated This is replaced with {@link createNodesV2}. Update your plugin to export its own `createNodesV2` function that wraps this one instead.
38
+ * This function will change to the v2 function in Nx 20.
39
+ */
40
+ exports.createNodes = [
41
+ cypressConfigGlob,
42
+ (configFile, options, context) => {
43
+ devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
44
+ return createNodesInternal(configFile, options, context, {});
45
+ },
46
+ ];
47
+ async function createNodesInternal(configFilePath, options, context, targetsCache) {
48
+ options = normalizeOptions(options);
49
+ const projectRoot = (0, path_1.dirname)(configFilePath);
50
+ // Do not create a project if package.json and project.json isn't there.
51
+ const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
52
+ if (!siblingFiles.includes('package.json') &&
53
+ !siblingFiles.includes('project.json')) {
54
+ return {};
55
+ }
56
+ const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
57
+ (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
58
+ ]);
59
+ targetsCache[hash] ??= await buildCypressTargets(configFilePath, projectRoot, options, context);
60
+ const { targets, metadata } = targetsCache[hash];
61
+ const project = {
62
+ projectType: 'application',
63
+ targets,
64
+ metadata,
65
+ };
66
+ return {
67
+ projects: {
68
+ [projectRoot]: project,
69
+ },
70
+ };
71
+ }
59
72
  function getOutputs(projectRoot, cypressConfig, testingType) {
60
73
  function getOutput(path) {
61
74
  if (path.startsWith('..')) {