Skip to content

Commit 7286f1f

Browse files
Merge branch 'browserstack:main' into main
2 parents 4f52723 + 47ccfc8 commit 7286f1f

File tree

5 files changed

+90
-37
lines changed

5 files changed

+90
-37
lines changed

.github/workflows/npm-publish.yml

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ permissions:
88

99
jobs:
1010
publish:
11-
name: "Publish to NPM"
1211
runs-on: ubuntu-latest
13-
1412
steps:
1513
- name: "Checkout source code"
1614
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
1717

1818
- name: "Set up Node.js"
1919
uses: actions/setup-node@v3
@@ -29,7 +29,63 @@ jobs:
2929

3030
- name: "Get version from package.json"
3131
id: get_version
32-
run: echo "version=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
32+
run: |
33+
VERSION="v$(node -p 'require("./package.json").version')"
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
35+
36+
- name: Get previous Git tag
37+
id: get_previous_tag
38+
run: |
39+
VERSION="${{ steps.get_version.outputs.version }}"
40+
PREV_TAG=$(git tag --sort=-creatordate | grep '^v' | grep -v "$VERSION" | head -n 1)
41+
echo "previous_tag=$PREV_TAG" >> $GITHUB_OUTPUT
42+
43+
- name: Fetch and categorize merged PRs
44+
id: fetch_prs
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
set -e
49+
PREVIOUS_TAG=${{ steps.get_previous_tag.outputs.previous_tag }}
50+
if [ -z "$PREVIOUS_TAG" ]; then
51+
echo "pr_list=No previous tag found to compare PRs." >> $GITHUB_OUTPUT
52+
exit 0
53+
fi
54+
PREVIOUS_SHA=$(git rev-list -n 1 $PREVIOUS_TAG)
55+
PREVIOUS_DATE=$(git show -s --format=%cI $PREVIOUS_SHA)
56+
CURRENT_DATE=$(git show -s --format=%cI HEAD)
57+
echo "Fetching PRs merged between $PREVIOUS_DATE and $CURRENT_DATE"
58+
59+
RAW_PRS=$(gh pr list --state merged --search "merged:${PREVIOUS_DATE}..${CURRENT_DATE}" \
60+
--json number,title,url \
61+
--jq '.[] | "- [#\(.number)](\(.url)) \(.title)"')
62+
63+
if [ -z "$RAW_PRS" ]; then
64+
echo "pr_list=No pull requests were merged during this release." >> $GITHUB_OUTPUT
65+
exit 0
66+
fi
67+
68+
ADDED=""
69+
FIXED=""
70+
while IFS= read -r pr; do
71+
if echo "$pr" | grep -iq "fix"; then
72+
FIXED+="$pr"$'\n'
73+
else
74+
ADDED+="$pr"$'\n'
75+
fi
76+
done <<< "$RAW_PRS"
77+
78+
BODY=""
79+
if [ -n "$ADDED" ]; then
80+
BODY="$BODY### Added"$'\n'"$ADDED"
81+
fi
82+
if [ -n "$FIXED" ]; then
83+
BODY="$BODY"$'\n'"### Fixed"$'\n'"$FIXED"
84+
fi
85+
86+
echo "pr_list<<EOF" >> $GITHUB_OUTPUT
87+
echo "$BODY" >> $GITHUB_OUTPUT
88+
echo "EOF" >> $GITHUB_OUTPUT
3389

3490
- name: "Set Git user name and email"
3591
run: |
@@ -51,11 +107,10 @@ jobs:
51107
uses: actions/create-release@v1
52108
with:
53109
tag_name: ${{ steps.get_version.outputs.version }}
54-
release_name: Release ${{ steps.get_version.outputs.version }}
110+
release_name: ${{ steps.get_version.outputs.version }}
55111
body: |
56-
```
57-
• See CHANGELOG.md for details
58-
• Published by ${{ github.actor }}
59-
```
112+
${{ steps.fetch_prs.outputs.pr_list }}
113+
114+
Published by ${{ github.actor }}
60115
env:
61-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@browserstack/mcp-server",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "BrowserStack's Official MCP Server",
55
"main": "dist/index.js",
66
"repository": {

src/lib/local.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export async function killExistingBrowserStackLocalProcesses() {
7373
}
7474
}
7575

76-
export async function ensureLocalBinarySetup(localIdentifier?: string): Promise<void> {
76+
export async function ensureLocalBinarySetup(
77+
localIdentifier?: string,
78+
): Promise<void> {
7779
logger.info(
7880
"Ensuring local binary setup as it is required for private URLs...",
7981
);
@@ -87,33 +89,30 @@ export async function ensureLocalBinarySetup(localIdentifier?: string): Promise<
8789
localIdentifier?: string;
8890
} = {
8991
key: config.browserstackAccessKey,
90-
username: config.browserstackUsername
92+
username: config.browserstackUsername,
9193
};
9294

9395
if (localIdentifier) {
9496
requestBody.localIdentifier = localIdentifier;
9597
}
9698

9799
return await new Promise((resolve, reject) => {
98-
localBinary.start(
99-
requestBody,
100-
(error?: Error) => {
101-
if (error) {
102-
logger.error(
103-
`Unable to start BrowserStack Local... please check your credentials and try again. Error: ${error}`,
104-
);
100+
localBinary.start(requestBody, (error?: Error) => {
101+
if (error) {
102+
logger.error(
103+
`Unable to start BrowserStack Local... please check your credentials and try again. Error: ${error}`,
104+
);
105105

106-
reject(
107-
new Error(
108-
`Unable to configure local tunnel binary, please check your credentials and try again. Error: ${error}`,
109-
),
110-
);
111-
} else {
112-
logger.info("Successfully started BrowserStack Local");
113-
resolve();
114-
}
115-
},
116-
);
106+
reject(
107+
new Error(
108+
`Unable to configure local tunnel binary, please check your credentials and try again. Error: ${error}`,
109+
),
110+
);
111+
} else {
112+
logger.info("Successfully started BrowserStack Local");
113+
resolve();
114+
}
115+
});
117116
});
118117
}
119118

src/tools/accessiblity-utils/scanner.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ export class AccessibilityScanner {
2929
name: string,
3030
urlList: string[],
3131
): Promise<AccessibilityScanResponse> {
32-
3332
// Check if any URL is local
3433
const hasLocal = urlList.some(isLocalURL);
3534
const localIdentifier = crypto.randomUUID();
36-
const LOCAL_IP = "127.0.0.1";
35+
const localHosts = new Set(["127.0.0.1", "localhost", "0.0.0.0"]);
3736
const BS_LOCAL_DOMAIN = "bs-local.com";
3837

3938
if (hasLocal) {
@@ -45,13 +44,13 @@ export class AccessibilityScanner {
4544
const transformedUrlList = urlList.map((url) => {
4645
try {
4746
const parsed = new URL(url);
48-
if (parsed.hostname === LOCAL_IP) {
47+
if (localHosts.has(parsed.hostname)) {
4948
parsed.hostname = BS_LOCAL_DOMAIN;
5049
return parsed.toString();
5150
}
5251
return url;
5352
} catch (e) {
54-
logger.warn(`[AccessibilityScan] Invalid URL skipped: ${url}`);
53+
logger.warn(`[AccessibilityScan] Invalid URL skipped: ${e}`);
5554
return url;
5655
}
5756
});
@@ -68,7 +67,7 @@ export class AccessibilityScanner {
6867
localTestingInfo: {
6968
localIdentifier,
7069
localEnabled: true,
71-
}
70+
},
7271
};
7372
requestBody = { ...baseRequestBody, ...localConfig };
7473
}

0 commit comments

Comments
 (0)