Skip to content

Commit

Permalink
Merge branch 'master' of https:/browserstack/browserstack…
Browse files Browse the repository at this point in the history
…-cypress-cli into build_artifacts_logging
  • Loading branch information
asambstack committed Oct 8, 2024
2 parents 6a6bb55 + a2cbd75 commit bfdfd52
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 5 deletions.
5 changes: 5 additions & 0 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ module.exports = function run(args, rawArgs) {
}
let message = `${data.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${data.build_id}`;
let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${data.dashboard_url}`;
if (turboScaleSession) {
dashboardLink = `${Constants.userMessages.VISIT_ATS_DASHBOARD} ${data.dashboard_url}`;
}
buildReportData = { 'build_id': data.build_id, 'parallels': userSpecifiedParallels, ...buildReportData }
utils.exportResults(data.build_id, `${config.dashboardUrl}${data.build_id}`);
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)) {
Expand Down Expand Up @@ -388,6 +391,8 @@ module.exports = function run(args, rawArgs) {
logger.info(Constants.userMessages.BUILD_FAILED_ERROR)
process.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
});
} else {
utils.handleSyncExit(exitCode, data.dashboard_url);
}
});
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads && !turboScaleSession)) {
Expand Down
25 changes: 23 additions & 2 deletions bin/helpers/archiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,30 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
});
}

// Split mac and win configs
let macPackageJSON = {};
let winPackageJSON = {};
Object.assign(macPackageJSON, packageJSON);
Object.assign(winPackageJSON, packageJSON);

if (typeof runSettings.npm_dependencies === 'object') {
let macNpmDependencies = Object.assign({}, runSettings.npm_dependencies, runSettings.mac_npm_dependencies || {});
let winNpmDependencies = Object.assign({}, runSettings.npm_dependencies, runSettings.win_npm_dependencies || {});

Object.assign(macPackageJSON, {
devDependencies: macNpmDependencies,
});

Object.assign(winPackageJSON, {
devDependencies: winNpmDependencies,
});
}

if (Object.keys(packageJSON).length > 0) {
let packageJSONString = JSON.stringify(packageJSON, null, 4);
archive.append(packageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-package.json`});
const macPackageJSONString = JSON.stringify(macPackageJSON, null, 4);
const winPackageJSONString = JSON.stringify(winPackageJSON, null, 4);
archive.append(macPackageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-mac-package.json`});
archive.append(winPackageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-win-package.json`});
}

//Create copy of package.json
Expand Down
3 changes: 2 additions & 1 deletion bin/helpers/checkUploaded.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const request = require('request');
const { combineMacWinNpmDependencies } = require('./helper');

const crypto = require('crypto'),
Constants = require('./constants'),
Expand Down Expand Up @@ -59,7 +60,7 @@ const checkPackageMd5 = (runSettings) => {

if (typeof runSettings.npm_dependencies === 'object') {
Object.assign(packageJSON, {
devDependencies: utils.sortJsonKeys(runSettings.npm_dependencies),
devDependencies: utils.sortJsonKeys(combineMacWinNpmDependencies(runSettings)),
});
}

Expand Down
5 changes: 5 additions & 0 deletions bin/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const userMessages = {
FAILED_MD5_CHECK:
"Something went wrong - you can retry running browserstack-cypress with ‘--force-upload’ parameter, or contact BrowserStack Support.",
VISIT_DASHBOARD: "Visit the Automate dashboard for real-time test reporting:",
VISIT_ATS_DASHBOARD: "Visit the Automate TurboScale dashboard for real-time test reporting:",
CONFLICTING_INIT_ARGUMENTS:
"Conflicting arguments given. You can use --path only with a file name, and not with a file path.",
NO_PARALLELS:
Expand Down Expand Up @@ -343,7 +344,11 @@ const filesToIgnoreWhileUploading = [
"package.json",
"**/package.json",
"browserstack-package.json",
"browserstack-mac-package.json",
"browserstack-win-package.json",
"**/browserstack-package.json",
"**/browserstack-mac-package.json",
"**/browserstack-win-package.json",
"tests.zip",
"**/tests.zip",
"cypress.json",
Expand Down
4 changes: 4 additions & 0 deletions bin/helpers/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,7 @@ exports.truncateString = (field, truncateSizeInBytes) => {

return field;
};

exports.combineMacWinNpmDependencies = (runSettings) => {
return Object.assign({}, runSettings.npm_dependencies, runSettings.win_npm_dependencies || {}, runSettings.mac_npm_dependencies || {})
};
5 changes: 4 additions & 1 deletion bin/helpers/packageInstaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
cliUtils = require("./utils"),
util = require('util');

const { combineMacWinNpmDependencies } = require("./helper");

let nodeProcess;

const setupPackageFolder = (runSettings, directoryPath) => {
Expand All @@ -29,9 +31,10 @@ const setupPackageFolder = (runSettings, directoryPath) => {
Object.assign(packageJSON, runSettings.package_config_options);
}

// Combine win and mac specific dependencies if present
if (typeof runSettings.npm_dependencies === 'object') {
Object.assign(packageJSON, {
devDependencies: runSettings.npm_dependencies,
devDependencies: combineMacWinNpmDependencies(runSettings),
});
}

Expand Down
10 changes: 10 additions & 0 deletions bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ exports.setDefaults = (bsConfig, args) => {
bsConfig.run_settings.npm_dependencies = {}
}

// setting win_npm_dependencies to {} if not present
if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.win_npm_dependencies)) {
bsConfig.run_settings.win_npm_dependencies = {}
}

// setting mac_npm_dependencies to {} if not present
if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.mac_npm_dependencies)) {
bsConfig.run_settings.mac_npm_dependencies = {}
}

// setting connection_settings to {} if not present
if (this.isUndefined(bsConfig.connection_settings)) {
bsConfig.connection_settings = {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browserstack-cypress-cli",
"version": "1.31.6",
"version": "1.31.8",
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit bfdfd52

Please sign in to comment.