@nx/cypress 16.0.0-beta.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +63 -0
  4. package/executors.json +16 -0
  5. package/generators.json +66 -0
  6. package/index.d.ts +5 -0
  7. package/index.js +14 -0
  8. package/index.js.map +1 -0
  9. package/migrations.json +53 -0
  10. package/package.json +59 -0
  11. package/plugins/cypress-preset.d.ts +62 -0
  12. package/plugins/cypress-preset.js +53 -0
  13. package/plugins/cypress-preset.js.map +1 -0
  14. package/src/executors/cypress/compat.d.ts +2 -0
  15. package/src/executors/cypress/compat.js +6 -0
  16. package/src/executors/cypress/compat.js.map +1 -0
  17. package/src/executors/cypress/cypress.impl.d.ts +40 -0
  18. package/src/executors/cypress/cypress.impl.js +372 -0
  19. package/src/executors/cypress/cypress.impl.js.map +1 -0
  20. package/src/executors/cypress/schema.json +158 -0
  21. package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.d.ts +4 -0
  22. package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +104 -0
  23. package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js.map +1 -0
  24. package/src/generators/convert-tslint-to-eslint/schema.json +44 -0
  25. package/src/generators/cypress-component-project/cypress-component-project.d.ts +4 -0
  26. package/src/generators/cypress-component-project/cypress-component-project.js +127 -0
  27. package/src/generators/cypress-component-project/cypress-component-project.js.map +1 -0
  28. package/src/generators/cypress-component-project/files/cypress/fixtures/example.json +5 -0
  29. package/src/generators/cypress-component-project/files/cypress/support/commands.ts__ext__ +34 -0
  30. package/src/generators/cypress-component-project/files/cypress/support/component-index.html +13 -0
  31. package/src/generators/cypress-component-project/files/cypress/support/component.ts__ext__ +17 -0
  32. package/src/generators/cypress-component-project/files/cypress/tsconfig.cy.json +17 -0
  33. package/src/generators/cypress-component-project/files/cypress.config.ts__ext__ +3 -0
  34. package/src/generators/cypress-component-project/schema.d.ts +5 -0
  35. package/src/generators/cypress-component-project/schema.json +33 -0
  36. package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.d.ts +18 -0
  37. package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.js +133 -0
  38. package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.js.map +1 -0
  39. package/src/generators/cypress-e2e-configuration/files/v10/__dir__/e2e/app.cy.ts__tmpl__ +13 -0
  40. package/src/generators/cypress-e2e-configuration/files/v10/__dir__/fixtures/example.json__tmpl__ +4 -0
  41. package/src/generators/cypress-e2e-configuration/files/v10/__dir__/support/app.po.ts__tmpl__ +1 -0
  42. package/src/generators/cypress-e2e-configuration/files/v10/__dir__/support/commands.ts__tmpl__ +33 -0
  43. package/src/generators/cypress-e2e-configuration/files/v10/__dir__/support/e2e.ts__tmpl__ +17 -0
  44. package/src/generators/cypress-e2e-configuration/files/v10/cypress.config.ts__tmpl__ +9 -0
  45. package/src/generators/cypress-e2e-configuration/files/v10/tsconfig__tsFileExt__ +10 -0
  46. package/src/generators/cypress-e2e-configuration/files/v9/__dir__/fixtures/example.json__tmpl__ +4 -0
  47. package/src/generators/cypress-e2e-configuration/files/v9/__dir__/integration/app.spec.ts__tmpl__ +13 -0
  48. package/src/generators/cypress-e2e-configuration/files/v9/__dir__/plugins/index.js +22 -0
  49. package/src/generators/cypress-e2e-configuration/files/v9/__dir__/support/app.po.ts__tmpl__ +1 -0
  50. package/src/generators/cypress-e2e-configuration/files/v9/__dir__/support/commands.ts__tmpl__ +33 -0
  51. package/src/generators/cypress-e2e-configuration/files/v9/__dir__/support/index.ts__tmpl__ +17 -0
  52. package/src/generators/cypress-e2e-configuration/files/v9/cypress.json +12 -0
  53. package/src/generators/cypress-e2e-configuration/files/v9/tsconfig__tsFileExt__ +10 -0
  54. package/src/generators/cypress-e2e-configuration/schema.json +91 -0
  55. package/src/generators/cypress-project/cypress-project.d.ts +13 -0
  56. package/src/generators/cypress-project/cypress-project.js +172 -0
  57. package/src/generators/cypress-project/cypress-project.js.map +1 -0
  58. package/src/generators/cypress-project/files/v10-and-after/cypress.config.ts__tmpl__ +10 -0
  59. package/src/generators/cypress-project/files/v10-and-after/src/e2e/app.cy.ts__tmpl__ +13 -0
  60. package/src/generators/cypress-project/files/v10-and-after/src/fixtures/example.json__tmpl__ +4 -0
  61. package/src/generators/cypress-project/files/v10-and-after/src/support/app.po.ts__tmpl__ +1 -0
  62. package/src/generators/cypress-project/files/v10-and-after/src/support/commands.ts__tmpl__ +33 -0
  63. package/src/generators/cypress-project/files/v10-and-after/src/support/e2e.ts__tmpl__ +17 -0
  64. package/src/generators/cypress-project/files/v10-and-after/tsconfig.json +10 -0
  65. package/src/generators/cypress-project/files/v9-and-under/cypress.json +12 -0
  66. package/src/generators/cypress-project/files/v9-and-under/src/fixtures/example.json__tmpl__ +4 -0
  67. package/src/generators/cypress-project/files/v9-and-under/src/integration/app.spec.ts__tmpl__ +13 -0
  68. package/src/generators/cypress-project/files/v9-and-under/src/plugins/index.js +22 -0
  69. package/src/generators/cypress-project/files/v9-and-under/src/support/app.po.ts__tmpl__ +1 -0
  70. package/src/generators/cypress-project/files/v9-and-under/src/support/commands.ts__tmpl__ +33 -0
  71. package/src/generators/cypress-project/files/v9-and-under/src/support/index.ts__tmpl__ +17 -0
  72. package/src/generators/cypress-project/files/v9-and-under/tsconfig.json +10 -0
  73. package/src/generators/cypress-project/schema.d.ts +15 -0
  74. package/src/generators/cypress-project/schema.json +79 -0
  75. package/src/generators/init/init.d.ts +5 -0
  76. package/src/generators/init/init.js +47 -0
  77. package/src/generators/init/init.js.map +1 -0
  78. package/src/generators/init/schema.d.ts +5 -0
  79. package/src/generators/init/schema.json +16 -0
  80. package/src/generators/migrate-to-cypress-11/conversion.util.d.ts +34 -0
  81. package/src/generators/migrate-to-cypress-11/conversion.util.js +241 -0
  82. package/src/generators/migrate-to-cypress-11/conversion.util.js.map +1 -0
  83. package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.d.ts +3 -0
  84. package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js +85 -0
  85. package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js.map +1 -0
  86. package/src/generators/migrate-to-cypress-11/schema.json +15 -0
  87. package/src/migrations/update-12-8-0/remove-typescript-plugin.d.ts +2 -0
  88. package/src/migrations/update-12-8-0/remove-typescript-plugin.js +89 -0
  89. package/src/migrations/update-12-8-0/remove-typescript-plugin.js.map +1 -0
  90. package/src/migrations/update-14-6-1/update-cypress-configs-presets.d.ts +3 -0
  91. package/src/migrations/update-14-6-1/update-cypress-configs-presets.js +111 -0
  92. package/src/migrations/update-14-6-1/update-cypress-configs-presets.js.map +1 -0
  93. package/src/migrations/update-14-7-0/update-cypress-version-if-10.d.ts +3 -0
  94. package/src/migrations/update-14-7-0/update-cypress-version-if-10.js +33 -0
  95. package/src/migrations/update-14-7-0/update-cypress-version-if-10.js.map +1 -0
  96. package/src/migrations/update-15-0-0/add-cypress-inputs.d.ts +2 -0
  97. package/src/migrations/update-15-0-0/add-cypress-inputs.js +48 -0
  98. package/src/migrations/update-15-0-0/add-cypress-inputs.js.map +1 -0
  99. package/src/migrations/update-15-0-0/update-cy-mount-usage.d.ts +5 -0
  100. package/src/migrations/update-15-0-0/update-cy-mount-usage.js +124 -0
  101. package/src/migrations/update-15-0-0/update-cy-mount-usage.js.map +1 -0
  102. package/src/migrations/update-15-1-0/cypress-11.d.ts +6 -0
  103. package/src/migrations/update-15-1-0/cypress-11.js +118 -0
  104. package/src/migrations/update-15-1-0/cypress-11.js.map +1 -0
  105. package/src/migrations/update-15-5-0/helpers.d.ts +3 -0
  106. package/src/migrations/update-15-5-0/helpers.js +40 -0
  107. package/src/migrations/update-15-5-0/helpers.js.map +1 -0
  108. package/src/migrations/update-15-5-0/update-to-cypress-12.d.ts +24 -0
  109. package/src/migrations/update-15-5-0/update-to-cypress-12.js +183 -0
  110. package/src/migrations/update-15-5-0/update-to-cypress-12.js.map +1 -0
  111. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  112. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  113. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  114. package/src/plugins/preprocessor-vite.d.ts +32 -0
  115. package/src/plugins/preprocessor-vite.js +96 -0
  116. package/src/plugins/preprocessor-vite.js.map +1 -0
  117. package/src/utils/add-linter.d.ts +21 -0
  118. package/src/utils/add-linter.js +90 -0
  119. package/src/utils/add-linter.js.map +1 -0
  120. package/src/utils/ct-helpers.d.ts +16 -0
  121. package/src/utils/ct-helpers.js +86 -0
  122. package/src/utils/ct-helpers.js.map +1 -0
  123. package/src/utils/cypress-version.d.ts +5 -0
  124. package/src/utils/cypress-version.js +34 -0
  125. package/src/utils/cypress-version.js.map +1 -0
  126. package/src/utils/find-target-options.d.ts +16 -0
  127. package/src/utils/find-target-options.js +115 -0
  128. package/src/utils/find-target-options.js.map +1 -0
  129. package/src/utils/project-name.d.ts +3 -0
  130. package/src/utils/project-name.js +20 -0
  131. package/src/utils/project-name.js.map +1 -0
  132. package/src/utils/versions.d.ts +9 -0
  133. package/src/utils/versions.js +13 -0
  134. package/src/utils/versions.js.map +1 -0
@@ -0,0 +1,372 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const devkit_1 = require("@nx/devkit");
5
+ require("dotenv/config");
6
+ const fs_1 = require("fs");
7
+ const path_1 = require("path");
8
+ const ct_helpers_1 = require("../../utils/ct-helpers");
9
+ const cypress_version_1 = require("../../utils/cypress-version");
10
+ const detectPort = require("detect-port");
11
+ const Cypress = require('cypress'); // @NOTE: Importing via ES6 messes the whole test dependencies.
12
+ function cypressExecutor(options, context) {
13
+ var _a, e_1, _b, _c;
14
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
+ options = normalizeOptions(options, context);
16
+ // this is used by cypress component testing presets to build the executor contexts with the correct configuration options.
17
+ process.env.NX_CYPRESS_TARGET_CONFIGURATION = context.configurationName;
18
+ let success;
19
+ try {
20
+ for (var _d = true, _e = tslib_1.__asyncValues(startDevServer(options, context)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
21
+ _c = _f.value;
22
+ _d = false;
23
+ try {
24
+ const devServerValues = _c;
25
+ try {
26
+ success = yield runCypress(devServerValues.baseUrl, Object.assign(Object.assign({}, options), { portLockFilePath: devServerValues.portLockFilePath }));
27
+ if (!options.watch)
28
+ break;
29
+ }
30
+ catch (e) {
31
+ devkit_1.logger.error(e.message);
32
+ success = false;
33
+ if (!options.watch)
34
+ break;
35
+ }
36
+ }
37
+ finally {
38
+ _d = true;
39
+ }
40
+ }
41
+ }
42
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
43
+ finally {
44
+ try {
45
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
46
+ }
47
+ finally { if (e_1) throw e_1.error; }
48
+ }
49
+ return { success };
50
+ });
51
+ }
52
+ exports.default = cypressExecutor;
53
+ function normalizeOptions(options, context) {
54
+ var _a, _b, _c;
55
+ options.env = options.env || {};
56
+ if (options.tsConfig) {
57
+ const tsConfigPath = (0, path_1.join)(context.root, options.tsConfig);
58
+ options.env.tsConfig = tsConfigPath;
59
+ process.env.TS_NODE_PROJECT = tsConfigPath;
60
+ }
61
+ if (options.testingType === 'component') {
62
+ const project = (_b = (_a = context === null || context === void 0 ? void 0 : context.projectGraph) === null || _a === void 0 ? void 0 : _a.nodes) === null || _b === void 0 ? void 0 : _b[context.projectName];
63
+ if ((_c = project === null || project === void 0 ? void 0 : project.data) === null || _c === void 0 ? void 0 : _c.root) {
64
+ options.ctTailwindPath = (0, ct_helpers_1.getTempTailwindPath)(context);
65
+ }
66
+ }
67
+ checkSupportedBrowser(options);
68
+ warnDeprecatedHeadless(options);
69
+ warnDeprecatedCypressVersion();
70
+ return options;
71
+ }
72
+ function checkSupportedBrowser({ browser }) {
73
+ // Browser was not passed in as an option, cypress will use whatever default it has set and we dont need to check it
74
+ if (!browser) {
75
+ return;
76
+ }
77
+ if ((0, cypress_version_1.installedCypressVersion)() >= 4 && browser == 'canary') {
78
+ devkit_1.logger.warn((0, devkit_1.stripIndents) `
79
+ Warning:
80
+ You are using a browser that is not supported by cypress v4+.
81
+
82
+ Read here for more info:
83
+ https://docs.cypress.io/guides/references/migration-guide.html#Launching-Chrome-Canary-with-browser
84
+ `);
85
+ return;
86
+ }
87
+ const supportedV3Browsers = ['electron', 'chrome', 'canary', 'chromium'];
88
+ if ((0, cypress_version_1.installedCypressVersion)() <= 3 &&
89
+ !supportedV3Browsers.includes(browser)) {
90
+ devkit_1.logger.warn((0, devkit_1.stripIndents) `
91
+ Warning:
92
+ You are using a browser that is not supported by cypress v3.
93
+ `);
94
+ return;
95
+ }
96
+ }
97
+ function warnDeprecatedHeadless({ headless }) {
98
+ if ((0, cypress_version_1.installedCypressVersion)() < 8 || headless === undefined) {
99
+ return;
100
+ }
101
+ if (headless) {
102
+ const deprecatedMsg = (0, devkit_1.stripIndents) `
103
+ NOTE:
104
+ You can now remove the use of the '--headless' flag during 'cypress run' as this is the default for all browsers.`;
105
+ devkit_1.logger.warn(deprecatedMsg);
106
+ }
107
+ }
108
+ function warnDeprecatedCypressVersion() {
109
+ if ((0, cypress_version_1.installedCypressVersion)() < 10) {
110
+ devkit_1.logger.warn((0, devkit_1.stripIndents) `
111
+ NOTE:
112
+ Support for Cypress versions < 10 is deprecated. Please upgrade to at least Cypress version 10.
113
+ A generator to migrate from v8 to v10 is provided. See https://nx.dev/cypress/v10-migration-guide
114
+ `);
115
+ }
116
+ }
117
+ function startDevServer(opts, context) {
118
+ var _a, _b, _c;
119
+ return tslib_1.__asyncGenerator(this, arguments, function* startDevServer_1() {
120
+ var _d, e_2, _e, _f;
121
+ // no dev server, return the provisioned base url
122
+ if (!opts.devServerTarget || opts.skipServe) {
123
+ yield yield tslib_1.__await({ baseUrl: opts.baseUrl });
124
+ return yield tslib_1.__await(void 0);
125
+ }
126
+ const parsedDevServerTarget = (0, devkit_1.parseTargetString)(opts.devServerTarget, context.projectGraph);
127
+ const [targetSupportsWatchOpt] = getValueFromSchema(context, parsedDevServerTarget, 'watch');
128
+ const overrides = Object.assign({}, (targetSupportsWatchOpt ? { watch: opts.watch } : {}));
129
+ if (opts.port === 'cypress-auto') {
130
+ const freePort = yield tslib_1.__await(getPortForProject(context, parsedDevServerTarget));
131
+ overrides['port'] = freePort;
132
+ }
133
+ else if (opts.port !== undefined) {
134
+ overrides['port'] = opts.port;
135
+ // zero is a special case that means any valid port so there is no reason to try to 'lock it'
136
+ if (opts.port !== 0) {
137
+ const didLock = attemptToLockPort(opts.port);
138
+ if (!didLock) {
139
+ devkit_1.logger.warn((0, devkit_1.stripIndents) `${opts.port} is potentially already in use by another cypress run.
140
+ If the port is in use, try using a different port value or passing --port='cypress-auto' to find a free port.`);
141
+ }
142
+ }
143
+ }
144
+ try {
145
+ for (var _g = true, _h = tslib_1.__asyncValues(yield tslib_1.__await((0, devkit_1.runExecutor)(parsedDevServerTarget, overrides, context))), _j; _j = yield tslib_1.__await(_h.next()), _d = _j.done, !_d;) {
146
+ _f = _j.value;
147
+ _g = false;
148
+ try {
149
+ const output = _f;
150
+ if (!output.success && !opts.watch)
151
+ throw new Error('Could not compile application files');
152
+ if (!opts.baseUrl &&
153
+ !output.baseUrl &&
154
+ !((_a = output.info) === null || _a === void 0 ? void 0 : _a.baseUrl) &&
155
+ ((_b = output.info) === null || _b === void 0 ? void 0 : _b.port)) {
156
+ output.baseUrl = `http://localhost:${output.info.port}`;
157
+ }
158
+ yield yield tslib_1.__await({
159
+ baseUrl: opts.baseUrl || output.baseUrl || ((_c = output.info) === null || _c === void 0 ? void 0 : _c.baseUrl),
160
+ portLockFilePath: overrides.port && (0, path_1.join)(__dirname, `${overrides.port}.txt`),
161
+ });
162
+ }
163
+ finally {
164
+ _g = true;
165
+ }
166
+ }
167
+ }
168
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
169
+ finally {
170
+ try {
171
+ if (!_g && !_d && (_e = _h.return)) yield tslib_1.__await(_e.call(_h));
172
+ }
173
+ finally { if (e_2) throw e_2.error; }
174
+ }
175
+ });
176
+ }
177
+ /**
178
+ * @whatItDoes Initialize the Cypress test runner with the provided project configuration.
179
+ * By default, Cypress will run tests from the CLI without the GUI and provide directly the results in the console output.
180
+ * If `watch` is `true`: Open Cypress in the interactive GUI to interact directly with the application.
181
+ */
182
+ function runCypress(baseUrl, opts) {
183
+ var _a, _b;
184
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
185
+ const cypressVersion = (0, cypress_version_1.installedCypressVersion)();
186
+ // Cypress expects the folder where a cypress config is present
187
+ const projectFolderPath = (0, path_1.dirname)(opts.cypressConfig);
188
+ const options = {
189
+ project: projectFolderPath,
190
+ configFile: (0, path_1.basename)(opts.cypressConfig),
191
+ };
192
+ // If not, will use the `baseUrl` normally from `cypress.json`
193
+ if (baseUrl) {
194
+ options.config = { baseUrl };
195
+ }
196
+ if (opts.browser) {
197
+ options.browser = opts.browser;
198
+ }
199
+ if (opts.env) {
200
+ options.env = opts.env;
201
+ }
202
+ if (opts.spec) {
203
+ options.spec = opts.spec;
204
+ }
205
+ options.tag = opts.tag;
206
+ options.exit = opts.exit;
207
+ options.headed = opts.headed;
208
+ if (opts.headless) {
209
+ options.headless = opts.headless;
210
+ }
211
+ options.record = opts.record;
212
+ options.key = opts.key;
213
+ options.parallel = opts.parallel;
214
+ options.ciBuildId = (_a = opts.ciBuildId) === null || _a === void 0 ? void 0 : _a.toString();
215
+ options.group = opts.group;
216
+ // renamed in cy 10
217
+ if (cypressVersion >= 10) {
218
+ (_b = options.config) !== null && _b !== void 0 ? _b : (options.config = {});
219
+ options.config[opts.testingType] = {
220
+ excludeSpecPattern: opts.ignoreTestFiles,
221
+ };
222
+ }
223
+ else {
224
+ options.ignoreTestFiles = opts.ignoreTestFiles;
225
+ }
226
+ if (opts.reporter) {
227
+ options.reporter = opts.reporter;
228
+ }
229
+ if (opts.reporterOptions) {
230
+ options.reporterOptions = opts.reporterOptions;
231
+ }
232
+ options.testingType = opts.testingType;
233
+ const result = yield (opts.watch
234
+ ? Cypress.open(options)
235
+ : Cypress.run(options));
236
+ cleanupTmpFile(opts.ctTailwindPath);
237
+ cleanupTmpFile(opts.portLockFilePath);
238
+ if (process.env.NX_VERBOSE_LOGGING === 'true' && opts.portLockFilePath) {
239
+ (0, fs_1.readdirSync)((0, path_1.dirname)(opts.portLockFilePath)).forEach((f) => {
240
+ if (f.endsWith('.txt')) {
241
+ devkit_1.logger.debug(`Lock file ${f} still present`);
242
+ }
243
+ });
244
+ }
245
+ /**
246
+ * `cypress.open` is returning `0` and is not of the same type as `cypress.run`.
247
+ * `cypress.open` is the graphical UI, so it will be obvious to know what wasn't
248
+ * working. Forcing the build to success when `cypress.open` is used.
249
+ */
250
+ return !result.totalFailed && !result.failures;
251
+ });
252
+ }
253
+ /**
254
+ * try to find a free port for the project to run on
255
+ * will return undefined if no port is found or the project doesn't have a port option
256
+ **/
257
+ function getPortForProject(context, target, defaultPort = 4200) {
258
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
259
+ const fmtTarget = (0, devkit_1.targetToTargetString)(target);
260
+ const [hasPortOpt, schemaPortValue] = getValueFromSchema(context, target, 'port');
261
+ let freePort;
262
+ if (hasPortOpt) {
263
+ let normalizedPortValue;
264
+ if (!schemaPortValue) {
265
+ devkit_1.logger.info(`NX ${fmtTarget} did not have a defined port value, checking for free port with the default value of ${defaultPort}`);
266
+ normalizedPortValue = defaultPort;
267
+ }
268
+ else {
269
+ normalizedPortValue = Number(schemaPortValue);
270
+ }
271
+ if (isNaN(normalizedPortValue)) {
272
+ devkit_1.output.warn({
273
+ title: `Port Not a Number`,
274
+ bodyLines: [
275
+ `The port value found was not a number or can't be parsed to a number`,
276
+ `When reading the devServerTarget (${fmtTarget}) schema, expected ${schemaPortValue} to be a number but got NaN.`,
277
+ `Nx will use the default value of ${defaultPort} instead.`,
278
+ `You can manually specify a port by setting the 'port' option`,
279
+ ],
280
+ });
281
+ normalizedPortValue = defaultPort;
282
+ }
283
+ try {
284
+ let attempts = 0;
285
+ // make sure when this check happens in parallel,
286
+ // we don't let the same port be used by multiple projects
287
+ do {
288
+ freePort = yield detectPort(freePort || normalizedPortValue);
289
+ if (attemptToLockPort(freePort)) {
290
+ break;
291
+ }
292
+ attempts++;
293
+ // increment port in case the lock file isn't cleaned up
294
+ freePort++;
295
+ } while (attempts < 20);
296
+ devkit_1.logger.info(`NX Using port ${freePort} for ${fmtTarget}`);
297
+ }
298
+ catch (err) {
299
+ throw new Error((0, devkit_1.stripIndents) `Unable to find a free port for the dev server, ${fmtTarget}.
300
+ You can disable auto port detection by specifing a port or not passing a value to --port`);
301
+ }
302
+ }
303
+ else {
304
+ devkit_1.output.warn({
305
+ title: `No Port Option Found`,
306
+ bodyLines: [
307
+ `The 'port' option is set to 'cypress-auto', but the devServerTarget (${fmtTarget}) does not have a port option.`,
308
+ `Because of this, Nx is unable to verify the port is free before starting the dev server.`,
309
+ `This might cause issues if the devServerTarget is trying to use a port that is already in use.`,
310
+ ],
311
+ });
312
+ }
313
+ return freePort;
314
+ });
315
+ }
316
+ /**
317
+ * Check if the given target has the given property in it's options.
318
+ * if the property is does not have a default value or is not in the actual executor options,
319
+ * the value will be undefined even if it's in the executor schema.
320
+ **/
321
+ function getValueFromSchema(context, target, property) {
322
+ var _a, _b;
323
+ let targetOpts;
324
+ try {
325
+ targetOpts = (0, devkit_1.readTargetOptions)(target, context);
326
+ }
327
+ catch (e) {
328
+ throw new Error(`Unable to read the target options for ${(0, devkit_1.targetToTargetString)(target)}.
329
+ Are you sure this is a valid target?
330
+ Was trying to read the target for the property: '${property}', but got the following error:
331
+ ${e.message || e}`);
332
+ }
333
+ let targetHasOpt = Object.keys(targetOpts).includes(property);
334
+ if (!targetHasOpt) {
335
+ // NOTE: readTargetOptions doesn't apply non defaulted values, i.e. @nrwl/vite has a port options but is optional
336
+ // so we double check the schema if readTargetOptions didn't return a value for the property
337
+ const projectConfig = (_b = (_a = context.projectsConfigurations) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b[target.project];
338
+ const targetConfig = projectConfig.targets[target.target];
339
+ const workspace = new devkit_1.Workspaces(context.root);
340
+ const [collection, executor] = targetConfig.executor.split(':');
341
+ const { schema } = workspace.readExecutor(collection, executor);
342
+ // NOTE: schema won't have a default since readTargetOptions would have
343
+ // already set that and this check wouldn't need to be made
344
+ targetHasOpt = Object.keys(schema.properties).includes(property);
345
+ }
346
+ return [targetHasOpt, targetOpts[property]];
347
+ }
348
+ function attemptToLockPort(port) {
349
+ const portLockFilePath = (0, path_1.join)(__dirname, `${port}.txt`);
350
+ try {
351
+ if ((0, fs_1.existsSync)(portLockFilePath)) {
352
+ return false;
353
+ }
354
+ (0, fs_1.writeFileSync)(portLockFilePath, 'locked');
355
+ return true;
356
+ }
357
+ catch (err) {
358
+ return false;
359
+ }
360
+ }
361
+ function cleanupTmpFile(path) {
362
+ try {
363
+ if (path && (0, fs_1.existsSync)(path)) {
364
+ (0, fs_1.unlinkSync)(path);
365
+ }
366
+ return true;
367
+ }
368
+ catch (err) {
369
+ return false;
370
+ }
371
+ }
372
+ //# sourceMappingURL=cypress.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cypress.impl.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/executors/cypress/cypress.impl.ts"],"names":[],"mappings":";;;AAAA,uCAWoB;AACpB,yBAAuB;AACvB,2BAAwE;AACxE,+BAA+C;AAC/C,uDAA6D;AAC7D,iEAAsE;AACtE,0CAA0C;AAE1C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,+DAA+D;AA0CnG,SAA8B,eAAe,CAC3C,OAA+B,EAC/B,OAAwB;;;QAExB,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,C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CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;IACxD,IAAI;QACF,IAAI,IAAA,eAAU,EAAC,gBAAgB,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QACD,IAAA,kBAAa,EAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI;QACF,IAAI,IAAI,IAAI,IAAA,eAAU,EAAC,IAAI,CAAC,EAAE;YAC5B,IAAA,eAAU,EAAC,IAAI,CAAC,CAAC;SAClB;QACD,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,KAAK,CAAC;KACd;AACH,CAAC"}
@@ -0,0 +1,158 @@
1
+ {
2
+ "version": 2,
3
+ "title": "Cypress Target",
4
+ "description": "Run Cypress for e2e, integration and component testing.",
5
+ "type": "object",
6
+ "outputCapture": "pipe",
7
+ "cli": "nx",
8
+ "presets": [
9
+ {
10
+ "name": "Starting Dev Server",
11
+ "keys": ["cypressConfig", "devServerTarget"]
12
+ },
13
+ {
14
+ "name": "Custom Base Url",
15
+ "keys": ["cypressConfig", "baseUrl"]
16
+ },
17
+ {
18
+ "name": "Component Testing",
19
+ "keys": ["cypressConfig", "devServerTarget", "testingType", "skipServe"]
20
+ }
21
+ ],
22
+ "properties": {
23
+ "cypressConfig": {
24
+ "type": "string",
25
+ "description": "The path of the Cypress configuration json file.",
26
+ "x-completion-type": "file",
27
+ "x-completion-glob": "cypress?(*)@(.js|.ts|.json)"
28
+ },
29
+ "watch": {
30
+ "type": "boolean",
31
+ "description": "Recompile and run tests when files change.",
32
+ "default": false
33
+ },
34
+ "tsConfig": {
35
+ "type": "string",
36
+ "description": "The path of the Cypress tsconfig configuration json file.",
37
+ "x-completion-type": "file",
38
+ "x-completion-glob": "tsconfig.*.json"
39
+ },
40
+ "devServerTarget": {
41
+ "type": "string",
42
+ "description": "Dev server target to run tests against."
43
+ },
44
+ "headed": {
45
+ "type": "boolean",
46
+ "description": "Displays the browser instead of running headlessly. Set this to `true` if your run depends on a Chrome extension being loaded.",
47
+ "default": false
48
+ },
49
+ "headless": {
50
+ "type": "boolean",
51
+ "description": "Hide the browser instead of running headed.",
52
+ "default": false,
53
+ "x-deprecated": "Cypress runs headless by default. Use the --watch flag to control head/headless behavior instead."
54
+ },
55
+ "exit": {
56
+ "type": "boolean",
57
+ "description": "Whether or not the Cypress Test Runner will stay open after running tests in a spec file.",
58
+ "default": true
59
+ },
60
+ "key": {
61
+ "type": "string",
62
+ "description": "The key cypress should use to run tests in parallel/record the run (CI only)."
63
+ },
64
+ "record": {
65
+ "type": "boolean",
66
+ "description": "Whether or not Cypress should record the results of the tests.",
67
+ "default": false
68
+ },
69
+ "parallel": {
70
+ "aliases": ["p"],
71
+ "type": "boolean",
72
+ "description": "Whether or not Cypress should run its tests in parallel (CI only).",
73
+ "default": false
74
+ },
75
+ "baseUrl": {
76
+ "type": "string",
77
+ "description": "The address (with the port) which your application is running on.",
78
+ "x-priority": "important"
79
+ },
80
+ "browser": {
81
+ "type": "string",
82
+ "description": "The browser to run tests in."
83
+ },
84
+ "env": {
85
+ "type": "object",
86
+ "description": "A key-value Pair of environment variables to pass to Cypress runner."
87
+ },
88
+ "spec": {
89
+ "type": "string",
90
+ "description": "A comma delimited glob string that is provided to the Cypress runner to specify which spec files to run. i.e. `**examples/**,**actions.spec**`."
91
+ },
92
+ "copyFiles": {
93
+ "type": "string",
94
+ "description": "A regex string that is used to choose what additional integration files to copy to the dist folder.",
95
+ "x-deprecated": "No longer used since cypress supports typescript out of the box. If specified, it will be ignored.",
96
+ "x-priority": "internal"
97
+ },
98
+ "ciBuildId": {
99
+ "oneOf": [
100
+ {
101
+ "type": "string"
102
+ },
103
+ {
104
+ "type": "number"
105
+ }
106
+ ],
107
+ "description": "A unique identifier for a run to enable grouping or parallelization."
108
+ },
109
+ "group": {
110
+ "type": "string",
111
+ "description": "A named group for recorded runs in the Cypress dashboard."
112
+ },
113
+ "ignoreTestFiles": {
114
+ "aliases": ["excludeSpecPattern"],
115
+ "type": "string",
116
+ "description": "A String or Array of glob patterns used to ignore test files that would otherwise be shown in your list of tests. Cypress uses minimatch with the options: `{dot: true, matchBase: true}`. We suggest using https://globster.xyz to test what files would match."
117
+ },
118
+ "reporter": {
119
+ "type": "string",
120
+ "description": "The reporter used during cypress run."
121
+ },
122
+ "reporterOptions": {
123
+ "type": "string",
124
+ "description": "The reporter options used. Supported options depend on the reporter."
125
+ },
126
+ "skipServe": {
127
+ "type": "boolean",
128
+ "description": "Skip dev-server build.",
129
+ "default": false
130
+ },
131
+ "testingType": {
132
+ "type": "string",
133
+ "description": "Specify the type of tests to execute.",
134
+ "enum": ["component", "e2e"],
135
+ "default": "e2e"
136
+ },
137
+ "tag": {
138
+ "type": "string",
139
+ "description": "A comma delimited list to identify a run with.",
140
+ "aliases": ["t"]
141
+ },
142
+ "port": {
143
+ "oneOf": [
144
+ {
145
+ "type": "string",
146
+ "enum": ["cypress-auto"]
147
+ },
148
+ {
149
+ "type": "number"
150
+ }
151
+ ],
152
+ "description": "Pass a specified port value to the devServerTarget, if the value is 'cypress-auto' a free port will automatically be picked for the devServerTarget."
153
+ }
154
+ },
155
+ "additionalProperties": true,
156
+ "required": ["cypressConfig"],
157
+ "examplesFile": "../../../docs/cypress-examples.md"
158
+ }
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { ConvertTSLintToESLintSchema } from '@nx/linter';
3
+ export declare function conversionGenerator(host: Tree, options: ConvertTSLintToESLintSchema): Promise<() => Promise<void>>;
4
+ export declare const conversionSchematic: (generatorOptions: ConvertTSLintToESLintSchema) => (tree: any, context: any) => Promise<any>;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.conversionSchematic = exports.conversionGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const linter_1 = require("@nx/linter");
7
+ const add_linter_1 = require("../../utils/add-linter");
8
+ function conversionGenerator(host, options) {
9
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
+ /**
11
+ * The ProjectConverter instance encapsulates all the standard operations we need
12
+ * to perform in order to convert a project from TSLint to ESLint, as well as some
13
+ * extensibility points for adjusting the behavior on a per package basis.
14
+ *
15
+ * E.g. @nrwl/angular projects might need to make different changes to the final
16
+ * ESLint config when compared with @nrwl/next projects.
17
+ *
18
+ * See the ProjectConverter implementation for a full breakdown of what it does.
19
+ */
20
+ const projectConverter = new linter_1.ProjectConverter({
21
+ host,
22
+ projectName: options.project,
23
+ ignoreExistingTslintConfig: options.ignoreExistingTslintConfig,
24
+ eslintInitializer: ({ projectName, projectConfig }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ yield (0, add_linter_1.addLinterToCyProject)(host, {
26
+ linter: linter_1.Linter.EsLint,
27
+ project: projectName,
28
+ /**
29
+ * We set the parserOptions.project config just in case the converted config uses
30
+ * rules which require type-checking. Later in the conversion we check if it actually
31
+ * does and remove the config again if it doesn't, so that it is most efficient.
32
+ */
33
+ setParserOptionsProject: true,
34
+ cypressDir: 'src',
35
+ overwriteExisting: true,
36
+ });
37
+ }),
38
+ });
39
+ /**
40
+ * If root eslint configuration already exists it will not be recreated
41
+ * but we also don't want to re-run the tslint config conversion
42
+ * as it was likely already done
43
+ */
44
+ const rootEslintConfigExists = host.exists('.eslintrc.json');
45
+ /**
46
+ * Create the standard (which is applicable to the current package) ESLint setup
47
+ * for converting the project.
48
+ */
49
+ const eslintInitInstallTask = yield projectConverter.initESLint();
50
+ /**
51
+ * Convert the root tslint.json and apply the converted rules to the root .eslintrc.json.
52
+ */
53
+ const rootConfigInstallTask = yield projectConverter.convertRootTSLintConfig((json) => removeCodelyzerRelatedRules(json), rootEslintConfigExists);
54
+ /**
55
+ * Convert the project's tslint.json to an equivalent ESLint config.
56
+ */
57
+ const projectConfigInstallTask = yield projectConverter.convertProjectConfig((json) => json);
58
+ /**
59
+ * Clean up the original TSLint configuration for the project.
60
+ */
61
+ projectConverter.removeProjectTSLintFile();
62
+ // Only project shouldn't be added as a default
63
+ const { project } = options, defaults = tslib_1.__rest(options, ["project"]);
64
+ /**
65
+ * Store user preferences for the collection
66
+ */
67
+ projectConverter.setDefaults('@nrwl/cypress', defaults);
68
+ /**
69
+ * Based on user preference and remaining usage, remove TSLint from the workspace entirely.
70
+ */
71
+ let uninstallTSLintTask = () => Promise.resolve(undefined);
72
+ if (options.removeTSLintIfNoMoreTSLintTargets &&
73
+ !projectConverter.isTSLintUsedInWorkspace()) {
74
+ uninstallTSLintTask = projectConverter.removeTSLintFromWorkspace();
75
+ }
76
+ if (!options.skipFormat) {
77
+ yield (0, devkit_1.formatFiles)(host);
78
+ }
79
+ return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
80
+ yield eslintInitInstallTask();
81
+ yield rootConfigInstallTask();
82
+ yield projectConfigInstallTask();
83
+ yield uninstallTSLintTask();
84
+ });
85
+ });
86
+ }
87
+ exports.conversionGenerator = conversionGenerator;
88
+ exports.conversionSchematic = (0, devkit_1.convertNxGenerator)(conversionGenerator);
89
+ /**
90
+ * Remove any @angular-eslint rules that were applied as a result of converting prior codelyzer
91
+ * rules, because they are only relevant for Angular projects.
92
+ */
93
+ function removeCodelyzerRelatedRules(json) {
94
+ for (const ruleName of Object.keys(json.rules)) {
95
+ if (ruleName.startsWith('@angular-eslint')) {
96
+ delete json.rules[ruleName];
97
+ }
98
+ }
99
+ if (json.plugins) {
100
+ json.plugins = json.plugins.filter((plugin) => !plugin.startsWith('@angular-eslint'));
101
+ }
102
+ return json;
103
+ }
104
+ //# sourceMappingURL=convert-tslint-to-eslint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-tslint-to-eslint.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.ts"],"names":[],"mappings":";;;;AAAA,uCAKoB;AACpB,uCAIoB;AACpB,uDAA8D;AAG9D,SAAsB,mBAAmB,CACvC,IAAU,EACV,OAAoC;;QAEpC;;;;;;;;;WASG;QACH,MAAM,gBAAgB,GAAG,IAAI,yBAAgB,CAAC;YAC5C,IAAI;YACJ,WAAW,EAAE,OAAO,CAAC,OAAO;YAC5B,0BAA0B,EAAE,OAAO,CAAC,0BAA0B;YAC9D,iBAAiB,EAAE,CAAO,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,EAAE;gBAC1D,MAAM,IAAA,iCAAoB,EAAC,IAAI,EAAE;oBAC/B,MAAM,EAAE,eAAM,CAAC,MAAM;oBACrB,OAAO,EAAE,WAAW;oBACpB;;;;uBAIG;oBACH,uBAAuB,EAAE,IAAI;oBAC7B,UAAU,EAAE,KAAK;oBACjB,iBAAiB,EAAE,IAAI;iBACxB,CAAC,CAAC;YACL,CAAC,CAAA;SACF,CAAC,CAAC;QAEH;;;;WAIG;QACH,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAE7D;;;WAGG;QACH,MAAM,qBAAqB,GAAG,MAAM,gBAAgB,CAAC,UAAU,EAAE,CAAC;QAElE;;WAEG;QACH,MAAM,qBAAqB,GAAG,MAAM,gBAAgB,CAAC,uBAAuB,CAC1E,CAAC,IAAI,EAAE,EAAE,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAC3C,sBAAsB,CACvB,CAAC;QAEF;;WAEG;QACH,MAAM,wBAAwB,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CAC1E,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CACf,CAAC;QAEF;;WAEG;QACH,gBAAgB,CAAC,uBAAuB,EAAE,CAAC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