cypress 15.1.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.
@@ -1,134 +1,125 @@
1
1
  "use strict";
2
-
3
- const _ = require('lodash');
4
- const os = require('os');
5
- const path = require('path');
6
- const untildify = require('untildify');
7
- const debug = require('debug')('cypress:cli');
8
- const fs = require('../fs');
9
- const util = require('../util');
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
- const platform = os.platform();
12
- switch (platform) {
13
- case 'darwin':
14
- return 'Contents/MacOS/Cypress';
15
- case 'linux':
16
- return 'Cypress';
17
- case 'win32':
18
- return 'Cypress.exe';
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
- const platform = os.platform();
26
- switch (platform) {
27
- case 'darwin':
28
- return 'Cypress.app';
29
- case 'linux':
30
- return 'Cypress';
31
- case 'win32':
32
- return 'Cypress';
33
- // TODO handle this error using our standard
34
- default:
35
- throw new Error(`Platform: "${platform}" is not supported.`);
36
- }
37
- };
38
- const getBinaryPkgPath = binaryDir => {
39
- const platform = os.platform();
40
- switch (platform) {
41
- case 'darwin':
42
- return path.join(binaryDir, 'Contents', 'Resources', 'app', 'package.json');
43
- case 'linux':
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 = util.pkgVersion()) => {
57
- return path.join(getVersionDir(version), getPlatFormBinaryFolder());
47
+ const getBinaryDir = (version = util_1.default.pkgVersion()) => {
48
+ return path_1.default.join(getVersionDir(version), getPlatFormBinaryFolder());
58
49
  };
59
- const getVersionDir = (version = util.pkgVersion(), buildInfo = util.pkgBuildInfo()) => {
60
- if (buildInfo && !buildInfo.stable) {
61
- version = ['beta', version, buildInfo.commitBranch, buildInfo.commitSha.slice(0, 8)].join('-');
62
- }
63
- return path.join(getCacheDir(), version);
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
- // individual folders
72
- const cwdFolders = process.cwd().split(path.sep);
73
- const length = cwdFolders.length;
74
- return cwdFolders[length - 2] === 'node_modules' && cwdFolders[length - 1] === 'cypress';
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
- let cache_directory = util.getCacheDir();
78
- if (util.getEnv('CYPRESS_CACHE_FOLDER')) {
79
- const envVarCacheDir = untildify(util.getEnv('CYPRESS_CACHE_FOLDER'));
80
- debug('using environment variable CYPRESS_CACHE_FOLDER %s', envVarCacheDir);
81
- if (!path.isAbsolute(envVarCacheDir) && isInstallingFromPostinstallHook()) {
82
- const packageRootFolder = path.join('..', '..', envVarCacheDir);
83
- cache_directory = path.resolve(packageRootFolder);
84
- debug('installing from postinstall hook, original root folder is %s', packageRootFolder);
85
- debug('and resolved cache directory is %s', cache_directory);
86
- } else {
87
- cache_directory = path.resolve(envVarCacheDir);
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
- if (os.platform() === 'darwin') {
99
- return path.resolve(realPath, '..', '..', '..');
100
- }
101
- return path.resolve(realPath, '..');
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
- return path.join(__dirname, '..', '..', 'dist');
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
- return path.join(binaryDir, '..', 'binary_state.json');
115
- };
116
- const getBinaryStateContentsAsync = binaryDir => {
117
- const fullPath = getBinaryStatePath(binaryDir);
118
- return fs.readJsonAsync(fullPath).catch({
119
- code: 'ENOENT'
120
- }, SyntaxError, () => {
121
- debug('could not read binary_state.json file at "%s"', fullPath);
122
- return {};
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
- return getBinaryStateContentsAsync(binaryDir).tap(debug).get('verified');
115
+ const getBinaryVerifiedAsync = (binaryDir) => {
116
+ return getBinaryStateContentsAsync(binaryDir)
117
+ .tap(debug)
118
+ .get('verified');
127
119
  };
128
- const clearBinaryStateAsync = binaryDir => {
129
- return fs.removeAsync(getBinaryStatePath(binaryDir));
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
- return getBinaryStateContentsAsync(binaryDir).then(contents => {
140
- return fs.outputJsonAsync(getBinaryStatePath(binaryDir), _.extend(contents, {
141
- verified
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
- return path.join(binaryDir, getPlatformExecutable());
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
- const pathToPackageJson = getBinaryPkgPath(binaryDir);
157
- debug('Reading binary package.json from:', pathToPackageJson);
158
- return fs.pathExistsAsync(pathToPackageJson).then(exists => {
159
- if (!exists) {
160
- return null;
161
- }
162
- return fs.readJsonAsync(pathToPackageJson);
163
- });
164
- };
165
- const getBinaryPkgVersion = o => _.get(o, 'version', null);
166
- const getBinaryElectronVersion = o => _.get(o, 'electronVersion', null);
167
- const getBinaryElectronNodeVersion = o => _.get(o, 'electronNodeVersion', null);
168
- module.exports = {
169
- getPathToExecutable,
170
- getPlatformExecutable,
171
- // those names start to sound like Java
172
- getBinaryElectronNodeVersion,
173
- getBinaryElectronVersion,
174
- getBinaryPkgVersion,
175
- getBinaryVerifiedAsync,
176
- getBinaryPkgAsync,
177
- getBinaryPkgPath,
178
- getBinaryDir,
179
- getCacheDir,
180
- clearBinaryStateAsync,
181
- writeBinaryVerifiedAsync,
182
- parseRealPlatformBinaryFolderAsync,
183
- getDistDir,
184
- getVersionDir
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;