@nx/cypress 19.0.0-rc.0 → 19.0.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/cypress",
3
- "version": "19.0.0-rc.0",
3
+ "version": "19.0.0-rc.1",
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": {
@@ -34,13 +34,13 @@
34
34
  "migrations": "./migrations.json"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "19.0.0-rc.0",
38
- "@nx/eslint": "19.0.0-rc.0",
39
- "@nx/js": "19.0.0-rc.0",
37
+ "@nx/devkit": "19.0.0-rc.1",
38
+ "@nx/eslint": "19.0.0-rc.1",
39
+ "@nx/js": "19.0.0-rc.1",
40
40
  "@phenomnomnominal/tsquery": "~5.0.1",
41
41
  "detect-port": "^1.5.1",
42
42
  "tslib": "^2.3.0",
43
- "@nrwl/cypress": "19.0.0-rc.0"
43
+ "@nrwl/cypress": "19.0.0-rc.1"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "cypress": ">= 3 < 14"
@@ -15,11 +15,16 @@ const tsquery_1 = require("@phenomnomnominal/tsquery");
15
15
  function addDevServerTargetToConfig(tree, configFilePath, webServerCommands, ciDevServerTarget) {
16
16
  let configFileContents = tree.read(configFilePath, 'utf-8');
17
17
  let ast = tsquery_1.tsquery.ast(configFileContents);
18
- const NX_E2E_PRESET_OPTIONS_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) CallExpression:has(Identifier[name=nxE2EPreset]) > ObjectLiteralExpression';
19
- const nxE2ePresetOptionsNodes = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_OPTIONS_SELECTOR, {
18
+ const NX_E2E_PRESET_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) CallExpression:has(Identifier[name=nxE2EPreset])';
19
+ const nxE2ePresetOptionsNodes = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_SELECTOR, {
20
20
  visitAllChildren: true,
21
21
  });
22
22
  if (nxE2ePresetOptionsNodes.length !== 0) {
23
+ const NX_E2E_PRESET_OPTIONS_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) CallExpression:has(Identifier[name=nxE2EPreset]) > ObjectLiteralExpression';
24
+ const optionsObjectNodes = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_OPTIONS_SELECTOR, {
25
+ visitAllChildren: true,
26
+ });
27
+ const hasObjectDefinition = optionsObjectNodes?.length > 0;
23
28
  let nxE2ePresetOptionsNode = nxE2ePresetOptionsNodes[0];
24
29
  const WEB_SERVER_COMMANDS_SELECTOR = 'PropertyAssignment:has(Identifier[name=webServerCommands])';
25
30
  const webServerCommandsNodes = (0, tsquery_1.tsquery)(nxE2ePresetOptionsNode, WEB_SERVER_COMMANDS_SELECTOR, { visitAllChildren: true });
@@ -28,14 +33,24 @@ function addDevServerTargetToConfig(tree, configFilePath, webServerCommands, ciD
28
33
  tree.write(configFilePath, `${configFileContents.slice(0, webServerCommandsNodes[0].getStart())}webServerCommands: ${JSON.stringify(webServerCommands)}${configFileContents.slice(webServerCommandsNodes[0].getEnd())}`);
29
34
  }
30
35
  else {
31
- tree.write(configFilePath, `${configFileContents.slice(0, nxE2ePresetOptionsNode.getStart() + 1)}webServerCommands: ${JSON.stringify(webServerCommands)},${configFileContents.slice(nxE2ePresetOptionsNode.getStart() + 1)}`);
36
+ if (hasObjectDefinition) {
37
+ tree.write(configFilePath, `${configFileContents.slice(0, optionsObjectNodes[0].getStart() + 1)}webServerCommands: ${JSON.stringify(webServerCommands)},${configFileContents.slice(optionsObjectNodes[0].getStart() + 1)}`);
38
+ }
39
+ else {
40
+ tree.write(configFilePath, `${configFileContents.slice(0, nxE2ePresetOptionsNode.getEnd() - 1)},{ webServerCommands: ${JSON.stringify(webServerCommands)},}${configFileContents.slice(nxE2ePresetOptionsNode.getEnd() - 1)}`);
41
+ }
32
42
  }
33
43
  if (ciDevServerTarget) {
34
44
  configFileContents = tree.read(configFilePath, 'utf-8');
35
45
  ast = tsquery_1.tsquery.ast(configFileContents);
36
- nxE2ePresetOptionsNode = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_OPTIONS_SELECTOR, {
46
+ nxE2ePresetOptionsNode = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_SELECTOR, {
37
47
  visitAllChildren: true,
38
48
  })[0];
49
+ const NX_E2E_PRESET_OPTIONS_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) CallExpression:has(Identifier[name=nxE2EPreset]) > ObjectLiteralExpression';
50
+ const optionsObjectNodes = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_OPTIONS_SELECTOR, {
51
+ visitAllChildren: true,
52
+ });
53
+ const hasObjectDefinition = optionsObjectNodes?.length > 0;
39
54
  const CI_WEB_SERVER_COMMANDS_SELECTOR = 'PropertyAssignment:has(Identifier[name=ciWebServerCommand])';
40
55
  const ciWebServerCommandsNodes = (0, tsquery_1.tsquery)(nxE2ePresetOptionsNode, CI_WEB_SERVER_COMMANDS_SELECTOR, { visitAllChildren: true });
41
56
  if (ciWebServerCommandsNodes.length !== 0) {
@@ -48,7 +63,12 @@ function addDevServerTargetToConfig(tree, configFilePath, webServerCommands, ciD
48
63
  }
49
64
  }
50
65
  else {
51
- tree.write(configFilePath, `${configFileContents.slice(0, nxE2ePresetOptionsNode.getStart() + 1)}ciWebServerCommand: "${ciDevServerTarget}",${configFileContents.slice(nxE2ePresetOptionsNode.getStart() + 1)}`);
66
+ if (hasObjectDefinition) {
67
+ tree.write(configFilePath, `${configFileContents.slice(0, optionsObjectNodes[0].getStart() + 1)}ciWebServerCommand: "${ciDevServerTarget}",${configFileContents.slice(optionsObjectNodes[0].getStart() + 1)}`);
68
+ }
69
+ else {
70
+ tree.write(configFilePath, `${configFileContents.slice(0, nxE2ePresetOptionsNode.getEnd() - 1)},{ ciWebServerCommand: "${ciDevServerTarget}",}${configFileContents.slice(nxE2ePresetOptionsNode.getEnd() - 1)}`);
71
+ }
52
72
  }
53
73
  }
54
74
  }