@nx/cypress 23.0.0-rc.3 → 23.0.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.
@@ -5,8 +5,7 @@ exports.componentConfigurationGeneratorInternal = componentConfigurationGenerato
5
5
  exports.updateTsConfigForComponentTesting = updateTsConfigForComponentTesting;
6
6
  const tslib_1 = require("tslib");
7
7
  const devkit_1 = require("@nx/devkit");
8
- const internal_1 = require("@nx/devkit/internal");
9
- const internal_2 = require("@nx/js/internal");
8
+ const internal_1 = require("@nx/js/internal");
10
9
  const assert_supported_cypress_version_1 = require("../../utils/assert-supported-cypress-version");
11
10
  const deprecation_1 = require("../../utils/deprecation");
12
11
  const versions_1 = require("../../utils/versions");
@@ -20,7 +19,7 @@ function componentConfigurationGenerator(tree, options) {
20
19
  }
21
20
  async function componentConfigurationGeneratorInternal(tree, options) {
22
21
  (0, assert_supported_cypress_version_1.assertSupportedCypressVersion)(tree);
23
- (0, internal_2.assertNotUsingTsSolutionSetup)(tree, 'cypress', 'component-configuration');
22
+ (0, internal_1.assertNotUsingTsSolutionSetup)(tree, 'cypress', 'component-configuration');
24
23
  const tasks = [];
25
24
  const opts = normalizeOptions(tree, options);
26
25
  if (!(0, versions_1.getInstalledCypressMajorVersion)(tree)) {
@@ -116,24 +115,14 @@ function updateNxJsonConfiguration(tree, hasPlugin) {
116
115
  !cacheableOperations.includes('component-test')) {
117
116
  cacheableOperations.push('component-test');
118
117
  }
119
- // Either a `target: 'component-test'` default or a default keyed on
120
- // the executor we're scaffolding will apply to the new target — pick
121
- // the more specific (target-keyed) when both are present.
122
- const existingForTarget = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
123
- target: 'component-test',
124
- });
125
- const existingForExecutor = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
126
- executor: '@nx/cypress:cypress',
127
- });
128
- const existing = existingForTarget ?? existingForExecutor;
129
- (0, internal_1.upsertTargetDefault)(tree, nxJson, {
130
- target: 'component-test',
131
- cache: existing?.cache ?? true,
132
- inputs: existing?.inputs ?? [
133
- 'default',
134
- productionFileSet ? '^production' : '^default',
135
- ],
136
- });
118
+ nxJson.targetDefaults ??= {};
119
+ nxJson.targetDefaults['component-test'] ??= {};
120
+ nxJson.targetDefaults['component-test'].cache ??= true;
121
+ nxJson.targetDefaults['component-test'] ??= {};
122
+ nxJson.targetDefaults['component-test'].inputs ??= [
123
+ 'default',
124
+ productionFileSet ? '^production' : '^default',
125
+ ];
137
126
  }
138
127
  (0, devkit_1.updateNxJson)(tree, nxJson);
139
128
  }
@@ -14,26 +14,15 @@ function setupE2ETargetDefaults(tree) {
14
14
  return;
15
15
  }
16
16
  // E2e targets depend on all their project's sources + production sources of dependencies
17
+ nxJson.targetDefaults ??= {};
17
18
  const productionFileSet = !!nxJson.namedInputs?.production;
18
- const existing = findExistingE2eDefault(nxJson.targetDefaults);
19
- const patch = {};
20
- if (existing?.cache === undefined)
21
- patch.cache = true;
22
- if (existing?.inputs === undefined) {
23
- patch.inputs = ['default', productionFileSet ? '^production' : '^default'];
24
- }
25
- if (Object.keys(patch).length > 0) {
26
- (0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'e2e', ...patch });
27
- (0, devkit_1.updateNxJson)(tree, nxJson);
28
- }
29
- }
30
- function findExistingE2eDefault(td) {
31
- if (!td)
32
- return undefined;
33
- if (Array.isArray(td)) {
34
- return td.find((e) => e.target === 'e2e' && e.projects === undefined && e.plugin === undefined);
35
- }
36
- return td['e2e'];
19
+ nxJson.targetDefaults.e2e ??= {};
20
+ nxJson.targetDefaults.e2e.cache ??= true;
21
+ nxJson.targetDefaults.e2e.inputs ??= [
22
+ 'default',
23
+ productionFileSet ? '^production' : '^default',
24
+ ];
25
+ (0, devkit_1.updateNxJson)(tree, nxJson);
37
26
  }
38
27
  function updateDependencies(tree, options) {
39
28
  const tasks = [];
@@ -22,37 +22,25 @@ async function default_1(tree) {
22
22
  // update options from nx.json target defaults
23
23
  const nxJson = (0, devkit_1.readNxJson)(tree);
24
24
  if (nxJson.targetDefaults) {
25
- const originalShape = nxJson.targetDefaults;
26
- const entries = (0, internal_1.normalizeTargetDefaults)(originalShape);
27
- const remaining = [];
28
- for (const entry of entries) {
29
- const matches = entry.executor === EXECUTOR_TO_MIGRATE ||
30
- entry.target === EXECUTOR_TO_MIGRATE;
31
- if (!matches) {
32
- remaining.push(entry);
25
+ for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
26
+ if (targetOrExecutor !== EXECUTOR_TO_MIGRATE &&
27
+ targetConfig.executor !== EXECUTOR_TO_MIGRATE) {
33
28
  continue;
34
29
  }
35
- if (entry.options) {
36
- updateOptions(entry);
30
+ if (targetConfig.options) {
31
+ updateOptions(targetConfig);
37
32
  }
38
- Object.keys(entry.configurations ?? {}).forEach((config) => {
39
- updateConfiguration(entry, config);
33
+ Object.keys(targetConfig.configurations ?? {}).forEach((config) => {
34
+ updateConfiguration(targetConfig, config);
40
35
  });
41
- const meaningfulKeys = Object.keys(entry).filter((k) => k !== 'target' &&
42
- k !== 'executor' &&
43
- k !== 'projects' &&
44
- k !== 'plugin');
45
- if (meaningfulKeys.length === 0)
46
- continue;
47
- remaining.push(entry);
48
- }
49
- if (remaining.length === 0) {
50
- delete nxJson.targetDefaults;
51
- }
52
- else {
53
- nxJson.targetDefaults = Array.isArray(originalShape)
54
- ? remaining
55
- : (0, internal_1.downgradeTargetDefaults)(remaining);
36
+ if (!Object.keys(targetConfig).length ||
37
+ (Object.keys(targetConfig).length === 1 &&
38
+ Object.keys(targetConfig)[0] === 'executor')) {
39
+ delete nxJson.targetDefaults[targetOrExecutor];
40
+ }
41
+ if (!Object.keys(nxJson.targetDefaults).length) {
42
+ delete nxJson.targetDefaults;
43
+ }
56
44
  }
57
45
  (0, devkit_1.updateNxJson)(tree, nxJson);
58
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/cypress",
3
- "version": "23.0.0-rc.3",
3
+ "version": "23.0.0",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -89,12 +89,12 @@
89
89
  "semver": "^7.6.3",
90
90
  "tree-kill": "^1.2.2",
91
91
  "tslib": "^2.3.0",
92
- "@nx/devkit": "23.0.0-rc.3",
93
- "@nx/eslint": "23.0.0-rc.3",
94
- "@nx/js": "23.0.0-rc.3"
92
+ "@nx/devkit": "23.0.0",
93
+ "@nx/eslint": "23.0.0",
94
+ "@nx/js": "23.0.0"
95
95
  },
96
96
  "devDependencies": {
97
- "nx": "23.0.0-rc.3"
97
+ "nx": "23.0.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "cypress": ">= 13 < 16"