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.
- package/index.js +6 -6
- package/lib/cli.js +119 -107
- package/lib/cypress.js +21 -21
- package/lib/errors.js +233 -276
- package/lib/exec/info.js +29 -32
- package/lib/exec/open.js +7 -8
- package/lib/exec/run.js +20 -20
- package/lib/exec/spawn.js +53 -49
- package/lib/exec/versions.js +18 -17
- package/lib/exec/xvfb.js +43 -37
- package/lib/fs.js +1 -1
- package/lib/logger.js +24 -50
- package/lib/tasks/cache.js +96 -36
- package/lib/tasks/download.js +113 -133
- package/lib/tasks/get-folder-size.js +41 -0
- package/lib/tasks/install.js +165 -249
- package/lib/tasks/state.js +54 -56
- package/lib/tasks/unzip.js +72 -69
- package/lib/tasks/verify.js +112 -147
- package/lib/util.js +172 -176
- package/package.json +4 -4
- package/types/cypress-npm-api.d.ts +13 -5
- package/types/cypress.d.ts +15 -15
- package/types/mocha/index.d.ts +123 -308
- package/types/net-stubbing.ts +132 -21
package/lib/tasks/install.js
CHANGED
@@ -1,152 +1,48 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
3
|
+
const _ = require('lodash');
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
9
|
+
const path = require('path');
|
114
10
|
|
115
|
-
|
11
|
+
const chalk = require('chalk');
|
116
12
|
|
117
|
-
|
13
|
+
const debug = require('debug')('cypress:cli');
|
118
14
|
|
119
|
-
|
15
|
+
const Listr = require('listr');
|
120
16
|
|
121
|
-
|
17
|
+
const verbose = require('@cypress/listr-verbose-renderer');
|
122
18
|
|
123
|
-
|
19
|
+
const Promise = require('bluebird');
|
124
20
|
|
125
|
-
|
21
|
+
const logSymbols = require('log-symbols');
|
126
22
|
|
127
|
-
|
23
|
+
const {
|
24
|
+
stripIndent
|
25
|
+
} = require('common-tags');
|
128
26
|
|
129
|
-
|
130
|
-
stripIndent = _require.stripIndent;
|
27
|
+
const fs = require('../fs');
|
131
28
|
|
132
|
-
|
29
|
+
const download = require('./download');
|
133
30
|
|
134
|
-
|
31
|
+
const util = require('../util');
|
135
32
|
|
136
|
-
|
33
|
+
const state = require('./state');
|
137
34
|
|
138
|
-
|
35
|
+
const unzip = require('./unzip');
|
139
36
|
|
140
|
-
|
37
|
+
const logger = require('../logger');
|
141
38
|
|
142
|
-
|
39
|
+
const {
|
40
|
+
throwFormErrorText,
|
41
|
+
errors
|
42
|
+
} = require('../errors');
|
143
43
|
|
144
|
-
|
145
|
-
|
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
|
-
|
167
|
-
|
168
|
-
var argv = getNpmArgv();
|
62
|
+
const getVersionSpecifier = (startDir = path.resolve(__dirname, '../..')) => {
|
63
|
+
const argv = getNpmArgv();
|
169
64
|
|
170
65
|
if (argv) {
|
171
|
-
|
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
|
-
|
73
|
+
const getVersionSpecifierFromPkg = dir => {
|
181
74
|
debug('looking for versionSpecifier %o', {
|
182
|
-
dir
|
75
|
+
dir
|
183
76
|
});
|
184
77
|
|
185
|
-
|
186
|
-
|
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'))
|
197
|
-
|
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(
|
97
|
+
return getVersionSpecifierFromPkg(startDir).then(versionSpecifier => {
|
209
98
|
debug('finished looking for versionSpecifier', {
|
210
|
-
versionSpecifier
|
99
|
+
versionSpecifier
|
211
100
|
});
|
212
101
|
return versionSpecifier;
|
213
102
|
});
|
214
103
|
};
|
215
104
|
|
216
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
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
|
-
|
130
|
+
const alreadyInstalledMsg = () => {
|
245
131
|
if (!util.isPostInstall()) {
|
246
|
-
logger.log(stripIndent
|
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
|
-
|
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
|
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
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
167
|
+
const downloadAndUnzip = ({
|
168
|
+
version,
|
169
|
+
installDir,
|
170
|
+
downloadDir
|
171
|
+
}) => {
|
172
|
+
const progress = {
|
271
173
|
throttle: 100,
|
272
174
|
onProgress: null
|
273
175
|
};
|
274
|
-
|
275
|
-
|
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(
|
179
|
+
logger.log(`Installing Cypress ${chalk.gray(`(version: ${version})`)}`);
|
278
180
|
logger.log();
|
279
|
-
|
181
|
+
const tasks = new Listr([{
|
280
182
|
title: util.titleize('Downloading Cypress'),
|
281
|
-
task:
|
183
|
+
task: (ctx, task) => {
|
282
184
|
// as our download progresses indicate the status
|
283
|
-
progress.onProgress = progessify(
|
185
|
+
progress.onProgress = progessify(task, 'Downloading Cypress');
|
284
186
|
return download.start({
|
285
|
-
version
|
286
|
-
downloadDestination
|
287
|
-
progress
|
288
|
-
}).then(
|
187
|
+
version,
|
188
|
+
downloadDestination,
|
189
|
+
progress
|
190
|
+
}).then(redirectVersion => {
|
289
191
|
if (redirectVersion) version = redirectVersion;
|
290
|
-
debug(
|
291
|
-
}).then(
|
192
|
+
debug(`finished downloading file: ${downloadDestination}`);
|
193
|
+
}).then(() => {
|
292
194
|
// save the download destination for unzipping
|
293
|
-
util.setTaskTitle(
|
195
|
+
util.setTaskTitle(task, util.titleize(chalk.green('Downloaded Cypress')), rendererOptions.renderer);
|
294
196
|
});
|
295
197
|
}
|
296
198
|
}, unzipTask({
|
297
|
-
progress
|
199
|
+
progress,
|
298
200
|
zipFilePath: downloadDestination,
|
299
|
-
installDir
|
300
|
-
rendererOptions
|
201
|
+
installDir,
|
202
|
+
rendererOptions
|
301
203
|
}), {
|
302
204
|
title: util.titleize('Finishing Installation'),
|
303
|
-
task:
|
304
|
-
|
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(
|
211
|
+
return cleanup().then(() => {
|
310
212
|
debug('finished installation in', installDir);
|
311
|
-
util.setTaskTitle(
|
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
|
-
|
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
|
-
|
338
|
-
|
339
|
-
|
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
|
-
|
346
|
-
|
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
|
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
|
-
|
361
|
-
logger.log(stripIndent
|
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
|
-
|
366
|
-
|
367
|
-
|
368
|
-
return fs.ensureDirAsync(cacheDir)
|
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
|
-
},
|
371
|
-
return throwFormErrorText(errors.invalidCacheDirectory)(stripIndent
|
372
|
-
|
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
|
-
|
285
|
+
const computedBinaryUrl = getBinaryUrlFromPrereleaseNpmUrl(versionSpecifier);
|
381
286
|
|
382
287
|
if (computedBinaryUrl) {
|
383
288
|
debug('computed binary url from version specifier %o', {
|
384
|
-
computedBinaryUrl
|
385
|
-
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
|
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(
|
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
|
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(
|
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
|
-
|
348
|
+
const possibleFile = util.formAbsolutePath(needVersion);
|
434
349
|
debug('checking local file', possibleFile, 'cwd', process.cwd());
|
435
|
-
return fs.pathExistsAsync(possibleFile).then(
|
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(
|
359
|
+
}).then(pathToLocalFile => {
|
445
360
|
if (pathToLocalFile) {
|
446
|
-
|
361
|
+
const absolutePath = path.resolve(needVersion);
|
447
362
|
debug('found local file at', absolutePath);
|
448
363
|
debug('skipping download');
|
449
|
-
|
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
|
457
|
-
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
|
-
|
382
|
+
const downloadDir = os.tmpdir();
|
468
383
|
return downloadAndUnzip({
|
469
384
|
version: needVersion,
|
470
|
-
installDir
|
471
|
-
downloadDir
|
385
|
+
installDir,
|
386
|
+
downloadDir
|
472
387
|
});
|
473
388
|
}) // delay 1 sec for UX, unless we are testing
|
474
|
-
.then(
|
389
|
+
.then(() => {
|
475
390
|
return Promise.delay(1000);
|
476
391
|
}).then(displayCompletionMsg);
|
477
392
|
});
|
478
393
|
};
|
479
394
|
|
480
395
|
module.exports = {
|
481
|
-
start
|
396
|
+
start,
|
482
397
|
_getVersionSpecifier: getVersionSpecifier,
|
483
398
|
_getBinaryUrlFromPrereleaseNpmUrl: getBinaryUrlFromPrereleaseNpmUrl
|
484
399
|
};
|
485
400
|
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
401
|
+
const unzipTask = ({
|
402
|
+
zipFilePath,
|
403
|
+
installDir,
|
404
|
+
progress,
|
405
|
+
rendererOptions
|
406
|
+
}) => {
|
491
407
|
return {
|
492
408
|
title: util.titleize('Unzipping Cypress'),
|
493
|
-
task:
|
409
|
+
task: (ctx, task) => {
|
494
410
|
// as our unzip progresses indicate the status
|
495
|
-
progress.onProgress = progessify(
|
411
|
+
progress.onProgress = progessify(task, 'Unzipping Cypress');
|
496
412
|
return unzip.start({
|
497
|
-
zipFilePath
|
498
|
-
installDir
|
499
|
-
progress
|
500
|
-
}).then(
|
501
|
-
util.setTaskTitle(
|
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
|
-
|
423
|
+
const progessify = (task, title) => {
|
508
424
|
// return higher order function
|
509
|
-
return
|
510
|
-
percentComplete = chalk.white(
|
425
|
+
return (percentComplete, remaining) => {
|
426
|
+
percentComplete = chalk.white(` ${percentComplete}%`); // pluralize seconds remaining
|
511
427
|
|
512
|
-
remaining = chalk.gray(
|
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
|
-
|
521
|
-
|
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
|
444
|
+
renderer
|
529
445
|
};
|
530
446
|
};
|