Skip to content

Commit 09780aa

Browse files
authored
Merge pull request #2 from BrowserStackCE/optimisatons
optimisations for mac
2 parents 1207d5d + 8cffd16 commit 09780aa

File tree

4 files changed

+375
-788
lines changed

4 files changed

+375
-788
lines changed

README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ This utility automates the entire first-mile experience — from credential inpu
1313
| 🔍 Pre-requisite Check | Validates if Java, Node, and Python are installed. Provides installation guidance if they are missing. |
1414
| 📊 Plan Variant Detection | Calls the `/plan` API to tailor the sample repo based on the customer’s subscription tier (e.g., Live, Pro). |
1515
| ✅ Console UX with Checkmarks | Mimics the BrowserStack Network Assessment Tool for a familiar experience. |
16-
| 🪵 Logging for Debugging | Saves all raw logs under `~/.browserstack/bstack_onboarding.log` for support and debugging purposes. |
16+
| 🪵 Logging for Debugging | Saves all raw logs under `~/.browserstack/NOW` for support and debugging purposes. |
1717
| 🖥️ (Planned) UI Framework Picker | Allows customers to select their preferred test framework via an interactive UI. |
1818

19-
## How to Use
19+
## How to Use?
2020

2121
You can either run the script directly from the web or clone the repository and run it locally.
2222

2323
### Clone and Run Locally
2424

2525
1. Clone the repository:
2626
```bash
27-
git clone https://github.com/http-heading/browserstack-now.git
27+
git clone https://github.com/BrowserStackCE/browserstack-now.git
2828
```
2929
2. Navigate to the directory:
3030
```bash
@@ -34,12 +34,17 @@ You can either run the script directly from the web or clone the repository and
3434

3535
**macOS / Linux**
3636
```bash
37-
bash mac_os.sh
37+
bash mac/run.sh or ./mac/run.sh
3838
```
39+
If you encounter any permission issues, ensure the script is executable:
3940

41+
```
42+
chmod +x ./mac/run.sh
43+
```
44+
4045
**Windows**
4146
```powershell
42-
./windows.ps1
47+
./win/run.ps1
4348
```
4449

4550
### Remote Execution
@@ -49,7 +54,7 @@ You can either run the script directly from the web or clone the repository and
4954
To run the onboarding utility on macOS or Linux without cloning, execute the following command in your terminal:
5055

5156
```bash
52-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/http-heading/browserstack-now/main/mac_os.sh)"
57+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/http-heading/browserstack-now/main/mac/run.sh)"
5358
```
5459

5560
#### Windows
@@ -58,6 +63,23 @@ To run the onboarding utility on Windows without cloning, execute the following
5863
**Note:** You may need to set the execution policy to `RemoteSigned` or `Bypass` to run the script.
5964

6065
```powershell
61-
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/http-heading/browserstack-now/main/windows.ps1'))
66+
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/http-heading/browserstack-now/main/win/run.ps1'))
67+
```
68+
69+
## Identifying and sharing the log files
70+
71+
The NOW framework creates the log files in this folder. To seek assistance from the BrowserStack team after running this Github repository, please share a zip of the logs with the BrowserStack team in toucn with you.
72+
73+
### NOW Framework Logs
74+
75+
#### macOS / Linux
76+
```
77+
$HOME/.browserstack/NOW/logs
6278
```
79+
80+
#### Windows
6381
```
82+
$HOME/.browserstack/NOW/logs
83+
```
84+
85+

mac/proxy-check.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env sh
2+
3+
# URL to test
4+
TEST_URL="https://www.browserstack.com/automate/browsers.json"
5+
6+
# Detect proxy from env (case insensitive)
7+
PROXY="${http_proxy:-${HTTP_PROXY:-${https_proxy:-${HTTPS_PROXY}}}}"
8+
9+
# Reset output variables
10+
export PROXY_HOST=""
11+
export PROXY_PORT=""
12+
13+
# Function: parse proxy url to host + port
14+
parse_proxy() {
15+
p="$1"
16+
# strip protocol e.g. http://, https://
17+
p="${p#http://}"
18+
p="${p#https://}"
19+
# strip credentials if any user:pass@
20+
p="${p#*[@]}"
21+
22+
# extract host and port
23+
export PROXY_HOST="${p%%:*}"
24+
export PROXY_PORT="${p##*:}"
25+
}
26+
27+
base64_encoded_creds=$(printf "%s" $BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY | base64 | tr -d '\n')
28+
29+
30+
# If no proxy configured, exit early
31+
if [ -z "$PROXY" ]; then
32+
echo "No proxy found in environment. Clearing proxy host and port variables."
33+
export PROXY_HOST=""
34+
export PROXY_PORT=""
35+
return 0 2>/dev/null || exit 0
36+
fi
37+
38+
echo "Proxy detected: $PROXY"
39+
parse_proxy "$PROXY"
40+
41+
echo "Testing reachability via proxy..."
42+
43+
44+
STATUS_CODE=$(curl -sS -o /dev/null -H "Authorization: Basic ${base64_encoded_creds}" -w "%{http_code}" --proxy "$PROXY" "$TEST_URL" 2>/dev/null)
45+
46+
if [ "${STATUS_CODE#2}" != "$STATUS_CODE" ]; then
47+
echo "✅ Reachable. HTTP $STATUS_CODE"
48+
echo "Exporting PROXY_HOST=$PROXY_HOST"
49+
echo "Exporting PROXY_PORT=$PROXY_PORT"
50+
export PROXY_HOST
51+
export PROXY_PORT
52+
else
53+
echo "❌ Not reachable (HTTP $STATUS_CODE). Clearing variables."
54+
export PROXY_HOST=""
55+
export PROXY_PORT=""
56+
fi

0 commit comments

Comments
 (0)