cypress 15.1.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.
@@ -1,163 +1,151 @@
1
1
  "use strict";
2
-
3
- const _ = require('lodash');
4
- const os = require('os');
5
- const path = require('path');
6
- const chalk = require('chalk');
7
- const debug = require('debug')('cypress:cli');
8
- const {
9
- Listr
10
- } = require('listr2');
11
- const Promise = require('bluebird');
12
- const logSymbols = require('log-symbols');
13
- const {
14
- stripIndent
15
- } = require('common-tags');
16
- const fs = require('../fs');
17
- const download = require('./download');
18
- const util = require('../util');
19
- const state = require('./state');
20
- const unzip = require('./unzip');
21
- const logger = require('../logger');
22
- const {
23
- throwFormErrorText,
24
- errors
25
- } = require('../errors');
26
- const verbose = require('../VerboseRenderer');
27
- const {
28
- buildInfo,
29
- version
30
- } = require('../../package.json');
31
- function _getBinaryUrlFromBuildInfo(arch, {
32
- commitSha,
33
- commitBranch
34
- }) {
35
- const platform = os.platform();
36
- if (platform === 'win32' && arch === 'arm64') {
37
- debug(`detected platform ${platform} architecture ${arch} combination`);
38
- arch = 'x64';
39
- debug(`overriding to download ${platform}-${arch} pre-release binary instead`);
40
- }
41
- return `https://cdn.cypress.io/beta/binary/${version}/${platform}-${arch}/${commitBranch}-${commitSha}/cypress.zip`;
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
- if (!util.isPostInstall()) {
45
- logger.log(stripIndent`
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 ${chalk.yellow('--force')} option if you'd like to reinstall anyway.
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
- // check here to see if we are globally installed
54
- if (util.isInstalledGlobally()) {
55
- // if we are display a warning
56
- logger.log();
57
- logger.warn(stripIndent`
58
- ${logSymbols.warning} Warning: It looks like you\'ve installed Cypress globally.
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
- - ${chalk.cyan('npm uninstall -g cypress')}
65
- - ${chalk.cyan('npm install --save-dev cypress')}
65
+ - ${chalk_1.default.cyan('npm uninstall -g cypress')}
66
+ - ${chalk_1.default.cyan('npm install --save-dev cypress')}
66
67
  `);
67
- return;
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
- rendererOptions
134
- });
135
-
136
- // start the tasks!
137
- return Promise.resolve(tasks.run());
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
- return util.getPlatformInfo().then(platformInfo => {
141
- return platformInfo.match(/(win32-x64|win32-arm64|linux-x64|linux-arm64|darwin-x64|darwin-arm64)/);
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
- arch,
151
- envVarVersion,
152
- buildInfo
153
- }) {
154
- // let this environment variable reset the binary version we need
155
- if (envVarVersion) {
156
- return envVarVersion;
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
- logger.log();
170
- return _getBinaryUrlFromBuildInfo(arch, buildInfo);
171
- }
157
+ logger_1.default.log();
158
+ return _getBinaryUrlFromBuildInfo(arch, buildInfo);
159
+ }
172
160
  }
173
161
  function getEnvVarVersion() {
174
- if (!util.getEnv('CYPRESS_INSTALL_BINARY')) return;
175
-
176
- // because passed file paths are often double quoted
177
- // and might have extra whitespace around, be robust and trim the string
178
- const trimAndRemoveDoubleQuotes = true;
179
- const envVarVersion = util.getEnv('CYPRESS_INSTALL_BINARY', trimAndRemoveDoubleQuotes);
180
- debug('using environment variable CYPRESS_INSTALL_BINARY "%s"', envVarVersion);
181
- return envVarVersion;
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 = async (options = {}) => {
184
- debug('installing with options %j', options);
185
- const envVarVersion = getEnvVarVersion();
186
- if (envVarVersion === '0') {
187
- debug('environment variable CYPRESS_INSTALL_BINARY = 0, skipping install');
188
- logger.log(stripIndent`
189
- ${chalk.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`);
190
- logger.log();
191
- return;
192
- }
193
- _.defaults(options, {
194
- force: false,
195
- buildInfo
196
- });
197
- if (util.getEnv('CYPRESS_CACHE_FOLDER')) {
198
- const envCache = util.getEnv('CYPRESS_CACHE_FOLDER');
199
- logger.log(stripIndent`
200
- ${chalk.yellow('Note:')} Overriding Cypress cache directory to: ${chalk.cyan(envCache)}
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
- logger.log();
205
- }
206
- const pkgVersion = util.pkgVersion();
207
- const arch = await util.getRealArch();
208
- const versionOverride = getVersionOverride({
209
- arch,
210
- envVarVersion,
211
- buildInfo: options.buildInfo
212
- });
213
- const versionToInstall = versionOverride || pkgVersion;
214
- debug('version in package.json is %s, version to install is %s', pkgVersion, versionToInstall);
215
- const installDir = state.getVersionDir(pkgVersion, options.buildInfo);
216
- const cacheDir = state.getCacheDir();
217
- const binaryDir = state.getBinaryDir(pkgVersion);
218
- if (!(await validateOS())) {
219
- return throwFormErrorText(errors.invalidOS)();
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
- const binaryPkg = await state.getBinaryPkgAsync(binaryDir);
231
- const binaryVersion = await state.getBinaryPkgVersion(binaryPkg);
232
- const shouldInstall = () => {
233
- if (!binaryVersion) {
234
- debug('no binary installed under cli version');
235
- return true;
236
- }
237
- logger.log();
238
- logger.log(stripIndent`
239
- Cypress ${chalk.green(binaryVersion)} is installed in ${chalk.cyan(installDir)}
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
- logger.log();
242
- if (options.force) {
243
- debug('performing force install over existing binary');
244
- return true;
245
- }
246
- if (binaryVersion === versionToInstall || !util.isSemver(versionToInstall)) {
247
- // our version matches, tell the user this is a noop
248
- alreadyInstalledMsg();
249
- return false;
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
- return true;
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
- // noop if we've been told not to download
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
- The CLI expected to install version: ${chalk.green(pkgVersion)}
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
- logger.log();
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 possibleFile = util.formAbsolutePath(versionToInstall);
276
- debug('checking local file', possibleFile, 'cwd', process.cwd());
277
-
278
- // if this exists return the path to it
279
- // else false
280
- if ((await fs.pathExistsAsync(possibleFile)) && path.extname(possibleFile) === '.zip') {
281
- return possibleFile;
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
- return false;
284
- };
285
- const pathToLocalFile = await getLocalFilePath();
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
- // return higher order function
348
- return (percentComplete, remaining) => {
349
- percentComplete = chalk.white(` ${percentComplete}%`);
350
-
351
- // pluralize seconds remaining
352
- remaining = chalk.gray(`${remaining}s`);
353
- util.setTaskTitle(task, util.titleize(title, percentComplete, remaining), getRendererOptions().renderer);
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
- let renderer = util.isCi() ? verbose : 'default';
362
- if (logger.logLevel() === 'silent') {
363
- renderer = 'silent';
364
- }
365
- return {
366
- renderer
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
+ };