Skip to content

Commit 828114c

Browse files
committed
fix: install script
1 parent 9e18590 commit 828114c

File tree

3 files changed

+20
-78
lines changed

3 files changed

+20
-78
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<p align="center">
1212
<a href="https://www.npmjs.com/package/%40brightdata%2Fcli"><img src="https://img.shields.io/npm/v/%40brightdata%2Fcli?color=black&label=npm" alt="npm version" /></a>
13-
<img src="https://img.shields.io/badge/node-%3E%3D18-black" alt="node requirement" />
13+
<img src="https://img.shields.io/badge/node-%3E%3D20-black" alt="node requirement" />
1414
<img src="https://img.shields.io/badge/license-ISC-black" alt="license" />
1515
</p>
1616

@@ -70,7 +70,7 @@ Or run without installing:
7070
npx --yes --package @brightdata/cli brightdata <command>
7171
```
7272

73-
> **Requires Node.js ≥ 18.0.0**
73+
> **Requires Node.js ≥ 20.0.0**
7474
7575
---
7676

@@ -614,7 +614,7 @@ Colors and spinners are disabled automatically when not in a TTY. If you still s
614614
- [Control Panel](https://brightdata.com/cp)
615615
- [API Key Settings](https://brightdata.com/cp/setting/users)
616616
- [API Reference](https://docs.brightdata.com/api-reference)
617-
- [Report an Issue](https://github.com/brightdata/brightdata-cli/issues)
617+
- [Report an Issue](https://github.com/brightdata/cli/issues)
618618

619619
---
620620

install.sh

Lines changed: 16 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
PACKAGE_NAME="@brightdata/cli"
55
COMMAND_NAME="brightdata"
66
COMMAND_ALIAS="bdata"
7-
MIN_NODE_MAJOR=18
7+
MIN_NODE_MAJOR=20
88

99
if [ -t 1 ]; then
1010
RED='\033[0;31m'
@@ -23,63 +23,21 @@ info() { printf "${BLUE}${BOLD}==>${RESET} %s\n" "$1"; }
2323
warn() { printf "${YELLOW}${BOLD}warning:${RESET} %s\n" "$1"; }
2424
error() { printf "${RED}${BOLD}error:${RESET} %s\n" "$1" >&2; exit 1; }
2525

26-
find_node() {
27-
if command -v node >/dev/null 2>&1; then
28-
version=$(node -v 2>/dev/null | sed 's/^v//')
29-
major=$(echo "$version" | cut -d. -f1)
30-
if [ "$major" -ge "$MIN_NODE_MAJOR" ] 2>/dev/null; then
31-
echo "$version"
32-
return 0
33-
fi
34-
fi
35-
return 1
36-
}
37-
38-
install_node() {
39-
info "Node.js ${MIN_NODE_MAJOR}+ not found. Attempting to install..."
40-
41-
if [ -n "$NVM_DIR" ] && [ -s "$NVM_DIR/nvm.sh" ]; then
42-
info "Found nvm — installing Node.js ${MIN_NODE_MAJOR}..."
43-
. "$NVM_DIR/nvm.sh"
44-
nvm install "$MIN_NODE_MAJOR"
45-
nvm use "$MIN_NODE_MAJOR"
46-
return 0
47-
fi
48-
49-
if command -v fnm >/dev/null 2>&1; then
50-
info "Found fnm — installing Node.js ${MIN_NODE_MAJOR}..."
51-
fnm install "$MIN_NODE_MAJOR"
52-
fnm use "$MIN_NODE_MAJOR"
53-
return 0
26+
check_node() {
27+
if ! command -v node >/dev/null 2>&1; then
28+
error "Node.js is not installed.
29+
Install Node.js ${MIN_NODE_MAJOR}+ from https://nodejs.org/ and try again."
5430
fi
5531

56-
if command -v brew >/dev/null 2>&1; then
57-
info "Installing Node.js via Homebrew..."
58-
brew install node@"$MIN_NODE_MAJOR"
59-
return 0
60-
fi
32+
version=$(node -v 2>/dev/null | sed 's/^v//')
33+
major=$(echo "$version" | cut -d. -f1)
6134

62-
if command -v apt-get >/dev/null 2>&1; then
63-
info "Installing Node.js via apt..."
64-
if command -v sudo >/dev/null 2>&1; then
65-
sudo apt-get update -y && sudo apt-get install -y nodejs npm
66-
else
67-
apt-get update -y && apt-get install -y nodejs npm
68-
fi
69-
return 0
35+
if ! [ "$major" -ge "$MIN_NODE_MAJOR" ] 2>/dev/null; then
36+
error "Node.js v${version} found, but v${MIN_NODE_MAJOR}+ is required.
37+
Update Node.js from https://nodejs.org/ and try again."
7038
fi
7139

72-
if command -v yum >/dev/null 2>&1; then
73-
info "Installing Node.js via yum..."
74-
if command -v sudo >/dev/null 2>&1; then
75-
sudo yum install -y nodejs npm
76-
else
77-
yum install -y nodejs npm
78-
fi
79-
return 0
80-
fi
81-
82-
return 1
40+
echo "$version"
8341
}
8442

8543
main() {
@@ -103,30 +61,15 @@ main() {
10361
printf "\n"
10462
printf "${DIM} CLI Installer${RESET}\n\n"
10563

106-
NODE_VERSION=$(find_node) || {
107-
install_node || error "Node.js ${MIN_NODE_MAJOR}+ is required but could not be installed.
108-
Install it from https://nodejs.org/ and try again."
109-
NODE_VERSION=$(find_node) || error "Node.js was installed but still not found in PATH.
110-
Restart your shell and try again."
111-
}
64+
NODE_VERSION=$(check_node)
11265
info "Found Node.js v${NODE_VERSION}"
11366

114-
if command -v npm >/dev/null 2>&1; then
115-
PM="npm"
116-
elif command -v yarn >/dev/null 2>&1; then
117-
PM="yarn"
118-
elif command -v pnpm >/dev/null 2>&1; then
119-
PM="pnpm"
120-
else
121-
error "No package manager found (npm, yarn, or pnpm). Install npm and try again."
67+
if ! command -v npm >/dev/null 2>&1; then
68+
error "npm is not available. Install npm and try again."
12269
fi
12370

124-
info "Installing ${PACKAGE_NAME} with ${PM}..."
125-
case "$PM" in
126-
npm) npm install -g "$PACKAGE_NAME" ;;
127-
yarn) yarn global add "$PACKAGE_NAME" ;;
128-
pnpm) pnpm add -g "$PACKAGE_NAME" ;;
129-
esac
71+
info "Installing ${PACKAGE_NAME} globally..."
72+
npm install -g "${PACKAGE_NAME}"
13073

13174
if command -v "$COMMAND_NAME" >/dev/null 2>&1; then
13275
installed_version=$("$COMMAND_NAME" --version 2>/dev/null || echo "unknown")
@@ -136,7 +79,6 @@ main() {
13679
printf "\n${GREEN}${BOLD}Success!${RESET} ${PACKAGE_NAME} ${installed_version} is installed.\n"
13780
else
13881
printf "\n${GREEN}${BOLD}Installed!${RESET} You may need to restart your shell or add the npm global bin directory to your PATH.\n"
139-
14082
npm_bin=$(npm bin -g 2>/dev/null) || true
14183
if [ -n "$npm_bin" ] && ! echo "$PATH" | tr ':' '\n' | grep -qx "$npm_bin"; then
14284
warn "${npm_bin} is not in your PATH. Add it with:"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"homepage": "https://brightdata.com",
4444
"engines": {
45-
"node": ">=18.0.0"
45+
"node": ">=20.0.0"
4646
},
4747
"files": [
4848
"dist",

0 commit comments

Comments
 (0)