browserstack-cypress-cli 1.33.0 → 1.34.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/.claude/settings.local.json +13 -0
- package/.nyc_output/1c1b6051-514d-4847-bd2a-d03b2d537cfb.json +1 -0
- package/.nyc_output/20afa9bb-5b9f-42e2-adfe-9dbf55591bb8.json +1 -0
- package/.nyc_output/22e511c5-8971-4265-b783-553560573bdc.json +1 -0
- package/.nyc_output/2d21e700-0ac9-4ac9-8f8c-322a5cbefe8d.json +1 -0
- package/.nyc_output/3c54171a-9bf6-478d-a4c0-28ec402806cf.json +1 -0
- package/.nyc_output/52675bfd-ff62-4f5b-944c-e3f48af2972c.json +1 -0
- package/.nyc_output/5766c03a-3d68-4298-89f7-c298c025e176.json +1 -0
- package/.nyc_output/625adc06-9859-4c11-8892-0498922cc2aa.json +1 -0
- package/.nyc_output/730f797e-97d0-44a8-b5d0-7fd3f8c06d75.json +1 -0
- package/.nyc_output/73501809-7c04-439e-8c09-9a1bff7962c6.json +1 -0
- package/.nyc_output/77484870-1b25-4c2d-a361-2ac51c0951bc.json +1 -0
- package/.nyc_output/8098fa2d-312d-4762-ad96-3e9827eaef09.json +1 -0
- package/.nyc_output/87357e21-685f-4861-9a6f-4c6b62f85ac0.json +1 -0
- package/.nyc_output/8fcd9f27-af41-43f7-bdf8-7bea2efd7abb.json +1 -0
- package/.nyc_output/9f8ad8fd-775b-4a99-ba77-c6142e7df5e9.json +1 -0
- package/.nyc_output/a1de1cdd-5eed-409d-a528-1c7cf16d56b5.json +1 -0
- package/.nyc_output/a25237ac-032d-4a27-af09-fb32326b539a.json +1 -0
- package/.nyc_output/a5d38a55-372c-4676-b4bc-c6def0669c0d.json +1 -0
- package/.nyc_output/a67d3cbf-0548-4fcb-8aad-2af60b532670.json +1 -0
- package/.nyc_output/aa2117b0-10c0-4f5b-9d8d-1f96375f0240.json +1 -0
- package/.nyc_output/ac17471f-3f16-45ab-b53e-ba8956afd5d4.json +1 -0
- package/.nyc_output/bbbe672a-8524-4850-b6b3-b725aa2b6c16.json +1 -0
- package/.nyc_output/c7289c09-7047-47cb-9737-f11fe7fc9628.json +1 -0
- package/.nyc_output/ceeeac29-3ca3-40af-b779-12c0408cf05d.json +1 -0
- package/.nyc_output/d08d37a4-6abc-41a7-98bd-de074a1fca7f.json +1 -0
- package/.nyc_output/d1dbecb0-8458-41bc-86c8-9d2470b60415.json +1 -0
- package/.nyc_output/d7245fa2-3732-4790-831b-44dbcba15a16.json +1 -0
- package/.nyc_output/e184572f-281b-4bd6-81e3-58842eac98ee.json +1 -0
- package/.nyc_output/efd98bd9-1699-472b-ab98-0808e5d39899.json +1 -0
- package/.nyc_output/processinfo/1c1b6051-514d-4847-bd2a-d03b2d537cfb.json +1 -0
- package/.nyc_output/processinfo/20afa9bb-5b9f-42e2-adfe-9dbf55591bb8.json +1 -0
- package/.nyc_output/processinfo/22e511c5-8971-4265-b783-553560573bdc.json +1 -0
- package/.nyc_output/processinfo/2d21e700-0ac9-4ac9-8f8c-322a5cbefe8d.json +1 -0
- package/.nyc_output/processinfo/3c54171a-9bf6-478d-a4c0-28ec402806cf.json +1 -0
- package/.nyc_output/processinfo/52675bfd-ff62-4f5b-944c-e3f48af2972c.json +1 -0
- package/.nyc_output/processinfo/5766c03a-3d68-4298-89f7-c298c025e176.json +1 -0
- package/.nyc_output/processinfo/625adc06-9859-4c11-8892-0498922cc2aa.json +1 -0
- package/.nyc_output/processinfo/730f797e-97d0-44a8-b5d0-7fd3f8c06d75.json +1 -0
- package/.nyc_output/processinfo/73501809-7c04-439e-8c09-9a1bff7962c6.json +1 -0
- package/.nyc_output/processinfo/77484870-1b25-4c2d-a361-2ac51c0951bc.json +1 -0
- package/.nyc_output/processinfo/8098fa2d-312d-4762-ad96-3e9827eaef09.json +1 -0
- package/.nyc_output/processinfo/87357e21-685f-4861-9a6f-4c6b62f85ac0.json +1 -0
- package/.nyc_output/processinfo/8fcd9f27-af41-43f7-bdf8-7bea2efd7abb.json +1 -0
- package/.nyc_output/processinfo/9f8ad8fd-775b-4a99-ba77-c6142e7df5e9.json +1 -0
- package/.nyc_output/processinfo/a1de1cdd-5eed-409d-a528-1c7cf16d56b5.json +1 -0
- package/.nyc_output/processinfo/a25237ac-032d-4a27-af09-fb32326b539a.json +1 -0
- package/.nyc_output/processinfo/a5d38a55-372c-4676-b4bc-c6def0669c0d.json +1 -0
- package/.nyc_output/processinfo/a67d3cbf-0548-4fcb-8aad-2af60b532670.json +1 -0
- package/.nyc_output/processinfo/aa2117b0-10c0-4f5b-9d8d-1f96375f0240.json +1 -0
- package/.nyc_output/processinfo/ac17471f-3f16-45ab-b53e-ba8956afd5d4.json +1 -0
- package/.nyc_output/processinfo/bbbe672a-8524-4850-b6b3-b725aa2b6c16.json +1 -0
- package/.nyc_output/processinfo/c7289c09-7047-47cb-9737-f11fe7fc9628.json +1 -0
- package/.nyc_output/processinfo/ceeeac29-3ca3-40af-b779-12c0408cf05d.json +1 -0
- package/.nyc_output/processinfo/d08d37a4-6abc-41a7-98bd-de074a1fca7f.json +1 -0
- package/.nyc_output/processinfo/d1dbecb0-8458-41bc-86c8-9d2470b60415.json +1 -0
- package/.nyc_output/processinfo/d7245fa2-3732-4790-831b-44dbcba15a16.json +1 -0
- package/.nyc_output/processinfo/e184572f-281b-4bd6-81e3-58842eac98ee.json +1 -0
- package/.nyc_output/processinfo/efd98bd9-1699-472b-ab98-0808e5d39899.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/bin/accessibility-automation/helper.js +1 -1
- package/bin/commands/runs.js +3 -0
- package/bin/helpers/build.js +2 -0
- package/bin/helpers/capabilityHelper.js +7 -1
- package/bin/helpers/constants.js +22 -0
- package/bin/helpers/packageInstaller.js +3 -2
- package/bin/helpers/readCypressConfigUtil.js +133 -11
- package/bin/helpers/utils.js +209 -0
- package/bin/templates/configTemplate.js +2 -0
- package/bin/testObservability/helper/helper.js +1 -1
- package/log/usage.log +393 -0
- package/package.json +6 -5
package/bin/helpers/utils.js
CHANGED
|
@@ -1812,6 +1812,215 @@ exports.decodeJWTToken = (token) => {
|
|
|
1812
1812
|
}
|
|
1813
1813
|
}
|
|
1814
1814
|
|
|
1815
|
+
exports.validateAutoImportConflict = (runSettings) => {
|
|
1816
|
+
const constants = require('./constants');
|
|
1817
|
+
|
|
1818
|
+
// Validate auto_import_dev_dependencies type
|
|
1819
|
+
if (runSettings.auto_import_dev_dependencies !== undefined &&
|
|
1820
|
+
typeof runSettings.auto_import_dev_dependencies !== 'boolean') {
|
|
1821
|
+
throw new Error(constants.validationMessages.AUTO_IMPORT_INVALID_TYPE);
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
// Skip validation if auto_import_dev_dependencies is not enabled
|
|
1825
|
+
if (!runSettings.auto_import_dev_dependencies) {
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
// Check if any manual npm dependency configurations have values
|
|
1830
|
+
const hasNpmDeps = runSettings.npm_dependencies &&
|
|
1831
|
+
typeof runSettings.npm_dependencies === 'object' &&
|
|
1832
|
+
Object.keys(runSettings.npm_dependencies).length > 0;
|
|
1833
|
+
|
|
1834
|
+
const hasWinDeps = runSettings.win_npm_dependencies &&
|
|
1835
|
+
typeof runSettings.win_npm_dependencies === 'object' &&
|
|
1836
|
+
Object.keys(runSettings.win_npm_dependencies).length > 0;
|
|
1837
|
+
|
|
1838
|
+
const hasMacDeps = runSettings.mac_npm_dependencies &&
|
|
1839
|
+
typeof runSettings.mac_npm_dependencies === 'object' &&
|
|
1840
|
+
Object.keys(runSettings.mac_npm_dependencies).length > 0;
|
|
1841
|
+
|
|
1842
|
+
if (hasNpmDeps || hasWinDeps || hasMacDeps) {
|
|
1843
|
+
throw new Error(constants.validationMessages.AUTO_IMPORT_CONFLICT_ERROR);
|
|
1844
|
+
}
|
|
1845
|
+
};
|
|
1846
|
+
|
|
1847
|
+
exports.readPackageJsonDevDependencies = (projectDir) => {
|
|
1848
|
+
const fs = require('fs');
|
|
1849
|
+
const path = require('path');
|
|
1850
|
+
const constants = require('./constants');
|
|
1851
|
+
|
|
1852
|
+
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
1853
|
+
|
|
1854
|
+
try {
|
|
1855
|
+
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');
|
|
1856
|
+
|
|
1857
|
+
// Remove BOM if present
|
|
1858
|
+
const cleanedContent = packageJsonContent.replace(/^\ufeff/, '');
|
|
1859
|
+
|
|
1860
|
+
if (!cleanedContent.trim()) {
|
|
1861
|
+
throw new Error(constants.validationMessages.PACKAGE_JSON_MALFORMED);
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
let packageJson;
|
|
1865
|
+
try {
|
|
1866
|
+
packageJson = JSON.parse(cleanedContent);
|
|
1867
|
+
} catch (parseError) {
|
|
1868
|
+
throw new Error(constants.validationMessages.PACKAGE_JSON_MALFORMED);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
if (typeof packageJson !== 'object' || packageJson === null || Array.isArray(packageJson)) {
|
|
1872
|
+
throw new Error(constants.validationMessages.PACKAGE_JSON_NOT_OBJECT);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// Handle missing devDependencies field
|
|
1876
|
+
if (packageJson.devDependencies === undefined) {
|
|
1877
|
+
return {};
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// Validate devDependencies format
|
|
1881
|
+
if (typeof packageJson.devDependencies !== 'object' ||
|
|
1882
|
+
packageJson.devDependencies === null ||
|
|
1883
|
+
Array.isArray(packageJson.devDependencies)) {
|
|
1884
|
+
throw new Error(constants.validationMessages.DEVDEPS_INVALID_FORMAT);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
return packageJson.devDependencies;
|
|
1888
|
+
|
|
1889
|
+
} catch (error) {
|
|
1890
|
+
if (error.code === 'ENOENT') {
|
|
1891
|
+
throw new Error(constants.validationMessages.PACKAGE_JSON_NOT_FOUND);
|
|
1892
|
+
} else if (error.code === 'EACCES') {
|
|
1893
|
+
throw new Error(constants.validationMessages.PACKAGE_JSON_PERMISSION_DENIED);
|
|
1894
|
+
} else if (error.message.includes(constants.validationMessages.PACKAGE_JSON_MALFORMED) ||
|
|
1895
|
+
error.message.includes(constants.validationMessages.PACKAGE_JSON_NOT_OBJECT) ||
|
|
1896
|
+
error.message.includes(constants.validationMessages.DEVDEPS_INVALID_FORMAT)) {
|
|
1897
|
+
throw error;
|
|
1898
|
+
} else {
|
|
1899
|
+
throw new Error(`Cannot read package.json: ${error.message}`);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
|
|
1904
|
+
exports.filterDependenciesWithRegex = (dependencies, excludePatterns) => {
|
|
1905
|
+
const constants = require('./constants');
|
|
1906
|
+
|
|
1907
|
+
// Validate dependencies parameter
|
|
1908
|
+
if (!dependencies || typeof dependencies !== 'object' || Array.isArray(dependencies)) {
|
|
1909
|
+
throw new Error(constants.validationMessages.DEPENDENCIES_PARAM_INVALID);
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
// Return all dependencies if no exclusion patterns
|
|
1913
|
+
if (!excludePatterns) {
|
|
1914
|
+
return dependencies;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
// Validate excludePatterns parameter
|
|
1918
|
+
if (!Array.isArray(excludePatterns)) {
|
|
1919
|
+
throw new Error(constants.validationMessages.EXCLUDE_DEPS_INVALID_TYPE);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
// Validate all patterns are strings
|
|
1923
|
+
for (const pattern of excludePatterns) {
|
|
1924
|
+
if (typeof pattern !== 'string') {
|
|
1925
|
+
throw new Error(constants.validationMessages.EXCLUDE_DEPS_INVALID_PATTERNS);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
// If no patterns, return all dependencies
|
|
1930
|
+
if (excludePatterns.length === 0) {
|
|
1931
|
+
return dependencies;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
const filteredDependencies = {};
|
|
1935
|
+
|
|
1936
|
+
for (const [packageName, version] of Object.entries(dependencies)) {
|
|
1937
|
+
let shouldExclude = false;
|
|
1938
|
+
|
|
1939
|
+
for (const pattern of excludePatterns) {
|
|
1940
|
+
// Skip empty patterns
|
|
1941
|
+
if (!pattern) {
|
|
1942
|
+
continue;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
try {
|
|
1946
|
+
const regex = new RegExp(pattern);
|
|
1947
|
+
if (regex.test(packageName)) {
|
|
1948
|
+
shouldExclude = true;
|
|
1949
|
+
break;
|
|
1950
|
+
}
|
|
1951
|
+
} catch (regexError) {
|
|
1952
|
+
const errorMsg = constants.validationMessages.INVALID_REGEX_PATTERN.replace('{pattern}', pattern);
|
|
1953
|
+
throw new Error(errorMsg);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
if (!shouldExclude) {
|
|
1958
|
+
filteredDependencies[packageName] = version;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
return filteredDependencies;
|
|
1963
|
+
};
|
|
1964
|
+
|
|
1965
|
+
exports.ensureBrowserstackCypressCliDependency = (npmDependencies) => {
|
|
1966
|
+
// Validate npmDependencies parameter
|
|
1967
|
+
if (npmDependencies === undefined || npmDependencies === null ||
|
|
1968
|
+
typeof npmDependencies !== 'object' || Array.isArray(npmDependencies)) {
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
// Check if browserstack-cypress-cli already exists
|
|
1973
|
+
if ("browserstack-cypress-cli" in npmDependencies) {
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
logger.warn("Missing browserstack-cypress-cli not found in npm_dependencies");
|
|
1978
|
+
|
|
1979
|
+
// Get version from package.json (similar to getAgentVersion)
|
|
1980
|
+
let version = "latest";
|
|
1981
|
+
try {
|
|
1982
|
+
const packageJsonPath = path.join(__dirname, '../../package.json');
|
|
1983
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
1984
|
+
version = require(packageJsonPath).version;
|
|
1985
|
+
}
|
|
1986
|
+
} catch (err) {
|
|
1987
|
+
logger.debug("Could not read package.json version, using 'latest'");
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
npmDependencies['browserstack-cypress-cli'] = version;
|
|
1991
|
+
logger.warn(`Adding browserstack-cypress-cli version ${version} in npm_dependencies`);
|
|
1992
|
+
};
|
|
1993
|
+
|
|
1994
|
+
exports.processAutoImportDependencies = (runSettings) => {
|
|
1995
|
+
// Always run validation first
|
|
1996
|
+
exports.validateAutoImportConflict(runSettings);
|
|
1997
|
+
|
|
1998
|
+
// Skip processing if auto_import_dev_dependencies is not enabled
|
|
1999
|
+
if (!runSettings.auto_import_dev_dependencies) {
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
// Determine project directory using battle-tested logic
|
|
2004
|
+
let projectDir;
|
|
2005
|
+
if (runSettings.home_directory) {
|
|
2006
|
+
projectDir = runSettings.home_directory;
|
|
2007
|
+
} else {
|
|
2008
|
+
const path = require('path');
|
|
2009
|
+
projectDir = path.dirname(runSettings.cypressConfigFilePath);
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
// Read devDependencies from package.json
|
|
2013
|
+
const devDependencies = exports.readPackageJsonDevDependencies(projectDir);
|
|
2014
|
+
|
|
2015
|
+
// Apply exclusion filters
|
|
2016
|
+
const filteredDependencies = exports.filterDependenciesWithRegex(devDependencies, runSettings.exclude_dependencies);
|
|
2017
|
+
|
|
2018
|
+
// Set the npm_dependencies in runSettings
|
|
2019
|
+
runSettings.npm_dependencies = filteredDependencies;
|
|
2020
|
+
|
|
2021
|
+
// Ensure browserstack-cypress-cli dependency is present when auto import is enabled
|
|
2022
|
+
exports.ensureBrowserstackCypressCliDependency(runSettings.npm_dependencies);
|
|
2023
|
+
};
|
|
1815
2024
|
exports.normalizeTestReportingEnvVars = () => {
|
|
1816
2025
|
if (!this.isUndefined(process.env.BROWSERSTACK_TEST_REPORTING)){
|
|
1817
2026
|
process.env.BROWSERSTACK_TEST_OBSERVABILITY = process.env.BROWSERSTACK_TEST_REPORTING;
|
|
@@ -418,7 +418,7 @@ exports.launchTestSession = async (user_config, bsConfigPath) => {
|
|
|
418
418
|
exports.debug('Build creation successfull!');
|
|
419
419
|
process.env.BS_TESTOPS_BUILD_COMPLETED = true;
|
|
420
420
|
setEnvironmentVariablesForRemoteReporter(response.data.jwt, response.data.build_hashed_id, response.data.allow_screenshots, data.observability_version.sdkVersion);
|
|
421
|
-
if(this.isBrowserstackInfra()) helper.setBrowserstackCypressCliDependency(user_config);
|
|
421
|
+
if(this.isBrowserstackInfra() && (user_config.run_settings.auto_import_dev_dependencies != true)) helper.setBrowserstackCypressCliDependency(user_config);
|
|
422
422
|
} catch(error) {
|
|
423
423
|
if(!error.errorType) {
|
|
424
424
|
if (error.response) {
|