cypress 15.2.0 → 15.4.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 +1 -1
- package/{lib → dist}/cli.js +221 -190
- package/{lib → dist}/cypress.js +29 -26
- package/{lib → dist}/errors.js +38 -26
- package/{lib → dist}/exec/info.js +2 -2
- package/{lib → dist}/exec/open.js +16 -7
- package/{lib → dist}/exec/run.js +41 -27
- package/dist/exec/spawn.js +311 -0
- package/dist/exec/versions.js +67 -0
- package/{lib → dist}/exec/xvfb.js +47 -20
- package/{index.js → dist/index.js} +5 -5
- package/dist/index.mjs +9 -0
- package/{lib → dist}/tasks/cache.js +49 -52
- package/{lib → dist}/tasks/download.js +55 -64
- package/{lib → dist}/tasks/get-folder-size.js +4 -4
- package/{lib → dist}/tasks/install.js +41 -45
- package/{lib → dist}/tasks/state.js +55 -45
- package/dist/tasks/unzip.js +192 -0
- package/{lib → dist}/tasks/verify.js +121 -131
- package/{lib → dist}/util.js +39 -39
- package/package.json +13 -13
- package/types/cypress-automation.d.ts +2 -1
- package/types/cypress-npm-api.d.ts +4 -0
- package/types/cypress.d.ts +42 -29
- package/index.mjs +0 -17
- package/lib/exec/spawn.js +0 -285
- package/lib/exec/versions.js +0 -61
- package/lib/fs.js +0 -8
- package/lib/tasks/unzip.js +0 -198
- /package/{lib → dist}/VerboseRenderer.js +0 -0
- /package/{lib → dist}/exec/shared.js +0 -0
- /package/{lib → dist}/logger.js +0 -0
package/lib/tasks/unzip.js
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
"use strict";
|
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');
|
29
|
-
const unzipTools = {
|
30
|
-
extract: extract_zip_1.default,
|
31
|
-
};
|
32
|
-
// expose this function for simple testing
|
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
|
-
}
|
156
|
-
});
|
157
|
-
})
|
158
|
-
.tap(() => {
|
159
|
-
debug('unzip completed %o', {
|
160
|
-
yauzlMs: yauzlDoneTime - startTime,
|
161
|
-
unzipMs: Date.now() - yauzlDoneTime,
|
162
|
-
});
|
163
|
-
});
|
164
|
-
});
|
165
|
-
};
|
166
|
-
function isMaybeWindowsMaxPathLengthError(err) {
|
167
|
-
return os_1.default.platform() === 'win32' && err.code === 'ENOENT' && err.syscall === 'realpath';
|
168
|
-
}
|
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
|
-
} };
|
175
|
-
}
|
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
|
-
},
|
197
|
-
};
|
198
|
-
exports.default = unzipModule;
|
File without changes
|
File without changes
|
/package/{lib → dist}/logger.js
RENAMED
File without changes
|