From f074ade6742dc43479dc8b738379b5578be42f42 Mon Sep 17 00:00:00 2001 From: Aditya Samantaray Date: Thu, 18 Jul 2024 20:28:42 +0530 Subject: [PATCH 1/3] chore: add support for reading .npmrc file during NPM package creation --- bin/helpers/packageInstaller.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/helpers/packageInstaller.js b/bin/helpers/packageInstaller.js index 1cdc3ea4..a3f71fbe 100644 --- a/bin/helpers/packageInstaller.js +++ b/bin/helpers/packageInstaller.js @@ -9,6 +9,7 @@ { get_version } = require('./usageReporting'), process = require('process'), { spawn } = require('child_process'), + cliUtils = require("./utils"), util = require('util'); let nodeProcess; @@ -58,7 +59,7 @@ const setupPackageFolder = (runSettings, directoryPath) => { }) }; -const packageInstall = (packageDir) => { +const packageInstall = (packageDir, bsConfig) => { return new Promise(function (resolve, reject) { const nodeProcessCloseCallback = (code) => { if(code == 0) { @@ -74,6 +75,16 @@ const packageInstall = (packageDir) => { reject(`Packages were not installed successfully. Error Description ${util.format('%j', error)}`); }; + // Moving .npmrc to tmpBstackPackages + try { + logger.debug(`Copying .npmrc file to temporary package directory`); + const npmrcRootPath = path.join(cliUtils.isNotUndefined(bsConfig.run_settings.home_directory) ? path.resolve(bsConfig.run_settings.home_directory) : './', '.npmrc'); + const npmrcTmpPath = path.join(path.resolve(packageDir), '.npmrc'); + fs.copyFileSync(npmrcRootPath, npmrcTmpPath); + } catch (error) { + logger.debug(`Failed copying .npmrc to ${packageDir}: ${error}`) + } + let nodeProcess; logger.debug(`Fetching npm version and its major version`); const npm_version = get_version('npm') @@ -147,7 +158,7 @@ const packageSetupAndInstaller = (bsConfig, packageDir, instrumentBlocks) => { instrumentBlocks.markBlockEnd("packageInstaller.folderSetup"); instrumentBlocks.markBlockStart("packageInstaller.packageInstall"); logger.debug("Started installing dependencies specified in browserstack.json"); - return packageInstall(packageDir); + return packageInstall(packageDir, bsConfig); }).then((_result) => { logger.debug("Completed installing dependencies"); instrumentBlocks.markBlockEnd("packageInstaller.packageInstall"); From 13bbe5d19a6c10741d82f5fe50f06d92245d0729 Mon Sep 17 00:00:00 2001 From: Aditya Samantaray Date: Thu, 18 Jul 2024 20:28:42 +0530 Subject: [PATCH 2/3] chore: add support for reading .npmrc file during NPM package creation --- bin/helpers/packageInstaller.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/helpers/packageInstaller.js b/bin/helpers/packageInstaller.js index 1cdc3ea4..a3f71fbe 100644 --- a/bin/helpers/packageInstaller.js +++ b/bin/helpers/packageInstaller.js @@ -9,6 +9,7 @@ { get_version } = require('./usageReporting'), process = require('process'), { spawn } = require('child_process'), + cliUtils = require("./utils"), util = require('util'); let nodeProcess; @@ -58,7 +59,7 @@ const setupPackageFolder = (runSettings, directoryPath) => { }) }; -const packageInstall = (packageDir) => { +const packageInstall = (packageDir, bsConfig) => { return new Promise(function (resolve, reject) { const nodeProcessCloseCallback = (code) => { if(code == 0) { @@ -74,6 +75,16 @@ const packageInstall = (packageDir) => { reject(`Packages were not installed successfully. Error Description ${util.format('%j', error)}`); }; + // Moving .npmrc to tmpBstackPackages + try { + logger.debug(`Copying .npmrc file to temporary package directory`); + const npmrcRootPath = path.join(cliUtils.isNotUndefined(bsConfig.run_settings.home_directory) ? path.resolve(bsConfig.run_settings.home_directory) : './', '.npmrc'); + const npmrcTmpPath = path.join(path.resolve(packageDir), '.npmrc'); + fs.copyFileSync(npmrcRootPath, npmrcTmpPath); + } catch (error) { + logger.debug(`Failed copying .npmrc to ${packageDir}: ${error}`) + } + let nodeProcess; logger.debug(`Fetching npm version and its major version`); const npm_version = get_version('npm') @@ -147,7 +158,7 @@ const packageSetupAndInstaller = (bsConfig, packageDir, instrumentBlocks) => { instrumentBlocks.markBlockEnd("packageInstaller.folderSetup"); instrumentBlocks.markBlockStart("packageInstaller.packageInstall"); logger.debug("Started installing dependencies specified in browserstack.json"); - return packageInstall(packageDir); + return packageInstall(packageDir, bsConfig); }).then((_result) => { logger.debug("Completed installing dependencies"); instrumentBlocks.markBlockEnd("packageInstaller.packageInstall"); From fc3f9061aedec2551b3d8e1e45bbe70847c20c5d Mon Sep 17 00:00:00 2001 From: Pranav Jain Date: Mon, 22 Jul 2024 19:00:29 +0530 Subject: [PATCH 3/3] 1.31.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aaa3d514..c3042ff5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserstack-cypress-cli", - "version": "1.31.2", + "version": "1.31.3", "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.", "main": "index.js", "scripts": {