-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·102 lines (87 loc) · 5.65 KB
/
install.sh
File metadata and controls
executable file
·102 lines (87 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
set -e
PACKAGE_NAME="@brightdata/cli"
COMMAND_NAME="brightdata"
COMMAND_ALIAS="bdata"
MIN_NODE_MAJOR=20
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
DIM='\033[2m'
RESET='\033[0m'
else
RED='' GREEN='' YELLOW='' BLUE='' CYAN='' BOLD='' DIM='' RESET=''
fi
info() { printf "${BLUE}${BOLD}==>${RESET} %s\n" "$1"; }
warn() { printf "${YELLOW}${BOLD}warning:${RESET} %s\n" "$1"; }
error() { printf "${RED}${BOLD}error:${RESET} %s\n" "$1" >&2; exit 1; }
check_node() {
if ! command -v node >/dev/null 2>&1; then
error "Node.js is not installed.
Install Node.js ${MIN_NODE_MAJOR}+ from https://nodejs.org/ and try again."
fi
version=$(node -v 2>/dev/null | sed 's/^v//')
major=$(echo "$version" | cut -d. -f1)
if ! [ "$major" -ge "$MIN_NODE_MAJOR" ] 2>/dev/null; then
error "Node.js v${version} found, but v${MIN_NODE_MAJOR}+ is required.
Update Node.js from https://nodejs.org/ and try again."
fi
echo "$version"
}
main() {
WHITE='' BLUE_FG=''
if [ -t 1 ]; then
WHITE='\033[37m'
BLUE_FG='\033[34m'
fi
printf "\n"
printf "${WHITE}███████████ ███ █████ █████ ${RESET}${BLUE_FG}██████████ █████ ${RESET}\n"
printf "${WHITE}░░███░░░░░███ ░░░ ░░███ ░░███ ${RESET}${BLUE_FG}░░███░░░░███ ░░███ ${RESET}\n"
printf "${WHITE} ░███ ░███ ████████ ████ ███████ ░███████ ███████ ${RESET}${BLUE_FG} ░███ ░░███ ██████ ███████ ██████ ${RESET}\n"
printf "${WHITE} ░██████████ ░░███░░███░░███ ███░░███ ░███░░███ ░░░███░ ${RESET}${BLUE_FG} ░███ ░███ ░░░░░███ ░░░███░ ░░░░░███ ${RESET}\n"
printf "${WHITE} ░███░░░░░███ ░███ ░░░ ░███ ░███ ░███ ░███ ░███ ░███ ${RESET}${BLUE_FG} ░███ ░███ ███████ ░███ ███████ ${RESET}\n"
printf "${WHITE} ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ███ ${RESET}${BLUE_FG} ░███ ███ ███░░███ ░███ ███ ███░░███ ${RESET}\n"
printf "${WHITE} ███████████ █████ █████░░███████ ████ █████ ░░█████ ${RESET}${BLUE_FG} ██████████ ░░████████ ░░█████ ░░████████${RESET}\n"
printf "${WHITE}░░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░███░░░░ ░░░░░ ░░░░░ ${RESET}${BLUE_FG}░░░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░░░ ${RESET}\n"
printf "${WHITE} ███ ░███ ${RESET}${BLUE_FG} ${RESET}\n"
printf "${WHITE} ░░██████ ${RESET}${BLUE_FG} ${RESET}\n"
printf "${WHITE} ░░░░░░ ${RESET}${BLUE_FG} ${RESET}\n"
printf "\n"
printf "${DIM} CLI Installer${RESET}\n\n"
NODE_VERSION=$(check_node)
info "Found Node.js v${NODE_VERSION}"
if ! command -v npm >/dev/null 2>&1; then
error "npm is not available. Install npm and try again."
fi
info "Installing ${PACKAGE_NAME} globally..."
npm install -g "${PACKAGE_NAME}"
if command -v "$COMMAND_NAME" >/dev/null 2>&1; then
installed_version=$("$COMMAND_NAME" --version 2>/dev/null || echo "unknown")
printf "\n${GREEN}${BOLD}Success!${RESET} ${PACKAGE_NAME} ${installed_version} is installed.\n"
elif command -v "$COMMAND_ALIAS" >/dev/null 2>&1; then
installed_version=$("$COMMAND_ALIAS" --version 2>/dev/null || echo "unknown")
printf "\n${GREEN}${BOLD}Success!${RESET} ${PACKAGE_NAME} ${installed_version} is installed.\n"
else
printf "\n${GREEN}${BOLD}Installed!${RESET} You may need to restart your shell or add the npm global bin directory to your PATH.\n"
npm_bin=$(npm bin -g 2>/dev/null) || true
if [ -n "$npm_bin" ] && ! echo "$PATH" | tr ':' '\n' | grep -qx "$npm_bin"; then
warn "${npm_bin} is not in your PATH. Add it with:"
printf " export PATH=\"%s:\$PATH\"\n\n" "$npm_bin"
fi
fi
printf "\n"
if command -v "$COMMAND_NAME" >/dev/null 2>&1; then
"$COMMAND_NAME" login
elif command -v "$COMMAND_ALIAS" >/dev/null 2>&1; then
"$COMMAND_ALIAS" login
fi
printf "\nGet started:\n"
printf " ${BOLD}${COMMAND_ALIAS} scrape${RESET} <url> # scrape any URL\n"
printf " ${BOLD}${COMMAND_ALIAS} search${RESET} <query> # search the web\n"
printf " ${BOLD}${COMMAND_ALIAS} skill${RESET} # install agent skills\n\n"
}
main