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/unzip.js
CHANGED
@@ -1,200 +1,198 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
const
|
18
|
-
const
|
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 lazy_ass_1 = __importDefault(require("lazy-ass"));
|
17
|
+
const check_more_types_1 = __importDefault(require("check-more-types"));
|
18
|
+
const child_process_1 = __importDefault(require("child_process"));
|
19
|
+
const os_1 = __importDefault(require("os"));
|
20
|
+
const yauzl_1 = __importDefault(require("yauzl"));
|
21
|
+
const debug_1 = __importDefault(require("debug"));
|
22
|
+
const extract_zip_1 = __importDefault(require("extract-zip"));
|
23
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
24
|
+
const readline_1 = __importDefault(require("readline"));
|
25
|
+
const errors_1 = require("../errors");
|
26
|
+
const fs_1 = __importDefault(require("../fs"));
|
27
|
+
const util_1 = __importDefault(require("../util"));
|
28
|
+
const debug = (0, debug_1.default)('cypress:cli:unzip');
|
19
29
|
const unzipTools = {
|
20
|
-
|
30
|
+
extract: extract_zip_1.default,
|
21
31
|
};
|
22
|
-
|
23
32
|
// expose this function for simple testing
|
24
|
-
const unzip = ({
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
33
|
+
const unzip = ({ zipFilePath, installDir, progress }) => {
|
34
|
+
debug('unzipping from %s', zipFilePath);
|
35
|
+
debug('into', installDir);
|
36
|
+
if (!zipFilePath) {
|
37
|
+
throw new Error('Missing zip filename');
|
38
|
+
}
|
39
|
+
const startTime = Date.now();
|
40
|
+
let yauzlDoneTime = 0;
|
41
|
+
return fs_1.default.ensureDirAsync(installDir)
|
42
|
+
.then(() => {
|
43
|
+
return new bluebird_1.default((resolve, reject) => {
|
44
|
+
return yauzl_1.default.open(zipFilePath, (err, zipFile) => {
|
45
|
+
yauzlDoneTime = Date.now();
|
46
|
+
if (err) {
|
47
|
+
debug('error using yauzl %s', err.message);
|
48
|
+
return reject(err);
|
49
|
+
}
|
50
|
+
const total = zipFile.entryCount;
|
51
|
+
debug('zipFile entries count', total);
|
52
|
+
const started = new Date();
|
53
|
+
let percent = 0;
|
54
|
+
let count = 0;
|
55
|
+
const notify = (percent) => {
|
56
|
+
const elapsed = +new Date() - +started;
|
57
|
+
const eta = util_1.default.calculateEta(percent, elapsed);
|
58
|
+
progress.onProgress(percent, util_1.default.secsRemaining(eta));
|
59
|
+
};
|
60
|
+
const tick = () => {
|
61
|
+
count += 1;
|
62
|
+
percent = ((count / total) * 100);
|
63
|
+
const displayPercent = percent.toFixed(0);
|
64
|
+
return notify(Number(displayPercent));
|
65
|
+
};
|
66
|
+
const unzipWithNode = () => {
|
67
|
+
debug('unzipping with node.js (slow)');
|
68
|
+
const opts = {
|
69
|
+
dir: installDir,
|
70
|
+
onEntry: tick,
|
71
|
+
};
|
72
|
+
debug('calling Node extract tool %s %o', zipFilePath, opts);
|
73
|
+
return unzipTools.extract(zipFilePath, opts)
|
74
|
+
.then(() => {
|
75
|
+
debug('node unzip finished');
|
76
|
+
return resolve();
|
77
|
+
})
|
78
|
+
.catch((err) => {
|
79
|
+
const error = err || new Error('Unknown error with Node extract tool');
|
80
|
+
debug('error %s', error.message);
|
81
|
+
return reject(error);
|
82
|
+
});
|
83
|
+
};
|
84
|
+
const unzipFallback = lodash_1.default.once(unzipWithNode);
|
85
|
+
const unzipWithUnzipTool = () => {
|
86
|
+
debug('unzipping via `unzip`');
|
87
|
+
const inflatingRe = /inflating:/;
|
88
|
+
const sp = child_process_1.default.spawn('unzip', ['-o', zipFilePath, '-d', installDir]);
|
89
|
+
sp.on('error', (err) => {
|
90
|
+
debug('unzip tool error: %s', err.message);
|
91
|
+
unzipFallback();
|
92
|
+
});
|
93
|
+
sp.on('close', (code) => {
|
94
|
+
debug('unzip tool close with code %d', code);
|
95
|
+
if (code === 0) {
|
96
|
+
percent = 100;
|
97
|
+
notify(percent);
|
98
|
+
return resolve();
|
99
|
+
}
|
100
|
+
debug('`unzip` failed %o', { code });
|
101
|
+
return unzipFallback();
|
102
|
+
});
|
103
|
+
sp.stdout.on('data', (data) => {
|
104
|
+
if (inflatingRe.test(data)) {
|
105
|
+
return tick();
|
106
|
+
}
|
107
|
+
});
|
108
|
+
sp.stderr.on('data', (data) => {
|
109
|
+
debug('`unzip` stderr %s', data);
|
110
|
+
});
|
111
|
+
};
|
112
|
+
// we attempt to first unzip with the native osx
|
113
|
+
// ditto because its less likely to have problems
|
114
|
+
// with corruption, symlinks, or icons causing failures
|
115
|
+
// and can handle resource forks
|
116
|
+
// http://automatica.com.au/2011/02/unzip-mac-os-x-zip-in-terminal/
|
117
|
+
const unzipWithOsx = () => {
|
118
|
+
debug('unzipping via `ditto`');
|
119
|
+
const copyingFileRe = /^copying file/;
|
120
|
+
const sp = child_process_1.default.spawn('ditto', ['-xkV', zipFilePath, installDir]);
|
121
|
+
// f-it just unzip with node
|
122
|
+
sp.on('error', (err) => {
|
123
|
+
debug(err.message);
|
124
|
+
unzipFallback();
|
125
|
+
});
|
126
|
+
sp.on('close', (code) => {
|
127
|
+
if (code === 0) {
|
128
|
+
// make sure we get to 100% on the progress bar
|
129
|
+
// because reading in lines is not really accurate
|
130
|
+
percent = 100;
|
131
|
+
notify(percent);
|
132
|
+
return resolve();
|
133
|
+
}
|
134
|
+
debug('`ditto` failed %o', { code });
|
135
|
+
return unzipFallback();
|
136
|
+
});
|
137
|
+
return readline_1.default.createInterface({
|
138
|
+
input: sp.stderr,
|
139
|
+
})
|
140
|
+
.on('line', (line) => {
|
141
|
+
if (copyingFileRe.test(line)) {
|
142
|
+
return tick();
|
143
|
+
}
|
144
|
+
});
|
145
|
+
};
|
146
|
+
switch (os_1.default.platform()) {
|
147
|
+
case 'darwin':
|
148
|
+
return unzipWithOsx();
|
149
|
+
case 'linux':
|
150
|
+
return unzipWithUnzipTool();
|
151
|
+
case 'win32':
|
152
|
+
return unzipWithNode();
|
153
|
+
default:
|
154
|
+
return;
|
155
|
+
}
|
94
156
|
});
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
});
|
102
|
-
sp.stderr.on('data', data => {
|
103
|
-
debug('`unzip` stderr %s', data);
|
104
|
-
});
|
105
|
-
};
|
106
|
-
|
107
|
-
// we attempt to first unzip with the native osx
|
108
|
-
// ditto because its less likely to have problems
|
109
|
-
// with corruption, symlinks, or icons causing failures
|
110
|
-
// and can handle resource forks
|
111
|
-
// http://automatica.com.au/2011/02/unzip-mac-os-x-zip-in-terminal/
|
112
|
-
const unzipWithOsx = () => {
|
113
|
-
debug('unzipping via `ditto`');
|
114
|
-
const copyingFileRe = /^copying file/;
|
115
|
-
const sp = cp.spawn('ditto', ['-xkV', zipFilePath, installDir]);
|
116
|
-
|
117
|
-
// f-it just unzip with node
|
118
|
-
sp.on('error', err => {
|
119
|
-
debug(err.message);
|
120
|
-
unzipFallback();
|
121
|
-
});
|
122
|
-
sp.on('close', code => {
|
123
|
-
if (code === 0) {
|
124
|
-
// make sure we get to 100% on the progress bar
|
125
|
-
// because reading in lines is not really accurate
|
126
|
-
percent = 100;
|
127
|
-
notify(percent);
|
128
|
-
return resolve();
|
129
|
-
}
|
130
|
-
debug('`ditto` failed %o', {
|
131
|
-
code
|
157
|
+
})
|
158
|
+
.tap(() => {
|
159
|
+
debug('unzip completed %o', {
|
160
|
+
yauzlMs: yauzlDoneTime - startTime,
|
161
|
+
unzipMs: Date.now() - yauzlDoneTime,
|
132
162
|
});
|
133
|
-
|
134
|
-
});
|
135
|
-
return readline.createInterface({
|
136
|
-
input: sp.stderr
|
137
|
-
}).on('line', line => {
|
138
|
-
if (copyingFileRe.test(line)) {
|
139
|
-
return tick();
|
140
|
-
}
|
141
|
-
});
|
142
|
-
};
|
143
|
-
switch (os.platform()) {
|
144
|
-
case 'darwin':
|
145
|
-
return unzipWithOsx();
|
146
|
-
case 'linux':
|
147
|
-
return unzipWithUnzipTool();
|
148
|
-
case 'win32':
|
149
|
-
return unzipWithNode();
|
150
|
-
default:
|
151
|
-
return;
|
152
|
-
}
|
153
|
-
});
|
154
|
-
}).tap(() => {
|
155
|
-
debug('unzip completed %o', {
|
156
|
-
yauzlMs: yauzlDoneTime - startTime,
|
157
|
-
unzipMs: Date.now() - yauzlDoneTime
|
158
|
-
});
|
163
|
+
});
|
159
164
|
});
|
160
|
-
});
|
161
165
|
};
|
162
166
|
function isMaybeWindowsMaxPathLengthError(err) {
|
163
|
-
|
167
|
+
return os_1.default.platform() === 'win32' && err.code === 'ENOENT' && err.syscall === 'realpath';
|
164
168
|
}
|
165
|
-
const start =
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
if (!progress) {
|
172
|
-
progress = {
|
173
|
-
onProgress: () => {
|
174
|
-
return {};
|
175
|
-
}
|
176
|
-
};
|
177
|
-
}
|
178
|
-
try {
|
179
|
-
const installDirExists = await fs.pathExists(installDir);
|
180
|
-
if (installDirExists) {
|
181
|
-
debug('removing existing unzipped binary', installDir);
|
182
|
-
await fs.removeAsync(installDir);
|
169
|
+
const start = (_a) => __awaiter(void 0, [_a], void 0, function* ({ zipFilePath, installDir, progress }) {
|
170
|
+
(0, lazy_ass_1.default)(check_more_types_1.default.unemptyString(installDir), 'missing installDir');
|
171
|
+
if (!progress) {
|
172
|
+
progress = { onProgress: () => {
|
173
|
+
return {};
|
174
|
+
} };
|
183
175
|
}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
176
|
+
try {
|
177
|
+
const installDirExists = yield fs_1.default.pathExists(installDir);
|
178
|
+
if (installDirExists) {
|
179
|
+
debug('removing existing unzipped binary', installDir);
|
180
|
+
yield fs_1.default.removeAsync(installDir);
|
181
|
+
}
|
182
|
+
yield unzip({ zipFilePath, installDir, progress });
|
183
|
+
}
|
184
|
+
catch (err) {
|
185
|
+
const errorTemplate = isMaybeWindowsMaxPathLengthError(err) ?
|
186
|
+
errors_1.errors.failedUnzipWindowsMaxPathLength
|
187
|
+
: errors_1.errors.failedUnzip;
|
188
|
+
yield (0, errors_1.throwFormErrorText)(errorTemplate)(err);
|
189
|
+
}
|
190
|
+
});
|
191
|
+
const unzipModule = {
|
192
|
+
start,
|
193
|
+
utils: {
|
194
|
+
unzip,
|
195
|
+
unzipTools,
|
196
|
+
},
|
193
197
|
};
|
194
|
-
|
195
|
-
start,
|
196
|
-
utils: {
|
197
|
-
unzip,
|
198
|
-
unzipTools
|
199
|
-
}
|
200
|
-
};
|
198
|
+
exports.default = unzipModule;
|