cypress 5.2.0 → 5.6.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,152 +1,48 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3
+ const _ = require('lodash');
4
4
 
5
- function _templateObject7() {
6
- var data = _taggedTemplateLiteral(["\n ", " Warning: Forcing a binary version different than the default.\n\n The CLI expected to install version: ", "\n\n Instead we will install version: ", "\n\n These versions may not work properly together.\n "]);
5
+ const os = require('os');
7
6
 
8
- _templateObject7 = function _templateObject7() {
9
- return data;
10
- };
11
-
12
- return data;
13
- }
14
-
15
- function _templateObject6() {
16
- var data = _taggedTemplateLiteral(["\n Cypress ", " is installed in ", "\n "]);
17
-
18
- _templateObject6 = function _templateObject6() {
19
- return data;
20
- };
21
-
22
- return data;
23
- }
24
-
25
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
26
-
27
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
28
-
29
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
30
-
31
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
32
-
33
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
34
-
35
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
36
-
37
- function _templateObject5() {
38
- var data = _taggedTemplateLiteral(["\n Failed to access ", ":\n\n ", "\n "]);
39
-
40
- _templateObject5 = function _templateObject5() {
41
- return data;
42
- };
43
-
44
- return data;
45
- }
46
-
47
- function _templateObject4() {
48
- var data = _taggedTemplateLiteral(["\n ", " Overriding Cypress cache directory to: ", "\n\n Previous installs of Cypress may not be found.\n "]);
49
-
50
- _templateObject4 = function _templateObject4() {
51
- return data;
52
- };
53
-
54
- return data;
55
- }
56
-
57
- function _templateObject3() {
58
- var data = _taggedTemplateLiteral(["\n ", " Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0."]);
59
-
60
- _templateObject3 = function _templateObject3() {
61
- return data;
62
- };
63
-
64
- return data;
65
- }
66
-
67
- function _templateObject2() {
68
- var data = _taggedTemplateLiteral(["\n ", " Warning: It looks like you've installed Cypress globally.\n\n This will work, but it's not recommended.\n\n The recommended way to install Cypress is as a devDependency per project.\n\n You should probably run these commands:\n\n - ", "\n - ", "\n "], ["\n ", " Warning: It looks like you\\'ve installed Cypress globally.\n\n This will work, but it'\\s not recommended.\n\n The recommended way to install Cypress is as a devDependency per project.\n\n You should probably run these commands:\n\n - ", "\n - ", "\n "]);
69
-
70
- _templateObject2 = function _templateObject2() {
71
- return data;
72
- };
73
-
74
- return data;
75
- }
76
-
77
- function _templateObject() {
78
- var data = _taggedTemplateLiteral(["\n Skipping installation:\n\n Pass the ", " option if you'd like to reinstall anyway.\n "]);
79
-
80
- _templateObject = function _templateObject() {
81
- return data;
82
- };
83
-
84
- return data;
85
- }
86
-
87
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
88
-
89
- function _wrapRegExp(re, groups) { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _RegExp = _wrapNativeSuper(RegExp); var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = _RegExp.call(this, re, flags); _groups.set(_this, groups || _groups.get(re)); return _this; } _inherits(BabelRegExp, _RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = []; args.push.apply(args, arguments); if (_typeof(args[args.length - 1]) !== "object") { args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
90
-
91
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
92
-
93
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
94
-
95
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
96
-
97
- function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
98
-
99
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
100
-
101
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
102
-
103
- function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
104
-
105
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
106
-
107
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
108
-
109
- var _ = require('lodash');
110
-
111
- var os = require('os');
7
+ const url = require('url');
112
8
 
113
- var url = require('url');
9
+ const path = require('path');
114
10
 
115
- var path = require('path');
11
+ const chalk = require('chalk');
116
12
 
117
- var chalk = require('chalk');
13
+ const debug = require('debug')('cypress:cli');
118
14
 
119
- var debug = require('debug')('cypress:cli');
15
+ const Listr = require('listr');
120
16
 
121
- var Listr = require('listr');
17
+ const verbose = require('@cypress/listr-verbose-renderer');
122
18
 
123
- var verbose = require('@cypress/listr-verbose-renderer');
19
+ const Promise = require('bluebird');
124
20
 
125
- var Promise = require('bluebird');
21
+ const logSymbols = require('log-symbols');
126
22
 
127
- var logSymbols = require('log-symbols');
23
+ const {
24
+ stripIndent
25
+ } = require('common-tags');
128
26
 
129
- var _require = require('common-tags'),
130
- stripIndent = _require.stripIndent;
27
+ const fs = require('../fs');
131
28
 
132
- var fs = require('../fs');
29
+ const download = require('./download');
133
30
 
134
- var download = require('./download');
31
+ const util = require('../util');
135
32
 
136
- var util = require('../util');
33
+ const state = require('./state');
137
34
 
138
- var state = require('./state');
35
+ const unzip = require('./unzip');
139
36
 
140
- var unzip = require('./unzip');
37
+ const logger = require('../logger');
141
38
 
142
- var logger = require('../logger');
39
+ const {
40
+ throwFormErrorText,
41
+ errors
42
+ } = require('../errors');
143
43
 
144
- var _require2 = require('../errors'),
145
- throwFormErrorText = _require2.throwFormErrorText,
146
- errors = _require2.errors;
147
-
148
- var getNpmArgv = function getNpmArgv() {
149
- var json = process.env.npm_config_argv;
44
+ const getNpmArgv = () => {
45
+ const json = process.env.npm_config_argv;
150
46
 
151
47
  if (!json) {
152
48
  return;
@@ -163,27 +59,24 @@ var getNpmArgv = function getNpmArgv() {
163
59
  // for example: "^5.0.0", "https://cdn.cypress.io/...", ...
164
60
 
165
61
 
166
- var getVersionSpecifier = function getVersionSpecifier() {
167
- var startDir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : path.resolve(__dirname, '../..');
168
- var argv = getNpmArgv();
62
+ const getVersionSpecifier = (startDir = path.resolve(__dirname, '../..')) => {
63
+ const argv = getNpmArgv();
169
64
 
170
65
  if (argv) {
171
- var tgz = _.find(argv, function (t) {
172
- return t.endsWith('cypress.tgz');
173
- });
66
+ const tgz = _.find(argv, t => t.endsWith('cypress.tgz'));
174
67
 
175
68
  if (tgz) {
176
69
  return tgz;
177
70
  }
178
71
  }
179
72
 
180
- var getVersionSpecifierFromPkg = function getVersionSpecifierFromPkg(dir) {
73
+ const getVersionSpecifierFromPkg = dir => {
181
74
  debug('looking for versionSpecifier %o', {
182
- dir: dir
75
+ dir
183
76
  });
184
77
 
185
- var tryParent = function tryParent() {
186
- var parentPath = path.resolve(dir, '..');
78
+ const tryParent = () => {
79
+ const parentPath = path.resolve(dir, '..');
187
80
 
188
81
  if (parentPath === dir) {
189
82
  debug('reached FS root with no versionSpecifier found');
@@ -193,34 +86,26 @@ var getVersionSpecifier = function getVersionSpecifier() {
193
86
  return getVersionSpecifierFromPkg(parentPath);
194
87
  };
195
88
 
196
- return fs.readJSON(path.join(dir, 'package.json'))["catch"](function () {
197
- return {};
198
- }).then(function (pkg) {
199
- var specifier = _.chain(['dependencies', 'devDependencies', 'optionalDependencies']).map(function (prop) {
200
- return _.get(pkg, "".concat(prop, ".cypress"));
201
- }).compact().first().value();
89
+ return fs.readJSON(path.join(dir, 'package.json')).catch(() => ({})).then(pkg => {
90
+ const specifier = _.chain(['dependencies', 'devDependencies', 'optionalDependencies']).map(prop => _.get(pkg, `${prop}.cypress`)).compact().first().value();
202
91
 
203
92
  return specifier || tryParent();
204
93
  });
205
94
  }; // recurse through parent directories until package.json with `cypress` is found
206
95
 
207
96
 
208
- return getVersionSpecifierFromPkg(startDir).then(function (versionSpecifier) {
97
+ return getVersionSpecifierFromPkg(startDir).then(versionSpecifier => {
209
98
  debug('finished looking for versionSpecifier', {
210
- versionSpecifier: versionSpecifier
99
+ versionSpecifier
211
100
  });
212
101
  return versionSpecifier;
213
102
  });
214
103
  };
215
104
 
216
- var betaNpmUrlRe = /*#__PURE__*/_wrapRegExp(/^\/beta\/npm\/([\.0-9]+)\/([\0-\.0-\uFFFF]+)\/cypress\.tgz$/, {
217
- version: 1,
218
- artifactSlug: 2
219
- }); // convert a prerelease NPM package .tgz URL to the corresponding binary .zip URL
105
+ const betaNpmUrlRe = /^\/beta\/npm\/(?<version>[0-9.]+)\/(?<artifactSlug>[^/]+)\/cypress\.tgz$/; // convert a prerelease NPM package .tgz URL to the corresponding binary .zip URL
220
106
 
221
-
222
- var getBinaryUrlFromPrereleaseNpmUrl = function getBinaryUrlFromPrereleaseNpmUrl(npmUrl) {
223
- var parsed;
107
+ const getBinaryUrlFromPrereleaseNpmUrl = npmUrl => {
108
+ let parsed;
224
109
 
225
110
  try {
226
111
  parsed = url.parse(npmUrl);
@@ -228,31 +113,47 @@ var getBinaryUrlFromPrereleaseNpmUrl = function getBinaryUrlFromPrereleaseNpmUrl
228
113
  return;
229
114
  }
230
115
 
231
- var matches = betaNpmUrlRe.exec(parsed.pathname);
116
+ const matches = betaNpmUrlRe.exec(parsed.pathname);
232
117
 
233
118
  if (parsed.hostname !== 'cdn.cypress.io' || !matches) {
234
119
  return;
235
120
  }
236
121
 
237
- var _matches$groups = matches.groups,
238
- version = _matches$groups.version,
239
- artifactSlug = _matches$groups.artifactSlug;
240
- parsed.pathname = "/beta/binary/".concat(version, "/").concat(os.platform(), "-").concat(os.arch(), "/").concat(artifactSlug, "/cypress.zip");
122
+ const {
123
+ version,
124
+ artifactSlug
125
+ } = matches.groups;
126
+ parsed.pathname = `/beta/binary/${version}/${os.platform()}-${os.arch()}/${artifactSlug}/cypress.zip`;
241
127
  return parsed.format();
242
128
  };
243
129
 
244
- var alreadyInstalledMsg = function alreadyInstalledMsg() {
130
+ const alreadyInstalledMsg = () => {
245
131
  if (!util.isPostInstall()) {
246
- logger.log(stripIndent(_templateObject(), chalk.yellow('--force')));
132
+ logger.log(stripIndent`
133
+ Skipping installation:
134
+
135
+ Pass the ${chalk.yellow('--force')} option if you'd like to reinstall anyway.
136
+ `);
247
137
  }
248
138
  };
249
139
 
250
- var displayCompletionMsg = function displayCompletionMsg() {
140
+ const displayCompletionMsg = () => {
251
141
  // check here to see if we are globally installed
252
142
  if (util.isInstalledGlobally()) {
253
143
  // if we are display a warning
254
144
  logger.log();
255
- logger.warn(stripIndent(_templateObject2(), logSymbols.warning, chalk.cyan('npm uninstall -g cypress'), chalk.cyan('npm install --save-dev cypress')));
145
+ logger.warn(stripIndent`
146
+ ${logSymbols.warning} Warning: It looks like you\'ve installed Cypress globally.
147
+
148
+ This will work, but it'\s not recommended.
149
+
150
+ The recommended way to install Cypress is as a devDependency per project.
151
+
152
+ You should probably run these commands:
153
+
154
+ - ${chalk.cyan('npm uninstall -g cypress')}
155
+ - ${chalk.cyan('npm install --save-dev cypress')}
156
+ `);
256
157
  return;
257
158
  }
258
159
 
@@ -263,52 +164,53 @@ var displayCompletionMsg = function displayCompletionMsg() {
263
164
  logger.log();
264
165
  };
265
166
 
266
- var downloadAndUnzip = function downloadAndUnzip(_ref) {
267
- var version = _ref.version,
268
- installDir = _ref.installDir,
269
- downloadDir = _ref.downloadDir;
270
- var progress = {
167
+ const downloadAndUnzip = ({
168
+ version,
169
+ installDir,
170
+ downloadDir
171
+ }) => {
172
+ const progress = {
271
173
  throttle: 100,
272
174
  onProgress: null
273
175
  };
274
- var downloadDestination = path.join(downloadDir, 'cypress.zip');
275
- var rendererOptions = getRendererOptions(); // let the user know what version of cypress we're downloading!
176
+ const downloadDestination = path.join(downloadDir, 'cypress.zip');
177
+ const rendererOptions = getRendererOptions(); // let the user know what version of cypress we're downloading!
276
178
 
277
- logger.log("Installing Cypress ".concat(chalk.gray("(version: ".concat(version, ")"))));
179
+ logger.log(`Installing Cypress ${chalk.gray(`(version: ${version})`)}`);
278
180
  logger.log();
279
- var tasks = new Listr([{
181
+ const tasks = new Listr([{
280
182
  title: util.titleize('Downloading Cypress'),
281
- task: function task(ctx, _task) {
183
+ task: (ctx, task) => {
282
184
  // as our download progresses indicate the status
283
- progress.onProgress = progessify(_task, 'Downloading Cypress');
185
+ progress.onProgress = progessify(task, 'Downloading Cypress');
284
186
  return download.start({
285
- version: version,
286
- downloadDestination: downloadDestination,
287
- progress: progress
288
- }).then(function (redirectVersion) {
187
+ version,
188
+ downloadDestination,
189
+ progress
190
+ }).then(redirectVersion => {
289
191
  if (redirectVersion) version = redirectVersion;
290
- debug("finished downloading file: ".concat(downloadDestination));
291
- }).then(function () {
192
+ debug(`finished downloading file: ${downloadDestination}`);
193
+ }).then(() => {
292
194
  // save the download destination for unzipping
293
- util.setTaskTitle(_task, util.titleize(chalk.green('Downloaded Cypress')), rendererOptions.renderer);
195
+ util.setTaskTitle(task, util.titleize(chalk.green('Downloaded Cypress')), rendererOptions.renderer);
294
196
  });
295
197
  }
296
198
  }, unzipTask({
297
- progress: progress,
199
+ progress,
298
200
  zipFilePath: downloadDestination,
299
- installDir: installDir,
300
- rendererOptions: rendererOptions
201
+ installDir,
202
+ rendererOptions
301
203
  }), {
302
204
  title: util.titleize('Finishing Installation'),
303
- task: function task(ctx, _task2) {
304
- var cleanup = function cleanup() {
205
+ task: (ctx, task) => {
206
+ const cleanup = () => {
305
207
  debug('removing zip file %s', downloadDestination);
306
208
  return fs.removeAsync(downloadDestination);
307
209
  };
308
210
 
309
- return cleanup().then(function () {
211
+ return cleanup().then(() => {
310
212
  debug('finished installation in', installDir);
311
- util.setTaskTitle(_task2, util.titleize(chalk.green('Finished Installation'), chalk.gray(installDir)), rendererOptions.renderer);
213
+ util.setTaskTitle(task, util.titleize(chalk.green('Finished Installation'), chalk.gray(installDir)), rendererOptions.renderer);
312
214
  });
313
215
  }
314
216
  }], rendererOptions); // start the tasks!
@@ -316,9 +218,7 @@ var downloadAndUnzip = function downloadAndUnzip(_ref) {
316
218
  return Promise.resolve(tasks.run());
317
219
  };
318
220
 
319
- var start = function start() {
320
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
321
-
221
+ const start = (options = {}) => {
322
222
  // handle deprecated / removed
323
223
  if (util.getEnv('CYPRESS_BINARY_VERSION')) {
324
224
  return throwFormErrorText(errors.removed.CYPRESS_BINARY_VERSION)();
@@ -334,21 +234,22 @@ var start = function start() {
334
234
  force: false
335
235
  });
336
236
 
337
- var pkgVersion = util.pkgVersion();
338
- var needVersion = pkgVersion;
339
- var binaryUrlOverride;
237
+ const pkgVersion = util.pkgVersion();
238
+ let needVersion = pkgVersion;
239
+ let binaryUrlOverride;
340
240
  debug('version in package.json is', needVersion); // let this environment variable reset the binary version we need
341
241
 
342
242
  if (util.getEnv('CYPRESS_INSTALL_BINARY')) {
343
243
  // because passed file paths are often double quoted
344
244
  // and might have extra whitespace around, be robust and trim the string
345
- var trimAndRemoveDoubleQuotes = true;
346
- var envVarVersion = util.getEnv('CYPRESS_INSTALL_BINARY', trimAndRemoveDoubleQuotes);
245
+ const trimAndRemoveDoubleQuotes = true;
246
+ const envVarVersion = util.getEnv('CYPRESS_INSTALL_BINARY', trimAndRemoveDoubleQuotes);
347
247
  debug('using environment variable CYPRESS_INSTALL_BINARY "%s"', envVarVersion);
348
248
 
349
249
  if (envVarVersion === '0') {
350
250
  debug('environment variable CYPRESS_INSTALL_BINARY = 0, skipping install');
351
- logger.log(stripIndent(_templateObject3(), chalk.yellow('Note:')));
251
+ logger.log(stripIndent`
252
+ ${chalk.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`);
352
253
  logger.log();
353
254
  return Promise.resolve();
354
255
  }
@@ -357,32 +258,36 @@ var start = function start() {
357
258
  }
358
259
 
359
260
  if (util.getEnv('CYPRESS_CACHE_FOLDER')) {
360
- var envCache = util.getEnv('CYPRESS_CACHE_FOLDER');
361
- logger.log(stripIndent(_templateObject4(), chalk.yellow('Note:'), chalk.cyan(envCache)));
261
+ const envCache = util.getEnv('CYPRESS_CACHE_FOLDER');
262
+ logger.log(stripIndent`
263
+ ${chalk.yellow('Note:')} Overriding Cypress cache directory to: ${chalk.cyan(envCache)}
264
+
265
+ Previous installs of Cypress may not be found.
266
+ `);
362
267
  logger.log();
363
268
  }
364
269
 
365
- var installDir = state.getVersionDir(pkgVersion);
366
- var cacheDir = state.getCacheDir();
367
- var binaryDir = state.getBinaryDir(pkgVersion);
368
- return fs.ensureDirAsync(cacheDir)["catch"]({
270
+ const installDir = state.getVersionDir(pkgVersion);
271
+ const cacheDir = state.getCacheDir();
272
+ const binaryDir = state.getBinaryDir(pkgVersion);
273
+ return fs.ensureDirAsync(cacheDir).catch({
369
274
  code: 'EACCES'
370
- }, function (err) {
371
- return throwFormErrorText(errors.invalidCacheDirectory)(stripIndent(_templateObject5(), chalk.cyan(cacheDir), err.message));
372
- }).then(function () {
373
- return Promise.all([state.getBinaryPkgVersionAsync(binaryDir), getVersionSpecifier()]);
374
- }).then(function (_ref2) {
375
- var _ref3 = _slicedToArray(_ref2, 2),
376
- binaryVersion = _ref3[0],
377
- versionSpecifier = _ref3[1];
275
+ }, err => {
276
+ return throwFormErrorText(errors.invalidCacheDirectory)(stripIndent`
277
+ Failed to access ${chalk.cyan(cacheDir)}:
378
278
 
279
+ ${err.message}
280
+ `);
281
+ }).then(() => {
282
+ return Promise.all([state.getBinaryPkgVersionAsync(binaryDir), getVersionSpecifier()]);
283
+ }).then(([binaryVersion, versionSpecifier]) => {
379
284
  if (!binaryUrlOverride && versionSpecifier) {
380
- var computedBinaryUrl = getBinaryUrlFromPrereleaseNpmUrl(versionSpecifier);
285
+ const computedBinaryUrl = getBinaryUrlFromPrereleaseNpmUrl(versionSpecifier);
381
286
 
382
287
  if (computedBinaryUrl) {
383
288
  debug('computed binary url from version specifier %o', {
384
- computedBinaryUrl: computedBinaryUrl,
385
- needVersion: needVersion
289
+ computedBinaryUrl,
290
+ needVersion
386
291
  });
387
292
  binaryUrlOverride = computedBinaryUrl;
388
293
  }
@@ -397,7 +302,9 @@ var start = function start() {
397
302
  }
398
303
 
399
304
  logger.log();
400
- logger.log(stripIndent(_templateObject6(), chalk.green(binaryVersion), chalk.cyan(installDir)));
305
+ logger.log(stripIndent`
306
+ Cypress ${chalk.green(binaryVersion)} is installed in ${chalk.cyan(installDir)}
307
+ `);
401
308
  logger.log();
402
309
 
403
310
  if (options.force) {
@@ -412,7 +319,7 @@ var start = function start() {
412
319
  }
413
320
 
414
321
  return true;
415
- }).then(function (shouldInstall) {
322
+ }).then(shouldInstall => {
416
323
  // noop if we've been told not to download
417
324
  if (!shouldInstall) {
418
325
  debug('Not downloading or installing binary');
@@ -420,19 +327,27 @@ var start = function start() {
420
327
  }
421
328
 
422
329
  if (needVersion !== pkgVersion) {
423
- logger.log(chalk.yellow(stripIndent(_templateObject7(), logSymbols.warning, chalk.green(pkgVersion), chalk.green(needVersion))));
330
+ logger.log(chalk.yellow(stripIndent`
331
+ ${logSymbols.warning} Warning: Forcing a binary version different than the default.
332
+
333
+ The CLI expected to install version: ${chalk.green(pkgVersion)}
334
+
335
+ Instead we will install version: ${chalk.green(needVersion)}
336
+
337
+ These versions may not work properly together.
338
+ `));
424
339
  logger.log();
425
340
  } // see if version supplied is a path to a binary
426
341
 
427
342
 
428
- return fs.pathExistsAsync(needVersion).then(function (exists) {
343
+ return fs.pathExistsAsync(needVersion).then(exists => {
429
344
  if (exists) {
430
345
  return path.extname(needVersion) === '.zip' ? needVersion : false;
431
346
  }
432
347
 
433
- var possibleFile = util.formAbsolutePath(needVersion);
348
+ const possibleFile = util.formAbsolutePath(needVersion);
434
349
  debug('checking local file', possibleFile, 'cwd', process.cwd());
435
- return fs.pathExistsAsync(possibleFile).then(function (exists) {
350
+ return fs.pathExistsAsync(possibleFile).then(exists => {
436
351
  // if this exists return the path to it
437
352
  // else false
438
353
  if (exists && path.extname(possibleFile) === '.zip') {
@@ -441,20 +356,20 @@ var start = function start() {
441
356
 
442
357
  return false;
443
358
  });
444
- }).then(function (pathToLocalFile) {
359
+ }).then(pathToLocalFile => {
445
360
  if (pathToLocalFile) {
446
- var absolutePath = path.resolve(needVersion);
361
+ const absolutePath = path.resolve(needVersion);
447
362
  debug('found local file at', absolutePath);
448
363
  debug('skipping download');
449
- var rendererOptions = getRendererOptions();
364
+ const rendererOptions = getRendererOptions();
450
365
  return new Listr([unzipTask({
451
366
  progress: {
452
367
  throttle: 100,
453
368
  onProgress: null
454
369
  },
455
370
  zipFilePath: absolutePath,
456
- installDir: installDir,
457
- rendererOptions: rendererOptions
371
+ installDir,
372
+ rendererOptions
458
373
  })], rendererOptions).run();
459
374
  }
460
375
 
@@ -464,52 +379,53 @@ var start = function start() {
464
379
  }
465
380
 
466
381
  debug('preparing to download and unzip version ', needVersion, 'to path', installDir);
467
- var downloadDir = os.tmpdir();
382
+ const downloadDir = os.tmpdir();
468
383
  return downloadAndUnzip({
469
384
  version: needVersion,
470
- installDir: installDir,
471
- downloadDir: downloadDir
385
+ installDir,
386
+ downloadDir
472
387
  });
473
388
  }) // delay 1 sec for UX, unless we are testing
474
- .then(function () {
389
+ .then(() => {
475
390
  return Promise.delay(1000);
476
391
  }).then(displayCompletionMsg);
477
392
  });
478
393
  };
479
394
 
480
395
  module.exports = {
481
- start: start,
396
+ start,
482
397
  _getVersionSpecifier: getVersionSpecifier,
483
398
  _getBinaryUrlFromPrereleaseNpmUrl: getBinaryUrlFromPrereleaseNpmUrl
484
399
  };
485
400
 
486
- var unzipTask = function unzipTask(_ref4) {
487
- var zipFilePath = _ref4.zipFilePath,
488
- installDir = _ref4.installDir,
489
- progress = _ref4.progress,
490
- rendererOptions = _ref4.rendererOptions;
401
+ const unzipTask = ({
402
+ zipFilePath,
403
+ installDir,
404
+ progress,
405
+ rendererOptions
406
+ }) => {
491
407
  return {
492
408
  title: util.titleize('Unzipping Cypress'),
493
- task: function task(ctx, _task3) {
409
+ task: (ctx, task) => {
494
410
  // as our unzip progresses indicate the status
495
- progress.onProgress = progessify(_task3, 'Unzipping Cypress');
411
+ progress.onProgress = progessify(task, 'Unzipping Cypress');
496
412
  return unzip.start({
497
- zipFilePath: zipFilePath,
498
- installDir: installDir,
499
- progress: progress
500
- }).then(function () {
501
- util.setTaskTitle(_task3, util.titleize(chalk.green('Unzipped Cypress')), rendererOptions.renderer);
413
+ zipFilePath,
414
+ installDir,
415
+ progress
416
+ }).then(() => {
417
+ util.setTaskTitle(task, util.titleize(chalk.green('Unzipped Cypress')), rendererOptions.renderer);
502
418
  });
503
419
  }
504
420
  };
505
421
  };
506
422
 
507
- var progessify = function progessify(task, title) {
423
+ const progessify = (task, title) => {
508
424
  // return higher order function
509
- return function (percentComplete, remaining) {
510
- percentComplete = chalk.white(" ".concat(percentComplete, "%")); // pluralize seconds remaining
425
+ return (percentComplete, remaining) => {
426
+ percentComplete = chalk.white(` ${percentComplete}%`); // pluralize seconds remaining
511
427
 
512
- remaining = chalk.gray("".concat(remaining, "s"));
428
+ remaining = chalk.gray(`${remaining}s`);
513
429
  util.setTaskTitle(task, util.titleize(title, percentComplete, remaining), getRendererOptions().renderer);
514
430
  };
515
431
  }; // if we are running in CI then use
@@ -517,14 +433,14 @@ var progessify = function progessify(task, title) {
517
433
  // the default
518
434
 
519
435
 
520
- var getRendererOptions = function getRendererOptions() {
521
- var renderer = util.isCi() ? verbose : 'default';
436
+ const getRendererOptions = () => {
437
+ let renderer = util.isCi() ? verbose : 'default';
522
438
 
523
439
  if (logger.logLevel() === 'silent') {
524
440
  renderer = 'silent';
525
441
  }
526
442
 
527
443
  return {
528
- renderer: renderer
444
+ renderer
529
445
  };
530
446
  };