@nx/cypress 19.6.0-beta.4 → 19.6.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/migrations.json CHANGED
@@ -32,15 +32,9 @@
32
32
  },
33
33
  "update-19-6-0-update-ci-webserver-for-vite": {
34
34
  "cli": "nx",
35
- "version": "19.6.0-beta.0",
36
- "description": "Update ciWebServerCommand to use previewTargetName if Vite is detected for the application.",
37
- "implementation": "./src/migrations/update-19-6-0/update-ci-webserver-for-vite"
38
- },
39
- "update-19-6-0-add-e2e-ci-target-defaults": {
40
- "cli": "nx",
41
- "version": "19.6.0-beta.0",
42
- "description": "Add inferred ciTargetNames to targetDefaults with dependsOn to ensure dependent application builds are scheduled before atomized tasks.",
43
- "implementation": "./src/migrations/update-19-6-0/add-e2e-ci-target-defaults"
35
+ "version": "19.6.0-beta.4",
36
+ "description": "Update ciWebServerCommand to use static serve for the application.",
37
+ "implementation": "./src/migrations/update-19-6-0/update-ci-webserver-for-static-serve"
44
38
  }
45
39
  },
46
40
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/cypress",
3
- "version": "19.6.0-beta.4",
3
+ "version": "19.6.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.6.0-beta.4",
40
- "@nx/eslint": "19.6.0-beta.4",
41
- "@nx/js": "19.6.0-beta.4",
39
+ "@nx/devkit": "19.6.0-beta.5",
40
+ "@nx/eslint": "19.6.0-beta.5",
41
+ "@nx/js": "19.6.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.6.0-beta.4"
45
+ "@nrwl/cypress": "19.6.0-beta.5"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "cypress": ">= 3 < 14"
@@ -4,6 +4,7 @@ exports.default = default_1;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const devkit_internals_1 = require("nx/src/devkit-internals");
6
6
  const tsquery_1 = require("@phenomnomnominal/tsquery");
7
+ const add_e2e_ci_target_defaults_1 = require("./add-e2e-ci-target-defaults");
7
8
  async function default_1(tree) {
8
9
  const pluginName = '@nx/cypress/plugin';
9
10
  const graph = await (0, devkit_1.createProjectGraphAsync)();
@@ -49,23 +50,43 @@ async function default_1(tree) {
49
50
  (0, devkit_1.joinPathFragments)(graph.nodes[project].data.root, 'vite.config.ts'),
50
51
  (0, devkit_1.joinPathFragments)(graph.nodes[project].data.root, 'vite.config.js'),
51
52
  ].find((p) => tree.exists(p));
52
- if (!pathToViteConfig) {
53
+ const pathToWebpackConfig = [
54
+ (0, devkit_1.joinPathFragments)(graph.nodes[project].data.root, 'webpack.config.ts'),
55
+ (0, devkit_1.joinPathFragments)(graph.nodes[project].data.root, 'webpack.config.js'),
56
+ ].find((p) => tree.exists(p));
57
+ if (!pathToViteConfig && !pathToWebpackConfig) {
53
58
  continue;
54
59
  }
55
- const viteConfigContents = tree.read(pathToViteConfig, 'utf-8');
56
- if (!viteConfigContents.includes('preview:')) {
57
- continue;
60
+ if (pathToWebpackConfig) {
61
+ const matchingWebpackPlugin = await findPluginForConfigFile(tree, '@nx/webpack/plugin', pathToWebpackConfig);
62
+ const serveStaticTargetName = matchingWebpackPlugin
63
+ ? typeof matchingWebpackPlugin === 'string'
64
+ ? 'serve-static'
65
+ : matchingWebpackPlugin.options?.serveStaticTargetName ??
66
+ 'serve-static'
67
+ : 'serve-static';
68
+ const newCommand = ciWebServerCommand.replace(/nx.*[^"']/, `nx run ${project}:${serveStaticTargetName}`);
69
+ tree.write(configFile, `${configFileContents.slice(0, nodes[0].getStart())}${newCommand}${configFileContents.slice(nodes[0].getEnd())}`);
58
70
  }
59
- const matchingVitePlugin = await findPluginForConfigFile(tree, '@nx/vite/plugin', pathToViteConfig);
60
- const previewTargetName = matchingVitePlugin
61
- ? typeof matchingVitePlugin === 'string'
62
- ? 'preview'
63
- : matchingVitePlugin.options?.previewTargetName ?? 'preview'
64
- : 'preview';
65
- tree.write(configFile, `${configFileContents.slice(0, nodes[0].getStart())}'nx run ${project}:${previewTargetName}',
71
+ else if (pathToViteConfig) {
72
+ const viteConfigContents = tree.read(pathToViteConfig, 'utf-8');
73
+ if (!viteConfigContents.includes('preview:')) {
74
+ continue;
75
+ }
76
+ const matchingVitePlugin = await findPluginForConfigFile(tree, '@nx/vite/plugin', pathToViteConfig);
77
+ const previewTargetName = matchingVitePlugin
78
+ ? typeof matchingVitePlugin === 'string'
79
+ ? 'preview'
80
+ : matchingVitePlugin.options?.previewTargetName ??
81
+ 'preview'
82
+ : 'preview';
83
+ const newCommand = ciWebServerCommand.replace(/nx.*[^"']/, `nx run ${project}:${previewTargetName}`);
84
+ tree.write(configFile, `${configFileContents.slice(0, nodes[0].getStart())}${newCommand},
66
85
  ciBaseUrl: "http://localhost:4300"${configFileContents.slice(nodes[0].getEnd())}`);
86
+ }
67
87
  }
68
88
  }
89
+ await (0, add_e2e_ci_target_defaults_1.default)(tree);
69
90
  await (0, devkit_1.formatFiles)(tree);
70
91
  }
71
92
  async function findPluginForConfigFile(tree, pluginName, pathToConfigFile) {