Skip to content

refactor: update SDK setup to use config and improve instructions #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/tools/sdk-utils/commands.ts
Original file line number Diff line number Diff line change
@@ -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<string, string> = {
testng: "testng",
Expand Down Expand Up @@ -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.`;
Expand All @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions src/tools/sdk-utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 4 additions & 4 deletions src/tools/sdk-utils/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down