browserstack-cypress-cli
Advanced tools
Comparing version 1.24.4 to 1.25.0
@@ -187,2 +187,5 @@ 'use strict'; | ||
// set the interactive debugging capability | ||
utils.setInteractiveCapability(bsConfig); | ||
// warn if specFiles cross our limit | ||
@@ -189,0 +192,0 @@ utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs, buildReportData); |
@@ -245,2 +245,19 @@ const fs = require('fs'), | ||
// check if Interactive Capabilities Caps passed is correct or not | ||
if(!Utils.isUndefined(bsConfig.run_settings.interactive_debugging) && !Utils.isUndefined(bsConfig.run_settings.interactiveDebugging)) { | ||
if(Utils.isConflictingBooleanValues(bsConfig.run_settings.interactive_debugging, bsConfig.run_settings.interactiveDebugging)) { | ||
reject(Constants.userMessages.CYPRESS_INTERACTIVE_SESSION_CONFLICT_VALUES); | ||
} else if(Utils.isNonBooleanValue(bsConfig.run_settings.interactive_debugging) && Utils.isNonBooleanValue(bsConfig.run_settings.interactiveDebugging)) { | ||
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).'); | ||
} | ||
} else if(!Utils.isUndefined(bsConfig.run_settings.interactive_debugging)) { | ||
if(Utils.isNonBooleanValue(bsConfig.run_settings.interactive_debugging)) { | ||
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).'); | ||
} | ||
} else if(!Utils.isUndefined(bsConfig.run_settings.interactiveDebugging)) { | ||
if(Utils.isNonBooleanValue(bsConfig.run_settings.interactiveDebugging)) { | ||
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).'); | ||
} | ||
} | ||
// check if two config files are present at the same location | ||
@@ -247,0 +264,0 @@ let cypressFileDirectory = path.dirname(path.resolve(bsConfig.run_settings.cypressConfigFilePath)); |
@@ -120,3 +120,5 @@ let config = require("./config"); | ||
CYPRESS_PORT_WARNING: | ||
"The requested port number <x> is ignored. The default BrowserStack port will be used for this execution" | ||
"The requested port number <x> is ignored. The default BrowserStack port will be used for this execution", | ||
CYPRESS_INTERACTIVE_SESSION_CONFLICT_VALUES: | ||
"Conflicting values (True & False) were found for the interactive_debugging capability. Please resolve this issue to proceed further." | ||
}; | ||
@@ -123,0 +125,0 @@ |
@@ -1003,2 +1003,20 @@ "use strict"; | ||
exports.isConflictingBooleanValues = (value1, value2) => { | ||
return (value1.toString() === "true" && value2.toString() === "false") || (value1.toString() === "false" && value2.toString() === "true") | ||
}; | ||
exports.isNonBooleanValue = (value) => { | ||
return value.toString() !== "true" && value.toString() !== "false"; | ||
}; | ||
exports.setInteractiveCapability = (bsConfig) => { | ||
let interactiveDebuggingTemp = "true"; | ||
let interactive_debugging = bsConfig.run_settings.interactive_debugging; | ||
let interactiveDebugging = bsConfig.run_settings.interactiveDebugging; | ||
if(this.isNotUndefined(interactive_debugging) && !this.isNonBooleanValue(interactive_debugging)) interactiveDebuggingTemp = interactive_debugging; | ||
else if(this.isNotUndefined(interactiveDebugging) && !this.isNonBooleanValue(interactiveDebugging)) interactiveDebuggingTemp = interactiveDebugging; | ||
logger.debug(`Setting interactiveDebugging flag to ${interactiveDebuggingTemp}`); | ||
bsConfig.run_settings.interactiveDebugging = interactiveDebuggingTemp; | ||
} | ||
exports.setNoWrap = (_bsConfig, args) => { | ||
@@ -1005,0 +1023,0 @@ if (args.noWrap === true || this.searchForOption('--no-wrap')) { |
@@ -8,2 +8,3 @@ const fs = require('fs'); | ||
const logger = require("../../helpers/logger").winstonLogger; | ||
const utils = require('../../helpers/utils'); | ||
@@ -51,5 +52,39 @@ const { API_URL, consoleHolder } = require('../helper/constants'); | ||
getPackageVersion = (package_) => { | ||
getPackageVersion = (package_, bsConfig = null) => { | ||
if(packages[package_]) return packages[package_]; | ||
return packages[package_] = this.requireModule(`${package_}/package.json`).version; | ||
let packageVersion; | ||
/* Try to find version from module path */ | ||
try { | ||
packages[package_] = this.requireModule(`${package_}/package.json`).version; | ||
logger.info(`Getting ${package_} package version from module path = ${packages[package_]}`); | ||
packageVersion = packages[package_]; | ||
} catch(e) { | ||
debug(`Unable to find package ${package_} at module path with error ${e}`); | ||
} | ||
/* Read package version from npm_dependencies in browserstack.json file if present */ | ||
if(utils.isUndefined(packageVersion) && bsConfig && (process.env.BROWSERSTACK_AUTOMATION == "true" || process.env.BROWSERSTACK_AUTOMATION == "1")) { | ||
const runSettings = bsConfig.run_settings; | ||
if (runSettings && runSettings.npm_dependencies !== undefined && | ||
Object.keys(runSettings.npm_dependencies).length !== 0 && | ||
typeof runSettings.npm_dependencies === 'object') { | ||
if (package_ in runSettings.npm_dependencies) { | ||
packages[package_] = runSettings.npm_dependencies[package_]; | ||
logger.info(`Getting ${package_} package version from browserstack.json = ${packages[package_]}`); | ||
packageVersion = packages[package_]; | ||
} | ||
} | ||
} | ||
/* Read package version from project's package.json if present */ | ||
const packageJSONPath = path.join(process.cwd(), 'package.json'); | ||
if(utils.isUndefined(packageVersion) && fs.existsSync(packageJSONPath)) { | ||
const packageJSONContents = require(packageJSONPath); | ||
if(packageJSONContents.devDependencies && !utils.isUndefined(packageJSONContents.devDependencies[package_])) packages[package_] = packageJSONContents.devDependencies[package_]; | ||
if(packageJSONContents.dependencies && !utils.isUndefined(packageJSONContents.dependencies[package_])) packages[package_] = packageJSONContents.dependencies[package_]; | ||
logger.info(`Getting ${package_} package version from package.json = ${packages[package_]}`); | ||
packageVersion = packages[package_]; | ||
} | ||
return packageVersion; | ||
} | ||
@@ -101,3 +136,3 @@ | ||
frameworkName: 'Cypress', | ||
frameworkVersion: getPackageVersion('cypress'), | ||
frameworkVersion: getPackageVersion('cypress', this.userConfigForReporting.browserstackConfigFile), | ||
sdkVersion: getAgentVersion() | ||
@@ -104,0 +139,0 @@ }, |
@@ -354,5 +354,39 @@ const fs = require('fs'); | ||
exports.getPackageVersion = (package_) => { | ||
exports.getPackageVersion = (package_, bsConfig = null) => { | ||
if(packages[package_]) return packages[package_]; | ||
return packages[package_] = this.requireModule(`${package_}/package.json`).version; | ||
let packageVersion; | ||
/* Try to find version from module path */ | ||
try { | ||
packages[package_] = this.requireModule(`${package_}/package.json`).version; | ||
logger.info(`Getting ${package_} package version from module path = ${packages[package_]}`); | ||
packageVersion = packages[package_]; | ||
} catch(e) { | ||
exports.debug(`Unable to find package ${package_} at module path with error ${e}`); | ||
} | ||
/* Read package version from npm_dependencies in browserstack.json file if present */ | ||
if(utils.isUndefined(packageVersion) && bsConfig && (process.env.BROWSERSTACK_AUTOMATION == "true" || process.env.BROWSERSTACK_AUTOMATION == "1")) { | ||
const runSettings = bsConfig.run_settings; | ||
if (runSettings && runSettings.npm_dependencies !== undefined && | ||
Object.keys(runSettings.npm_dependencies).length !== 0 && | ||
typeof runSettings.npm_dependencies === 'object') { | ||
if (package_ in runSettings.npm_dependencies) { | ||
packages[package_] = runSettings.npm_dependencies[package_]; | ||
logger.info(`Getting ${package_} package version from browserstack.json = ${packages[package_]}`); | ||
packageVersion = packages[package_]; | ||
} | ||
} | ||
} | ||
/* Read package version from project's package.json if present */ | ||
const packageJSONPath = path.join(process.cwd(), 'package.json'); | ||
if(utils.isUndefined(packageVersion) && fs.existsSync(packageJSONPath)) { | ||
const packageJSONContents = require(packageJSONPath); | ||
if(packageJSONContents.devDependencies && !utils.isUndefined(packageJSONContents.devDependencies[package_])) packages[package_] = packageJSONContents.devDependencies[package_]; | ||
if(packageJSONContents.dependencies && !utils.isUndefined(packageJSONContents.dependencies[package_])) packages[package_] = packageJSONContents.dependencies[package_]; | ||
logger.info(`Getting ${package_} package version from package.json = ${packages[package_]}`); | ||
packageVersion = packages[package_]; | ||
} | ||
return packageVersion; | ||
} | ||
@@ -456,5 +490,10 @@ | ||
const getCypressConfigFileContent = (bsConfig, cypressConfigPath) => { | ||
const cypressConfigFile = require(path.resolve(bsConfig ? bsConfig.run_settings.cypress_config_file : cypressConfigPath)); | ||
if(bsConfig) process.env.OBS_CRASH_REPORTING_CYPRESS_CONFIG_PATH = bsConfig.run_settings.cypress_config_file; | ||
return cypressConfigFile; | ||
try { | ||
const cypressConfigFile = require(path.resolve(bsConfig ? bsConfig.run_settings.cypress_config_file : cypressConfigPath)); | ||
if(bsConfig) process.env.OBS_CRASH_REPORTING_CYPRESS_CONFIG_PATH = bsConfig.run_settings.cypress_config_file; | ||
return cypressConfigFile; | ||
} catch(e) { | ||
exports.debug(`Encountered an error when trying to import Cypress Config File ${e}`); | ||
return {}; | ||
} | ||
} | ||
@@ -535,3 +574,3 @@ | ||
frameworkName: "Cypress", | ||
frameworkVersion: exports.getPackageVersion('cypress'), | ||
frameworkVersion: exports.getPackageVersion('cypress', user_config), | ||
sdkVersion: exports.getAgentVersion() | ||
@@ -538,0 +577,0 @@ } |
{ | ||
"name": "browserstack-cypress-cli", | ||
"version": "1.24.4", | ||
"version": "1.25.0", | ||
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
351182
52
9213
32280
158
1