cypress 15.0.0 → 15.2.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.
- package/bin/cypress +3 -1
- package/index.js +49 -24
- package/lib/VerboseRenderer.js +50 -47
- package/lib/cli.js +455 -351
- package/lib/cypress.js +93 -90
- package/lib/errors.js +181 -194
- package/lib/exec/info.js +85 -74
- package/lib/exec/open.js +77 -73
- package/lib/exec/run.js +144 -154
- package/lib/exec/shared.js +37 -44
- package/lib/exec/spawn.js +270 -232
- package/lib/exec/versions.js +57 -49
- package/lib/exec/xvfb.js +79 -81
- package/lib/fs.js +7 -3
- package/lib/logger.js +37 -32
- package/lib/tasks/cache.js +128 -113
- package/lib/tasks/download.js +247 -258
- package/lib/tasks/get-folder-size.js +33 -22
- package/lib/tasks/install.js +274 -312
- package/lib/tasks/state.js +132 -143
- package/lib/tasks/unzip.js +186 -188
- package/lib/tasks/verify.js +274 -261
- package/lib/util.js +357 -356
- package/package.json +7 -4
- package/react/package.json +1 -1
- package/react/react/package.json +1 -1
- package/types/cypress-automation.d.ts +18 -0
- package/types/cypress.d.ts +15 -2
- package/types/index.d.ts +1 -1
- package/vue/package.json +1 -1
- package/vue/vue/package.json +1 -1
package/lib/tasks/install.js
CHANGED
@@ -1,163 +1,151 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
const
|
21
|
-
const
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
const
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
})
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
+
const lodash_1 = __importDefault(require("lodash"));
|
16
|
+
const os_1 = __importDefault(require("os"));
|
17
|
+
const path_1 = __importDefault(require("path"));
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
19
|
+
const debug_1 = __importDefault(require("debug"));
|
20
|
+
const listr2_1 = require("listr2");
|
21
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
22
|
+
const log_symbols_1 = __importDefault(require("log-symbols"));
|
23
|
+
const common_tags_1 = require("common-tags");
|
24
|
+
const fs_1 = __importDefault(require("../fs"));
|
25
|
+
const download_1 = __importDefault(require("./download"));
|
26
|
+
const util_1 = __importDefault(require("../util"));
|
27
|
+
const state_1 = __importDefault(require("./state"));
|
28
|
+
const unzip_1 = __importDefault(require("./unzip"));
|
29
|
+
const logger_1 = __importDefault(require("../logger"));
|
30
|
+
const errors_1 = require("../errors");
|
31
|
+
const VerboseRenderer_1 = __importDefault(require("../VerboseRenderer"));
|
32
|
+
const debug = (0, debug_1.default)('cypress:cli');
|
33
|
+
// Import package.json dynamically to avoid TypeScript JSON import issues
|
34
|
+
const { buildInfo, version } = require('../../package.json');
|
35
|
+
function _getBinaryUrlFromBuildInfo(arch, { commitSha, commitBranch }) {
|
36
|
+
const platform = os_1.default.platform();
|
37
|
+
if ((platform === 'win32') && (arch === 'arm64')) {
|
38
|
+
debug(`detected platform ${platform} architecture ${arch} combination`);
|
39
|
+
arch = 'x64';
|
40
|
+
debug(`overriding to download ${platform}-${arch} pre-release binary instead`);
|
41
|
+
}
|
42
|
+
return `https://cdn.cypress.io/beta/binary/${version}/${platform}-${arch}/${commitBranch}-${commitSha}/cypress.zip`;
|
42
43
|
}
|
43
44
|
const alreadyInstalledMsg = () => {
|
44
|
-
|
45
|
-
|
45
|
+
if (!util_1.default.isPostInstall()) {
|
46
|
+
logger_1.default.log((0, common_tags_1.stripIndent) `
|
46
47
|
Skipping installation:
|
47
48
|
|
48
|
-
Pass the ${
|
49
|
+
Pass the ${chalk_1.default.yellow('--force')} option if you'd like to reinstall anyway.
|
49
50
|
`);
|
50
|
-
|
51
|
+
}
|
51
52
|
};
|
52
53
|
const displayCompletionMsg = () => {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
${
|
54
|
+
// check here to see if we are globally installed
|
55
|
+
if (util_1.default.isInstalledGlobally()) {
|
56
|
+
// if we are display a warning
|
57
|
+
logger_1.default.log();
|
58
|
+
logger_1.default.warn((0, common_tags_1.stripIndent) `
|
59
|
+
${log_symbols_1.default.warning} Warning: It looks like you\'ve installed Cypress globally.
|
59
60
|
|
60
61
|
The recommended way to install Cypress is as a devDependency per project.
|
61
62
|
|
62
63
|
You should probably run these commands:
|
63
64
|
|
64
|
-
- ${
|
65
|
-
- ${
|
65
|
+
- ${chalk_1.default.cyan('npm uninstall -g cypress')}
|
66
|
+
- ${chalk_1.default.cyan('npm install --save-dev cypress')}
|
66
67
|
`);
|
67
|
-
|
68
|
-
}
|
69
|
-
logger.log();
|
70
|
-
logger.log('You can now open Cypress by running one of the following, depending on your package manager:');
|
71
|
-
logger.log();
|
72
|
-
logger.log(chalk.cyan('- npx cypress open'));
|
73
|
-
logger.log(chalk.cyan('- yarn cypress open'));
|
74
|
-
logger.log(chalk.cyan('- pnpm cypress open'));
|
75
|
-
logger.log();
|
76
|
-
logger.log(chalk.grey('https://on.cypress.io/opening-the-app'));
|
77
|
-
logger.log();
|
78
|
-
};
|
79
|
-
const downloadAndUnzip = ({
|
80
|
-
version,
|
81
|
-
installDir,
|
82
|
-
downloadDir
|
83
|
-
}) => {
|
84
|
-
const progress = {
|
85
|
-
throttle: 100,
|
86
|
-
onProgress: null
|
87
|
-
};
|
88
|
-
const downloadDestination = path.join(downloadDir, `cypress-${process.pid}.zip`);
|
89
|
-
const rendererOptions = getRendererOptions();
|
90
|
-
|
91
|
-
// let the user know what version of cypress we're downloading!
|
92
|
-
logger.log(`Installing Cypress ${chalk.gray(`(version: ${version})`)}`);
|
93
|
-
logger.log();
|
94
|
-
const tasks = new Listr([{
|
95
|
-
options: {
|
96
|
-
title: util.titleize('Downloading Cypress')
|
97
|
-
},
|
98
|
-
task: (ctx, task) => {
|
99
|
-
// as our download progresses indicate the status
|
100
|
-
progress.onProgress = progessify(task, 'Downloading Cypress');
|
101
|
-
return download.start({
|
102
|
-
version,
|
103
|
-
downloadDestination,
|
104
|
-
progress
|
105
|
-
}).then(redirectVersion => {
|
106
|
-
if (redirectVersion) version = redirectVersion;
|
107
|
-
debug(`finished downloading file: ${downloadDestination}`);
|
108
|
-
}).then(() => {
|
109
|
-
// save the download destination for unzipping
|
110
|
-
util.setTaskTitle(task, util.titleize(chalk.green('Downloaded Cypress')), rendererOptions.renderer);
|
111
|
-
});
|
112
|
-
}
|
113
|
-
}, unzipTask({
|
114
|
-
progress,
|
115
|
-
zipFilePath: downloadDestination,
|
116
|
-
installDir,
|
117
|
-
rendererOptions
|
118
|
-
}), {
|
119
|
-
options: {
|
120
|
-
title: util.titleize('Finishing Installation')
|
121
|
-
},
|
122
|
-
task: (ctx, task) => {
|
123
|
-
const cleanup = () => {
|
124
|
-
debug('removing zip file %s', downloadDestination);
|
125
|
-
return fs.removeAsync(downloadDestination);
|
126
|
-
};
|
127
|
-
return cleanup().then(() => {
|
128
|
-
debug('finished installation in', installDir);
|
129
|
-
util.setTaskTitle(task, util.titleize(chalk.green('Finished Installation'), chalk.gray(installDir)), rendererOptions.renderer);
|
130
|
-
});
|
68
|
+
return;
|
131
69
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
70
|
+
logger_1.default.log();
|
71
|
+
logger_1.default.log('You can now open Cypress by running one of the following, depending on your package manager:');
|
72
|
+
logger_1.default.log();
|
73
|
+
logger_1.default.log(chalk_1.default.cyan('- npx cypress open'));
|
74
|
+
logger_1.default.log(chalk_1.default.cyan('- yarn cypress open'));
|
75
|
+
logger_1.default.log(chalk_1.default.cyan('- pnpm cypress open'));
|
76
|
+
logger_1.default.log();
|
77
|
+
logger_1.default.log(chalk_1.default.grey('https://on.cypress.io/opening-the-app'));
|
78
|
+
logger_1.default.log();
|
79
|
+
};
|
80
|
+
const downloadAndUnzip = ({ version, installDir, downloadDir }) => {
|
81
|
+
const progress = {
|
82
|
+
throttle: 100,
|
83
|
+
onProgress: null,
|
84
|
+
};
|
85
|
+
const downloadDestination = path_1.default.join(downloadDir, `cypress-${process.pid}.zip`);
|
86
|
+
const rendererOptions = getRendererOptions();
|
87
|
+
// let the user know what version of cypress we're downloading!
|
88
|
+
logger_1.default.log(`Installing Cypress ${chalk_1.default.gray(`(version: ${version})`)}`);
|
89
|
+
logger_1.default.log();
|
90
|
+
const tasks = new listr2_1.Listr([
|
91
|
+
{
|
92
|
+
options: { title: util_1.default.titleize('Downloading Cypress') },
|
93
|
+
task: (ctx, task) => {
|
94
|
+
// as our download progresses indicate the status
|
95
|
+
progress.onProgress = progessify(task, 'Downloading Cypress');
|
96
|
+
return download_1.default.start({ version, downloadDestination, progress })
|
97
|
+
.then((redirectVersion) => {
|
98
|
+
if (redirectVersion)
|
99
|
+
version = redirectVersion;
|
100
|
+
debug(`finished downloading file: ${downloadDestination}`);
|
101
|
+
})
|
102
|
+
.then(() => {
|
103
|
+
// save the download destination for unzipping
|
104
|
+
util_1.default.setTaskTitle(task, util_1.default.titleize(chalk_1.default.green('Downloaded Cypress')), rendererOptions.renderer);
|
105
|
+
});
|
106
|
+
},
|
107
|
+
},
|
108
|
+
unzipTask({
|
109
|
+
progress,
|
110
|
+
zipFilePath: downloadDestination,
|
111
|
+
installDir,
|
112
|
+
rendererOptions,
|
113
|
+
}),
|
114
|
+
{
|
115
|
+
options: { title: util_1.default.titleize('Finishing Installation') },
|
116
|
+
task: (ctx, task) => {
|
117
|
+
const cleanup = () => {
|
118
|
+
debug('removing zip file %s', downloadDestination);
|
119
|
+
return fs_1.default.removeAsync(downloadDestination);
|
120
|
+
};
|
121
|
+
return cleanup()
|
122
|
+
.then(() => {
|
123
|
+
debug('finished installation in', installDir);
|
124
|
+
util_1.default.setTaskTitle(task, util_1.default.titleize(chalk_1.default.green('Finished Installation'), chalk_1.default.gray(installDir)), rendererOptions.renderer);
|
125
|
+
});
|
126
|
+
},
|
127
|
+
},
|
128
|
+
], { rendererOptions });
|
129
|
+
// start the tasks!
|
130
|
+
return bluebird_1.default.resolve(tasks.run());
|
138
131
|
};
|
139
132
|
const validateOS = () => {
|
140
|
-
|
141
|
-
|
142
|
-
|
133
|
+
return util_1.default.getPlatformInfo().then((platformInfo) => {
|
134
|
+
return platformInfo.match(/(win32-x64|win32-arm64|linux-x64|linux-arm64|darwin-x64|darwin-arm64)/);
|
135
|
+
});
|
143
136
|
};
|
144
|
-
|
145
137
|
/**
|
146
138
|
* Returns the version to install - either a string like `1.2.3` to be fetched
|
147
139
|
* from the download server or a file path or HTTP URL.
|
148
140
|
*/
|
149
|
-
function getVersionOverride({
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
158
|
-
if (buildInfo && !buildInfo.stable) {
|
159
|
-
logger.log(chalk.yellow(stripIndent`
|
160
|
-
${logSymbols.warning} Warning: You are installing a pre-release build of Cypress.
|
141
|
+
function getVersionOverride({ arch, envVarVersion, buildInfo }) {
|
142
|
+
// let this environment variable reset the binary version we need
|
143
|
+
if (envVarVersion) {
|
144
|
+
return envVarVersion;
|
145
|
+
}
|
146
|
+
if (buildInfo && !buildInfo.stable) {
|
147
|
+
logger_1.default.log(chalk_1.default.yellow((0, common_tags_1.stripIndent) `
|
148
|
+
${log_symbols_1.default.warning} Warning: You are installing a pre-release build of Cypress.
|
161
149
|
|
162
150
|
Bugs may be present which do not exist in production builds.
|
163
151
|
|
@@ -166,203 +154,177 @@ function getVersionOverride({
|
|
166
154
|
* Commit Branch: ${buildInfo.commitBranch}
|
167
155
|
* Commit Timestamp: ${buildInfo.commitDate}
|
168
156
|
`));
|
169
|
-
|
170
|
-
|
171
|
-
|
157
|
+
logger_1.default.log();
|
158
|
+
return _getBinaryUrlFromBuildInfo(arch, buildInfo);
|
159
|
+
}
|
172
160
|
}
|
173
161
|
function getEnvVarVersion() {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
162
|
+
if (!util_1.default.getEnv('CYPRESS_INSTALL_BINARY'))
|
163
|
+
return;
|
164
|
+
// because passed file paths are often double quoted
|
165
|
+
// and might have extra whitespace around, be robust and trim the string
|
166
|
+
const trimAndRemoveDoubleQuotes = true;
|
167
|
+
const envVarVersion = util_1.default.getEnv('CYPRESS_INSTALL_BINARY', trimAndRemoveDoubleQuotes);
|
168
|
+
debug('using environment variable CYPRESS_INSTALL_BINARY "%s"', envVarVersion);
|
169
|
+
return envVarVersion;
|
182
170
|
}
|
183
|
-
const start =
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
${
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
${
|
171
|
+
const start = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (options = {}) {
|
172
|
+
debug('installing with options %j', options);
|
173
|
+
const envVarVersion = getEnvVarVersion();
|
174
|
+
if (envVarVersion === '0') {
|
175
|
+
debug('environment variable CYPRESS_INSTALL_BINARY = 0, skipping install');
|
176
|
+
logger_1.default.log((0, common_tags_1.stripIndent) `
|
177
|
+
${chalk_1.default.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`);
|
178
|
+
logger_1.default.log();
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
lodash_1.default.defaults(options, {
|
182
|
+
force: false,
|
183
|
+
buildInfo,
|
184
|
+
});
|
185
|
+
if (util_1.default.getEnv('CYPRESS_CACHE_FOLDER')) {
|
186
|
+
const envCache = util_1.default.getEnv('CYPRESS_CACHE_FOLDER');
|
187
|
+
logger_1.default.log((0, common_tags_1.stripIndent) `
|
188
|
+
${chalk_1.default.yellow('Note:')} Overriding Cypress cache directory to: ${chalk_1.default.cyan(envCache)}
|
201
189
|
|
202
190
|
Previous installs of Cypress may not be found.
|
203
191
|
`);
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
await fs.ensureDirAsync(cacheDir).catch({
|
222
|
-
code: 'EACCES'
|
223
|
-
}, err => {
|
224
|
-
return throwFormErrorText(errors.invalidCacheDirectory)(stripIndent`
|
225
|
-
Failed to access ${chalk.cyan(cacheDir)}:
|
192
|
+
logger_1.default.log();
|
193
|
+
}
|
194
|
+
const pkgVersion = util_1.default.pkgVersion();
|
195
|
+
const arch = yield util_1.default.getRealArch();
|
196
|
+
const versionOverride = getVersionOverride({ arch, envVarVersion, buildInfo: options.buildInfo });
|
197
|
+
const versionToInstall = versionOverride || pkgVersion;
|
198
|
+
debug('version in package.json is %s, version to install is %s', pkgVersion, versionToInstall);
|
199
|
+
const installDir = state_1.default.getVersionDir(pkgVersion, options.buildInfo);
|
200
|
+
const cacheDir = state_1.default.getCacheDir();
|
201
|
+
const binaryDir = state_1.default.getBinaryDir(pkgVersion);
|
202
|
+
if (!(yield validateOS())) {
|
203
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.invalidOS)();
|
204
|
+
}
|
205
|
+
yield fs_1.default.ensureDirAsync(cacheDir)
|
206
|
+
.catch({ code: 'EACCES' }, (err) => {
|
207
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.invalidCacheDirectory)((0, common_tags_1.stripIndent) `
|
208
|
+
Failed to access ${chalk_1.default.cyan(cacheDir)}:
|
226
209
|
|
227
210
|
${err.message}
|
228
211
|
`);
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
Cypress ${
|
212
|
+
});
|
213
|
+
const binaryPkg = yield state_1.default.getBinaryPkgAsync(binaryDir);
|
214
|
+
const binaryVersion = yield state_1.default.getBinaryPkgVersion(binaryPkg);
|
215
|
+
const shouldInstall = () => {
|
216
|
+
if (!binaryVersion) {
|
217
|
+
debug('no binary installed under cli version');
|
218
|
+
return true;
|
219
|
+
}
|
220
|
+
logger_1.default.log();
|
221
|
+
logger_1.default.log((0, common_tags_1.stripIndent) `
|
222
|
+
Cypress ${chalk_1.default.green(binaryVersion)} is installed in ${chalk_1.default.cyan(installDir)}
|
240
223
|
`);
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
224
|
+
logger_1.default.log();
|
225
|
+
if (options.force) {
|
226
|
+
debug('performing force install over existing binary');
|
227
|
+
return true;
|
228
|
+
}
|
229
|
+
if ((binaryVersion === versionToInstall) || !util_1.default.isSemver(versionToInstall)) {
|
230
|
+
// our version matches, tell the user this is a noop
|
231
|
+
alreadyInstalledMsg();
|
232
|
+
return false;
|
233
|
+
}
|
234
|
+
return true;
|
235
|
+
};
|
236
|
+
// noop if we've been told not to download
|
237
|
+
if (!shouldInstall()) {
|
238
|
+
return debug('Not downloading or installing binary');
|
250
239
|
}
|
251
|
-
|
252
|
-
|
240
|
+
if (envVarVersion) {
|
241
|
+
logger_1.default.log(chalk_1.default.yellow((0, common_tags_1.stripIndent) `
|
242
|
+
${log_symbols_1.default.warning} Warning: Forcing a binary version different than the default.
|
253
243
|
|
254
|
-
|
255
|
-
if (!shouldInstall()) {
|
256
|
-
return debug('Not downloading or installing binary');
|
257
|
-
}
|
258
|
-
if (envVarVersion) {
|
259
|
-
logger.log(chalk.yellow(stripIndent`
|
260
|
-
${logSymbols.warning} Warning: Forcing a binary version different than the default.
|
244
|
+
The CLI expected to install version: ${chalk_1.default.green(pkgVersion)}
|
261
245
|
|
262
|
-
|
263
|
-
|
264
|
-
Instead we will install version: ${chalk.green(versionToInstall)}
|
246
|
+
Instead we will install version: ${chalk_1.default.green(versionToInstall)}
|
265
247
|
|
266
248
|
These versions may not work properly together.
|
267
249
|
`));
|
268
|
-
|
269
|
-
}
|
270
|
-
const getLocalFilePath = async () => {
|
271
|
-
// see if version supplied is a path to a binary
|
272
|
-
if (await fs.pathExistsAsync(versionToInstall)) {
|
273
|
-
return path.extname(versionToInstall) === '.zip' ? versionToInstall : false;
|
250
|
+
logger_1.default.log();
|
274
251
|
}
|
275
|
-
const
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
252
|
+
const getLocalFilePath = () => __awaiter(void 0, void 0, void 0, function* () {
|
253
|
+
// see if version supplied is a path to a binary
|
254
|
+
if (yield fs_1.default.pathExistsAsync(versionToInstall)) {
|
255
|
+
return path_1.default.extname(versionToInstall) === '.zip' ? versionToInstall : false;
|
256
|
+
}
|
257
|
+
const possibleFile = util_1.default.formAbsolutePath(versionToInstall);
|
258
|
+
debug('checking local file', possibleFile, 'cwd', process.cwd());
|
259
|
+
// if this exists return the path to it
|
260
|
+
// else false
|
261
|
+
if ((yield fs_1.default.pathExistsAsync(possibleFile)) && path_1.default.extname(possibleFile) === '.zip') {
|
262
|
+
return possibleFile;
|
263
|
+
}
|
264
|
+
return false;
|
265
|
+
});
|
266
|
+
const pathToLocalFile = yield getLocalFilePath();
|
267
|
+
if (pathToLocalFile) {
|
268
|
+
const absolutePath = path_1.default.resolve(versionToInstall);
|
269
|
+
debug('found local file at', absolutePath);
|
270
|
+
debug('skipping download');
|
271
|
+
const rendererOptions = getRendererOptions();
|
272
|
+
return new listr2_1.Listr([unzipTask({
|
273
|
+
progress: {
|
274
|
+
throttle: 100,
|
275
|
+
onProgress: null,
|
276
|
+
},
|
277
|
+
zipFilePath: absolutePath,
|
278
|
+
installDir,
|
279
|
+
rendererOptions,
|
280
|
+
})], { rendererOptions }).run();
|
282
281
|
}
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
if (pathToLocalFile) {
|
287
|
-
const absolutePath = path.resolve(versionToInstall);
|
288
|
-
debug('found local file at', absolutePath);
|
289
|
-
debug('skipping download');
|
290
|
-
const rendererOptions = getRendererOptions();
|
291
|
-
return new Listr([unzipTask({
|
292
|
-
progress: {
|
293
|
-
throttle: 100,
|
294
|
-
onProgress: null
|
295
|
-
},
|
296
|
-
zipFilePath: absolutePath,
|
297
|
-
installDir,
|
298
|
-
rendererOptions
|
299
|
-
})], {
|
300
|
-
rendererOptions
|
301
|
-
}).run();
|
302
|
-
}
|
303
|
-
if (options.force) {
|
304
|
-
debug('Cypress already installed at', installDir);
|
305
|
-
debug('but the installation was forced');
|
306
|
-
}
|
307
|
-
debug('preparing to download and unzip version ', versionToInstall, 'to path', installDir);
|
308
|
-
const downloadDir = os.tmpdir();
|
309
|
-
await downloadAndUnzip({
|
310
|
-
version: versionToInstall,
|
311
|
-
installDir,
|
312
|
-
downloadDir
|
313
|
-
});
|
314
|
-
|
315
|
-
// delay 1 sec for UX, unless we are testing
|
316
|
-
await Promise.delay(1000);
|
317
|
-
displayCompletionMsg();
|
318
|
-
};
|
319
|
-
module.exports = {
|
320
|
-
start,
|
321
|
-
_getBinaryUrlFromBuildInfo
|
322
|
-
};
|
323
|
-
const unzipTask = ({
|
324
|
-
zipFilePath,
|
325
|
-
installDir,
|
326
|
-
progress,
|
327
|
-
rendererOptions
|
328
|
-
}) => {
|
329
|
-
return {
|
330
|
-
options: {
|
331
|
-
title: util.titleize('Unzipping Cypress')
|
332
|
-
},
|
333
|
-
task: (ctx, task) => {
|
334
|
-
// as our unzip progresses indicate the status
|
335
|
-
progress.onProgress = progessify(task, 'Unzipping Cypress');
|
336
|
-
return unzip.start({
|
337
|
-
zipFilePath,
|
338
|
-
installDir,
|
339
|
-
progress
|
340
|
-
}).then(() => {
|
341
|
-
util.setTaskTitle(task, util.titleize(chalk.green('Unzipped Cypress')), rendererOptions.renderer);
|
342
|
-
});
|
282
|
+
if (options.force) {
|
283
|
+
debug('Cypress already installed at', installDir);
|
284
|
+
debug('but the installation was forced');
|
343
285
|
}
|
344
|
-
|
286
|
+
debug('preparing to download and unzip version ', versionToInstall, 'to path', installDir);
|
287
|
+
const downloadDir = os_1.default.tmpdir();
|
288
|
+
yield downloadAndUnzip({ version: versionToInstall, installDir, downloadDir });
|
289
|
+
// delay 1 sec for UX, unless we are testing
|
290
|
+
yield bluebird_1.default.delay(1000);
|
291
|
+
displayCompletionMsg();
|
292
|
+
});
|
293
|
+
const unzipTask = ({ zipFilePath, installDir, progress, rendererOptions }) => {
|
294
|
+
return {
|
295
|
+
options: { title: util_1.default.titleize('Unzipping Cypress') },
|
296
|
+
task: (ctx, task) => {
|
297
|
+
// as our unzip progresses indicate the status
|
298
|
+
progress.onProgress = progessify(task, 'Unzipping Cypress');
|
299
|
+
return unzip_1.default.start({ zipFilePath, installDir, progress })
|
300
|
+
.then(() => {
|
301
|
+
util_1.default.setTaskTitle(task, util_1.default.titleize(chalk_1.default.green('Unzipped Cypress')), rendererOptions.renderer);
|
302
|
+
});
|
303
|
+
},
|
304
|
+
};
|
345
305
|
};
|
346
306
|
const progessify = (task, title) => {
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
};
|
307
|
+
// return higher order function
|
308
|
+
return (percentComplete, remaining) => {
|
309
|
+
const percentCompleteStr = chalk_1.default.white(` ${percentComplete}%`);
|
310
|
+
// pluralize seconds remaining
|
311
|
+
const remainingStr = chalk_1.default.gray(`${remaining}s`);
|
312
|
+
util_1.default.setTaskTitle(task, util_1.default.titleize(title, percentCompleteStr, remainingStr), getRendererOptions().renderer);
|
313
|
+
};
|
355
314
|
};
|
356
|
-
|
357
315
|
// if we are running in CI then use
|
358
316
|
// the verbose renderer else use
|
359
317
|
// the default
|
360
318
|
const getRendererOptions = () => {
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
};
|
319
|
+
let renderer = util_1.default.isCi() ? VerboseRenderer_1.default : 'default';
|
320
|
+
if (logger_1.default.logLevel() === 'silent') {
|
321
|
+
renderer = 'silent';
|
322
|
+
}
|
323
|
+
return {
|
324
|
+
renderer,
|
325
|
+
};
|
326
|
+
};
|
327
|
+
exports.default = {
|
328
|
+
start,
|
329
|
+
_getBinaryUrlFromBuildInfo,
|
330
|
+
};
|