Skip to content

Commit e2796b8

Browse files
committed
refactor: Improve code formatting and structure across multiple files
1 parent e096ad3 commit e2796b8

File tree

5 files changed

+42
-24
lines changed

5 files changed

+42
-24
lines changed

src/tools/appautomate-utils/appium-sdk/handler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import { z } from "zod";
22
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
33
import { BrowserStackConfig } from "../../../lib/types.js";
44
import { getBrowserStackAuth } from "../../../lib/get-auth.js";
5-
import { getAppUploadInstruction, validateSupportforAppAutomate, SupportedFramework } from "./utils.js";
6-
import logger from "../../../logger.js";
5+
import {
6+
getAppUploadInstruction,
7+
validateSupportforAppAutomate,
8+
SupportedFramework,
9+
} from "./utils.js";
710

811
import {
912
getAppSDKPrefixCommand,
@@ -23,7 +26,6 @@ export async function setupAppAutomateHandler(
2326
rawInput: unknown,
2427
config: BrowserStackConfig,
2528
): Promise<CallToolResult> {
26-
2729
const input = z.object(SETUP_APP_AUTOMATE_SCHEMA).parse(rawInput);
2830
const auth = getBrowserStackAuth(config);
2931
const [username, accessKey] = auth.split(":");

src/tools/appautomate-utils/appium-sdk/languages/ruby.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ browser_caps:
2828
"os_version": "9.0"
2929
"app": "<replace with the APK path from the upload step>"
3030
"name": "first_test"
31-
\`\`\``
31+
\`\`\``,
3232
);
3333

3434
const envStep = createStep(
@@ -63,14 +63,14 @@ end
6363
at_exit do
6464
$driver.quit if $driver
6565
end
66-
\`\`\``
66+
\`\`\``,
6767
);
6868

6969
const runStep = createStep(
7070
"Run the test:",
7171
`\`\`\`bash
7272
bundle exec cucumber
73-
\`\`\``
73+
\`\`\``,
7474
);
7575

7676
return combineInstructions(configStep, envStep, runStep);
@@ -79,7 +79,7 @@ bundle exec cucumber
7979
export function getRubySDKCommand(
8080
framework: string,
8181
username: string,
82-
accessKey: string
82+
accessKey: string,
8383
): string {
8484
const { isWindows, getPlatformLabel } = PLATFORM_UTILS;
8585

@@ -88,7 +88,7 @@ export function getRubySDKCommand(
8888
accessKey,
8989
isWindows,
9090
getPlatformLabel(),
91-
"Set your BrowserStack credentials as environment variables:"
91+
"Set your BrowserStack credentials as environment variables:",
9292
);
9393

9494
const installStep = createStep(
@@ -102,7 +102,7 @@ gem install appium_lib
102102
103103
# Install Cucumber
104104
gem install cucumber
105-
\`\`\``
105+
\`\`\``,
106106
);
107107

108108
const gemfileStep = createStep(
@@ -118,7 +118,7 @@ gem 'cucumber'
118118
Then run:
119119
\`\`\`bash
120120
bundle install
121-
\`\`\``
121+
\`\`\``,
122122
);
123123

124124
return combineInstructions(envStep, installStep, gemfileStep);

src/tools/appautomate-utils/appium-sdk/types.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export enum AppSDKSupportedLanguageEnum {
99
export type AppSDKSupportedLanguage = keyof typeof AppSDKSupportedLanguageEnum;
1010

1111
export enum AppSDKSupportedFrameworkEnum {
12-
appium = "appium"
12+
appium = "appium",
1313
}
1414

1515
export type AppSDKSupportedFramework =
@@ -60,7 +60,14 @@ export interface AppSDKInstruction {
6060
export const SUPPORTED_CONFIGURATIONS = {
6161
appium: {
6262
ruby: ["cucumberRuby"],
63-
java: ["junit5", "junit4", "testng", "cucumberTestng", "selenide", "jbehave"],
63+
java: [
64+
"junit5",
65+
"junit4",
66+
"testng",
67+
"cucumberTestng",
68+
"selenide",
69+
"jbehave",
70+
],
6471
csharp: ["nunit", "xunit", "mstest", "specflow", "reqnroll"],
6572
python: ["pytest", "robot", "behave", "lettuce"],
6673
nodejs: ["jest", "mocha", "cucumberJs", "webdriverio", "nightwatch"],

src/tools/appautomate-utils/appium-sdk/utils.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { uploadApp } from "../native-execution/appautomate.js";
12
import {
23
AppSDKSupportedTestingFramework,
34
AppSDKSupportedTestingFrameworkEnum,
45
createStep,
56
} from "./index.js";
6-
import {SUPPORTED_CONFIGURATIONS} from "./types.js"
7+
import { SUPPORTED_CONFIGURATIONS } from "./types.js";
78

89
export function isBrowserStackAppUrl(appPath: string): boolean {
910
return appPath.startsWith("bs://");
@@ -51,10 +52,12 @@ export async function getAppUploadInstruction(
5152
if (
5253
detectedTestingFramework ===
5354
AppSDKSupportedTestingFrameworkEnum.nightwatch ||
54-
detectedTestingFramework === AppSDKSupportedTestingFrameworkEnum.webdriverio ||
55-
detectedTestingFramework === AppSDKSupportedTestingFrameworkEnum.cucumberRuby
55+
detectedTestingFramework ===
56+
AppSDKSupportedTestingFrameworkEnum.webdriverio ||
57+
detectedTestingFramework ===
58+
AppSDKSupportedTestingFrameworkEnum.cucumberRuby
5659
) {
57-
const app_url = "bs://ff4e358328a3e914fe4f0e46ec7af73f9c08cd55";
60+
const app_url = await uploadApp(appPath, username, accessKey);
5861
if (app_url) {
5962
return createStep(
6063
"Updating app_path with app_url",
@@ -66,32 +69,37 @@ export async function getAppUploadInstruction(
6669
}
6770

6871
export type SupportedFramework = keyof typeof SUPPORTED_CONFIGURATIONS;
69-
type SupportedLanguage = keyof typeof SUPPORTED_CONFIGURATIONS[SupportedFramework];
72+
type SupportedLanguage =
73+
keyof (typeof SUPPORTED_CONFIGURATIONS)[SupportedFramework];
7074
type SupportedTestingFramework = string;
7175

7276
export function validateSupportforAppAutomate(
7377
framework: SupportedFramework,
7478
language: SupportedLanguage,
75-
testingFramework: SupportedTestingFramework
79+
testingFramework: SupportedTestingFramework,
7680
) {
77-
const frameworks = Object.keys(SUPPORTED_CONFIGURATIONS) as SupportedFramework[];
81+
const frameworks = Object.keys(
82+
SUPPORTED_CONFIGURATIONS,
83+
) as SupportedFramework[];
7884
if (!SUPPORTED_CONFIGURATIONS[framework]) {
7985
throw new Error(
80-
`Unsupported framework '${framework}'. Supported frameworks: ${frameworks.join(", ")}`
86+
`Unsupported framework '${framework}'. Supported frameworks: ${frameworks.join(", ")}`,
8187
);
8288
}
8389

84-
const languages = Object.keys(SUPPORTED_CONFIGURATIONS[framework]) as SupportedLanguage[];
90+
const languages = Object.keys(
91+
SUPPORTED_CONFIGURATIONS[framework],
92+
) as SupportedLanguage[];
8593
if (!SUPPORTED_CONFIGURATIONS[framework][language]) {
8694
throw new Error(
87-
`Unsupported language '${language}' for framework '${framework}'. Supported languages: ${languages.join(", ")}`
95+
`Unsupported language '${language}' for framework '${framework}'. Supported languages: ${languages.join(", ")}`,
8896
);
8997
}
9098

9199
const testingFrameworks = SUPPORTED_CONFIGURATIONS[framework][language];
92100
if (!testingFrameworks.includes(testingFramework)) {
93101
throw new Error(
94-
`Unsupported testing framework '${testingFramework}' for language '${language}' and framework '${framework}'. Supported testing frameworks: ${testingFrameworks.join(", ")}`
102+
`Unsupported testing framework '${testingFramework}' for language '${language}' and framework '${framework}'. Supported testing frameworks: ${testingFrameworks.join(", ")}`,
95103
);
96104
}
97105
}

src/tools/appautomate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ export default function addAppAutomationTools(
393393
try {
394394
return await setupAppAutomateHandler(args, config);
395395
} catch (error) {
396-
const error_message = error instanceof Error ? error.message : "Unknown error";
396+
const error_message =
397+
error instanceof Error ? error.message : "Unknown error";
397398
return {
398399
content: [
399400
{

0 commit comments

Comments
 (0)