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/state.js
CHANGED
@@ -1,134 +1,125 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
const
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const lodash_1 = __importDefault(require("lodash"));
|
7
|
+
const os_1 = __importDefault(require("os"));
|
8
|
+
const path_1 = __importDefault(require("path"));
|
9
|
+
const untildify_1 = __importDefault(require("untildify"));
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
11
|
+
const fs_1 = __importDefault(require("../fs"));
|
12
|
+
const util_1 = __importDefault(require("../util"));
|
13
|
+
const debug = (0, debug_1.default)('cypress:cli');
|
10
14
|
const getPlatformExecutable = () => {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
// TODO handle this error using our standard
|
20
|
-
default:
|
21
|
-
throw new Error(`Platform: "${platform}" is not supported.`);
|
22
|
-
}
|
15
|
+
const platform = os_1.default.platform();
|
16
|
+
switch (platform) {
|
17
|
+
case 'darwin': return 'Contents/MacOS/Cypress';
|
18
|
+
case 'linux': return 'Cypress';
|
19
|
+
case 'win32': return 'Cypress.exe';
|
20
|
+
// TODO handle this error using our standard
|
21
|
+
default: throw new Error(`Platform: "${platform}" is not supported.`);
|
22
|
+
}
|
23
23
|
};
|
24
24
|
const getPlatFormBinaryFolder = () => {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
return path.join(binaryDir, 'resources', 'app', 'package.json');
|
45
|
-
case 'win32':
|
46
|
-
return path.join(binaryDir, 'resources', 'app', 'package.json');
|
47
|
-
// TODO handle this error using our standard
|
48
|
-
default:
|
49
|
-
throw new Error(`Platform: "${platform}" is not supported.`);
|
50
|
-
}
|
51
|
-
};
|
52
|
-
|
25
|
+
const platform = os_1.default.platform();
|
26
|
+
switch (platform) {
|
27
|
+
case 'darwin': return 'Cypress.app';
|
28
|
+
case 'linux': return 'Cypress';
|
29
|
+
case 'win32': return 'Cypress';
|
30
|
+
// TODO handle this error using our standard
|
31
|
+
default: throw new Error(`Platform: "${platform}" is not supported.`);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
const getBinaryPkgPath = (binaryDir) => {
|
35
|
+
const platform = os_1.default.platform();
|
36
|
+
switch (platform) {
|
37
|
+
case 'darwin': return path_1.default.join(binaryDir, 'Contents', 'Resources', 'app', 'package.json');
|
38
|
+
case 'linux': return path_1.default.join(binaryDir, 'resources', 'app', 'package.json');
|
39
|
+
case 'win32': return path_1.default.join(binaryDir, 'resources', 'app', 'package.json');
|
40
|
+
// TODO handle this error using our standard
|
41
|
+
default: throw new Error(`Platform: "${platform}" is not supported.`);
|
42
|
+
}
|
43
|
+
};
|
53
44
|
/**
|
54
45
|
* Get path to binary directory
|
55
46
|
*/
|
56
|
-
const getBinaryDir = (version =
|
57
|
-
|
47
|
+
const getBinaryDir = (version = util_1.default.pkgVersion()) => {
|
48
|
+
return path_1.default.join(getVersionDir(version), getPlatFormBinaryFolder());
|
58
49
|
};
|
59
|
-
const getVersionDir = (version =
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
50
|
+
const getVersionDir = (version = util_1.default.pkgVersion(), buildInfo = util_1.default.pkgBuildInfo()) => {
|
51
|
+
if (buildInfo && !buildInfo.stable) {
|
52
|
+
version = ['beta', version, buildInfo.commitBranch, buildInfo.commitSha.slice(0, 8)].join('-');
|
53
|
+
}
|
54
|
+
return path_1.default.join(getCacheDir(), version);
|
64
55
|
};
|
65
|
-
|
66
56
|
/**
|
67
57
|
* When executing "npm postinstall" hook, the working directory is set to
|
68
58
|
* "<current folder>/node_modules/cypress", which can be surprising when using relative paths.
|
69
59
|
*/
|
70
60
|
const isInstallingFromPostinstallHook = () => {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
61
|
+
// individual folders
|
62
|
+
const cwdFolders = process.cwd().split(path_1.default.sep);
|
63
|
+
const length = cwdFolders.length;
|
64
|
+
return cwdFolders[length - 2] === 'node_modules' && cwdFolders[length - 1] === 'cypress';
|
75
65
|
};
|
76
66
|
const getCacheDir = () => {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
return cache_directory;
|
91
|
-
};
|
92
|
-
const parseRealPlatformBinaryFolderAsync = binaryPath => {
|
93
|
-
return fs.realpathAsync(binaryPath).then(realPath => {
|
94
|
-
debug('CYPRESS_RUN_BINARY has realpath:', realPath);
|
95
|
-
if (!realPath.toString().endsWith(getPlatformExecutable())) {
|
96
|
-
return false;
|
67
|
+
let cache_directory = util_1.default.getCacheDir();
|
68
|
+
if (util_1.default.getEnv('CYPRESS_CACHE_FOLDER')) {
|
69
|
+
const envVarCacheDir = (0, untildify_1.default)(util_1.default.getEnv('CYPRESS_CACHE_FOLDER'));
|
70
|
+
debug('using environment variable CYPRESS_CACHE_FOLDER %s', envVarCacheDir);
|
71
|
+
if (!path_1.default.isAbsolute(envVarCacheDir) && isInstallingFromPostinstallHook()) {
|
72
|
+
const packageRootFolder = path_1.default.join('..', '..', envVarCacheDir);
|
73
|
+
cache_directory = path_1.default.resolve(packageRootFolder);
|
74
|
+
debug('installing from postinstall hook, original root folder is %s', packageRootFolder);
|
75
|
+
debug('and resolved cache directory is %s', cache_directory);
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
cache_directory = path_1.default.resolve(envVarCacheDir);
|
79
|
+
}
|
97
80
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
return
|
102
|
-
|
81
|
+
return cache_directory;
|
82
|
+
};
|
83
|
+
const parseRealPlatformBinaryFolderAsync = (binaryPath) => {
|
84
|
+
return fs_1.default.realpathAsync(binaryPath)
|
85
|
+
.then((realPath) => {
|
86
|
+
debug('CYPRESS_RUN_BINARY has realpath:', realPath);
|
87
|
+
if (!realPath.toString().endsWith(getPlatformExecutable())) {
|
88
|
+
return false;
|
89
|
+
}
|
90
|
+
if (os_1.default.platform() === 'darwin') {
|
91
|
+
return path_1.default.resolve(realPath, '..', '..', '..');
|
92
|
+
}
|
93
|
+
return path_1.default.resolve(realPath, '..');
|
94
|
+
});
|
103
95
|
};
|
104
96
|
const getDistDir = () => {
|
105
|
-
|
97
|
+
return path_1.default.join(__dirname, '..', '..', 'dist');
|
106
98
|
};
|
107
|
-
|
108
99
|
/**
|
109
100
|
* Returns full filename to the file that keeps the Test Runner verification state as JSON text.
|
110
101
|
* Note: the binary state file will be stored one level up from the given binary folder.
|
111
102
|
* @param {string} binaryDir - full path to the folder holding the binary.
|
112
103
|
*/
|
113
|
-
const getBinaryStatePath = binaryDir => {
|
114
|
-
|
115
|
-
};
|
116
|
-
const getBinaryStateContentsAsync = binaryDir => {
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
});
|
104
|
+
const getBinaryStatePath = (binaryDir) => {
|
105
|
+
return path_1.default.join(binaryDir, '..', 'binary_state.json');
|
106
|
+
};
|
107
|
+
const getBinaryStateContentsAsync = (binaryDir) => {
|
108
|
+
const fullPath = getBinaryStatePath(binaryDir);
|
109
|
+
return fs_1.default.readJsonAsync(fullPath)
|
110
|
+
.catch({ code: 'ENOENT' }, SyntaxError, () => {
|
111
|
+
debug('could not read binary_state.json file at "%s"', fullPath);
|
112
|
+
return {};
|
113
|
+
});
|
124
114
|
};
|
125
|
-
const getBinaryVerifiedAsync = binaryDir => {
|
126
|
-
|
115
|
+
const getBinaryVerifiedAsync = (binaryDir) => {
|
116
|
+
return getBinaryStateContentsAsync(binaryDir)
|
117
|
+
.tap(debug)
|
118
|
+
.get('verified');
|
127
119
|
};
|
128
|
-
const clearBinaryStateAsync = binaryDir => {
|
129
|
-
|
120
|
+
const clearBinaryStateAsync = (binaryDir) => {
|
121
|
+
return fs_1.default.removeAsync(getBinaryStatePath(binaryDir));
|
130
122
|
};
|
131
|
-
|
132
123
|
/**
|
133
124
|
* Writes the new binary status.
|
134
125
|
* @param {boolean} verified The new test runner state after smoke test
|
@@ -136,50 +127,48 @@ const clearBinaryStateAsync = binaryDir => {
|
|
136
127
|
* @returns {Promise<void>} returns a promise
|
137
128
|
*/
|
138
129
|
const writeBinaryVerifiedAsync = (verified, binaryDir) => {
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
}), {
|
143
|
-
spaces: 2
|
130
|
+
return getBinaryStateContentsAsync(binaryDir)
|
131
|
+
.then((contents) => {
|
132
|
+
return fs_1.default.outputJsonAsync(getBinaryStatePath(binaryDir), lodash_1.default.extend(contents, { verified }), { spaces: 2 });
|
144
133
|
});
|
145
|
-
});
|
146
134
|
};
|
147
|
-
const getPathToExecutable = binaryDir => {
|
148
|
-
|
135
|
+
const getPathToExecutable = (binaryDir) => {
|
136
|
+
return path_1.default.join(binaryDir, getPlatformExecutable());
|
149
137
|
};
|
150
|
-
|
151
138
|
/**
|
152
139
|
* Resolves with an object read from the binary app package.json file.
|
153
140
|
* If the file does not exist resolves with null
|
154
141
|
*/
|
155
|
-
const getBinaryPkgAsync = binaryDir => {
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
};
|
165
|
-
|
166
|
-
const
|
167
|
-
const
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
142
|
+
const getBinaryPkgAsync = (binaryDir) => {
|
143
|
+
const pathToPackageJson = getBinaryPkgPath(binaryDir);
|
144
|
+
debug('Reading binary package.json from:', pathToPackageJson);
|
145
|
+
return fs_1.default.pathExistsAsync(pathToPackageJson)
|
146
|
+
.then((exists) => {
|
147
|
+
if (!exists) {
|
148
|
+
return null;
|
149
|
+
}
|
150
|
+
return fs_1.default.readJsonAsync(pathToPackageJson);
|
151
|
+
});
|
152
|
+
};
|
153
|
+
const getBinaryPkgVersion = (o) => lodash_1.default.get(o, 'version', null);
|
154
|
+
const getBinaryElectronVersion = (o) => lodash_1.default.get(o, 'electronVersion', null);
|
155
|
+
const getBinaryElectronNodeVersion = (o) => lodash_1.default.get(o, 'electronNodeVersion', null);
|
156
|
+
const stateModule = {
|
157
|
+
getPathToExecutable,
|
158
|
+
getPlatformExecutable,
|
159
|
+
// those names start to sound like Java
|
160
|
+
getBinaryElectronNodeVersion,
|
161
|
+
getBinaryElectronVersion,
|
162
|
+
getBinaryPkgVersion,
|
163
|
+
getBinaryVerifiedAsync,
|
164
|
+
getBinaryPkgAsync,
|
165
|
+
getBinaryPkgPath,
|
166
|
+
getBinaryDir,
|
167
|
+
getCacheDir,
|
168
|
+
clearBinaryStateAsync,
|
169
|
+
writeBinaryVerifiedAsync,
|
170
|
+
parseRealPlatformBinaryFolderAsync,
|
171
|
+
getDistDir,
|
172
|
+
getVersionDir,
|
173
|
+
};
|
174
|
+
exports.default = stateModule;
|