browserstack-cypress-cli 1.10.1 → 1.12.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/commands/generateDownloads.js +5 -4
- package/bin/commands/generateReport.js +5 -4
- package/bin/commands/info.js +4 -3
- package/bin/commands/init.js +6 -6
- package/bin/commands/runs.js +224 -98
- package/bin/commands/stop.js +5 -65
- package/bin/helpers/archiver.js +16 -6
- package/bin/helpers/buildArtifacts.js +117 -85
- package/bin/helpers/capabilityHelper.js +46 -3
- package/bin/helpers/checkUploaded.js +54 -15
- package/bin/helpers/config.js +2 -0
- package/bin/helpers/constants.js +56 -6
- package/bin/helpers/downloadBuildStacktrace.js +29 -0
- package/bin/helpers/fileHelpers.js +14 -0
- package/bin/helpers/packageInstaller.js +134 -0
- package/bin/helpers/reporterHTML.js +78 -22
- package/bin/helpers/sync/syncSpecsLogs.js +28 -7
- package/bin/helpers/usageReporting.js +30 -2
- package/bin/helpers/utils.js +294 -13
- package/bin/helpers/zipUpload.js +123 -31
- package/bin/runner.js +24 -7
- package/package.json +6 -5
- package/.nyc_output/8250a512-572d-46ce-b8a0-1994c1cafa91.json +0 -1
- package/.nyc_output/c4d99e47-3a09-4e3a-9b8d-5fd3063b36ae.json +0 -1
- package/.nyc_output/processinfo/8250a512-572d-46ce-b8a0-1994c1cafa91.json +0 -1
- package/.nyc_output/processinfo/c4d99e47-3a09-4e3a-9b8d-5fd3063b36ae.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/log/usage.log +0 -16
|
@@ -6,7 +6,7 @@ const logger = require("../helpers/logger").winstonLogger,
|
|
|
6
6
|
downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts;
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
module.exports = async function generateDownloads(args) {
|
|
9
|
+
module.exports = async function generateDownloads(args, rawArgs) {
|
|
10
10
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
11
11
|
|
|
12
12
|
return utils.validateBstackJson(bsConfigPath).then(async function (bsConfig) {
|
|
@@ -28,11 +28,12 @@ module.exports = async function generateDownloads(args) {
|
|
|
28
28
|
let errorCode = null;
|
|
29
29
|
let buildId = args._[1];
|
|
30
30
|
|
|
31
|
-
await downloadBuildArtifacts(bsConfig, buildId, args);
|
|
32
|
-
utils.sendUsageReport(bsConfig, args, Constants.usageReportingConstants.GENERATE_DOWNLOADS, messageType, errorCode);
|
|
31
|
+
await downloadBuildArtifacts(bsConfig, buildId, args, rawArgs);
|
|
32
|
+
utils.sendUsageReport(bsConfig, args, Constants.usageReportingConstants.GENERATE_DOWNLOADS, messageType, errorCode, null, rawArgs);
|
|
33
33
|
}).catch(function (err) {
|
|
34
34
|
logger.error(err);
|
|
35
35
|
utils.setUsageReportingFlag(null, args.disableUsageReporting);
|
|
36
|
-
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
|
|
36
|
+
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
|
|
37
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
37
38
|
});
|
|
38
39
|
};
|
|
@@ -6,7 +6,7 @@ const logger = require("../helpers/logger").winstonLogger,
|
|
|
6
6
|
reporterHTML = require('../helpers/reporterHTML');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
module.exports = function generateReport(args) {
|
|
9
|
+
module.exports = function generateReport(args, rawArgs) {
|
|
10
10
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
11
11
|
let reportGenerator = reporterHTML.reportGenerator;
|
|
12
12
|
|
|
@@ -29,11 +29,12 @@ module.exports = function generateReport(args) {
|
|
|
29
29
|
let errorCode = null;
|
|
30
30
|
let buildId = args._[1];
|
|
31
31
|
|
|
32
|
-
reportGenerator(bsConfig, buildId, args);
|
|
33
|
-
utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode);
|
|
32
|
+
reportGenerator(bsConfig, buildId, args, rawArgs);
|
|
33
|
+
utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode, null, rawArgs);
|
|
34
34
|
}).catch(function (err) {
|
|
35
35
|
logger.error(err);
|
|
36
36
|
utils.setUsageReportingFlag(null, args.disableUsageReporting);
|
|
37
|
-
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
|
|
37
|
+
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
|
|
38
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
38
39
|
});
|
|
39
40
|
};
|
package/bin/commands/info.js
CHANGED
|
@@ -6,7 +6,7 @@ const config = require("../helpers/config"),
|
|
|
6
6
|
Constants = require("../helpers/constants"),
|
|
7
7
|
utils = require("../helpers/utils");
|
|
8
8
|
|
|
9
|
-
module.exports = function info(args) {
|
|
9
|
+
module.exports = function info(args, rawArgs) {
|
|
10
10
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
11
11
|
|
|
12
12
|
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
|
|
@@ -90,11 +90,12 @@ module.exports = function info(args) {
|
|
|
90
90
|
logger.info(message);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode);
|
|
93
|
+
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
|
|
94
94
|
});
|
|
95
95
|
}).catch(function (err) {
|
|
96
96
|
logger.error(err);
|
|
97
97
|
utils.setUsageReportingFlag(null, args.disableUsageReporting);
|
|
98
|
-
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
|
|
98
|
+
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
|
|
99
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
99
100
|
})
|
|
100
101
|
}
|
package/bin/commands/init.js
CHANGED
|
@@ -7,7 +7,7 @@ const fileHelpers = require("../helpers/fileHelpers"),
|
|
|
7
7
|
path = require('path');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
function get_path(args) {
|
|
10
|
+
function get_path(args, rawArgs) {
|
|
11
11
|
if (args._.length > 1 && args.p) {
|
|
12
12
|
let filename = args._[1];
|
|
13
13
|
if (filename !== path.basename(filename)) {
|
|
@@ -15,7 +15,7 @@ function get_path(args) {
|
|
|
15
15
|
logger.error(message);
|
|
16
16
|
// set cypress config filename
|
|
17
17
|
utils.setCypressConfigFilename(args.bstack_config, args);
|
|
18
|
-
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'conflicting_path_json_init');
|
|
18
|
+
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'conflicting_path_json_init', null, rawArgs);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -35,9 +35,9 @@ function get_path(args) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
module.exports = function init(args) {
|
|
38
|
+
module.exports = function init(args, rawArgs) {
|
|
39
39
|
|
|
40
|
-
let path_to_json = get_path(args);
|
|
40
|
+
let path_to_json = get_path(args, rawArgs);
|
|
41
41
|
if (path_to_json === undefined) return;
|
|
42
42
|
|
|
43
43
|
// append .json if filename passed is not of json type
|
|
@@ -57,7 +57,7 @@ module.exports = function init(args) {
|
|
|
57
57
|
if (exists) {
|
|
58
58
|
let message = Constants.userMessages.CONFIG_FILE_EXISTS;
|
|
59
59
|
logger.error(message);
|
|
60
|
-
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'bstack_json_already_exists');
|
|
60
|
+
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'bstack_json_already_exists', null, rawArgs);
|
|
61
61
|
} else {
|
|
62
62
|
fileHelpers.write(config, null, args, utils.configCreated);
|
|
63
63
|
}
|
|
@@ -65,7 +65,7 @@ module.exports = function init(args) {
|
|
|
65
65
|
} else {
|
|
66
66
|
let message = util.format(Constants.userMessages.DIR_NOT_FOUND, path.dirname(config.path));
|
|
67
67
|
logger.error(message);
|
|
68
|
-
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'path_to_init_not_found');
|
|
68
|
+
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'path_to_init_not_found', null, rawArgs);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
}
|
package/bin/commands/runs.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
2
4
|
const archiver = require("../helpers/archiver"),
|
|
3
5
|
zipUploader = require("../helpers/zipUpload"),
|
|
4
6
|
build = require("../helpers/build"),
|
|
@@ -10,11 +12,16 @@ const archiver = require("../helpers/archiver"),
|
|
|
10
12
|
fileHelpers = require("../helpers/fileHelpers"),
|
|
11
13
|
syncRunner = require("../helpers/syncRunner"),
|
|
12
14
|
checkUploaded = require("../helpers/checkUploaded"),
|
|
15
|
+
packageInstaller = require("../helpers/packageInstaller"),
|
|
13
16
|
reportGenerator = require('../helpers/reporterHTML').reportGenerator,
|
|
14
17
|
{initTimeComponents, instrumentEventTime, markBlockStart, markBlockEnd, getTimeComponents} = require('../helpers/timeComponents'),
|
|
15
|
-
downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts
|
|
18
|
+
downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts,
|
|
19
|
+
downloadBuildStacktrace = require('../helpers/downloadBuildStacktrace').downloadBuildStacktrace,
|
|
20
|
+
updateNotifier = require('update-notifier'),
|
|
21
|
+
pkg = require('../../package.json');
|
|
22
|
+
const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
|
|
16
23
|
|
|
17
|
-
module.exports = function run(args) {
|
|
24
|
+
module.exports = function run(args, rawArgs) {
|
|
18
25
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
19
26
|
//Delete build_results.txt from log folder if already present.
|
|
20
27
|
initTimeComponents();
|
|
@@ -43,6 +50,9 @@ module.exports = function run(args) {
|
|
|
43
50
|
// set cypress config filename
|
|
44
51
|
utils.setCypressConfigFilename(bsConfig, args);
|
|
45
52
|
|
|
53
|
+
// set cypress geo location
|
|
54
|
+
utils.setGeolocation(bsConfig, args);
|
|
55
|
+
|
|
46
56
|
// accept the specs list from command line if provided
|
|
47
57
|
utils.setUserSpecs(bsConfig, args);
|
|
48
58
|
|
|
@@ -75,6 +85,10 @@ module.exports = function run(args) {
|
|
|
75
85
|
|
|
76
86
|
//set config (--config)
|
|
77
87
|
utils.setConfig(bsConfig, args);
|
|
88
|
+
|
|
89
|
+
// set sync/async mode (--async/--sync)
|
|
90
|
+
utils.setCLIMode(bsConfig, args);
|
|
91
|
+
|
|
78
92
|
// set other cypress configs e.g. reporter and reporter-options
|
|
79
93
|
utils.setOtherConfigs(bsConfig, args);
|
|
80
94
|
markBlockEnd('setConfig');
|
|
@@ -87,136 +101,226 @@ module.exports = function run(args) {
|
|
|
87
101
|
//get the number of spec files
|
|
88
102
|
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressJson);
|
|
89
103
|
|
|
104
|
+
bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressJson);
|
|
105
|
+
|
|
106
|
+
// return the number of parallels user specified
|
|
107
|
+
let userSpecifiedParallels = utils.getParallels(bsConfig, args);
|
|
108
|
+
|
|
90
109
|
// accept the number of parallels
|
|
91
110
|
utils.setParallels(bsConfig, args, specFiles.length);
|
|
92
111
|
|
|
93
112
|
// warn if specFiles cross our limit
|
|
94
|
-
utils.warnSpecLimit(bsConfig, args, specFiles);
|
|
113
|
+
utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
|
|
95
114
|
markBlockEnd('preArchiveSteps');
|
|
96
115
|
markBlockStart('checkAlreadyUploaded');
|
|
97
116
|
return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
|
|
98
117
|
markBlockEnd('checkAlreadyUploaded');
|
|
99
118
|
|
|
100
|
-
|
|
101
|
-
markBlockStart(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
markBlockStart('
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
119
|
+
markBlockStart('packageInstaller');
|
|
120
|
+
return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
|
|
121
|
+
markBlockEnd('packageInstaller');
|
|
122
|
+
|
|
123
|
+
// Archive the spec files
|
|
124
|
+
markBlockStart('zip');
|
|
125
|
+
markBlockStart('zip.archive');
|
|
126
|
+
return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
|
|
127
|
+
markBlockEnd('zip.archive');
|
|
128
|
+
|
|
129
|
+
let test_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.fileName));
|
|
130
|
+
let npm_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.packageFileName));
|
|
131
|
+
|
|
132
|
+
// Uploaded zip file
|
|
133
|
+
markBlockStart('zip.zipUpload');
|
|
134
|
+
return zipUploader.zipUpload(bsConfig, md5data, packageData).then(async function (zip) {
|
|
135
|
+
markBlockEnd('zip.zipUpload');
|
|
136
|
+
markBlockEnd('zip');
|
|
137
|
+
|
|
138
|
+
// Create build
|
|
139
|
+
//setup Local Testing
|
|
140
|
+
markBlockStart('localSetup');
|
|
141
|
+
let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs);
|
|
142
|
+
markBlockEnd('localSetup');
|
|
143
|
+
markBlockStart('createBuild');
|
|
144
|
+
return build.createBuild(bsConfig, zip).then(function (data) {
|
|
145
|
+
markBlockEnd('createBuild');
|
|
146
|
+
markBlockEnd('total');
|
|
147
|
+
utils.setProcessHooks(data.build_id, bsConfig, bs_local, args);
|
|
148
|
+
let message = `${data.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${data.build_id}`;
|
|
149
|
+
let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${data.dashboard_url}`;
|
|
150
|
+
let buildReportData = {
|
|
151
|
+
'build_id': data.build_id,
|
|
152
|
+
'user_id': data.user_id,
|
|
153
|
+
'parallels': userSpecifiedParallels
|
|
154
|
+
};
|
|
155
|
+
utils.exportResults(data.build_id, `${config.dashboardUrl}${data.build_id}`);
|
|
156
|
+
if ((utils.isUndefined(bsConfig.run_settings.parallels) && utils.isUndefined(args.parallels)) || (!utils.isUndefined(bsConfig.run_settings.parallels) && bsConfig.run_settings.parallels == Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE)) {
|
|
157
|
+
logger.warn(Constants.userMessages.NO_PARALLELS);
|
|
135
158
|
}
|
|
136
|
-
}
|
|
137
159
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
160
|
+
if (bsConfig.run_settings.cypress_version && bsConfig.run_settings.cypress_version !== data.cypress_version) {
|
|
161
|
+
if (bsConfig.run_settings.cypress_version.toString().match(Constants.LATEST_VERSION_SYNTAX_REGEX)) {
|
|
162
|
+
let versionMessage = utils.latestSyntaxToActualVersionMessage(bsConfig.run_settings.cypress_version, data.cypress_version, data.framework_upgrade_message);
|
|
163
|
+
logger.info(versionMessage);
|
|
164
|
+
} else {
|
|
165
|
+
let versionMessage = utils.versionChangedMessage(bsConfig.run_settings.cypress_version, data.cypress_version, data.framework_upgrade_message);
|
|
166
|
+
logger.warn(versionMessage);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
142
169
|
|
|
143
|
-
|
|
144
|
-
|
|
170
|
+
if (!args.disableNpmWarning && bsConfig.run_settings.npm_dependencies && Object.keys(bsConfig.run_settings.npm_dependencies).length <= 0) {
|
|
171
|
+
logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES);
|
|
172
|
+
logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES_READ_MORE);
|
|
173
|
+
}
|
|
145
174
|
|
|
146
|
-
// stop the Local instance
|
|
147
|
-
await utils.stopLocalBinary(bsConfig, bs_local, args);
|
|
148
175
|
|
|
149
|
-
|
|
150
|
-
|
|
176
|
+
if (args.sync) {
|
|
177
|
+
syncRunner.pollBuildStatus(bsConfig, data, rawArgs).then(async (exitCode) => {
|
|
178
|
+
|
|
179
|
+
// stop the Local instance
|
|
180
|
+
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
|
|
181
|
+
|
|
182
|
+
// waiting for 5 secs for upload to complete (as a safety measure)
|
|
183
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
184
|
+
|
|
185
|
+
// download build artifacts
|
|
186
|
+
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
|
|
187
|
+
if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
188
|
+
await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Generate custom report!
|
|
192
|
+
reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
|
|
193
|
+
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
194
|
+
utils.handleSyncExit(exitCode, data.dashboard_url);
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
let stacktraceUrl = getStackTraceUrl();
|
|
198
|
+
downloadBuildStacktrace(stacktraceUrl).then((message) => {
|
|
199
|
+
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
200
|
+
}).catch((err) => {
|
|
201
|
+
let message = `Downloading build stacktrace failed with statuscode: ${err}. Please visit ${data.dashboard_url} for additional details.`;
|
|
202
|
+
logger.error(message);
|
|
203
|
+
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.ERROR, null, buildReportData, rawArgs);
|
|
204
|
+
}).finally(() =>{
|
|
205
|
+
let terminalWidth = (process.stdout.columns) * 0.9;
|
|
206
|
+
let lineSeparator = "\n" + "-".repeat(terminalWidth);
|
|
207
|
+
console.log(lineSeparator)
|
|
208
|
+
logger.info(Constants.userMessages.BUILD_FAILED_ERROR)
|
|
209
|
+
process.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
214
|
+
logger.info(Constants.userMessages.ASYNC_DOWNLOADS.replace('<build-id>', data.build_id));
|
|
215
|
+
}
|
|
151
216
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
217
|
+
logger.info(message);
|
|
218
|
+
logger.info(dashboardLink);
|
|
219
|
+
if(!args.sync) logger.info(Constants.userMessages.EXIT_SYNC_CLI_MESSAGE.replace("<build-id>",data.build_id));
|
|
220
|
+
let dataToSend = {
|
|
221
|
+
time_components: getTimeComponents(),
|
|
222
|
+
unique_id: utils.generateUniqueHash(),
|
|
223
|
+
package_error: utils.checkError(packageData),
|
|
224
|
+
checkmd5_error: utils.checkError(md5data),
|
|
225
|
+
build_id: data.build_id,
|
|
226
|
+
test_zip_size: test_zip_size,
|
|
227
|
+
npm_zip_size: npm_zip_size,
|
|
228
|
+
test_suite_zip_upload: md5data.zipUrlPresent ? 0 : 1,
|
|
229
|
+
package_zip_upload: md5data.packageUrlPresent ? 0 : 1
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
if (!md5data.zipUrlPresent && zip.tests_upload_time) {
|
|
233
|
+
dataToSend.test_suite_zip_size = parseFloat((test_zip_size / 1024).toFixed(2));
|
|
234
|
+
dataToSend.test_suite_zip_upload_avg_speed = parseFloat(((test_zip_size * 1000) / (1024 * zip.tests_upload_time)).toFixed(2));
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
if (!md5data.packageUrlPresent && zip.npm_package_upload_time) {
|
|
238
|
+
dataToSend.npm_package_zip_size = parseFloat((npm_zip_size / 1024).toFixed(2));
|
|
239
|
+
dataToSend.npm_package_zip_upload_avg_speed = parseFloat(((npm_zip_size * 1000) / (1024 * zip.npm_package_upload_time)).toFixed(2));
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
if (zip.tests_upload_time || zip.npm_package_upload_time) {
|
|
243
|
+
dataToSend.time_components.zip.zipUploadSplit = {
|
|
244
|
+
tests_upload_time: zip.tests_upload_time,
|
|
245
|
+
npm_package_upload_time: zip.npm_package_upload_time,
|
|
155
246
|
}
|
|
247
|
+
}
|
|
156
248
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
logger.info(Constants.userMessages.ASYNC_DOWNLOADS.replace('<build-id>', data.build_id));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
logger.info(message);
|
|
168
|
-
logger.info(dashboardLink);
|
|
169
|
-
if(!args.sync) logger.info(Constants.userMessages.EXIT_SYNC_CLI_MESSAGE.replace("<build-id>", data.build_id));
|
|
170
|
-
let dataToSend = {
|
|
171
|
-
time_components: getTimeComponents(),
|
|
172
|
-
unique_id: utils.generateUniqueHash(),
|
|
173
|
-
build_id: data.build_id,
|
|
174
|
-
};
|
|
175
|
-
if (bsConfig && bsConfig.connection_settings) {
|
|
176
|
-
if (bsConfig.connection_settings.local_mode) {
|
|
177
|
-
dataToSend.local_mode = bsConfig.connection_settings.local_mode;
|
|
249
|
+
if (bsConfig && bsConfig.connection_settings) {
|
|
250
|
+
if (bsConfig.connection_settings.local_mode) {
|
|
251
|
+
dataToSend.local_mode = bsConfig.connection_settings.local_mode;
|
|
252
|
+
}
|
|
253
|
+
if (bsConfig.connection_settings.usedAutoLocal) {
|
|
254
|
+
dataToSend.used_auto_local = bsConfig.connection_settings.usedAutoLocal;
|
|
255
|
+
}
|
|
178
256
|
}
|
|
179
|
-
|
|
180
|
-
|
|
257
|
+
buildReportData = { ...buildReportData, ...dataToSend };
|
|
258
|
+
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
259
|
+
return;
|
|
260
|
+
}).catch(async function (err) {
|
|
261
|
+
if (err && err.includes('browserstack.geoLocation')) {
|
|
262
|
+
err = err.replace(/browserstack.geoLocation/g, 'geolocation');
|
|
181
263
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
264
|
+
// Build creation failed
|
|
265
|
+
logger.error(err);
|
|
266
|
+
// stop the Local instance
|
|
267
|
+
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
|
|
268
|
+
|
|
269
|
+
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed', null, rawArgs);
|
|
270
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
271
|
+
});
|
|
272
|
+
}).catch(function (err) {
|
|
273
|
+
// Zip Upload failed | Local Start failed
|
|
187
274
|
logger.error(err);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
275
|
+
if(err === Constants.userMessages.LOCAL_START_FAILED){
|
|
276
|
+
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.LOCAL_START_FAILED}`, Constants.messageTypes.ERROR, 'local_start_failed', null, rawArgs);
|
|
277
|
+
} else {
|
|
278
|
+
logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED);
|
|
279
|
+
fileHelpers.deleteZip();
|
|
280
|
+
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed', null, rawArgs);
|
|
281
|
+
try {
|
|
282
|
+
fileHelpers.deletePackageArchieve();
|
|
283
|
+
} catch (err) {
|
|
284
|
+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
192
288
|
});
|
|
193
289
|
}).catch(function (err) {
|
|
194
|
-
//
|
|
290
|
+
// Zipping failed
|
|
195
291
|
logger.error(err);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED);
|
|
292
|
+
logger.error(Constants.userMessages.FAILED_TO_ZIP);
|
|
293
|
+
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.FAILED_TO_ZIP}`, Constants.messageTypes.ERROR, 'zip_creation_failed', null, rawArgs);
|
|
294
|
+
try {
|
|
200
295
|
fileHelpers.deleteZip();
|
|
201
|
-
|
|
296
|
+
} catch (err) {
|
|
297
|
+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed', null, rawArgs);
|
|
202
298
|
}
|
|
299
|
+
try {
|
|
300
|
+
fileHelpers.deletePackageArchieve();
|
|
301
|
+
} catch (err) {
|
|
302
|
+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
|
|
303
|
+
}
|
|
304
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
203
305
|
});
|
|
204
306
|
}).catch(function (err) {
|
|
205
|
-
//
|
|
307
|
+
// package installer failed
|
|
206
308
|
logger.error(err);
|
|
207
|
-
logger.error(Constants.userMessages.
|
|
208
|
-
utils.sendUsageReport(bsConfig, args,
|
|
309
|
+
logger.error(Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE);
|
|
310
|
+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE, Constants.messageTypes.ERROR, 'npm_package_archive_failed', null, rawArgs);
|
|
209
311
|
try {
|
|
210
|
-
fileHelpers.
|
|
312
|
+
fileHelpers.deletePackageArchieve();
|
|
211
313
|
} catch (err) {
|
|
212
|
-
utils.sendUsageReport(bsConfig, args, Constants.userMessages.
|
|
314
|
+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
|
|
213
315
|
}
|
|
316
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
214
317
|
});
|
|
215
318
|
}).catch(function (err) {
|
|
216
319
|
// md5 check failed
|
|
217
320
|
logger.error(err);
|
|
218
321
|
logger.error(Constants.userMessages.FAILED_MD5_CHECK);
|
|
219
|
-
utils.sendUsageReport(bsConfig, args, Constants.userMessages.MD5_CHECK_FAILED, Constants.messageTypes.ERROR, 'zip_already_uploaded_failed');
|
|
322
|
+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.MD5_CHECK_FAILED, Constants.messageTypes.ERROR, 'zip_already_uploaded_failed', null, rawArgs);
|
|
323
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
220
324
|
});
|
|
221
325
|
}).catch(function (err) {
|
|
222
326
|
// browerstack.json is not valid
|
|
@@ -229,11 +333,33 @@ module.exports = function run(args) {
|
|
|
229
333
|
}
|
|
230
334
|
|
|
231
335
|
let error_code = utils.getErrorCodeFromMsg(err);
|
|
232
|
-
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code);
|
|
336
|
+
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code, null, rawArgs);
|
|
337
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
233
338
|
});
|
|
234
339
|
}).catch(function (err) {
|
|
235
340
|
logger.error(err);
|
|
236
341
|
utils.setUsageReportingFlag(null, args.disableUsageReporting);
|
|
237
|
-
|
|
342
|
+
let bsJsonData = utils.readBsConfigJSON(bsConfigPath);
|
|
343
|
+
utils.sendUsageReport(bsJsonData, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
|
|
344
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
345
|
+
}).finally(function(){
|
|
346
|
+
const notifier = updateNotifier({
|
|
347
|
+
pkg,
|
|
348
|
+
updateCheckInterval: 1000 * 60 * 60 * 24 * 7,
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// Checks for update on first run.
|
|
352
|
+
// Set lastUpdateCheck to 0 to spawn the check update process as notifier sets this to Date.now() for preventing
|
|
353
|
+
// the check untill one interval period. It runs once.
|
|
354
|
+
if (!notifier.disabled && Date.now() - notifier.config.get('lastUpdateCheck') < 50) {
|
|
355
|
+
notifier.config.set('lastUpdateCheck', 0);
|
|
356
|
+
notifier.check();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Set the config update as notifier clears this after reading.
|
|
360
|
+
if (notifier.update && notifier.update.current !== notifier.update.latest) {
|
|
361
|
+
notifier.config.set('update', notifier.update);
|
|
362
|
+
notifier.notify({isGlobal: true});
|
|
363
|
+
}
|
|
238
364
|
});
|
|
239
365
|
}
|
package/bin/commands/stop.js
CHANGED
|
@@ -6,10 +6,10 @@ const config = require("../helpers/config"),
|
|
|
6
6
|
Constants = require("../helpers/constants"),
|
|
7
7
|
utils = require("../helpers/utils");
|
|
8
8
|
|
|
9
|
-
module.exports = function stop(args) {
|
|
9
|
+
module.exports = function stop(args, rawArgs) {
|
|
10
10
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
11
11
|
|
|
12
|
-
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
|
|
12
|
+
return utils.validateBstackJson(bsConfigPath).then(async function (bsConfig) {
|
|
13
13
|
utils.setDefaults(bsConfig, args);
|
|
14
14
|
|
|
15
15
|
// accept the username from command line if provided
|
|
@@ -25,72 +25,12 @@ module.exports = function stop(args) {
|
|
|
25
25
|
|
|
26
26
|
let buildId = args._[1];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
url: config.buildStopUrl + buildId,
|
|
30
|
-
auth: {
|
|
31
|
-
user: bsConfig.auth.username,
|
|
32
|
-
password: bsConfig.auth.access_key,
|
|
33
|
-
},
|
|
34
|
-
headers: {
|
|
35
|
-
'User-Agent': utils.getUserAgent(),
|
|
36
|
-
},
|
|
37
|
-
};
|
|
28
|
+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
|
|
38
29
|
|
|
39
|
-
request.post(options, function (err, resp, body) {
|
|
40
|
-
let message = null;
|
|
41
|
-
let messageType = null;
|
|
42
|
-
let errorCode = null;
|
|
43
|
-
|
|
44
|
-
if (err) {
|
|
45
|
-
message = Constants.userMessages.BUILD_STOP_FAILED;
|
|
46
|
-
messageType = Constants.messageTypes.ERROR;
|
|
47
|
-
errorCode = 'api_failed_build_stop';
|
|
48
|
-
|
|
49
|
-
logger.info(message);
|
|
50
|
-
} else {
|
|
51
|
-
let build = null;
|
|
52
|
-
try {
|
|
53
|
-
build = JSON.parse(body);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
build = null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (resp.statusCode == 299) {
|
|
59
|
-
messageType = Constants.messageTypes.INFO;
|
|
60
|
-
errorCode = 'api_deprecated';
|
|
61
|
-
|
|
62
|
-
if (build) {
|
|
63
|
-
message = build.message;
|
|
64
|
-
logger.info(message);
|
|
65
|
-
} else {
|
|
66
|
-
message = Constants.userMessages.API_DEPRECATED;
|
|
67
|
-
logger.info(message);
|
|
68
|
-
}
|
|
69
|
-
} else if (resp.statusCode != 200) {
|
|
70
|
-
messageType = Constants.messageTypes.ERROR;
|
|
71
|
-
errorCode = 'api_failed_build_stop';
|
|
72
|
-
|
|
73
|
-
if (build) {
|
|
74
|
-
message = `${
|
|
75
|
-
Constants.userMessages.BUILD_STOP_FAILED
|
|
76
|
-
} with error: \n${JSON.stringify(build, null, 2)}`;
|
|
77
|
-
logger.error(message);
|
|
78
|
-
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
|
|
79
|
-
} else {
|
|
80
|
-
message = Constants.userMessages.BUILD_STOP_FAILED;
|
|
81
|
-
logger.error(message);
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
messageType = Constants.messageTypes.SUCCESS;
|
|
85
|
-
message = `${JSON.stringify(build, null, 2)}`;
|
|
86
|
-
logger.info(message);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode);
|
|
90
|
-
});
|
|
91
30
|
}).catch(function (err) {
|
|
92
31
|
logger.error(err);
|
|
93
32
|
utils.setUsageReportingFlag(null, args.disableUsageReporting);
|
|
94
|
-
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
|
|
33
|
+
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
|
|
34
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
95
35
|
})
|
|
96
36
|
}
|