cypress 15.1.0 → 15.3.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.
Files changed (49) hide show
  1. package/bin/cypress +3 -1
  2. package/dist/VerboseRenderer.js +61 -0
  3. package/dist/cli.js +544 -0
  4. package/dist/cypress.js +104 -0
  5. package/dist/errors.js +391 -0
  6. package/dist/exec/info.js +103 -0
  7. package/dist/exec/open.js +103 -0
  8. package/dist/exec/run.js +177 -0
  9. package/dist/exec/shared.js +55 -0
  10. package/dist/exec/spawn.js +301 -0
  11. package/dist/exec/versions.js +67 -0
  12. package/dist/exec/xvfb.js +118 -0
  13. package/dist/index.js +52 -0
  14. package/dist/index.mjs +9 -0
  15. package/dist/logger.js +55 -0
  16. package/dist/tasks/cache.js +144 -0
  17. package/dist/tasks/download.js +304 -0
  18. package/dist/tasks/get-folder-size.js +44 -0
  19. package/dist/tasks/install.js +326 -0
  20. package/dist/tasks/state.js +184 -0
  21. package/dist/tasks/unzip.js +192 -0
  22. package/dist/tasks/verify.js +303 -0
  23. package/dist/util.js +452 -0
  24. package/package.json +10 -13
  25. package/types/cypress-automation.d.ts +2 -1
  26. package/types/cypress.d.ts +1 -0
  27. package/index.js +0 -27
  28. package/index.mjs +0 -17
  29. package/lib/VerboseRenderer.js +0 -58
  30. package/lib/cli.js +0 -411
  31. package/lib/cypress.js +0 -98
  32. package/lib/errors.js +0 -392
  33. package/lib/exec/info.js +0 -92
  34. package/lib/exec/open.js +0 -90
  35. package/lib/exec/run.js +0 -176
  36. package/lib/exec/shared.js +0 -62
  37. package/lib/exec/spawn.js +0 -247
  38. package/lib/exec/versions.js +0 -53
  39. package/lib/exec/xvfb.js +0 -93
  40. package/lib/fs.js +0 -4
  41. package/lib/logger.js +0 -50
  42. package/lib/tasks/cache.js +0 -132
  43. package/lib/tasks/download.js +0 -324
  44. package/lib/tasks/get-folder-size.js +0 -33
  45. package/lib/tasks/install.js +0 -368
  46. package/lib/tasks/state.js +0 -185
  47. package/lib/tasks/unzip.js +0 -200
  48. package/lib/tasks/verify.js +0 -300
  49. package/lib/util.js +0 -448
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ // https://github.com/cypress-io/cypress/issues/316
15
+ const tmp_1 = __importDefault(require("tmp"));
16
+ const fs_extra_1 = __importDefault(require("fs-extra"));
17
+ const open_1 = __importDefault(require("./exec/open"));
18
+ const run_1 = __importDefault(require("./exec/run"));
19
+ const util_1 = __importDefault(require("./util"));
20
+ const cli_1 = __importDefault(require("./cli"));
21
+ const cypressModuleApi = {
22
+ /**
23
+ * Opens Cypress GUI
24
+ * @see https://on.cypress.io/module-api#cypress-open
25
+ */
26
+ open(options = {}) {
27
+ options = util_1.default.normalizeModuleOptions(options);
28
+ return open_1.default.start(options);
29
+ },
30
+ /**
31
+ * Runs Cypress tests in the current project
32
+ * @see https://on.cypress.io/module-api#cypress-run
33
+ */
34
+ run() {
35
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
36
+ if (!run_1.default.isValidProject(options.project)) {
37
+ throw new Error(`Invalid project path parameter: ${options.project}`);
38
+ }
39
+ options = util_1.default.normalizeModuleOptions(options);
40
+ tmp_1.default.setGracefulCleanup();
41
+ const outputPath = tmp_1.default.fileSync().name;
42
+ options.outputPath = outputPath;
43
+ const failedTests = yield run_1.default.start(options);
44
+ const output = yield fs_extra_1.default.readJson(outputPath, { throws: false });
45
+ if (!output) {
46
+ return {
47
+ status: 'failed',
48
+ failures: failedTests,
49
+ message: 'Could not find Cypress test run results',
50
+ };
51
+ }
52
+ return output;
53
+ });
54
+ },
55
+ cli: {
56
+ /**
57
+ * Parses CLI arguments into an object that you can pass to "cypress.run"
58
+ * @example
59
+ * const cypress = require('cypress')
60
+ * const cli = ['cypress', 'run', '--browser', 'firefox']
61
+ * const options = await cypress.cli.parseRunArguments(cli)
62
+ * // options is {browser: 'firefox'}
63
+ * await cypress.run(options)
64
+ * @see https://on.cypress.io/module-api
65
+ */
66
+ parseRunArguments(args) {
67
+ return cli_1.default.parseRunCommand(args);
68
+ },
69
+ },
70
+ /**
71
+ * Provides automatic code completion for configuration in many popular code editors.
72
+ * While it's not strictly necessary for Cypress to parse your configuration, we
73
+ * recommend wrapping your config object with `defineConfig()`
74
+ * @example
75
+ * module.exports = defineConfig({
76
+ * viewportWith: 400
77
+ * })
78
+ *
79
+ * @see ../types/cypress-npm-api.d.ts
80
+ * @param {Cypress.ConfigOptions} config
81
+ * @returns {Cypress.ConfigOptions} the configuration passed in parameter
82
+ */
83
+ defineConfig(config) {
84
+ return config;
85
+ },
86
+ /**
87
+ * Provides automatic code completion for Component Frameworks Definitions.
88
+ * While it's not strictly necessary for Cypress to parse your configuration, we
89
+ * recommend wrapping your Component Framework Definition object with `defineComponentFramework()`
90
+ * @example
91
+ * module.exports = defineComponentFramework({
92
+ * type: 'cypress-ct-solid-js'
93
+ * // ...
94
+ * })
95
+ *
96
+ * @see ../types/cypress-npm-api.d.ts
97
+ * @param {Cypress.ThirdPartyComponentFrameworkDefinition} config
98
+ * @returns {Cypress.ThirdPartyComponentFrameworkDefinition} the configuration passed in parameter
99
+ */
100
+ defineComponentFramework(config) {
101
+ return config;
102
+ },
103
+ };
104
+ module.exports = cypressModuleApi;
package/dist/errors.js ADDED
@@ -0,0 +1,391 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.errors = exports.exitWithError = exports.throwFormErrorText = exports.raise = exports.hr = void 0;
16
+ exports.getError = getError;
17
+ exports.formErrorText = formErrorText;
18
+ const chalk_1 = __importDefault(require("chalk"));
19
+ const common_tags_1 = require("common-tags");
20
+ const lodash_1 = __importDefault(require("lodash"));
21
+ const assert_1 = __importDefault(require("assert"));
22
+ const util_1 = __importDefault(require("./util"));
23
+ const state_1 = __importDefault(require("./tasks/state"));
24
+ const docsUrl = 'https://on.cypress.io';
25
+ const requiredDependenciesUrl = `${docsUrl}/required-dependencies`;
26
+ const runDocumentationUrl = `${docsUrl}/cypress-run`;
27
+ // TODO it would be nice if all error objects could be enforced via types
28
+ // to only have description + solution properties
29
+ exports.hr = '----------';
30
+ const genericErrorSolution = (0, common_tags_1.stripIndent) `
31
+ Search for an existing issue or open a GitHub issue at
32
+
33
+ ${chalk_1.default.blue(util_1.default.issuesUrl)}
34
+ `;
35
+ // common errors Cypress application can encounter
36
+ const unknownError = {
37
+ description: 'Unknown Cypress CLI error',
38
+ solution: genericErrorSolution,
39
+ };
40
+ const invalidRunProjectPath = {
41
+ description: 'Invalid --project path',
42
+ solution: (0, common_tags_1.stripIndent) `
43
+ Please provide a valid project path.
44
+
45
+ Learn more about ${chalk_1.default.cyan('cypress run')} at:
46
+
47
+ ${chalk_1.default.blue(runDocumentationUrl)}
48
+ `,
49
+ };
50
+ const invalidOS = {
51
+ description: 'The Cypress App could not be installed. Your machine does not meet the operating system requirements.',
52
+ solution: (0, common_tags_1.stripIndent) `
53
+
54
+ ${chalk_1.default.blue('https://on.cypress.io/app/get-started/install-cypress#System-requirements')}`,
55
+ };
56
+ const failedDownload = {
57
+ description: 'The Cypress App could not be downloaded.',
58
+ solution: (0, common_tags_1.stripIndent) `
59
+ Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration
60
+
61
+ Otherwise, please check network connectivity and try again:`,
62
+ };
63
+ const failedUnzip = {
64
+ description: 'The Cypress App could not be unzipped.',
65
+ solution: genericErrorSolution,
66
+ };
67
+ const failedUnzipWindowsMaxPathLength = {
68
+ description: 'The Cypress App could not be unzipped.',
69
+ solution: `This is most likely because the maximum path length is being exceeded on your system.
70
+
71
+ Read here for solutions to this problem: https://on.cypress.io/win-max-path-length-error`,
72
+ };
73
+ const missingApp = (binaryDir) => {
74
+ return {
75
+ description: `No version of Cypress is installed in: ${chalk_1.default.cyan(binaryDir)}`,
76
+ solution: (0, common_tags_1.stripIndent) `
77
+ \nPlease reinstall Cypress by running: ${chalk_1.default.cyan('cypress install')}
78
+ `,
79
+ };
80
+ };
81
+ const binaryNotExecutable = (executable) => {
82
+ return {
83
+ description: `Cypress cannot run because this binary file does not have executable permissions here:\n\n${executable}`,
84
+ solution: (0, common_tags_1.stripIndent) `\n
85
+ Reasons this may happen:
86
+
87
+ - node was installed as 'root' or with 'sudo'
88
+ - the cypress npm package as 'root' or with 'sudo'
89
+
90
+ Please check that you have the appropriate user permissions.
91
+
92
+ You can also try clearing the cache with 'cypress cache clear' and reinstalling.
93
+ `,
94
+ };
95
+ };
96
+ const notInstalledCI = (executable) => {
97
+ return {
98
+ description: 'The cypress npm package is installed, but the Cypress binary is missing.',
99
+ solution: (0, common_tags_1.stripIndent) `\n
100
+ We expected the binary to be installed here: ${chalk_1.default.cyan(executable)}
101
+
102
+ Reasons it may be missing:
103
+
104
+ - You're caching 'node_modules' but are not caching this path: ${util_1.default.getCacheDir()}
105
+ - You ran 'npm install' at an earlier build step but did not persist: ${util_1.default.getCacheDir()}
106
+
107
+ Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
108
+
109
+ Alternatively, you can run 'cypress install' to download the binary again.
110
+
111
+ ${chalk_1.default.blue('https://on.cypress.io/not-installed-ci-error')}
112
+ `,
113
+ };
114
+ };
115
+ const nonZeroExitCodeXvfb = {
116
+ description: 'Xvfb exited with a non zero exit code.',
117
+ solution: (0, common_tags_1.stripIndent) `
118
+ There was a problem spawning Xvfb.
119
+
120
+ This is likely a problem with your system, permissions, or installation of Xvfb.
121
+ `,
122
+ };
123
+ const missingXvfb = {
124
+ description: 'Your system is missing the dependency: Xvfb',
125
+ solution: (0, common_tags_1.stripIndent) `
126
+ Install Xvfb and run Cypress again.
127
+
128
+ Read our documentation on dependencies for more information:
129
+
130
+ ${chalk_1.default.blue(requiredDependenciesUrl)}
131
+
132
+ If you are using Docker, we provide containers with all required dependencies installed.
133
+ `,
134
+ };
135
+ const smokeTestFailure = (smokeTestCommand, timedOut) => {
136
+ return {
137
+ description: `Cypress verification ${timedOut ? 'timed out' : 'failed'}.`,
138
+ solution: (0, common_tags_1.stripIndent) `
139
+ This command failed with the following output:
140
+
141
+ ${smokeTestCommand}
142
+
143
+ `,
144
+ };
145
+ };
146
+ const invalidSmokeTestDisplayError = {
147
+ code: 'INVALID_SMOKE_TEST_DISPLAY_ERROR',
148
+ description: 'Cypress verification failed.',
149
+ solution(msg) {
150
+ return (0, common_tags_1.stripIndent) `
151
+ Cypress failed to start after spawning a new Xvfb server.
152
+
153
+ The error logs we received were:
154
+
155
+ ${exports.hr}
156
+
157
+ ${msg}
158
+
159
+ ${exports.hr}
160
+
161
+ This may be due to a missing library or dependency. ${chalk_1.default.blue(requiredDependenciesUrl)}
162
+
163
+ Please refer to the error above for more detail.
164
+ `;
165
+ },
166
+ };
167
+ const missingDependency = {
168
+ description: 'Cypress failed to start.',
169
+ // this message is too Linux specific
170
+ solution: (0, common_tags_1.stripIndent) `
171
+ This may be due to a missing library or dependency. ${chalk_1.default.blue(requiredDependenciesUrl)}
172
+
173
+ Please refer to the error below for more details.
174
+ `,
175
+ };
176
+ const invalidCacheDirectory = {
177
+ description: 'Cypress cannot write to the cache directory due to file permissions',
178
+ solution: (0, common_tags_1.stripIndent) `
179
+ See discussion and possible solutions at
180
+ ${chalk_1.default.blue(util_1.default.getGitHubIssueUrl(1281))}
181
+ `,
182
+ };
183
+ const versionMismatch = {
184
+ description: 'Installed version does not match package version.',
185
+ solution: 'Install Cypress and verify app again',
186
+ };
187
+ const incompatibleHeadlessFlags = {
188
+ description: '`--headed` and `--headless` cannot both be passed.',
189
+ solution: 'Either pass `--headed` or `--headless`, but not both.',
190
+ };
191
+ const solutionUnknown = (0, common_tags_1.stripIndent) `
192
+ Please search Cypress documentation for possible solutions:
193
+
194
+ ${chalk_1.default.blue(docsUrl)}
195
+
196
+ Check if there is a GitHub issue describing this crash:
197
+
198
+ ${chalk_1.default.blue(util_1.default.issuesUrl)}
199
+
200
+ Consider opening a new issue.
201
+ `;
202
+ const unexpected = {
203
+ description: 'An unexpected error occurred while verifying the Cypress executable.',
204
+ solution: solutionUnknown,
205
+ };
206
+ const invalidCypressEnv = {
207
+ description: chalk_1.default.red('The environment variable with the reserved name "CYPRESS_INTERNAL_ENV" is set.'),
208
+ solution: chalk_1.default.red('Unset the "CYPRESS_INTERNAL_ENV" environment variable and run Cypress again.'),
209
+ exitCode: 11,
210
+ };
211
+ const invalidTestingType = {
212
+ description: 'Invalid testingType',
213
+ solution: `Please provide a valid testingType. Valid test types are ${chalk_1.default.cyan('\'e2e\'')} and ${chalk_1.default.cyan('\'component\'')}.`,
214
+ };
215
+ const incompatibleTestTypeFlags = {
216
+ description: '`--e2e` and `--component` cannot both be passed.',
217
+ solution: 'Either pass `--e2e` or `--component`, but not both.',
218
+ };
219
+ const incompatibleTestingTypeAndFlag = {
220
+ description: 'Set a `testingType` and also passed `--e2e` or `--component` flags.',
221
+ solution: 'Either set `testingType` or pass a testing type flag, but not both.',
222
+ };
223
+ const invalidConfigFile = {
224
+ description: '`--config-file` cannot be false.',
225
+ solution: 'Either pass a relative path to a valid Cypress config file or remove this option.',
226
+ };
227
+ /**
228
+ * This error happens when CLI detects that the child Test Runner process
229
+ * was killed with a signal, like SIGBUS
230
+ * @see https://github.com/cypress-io/cypress/issues/5808
231
+ * @param {'close'|'event'} eventName Child close event name
232
+ * @param {string} signal Signal that closed the child process, like "SIGBUS"
233
+ */
234
+ const childProcessKilled = (eventName, signal) => {
235
+ return {
236
+ description: `The Test Runner unexpectedly exited via a ${chalk_1.default.cyan(eventName)} event with signal ${chalk_1.default.cyan(signal)}`,
237
+ solution: solutionUnknown,
238
+ };
239
+ };
240
+ const CYPRESS_RUN_BINARY = {
241
+ notValid: (value) => {
242
+ const properFormat = `**/${state_1.default.getPlatformExecutable()}`;
243
+ return {
244
+ description: `Could not run binary set by environment variable: CYPRESS_RUN_BINARY=${value}`,
245
+ solution: `Ensure the environment variable is a path to the Cypress binary, matching ${properFormat}`,
246
+ };
247
+ },
248
+ };
249
+ function addPlatformInformation(info) {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ const platform = yield util_1.default.getPlatformInfo();
252
+ return Object.assign(Object.assign({}, info), { platform });
253
+ });
254
+ }
255
+ /**
256
+ * Given an error object (see the errors above), forms error message text with details,
257
+ * then resolves with Error instance you can throw or reject with.
258
+ * @param {object} errorObject
259
+ * @returns {Promise<Error>} resolves with an Error
260
+ * @example
261
+ ```js
262
+ // inside a Promise with "resolve" and "reject"
263
+ const errorObject = childProcessKilled('exit', 'SIGKILL')
264
+ return getError(errorObject).then(reject)
265
+ ```
266
+ */
267
+ function getError(errorObject) {
268
+ return __awaiter(this, void 0, void 0, function* () {
269
+ const errorMessage = yield formErrorText(errorObject);
270
+ const err = new Error(errorMessage);
271
+ err.known = true;
272
+ return err;
273
+ });
274
+ }
275
+ /**
276
+ * Forms nice error message with error and platform information,
277
+ * and if possible a way to solve it. Resolves with a string.
278
+ */
279
+ function formErrorText(info, msg, prevMessage) {
280
+ return __awaiter(this, void 0, void 0, function* () {
281
+ const infoWithPlatform = yield addPlatformInformation(info);
282
+ const formatted = [];
283
+ function add(msg) {
284
+ formatted.push((0, common_tags_1.stripIndents)(msg));
285
+ }
286
+ assert_1.default.ok(lodash_1.default.isString(infoWithPlatform.description) && !lodash_1.default.isEmpty(infoWithPlatform.description), 'expected error description to be text.');
287
+ // assuming that if there the solution is a function it will handle
288
+ // error message and (optional previous error message)
289
+ if (lodash_1.default.isFunction(infoWithPlatform.solution)) {
290
+ const text = infoWithPlatform.solution(msg, prevMessage);
291
+ assert_1.default.ok(lodash_1.default.isString(text) && !lodash_1.default.isEmpty(text), 'expected solution to be text.');
292
+ add(`
293
+ ${infoWithPlatform.description}
294
+
295
+ ${text}
296
+
297
+ `);
298
+ }
299
+ else {
300
+ assert_1.default.ok(lodash_1.default.isString(infoWithPlatform.solution) && !lodash_1.default.isEmpty(infoWithPlatform.solution), 'expected error solution to be text.');
301
+ add(`
302
+ ${infoWithPlatform.description}
303
+
304
+ ${infoWithPlatform.solution}
305
+
306
+ `);
307
+ if (msg) {
308
+ add(`
309
+ ${exports.hr}
310
+
311
+ ${msg}
312
+
313
+ `);
314
+ }
315
+ }
316
+ add(`
317
+ ${exports.hr}
318
+
319
+ ${infoWithPlatform.platform}
320
+ `);
321
+ if (infoWithPlatform.footer) {
322
+ add(`
323
+
324
+ ${exports.hr}
325
+
326
+ ${infoWithPlatform.footer}
327
+ `);
328
+ }
329
+ return formatted.join('\n\n');
330
+ });
331
+ }
332
+ const raise = (info) => {
333
+ return (text) => {
334
+ const err = new Error(text);
335
+ if (info.code) {
336
+ err.code = info.code;
337
+ }
338
+ err.known = true;
339
+ throw err;
340
+ };
341
+ };
342
+ exports.raise = raise;
343
+ const throwFormErrorText = (info) => {
344
+ return (msg, prevMessage) => __awaiter(void 0, void 0, void 0, function* () {
345
+ const errorText = yield formErrorText(info, msg, prevMessage);
346
+ (0, exports.raise)(info)(errorText);
347
+ });
348
+ };
349
+ exports.throwFormErrorText = throwFormErrorText;
350
+ /**
351
+ * Forms full error message with error and OS details, prints to the error output
352
+ * and then exits the process.
353
+ * @param {ErrorInformation} info Error information {description, solution}
354
+ * @example return exitWithError(errors.invalidCypressEnv)('foo')
355
+ */
356
+ const exitWithError = (info) => {
357
+ return (msg) => __awaiter(void 0, void 0, void 0, function* () {
358
+ const text = yield formErrorText(info, msg);
359
+ // eslint-disable-next-line no-console
360
+ console.error(text);
361
+ process.exit(info.exitCode || 1);
362
+ });
363
+ };
364
+ exports.exitWithError = exitWithError;
365
+ exports.errors = {
366
+ unknownError,
367
+ nonZeroExitCodeXvfb,
368
+ missingXvfb,
369
+ missingApp,
370
+ notInstalledCI,
371
+ missingDependency,
372
+ invalidOS,
373
+ invalidSmokeTestDisplayError,
374
+ versionMismatch,
375
+ binaryNotExecutable,
376
+ unexpected,
377
+ failedDownload,
378
+ failedUnzip,
379
+ failedUnzipWindowsMaxPathLength,
380
+ invalidCypressEnv,
381
+ invalidCacheDirectory,
382
+ CYPRESS_RUN_BINARY,
383
+ smokeTestFailure,
384
+ childProcessKilled,
385
+ incompatibleHeadlessFlags,
386
+ invalidRunProjectPath,
387
+ invalidTestingType,
388
+ incompatibleTestTypeFlags,
389
+ incompatibleTestingTypeAndFlag,
390
+ invalidConfigFile,
391
+ };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ /* eslint-disable no-console */
16
+ const spawn_1 = __importDefault(require("./spawn"));
17
+ const util_1 = __importDefault(require("../util"));
18
+ const state_1 = __importDefault(require("../tasks/state"));
19
+ const os_1 = __importDefault(require("os"));
20
+ const chalk_1 = __importDefault(require("chalk"));
21
+ const pretty_bytes_1 = __importDefault(require("pretty-bytes"));
22
+ const lodash_1 = __importDefault(require("lodash"));
23
+ // color for numbers and show values
24
+ const g = chalk_1.default.green;
25
+ // color for paths
26
+ const p = chalk_1.default.cyan;
27
+ const red = chalk_1.default.red;
28
+ // urls
29
+ const link = chalk_1.default.blue.underline;
30
+ // to be exported
31
+ const methods = {};
32
+ methods.findProxyEnvironmentVariables = () => {
33
+ return lodash_1.default.pick(process.env, ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY']);
34
+ };
35
+ const maskSensitiveVariables = (obj) => {
36
+ const masked = Object.assign({}, obj);
37
+ if (masked.CYPRESS_RECORD_KEY) {
38
+ masked.CYPRESS_RECORD_KEY = '<redacted>';
39
+ }
40
+ return masked;
41
+ };
42
+ methods.findCypressEnvironmentVariables = () => {
43
+ const isCyVariable = (val, key) => key.startsWith('CYPRESS_');
44
+ return lodash_1.default.pickBy(process.env, isCyVariable);
45
+ };
46
+ const formatCypressVariables = () => {
47
+ const vars = methods.findCypressEnvironmentVariables();
48
+ return maskSensitiveVariables(vars);
49
+ };
50
+ methods.start = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (options = {}) {
51
+ const args = ['--mode=info'];
52
+ yield spawn_1.default.start(args, {
53
+ dev: options.dev,
54
+ });
55
+ console.log();
56
+ const proxyVars = methods.findProxyEnvironmentVariables();
57
+ if (lodash_1.default.isEmpty(proxyVars)) {
58
+ console.log('Proxy Settings: none detected');
59
+ }
60
+ else {
61
+ console.log('Proxy Settings:');
62
+ lodash_1.default.forEach(proxyVars, (value, key) => {
63
+ console.log('%s: %s', key, g(value));
64
+ });
65
+ console.log();
66
+ console.log('Learn More: %s', link('https://on.cypress.io/proxy-configuration'));
67
+ console.log();
68
+ }
69
+ const cyVars = formatCypressVariables();
70
+ if (lodash_1.default.isEmpty(cyVars)) {
71
+ console.log('Environment Variables: none detected');
72
+ }
73
+ else {
74
+ console.log('Environment Variables:');
75
+ lodash_1.default.forEach(cyVars, (value, key) => {
76
+ console.log('%s: %s', key, g(value));
77
+ });
78
+ }
79
+ console.log();
80
+ console.log('Application Data:', p(util_1.default.getApplicationDataFolder()));
81
+ console.log('Browser Profiles:', p(util_1.default.getApplicationDataFolder('browsers')));
82
+ console.log('Binary Caches: %s', p(state_1.default.getCacheDir()));
83
+ console.log();
84
+ const osVersion = yield util_1.default.getOsVersionAsync();
85
+ const buildInfo = util_1.default.pkgBuildInfo();
86
+ const isStable = buildInfo && buildInfo.stable;
87
+ console.log('Cypress Version: %s', g(util_1.default.pkgVersion()), isStable ? g('(stable)') : red('(pre-release)'));
88
+ console.log('System Platform: %s (%s)', g(os_1.default.platform()), g(osVersion));
89
+ console.log('System Memory: %s free %s', g((0, pretty_bytes_1.default)(os_1.default.totalmem())), g((0, pretty_bytes_1.default)(os_1.default.freemem())));
90
+ if (!buildInfo) {
91
+ console.log();
92
+ console.log('This is the', red('development'), '(un-built) Cypress CLI.');
93
+ }
94
+ else if (!isStable) {
95
+ console.log();
96
+ console.log('This is a', red('pre-release'), 'build of Cypress.');
97
+ console.log('Build info:');
98
+ console.log(' Commit SHA:', g(buildInfo.commitSha));
99
+ console.log(' Commit Branch:', g(buildInfo.commitBranch));
100
+ console.log(' Commit Date:', g(buildInfo.commitDate));
101
+ }
102
+ });
103
+ exports.default = methods;