From 913d91a3de1826fc4f0a11fef5c909cb11bd3733 Mon Sep 17 00:00:00 2001 From: tech-sushant Date: Mon, 7 Jul 2025 14:33:43 +0530 Subject: [PATCH] refactor: update BrowserStack SDK setup to use config and improve instruction clarity --- src/tools/sdk-utils/commands.ts | 10 +++++----- src/tools/sdk-utils/constants.ts | 4 ++-- src/tools/sdk-utils/instructions.ts | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tools/sdk-utils/commands.ts b/src/tools/sdk-utils/commands.ts index 6865551..b4ccd7d 100644 --- a/src/tools/sdk-utils/commands.ts +++ b/src/tools/sdk-utils/commands.ts @@ -1,6 +1,6 @@ // Utility to get the language-dependent prefix command for BrowserStack SDK setup import { SDKSupportedLanguage } from "./types.js"; - +import config from "../../config.js"; // Framework mapping for Java Maven archetype generation const JAVA_FRAMEWORK_MAP: Record = { testng: "testng", @@ -36,7 +36,7 @@ npm i -D browserstack-node-sdk@latest ---STEP--- Run the following command to setup browserstack sdk: \`\`\`bash -npx setup --username ${process.env.BROWSERSTACK_USERNAME} --key ${process.env.BROWSERSTACK_ACCESS_KEY} +npx setup --username ${config.browserstackUsername} --key ${config.browserstackAccessKey} \`\`\` ---STEP--- Edit the browserstack.yml file that was created in the project root to add your desired platforms and browsers.`; @@ -46,12 +46,12 @@ Edit the browserstack.yml file that was created in the project root to add your const isWindows = process.platform === "win32"; const mavenCommand = isWindows - ? `mvn archetype:generate -B -DarchetypeGroupId="com.browserstack" -DarchetypeArtifactId="browserstack-sdk-archetype-integrate" -DarchetypeVersion="1.0" -DgroupId="com.browserstack" -DartifactId="browserstack-sdk-archetype-integrate" -Dversion="1.0" -DBROWSERSTACK_USERNAME="${process.env.BROWSERSTACK_USERNAME}" -DBROWSERSTACK_ACCESS_KEY="${process.env.BROWSERSTACK_ACCESS_KEY}" -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"` + ? `mvn archetype:generate -B -DarchetypeGroupId="com.browserstack" -DarchetypeArtifactId="browserstack-sdk-archetype-integrate" -DarchetypeVersion="1.0" -DgroupId="com.browserstack" -DartifactId="browserstack-sdk-archetype-integrate" -Dversion="1.0" -DBROWSERSTACK_USERNAME="${config.browserstackUsername}" -DBROWSERSTACK_ACCESS_KEY="${config.browserstackAccessKey}" -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"` : `mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \\ -DarchetypeArtifactId=browserstack-sdk-archetype-integrate -DarchetypeVersion=1.0 \\ -DgroupId=com.browserstack -DartifactId=browserstack-sdk-archetype-integrate -Dversion=1.0 \\ --DBROWSERSTACK_USERNAME="${process.env.BROWSERSTACK_USERNAME}" \\ --DBROWSERSTACK_ACCESS_KEY="${process.env.BROWSERSTACK_ACCESS_KEY}" \\ +-DBROWSERSTACK_USERNAME="${config.browserstackUsername}" \\ +-DBROWSERSTACK_ACCESS_KEY="${config.browserstackAccessKey}" \\ -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"`; const platformLabel = isWindows ? "Windows" : "macOS/Linux"; diff --git a/src/tools/sdk-utils/constants.ts b/src/tools/sdk-utils/constants.ts index 801eb53..dc74998 100644 --- a/src/tools/sdk-utils/constants.ts +++ b/src/tools/sdk-utils/constants.ts @@ -315,8 +315,8 @@ Here is an example configuration: \`\`\`javascript exports.config = { // Set your BrowserStack credentials - user: process.env.BROWSERSTACK_USERNAME, - key: process.env.BROWSERSTACK_ACCESS_KEY, + user: ${config.browserstackUsername}, + key: ${config.browserstackAccessKey}, // Set BrowserStack hostname hostname: 'hub.browserstack.com', diff --git a/src/tools/sdk-utils/instructions.ts b/src/tools/sdk-utils/instructions.ts index 861a8d9..ecca7db 100644 --- a/src/tools/sdk-utils/instructions.ts +++ b/src/tools/sdk-utils/instructions.ts @@ -46,10 +46,10 @@ export function generateBrowserStackYMLInstructions( # ====================== # BrowserStack Reporting # ====================== -# A single name for your project to organize all your tests. This is required for Percy. -projectName: BrowserStack SDK Tests -# A name for the group of tests you are running -buildName: mcp-run +# Project and build names help organize your test runs in BrowserStack dashboard and Percy. +# TODO: Replace these sample values with your actual project details +projectName: Sample Project +buildName: Sample Build # ======================================= # Platforms (Browsers / Devices to test)