-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
139 lines (118 loc) Β· 5.29 KB
/
Copy pathinstall.sh
File metadata and controls
139 lines (118 loc) Β· 5.29 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env sh
# install.sh β Lucella Protocol installer
# Detects OS/arch, downloads correct binary from GitHub Releases
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/Gicelldev/lucella/main/install.sh | sh
# curl -fsSL https://raw.githubusercontent.com/Gicelldev/lucella/main/install.sh | sh -s -- --version v0.1.0
set -e
REPO="Gicelldev/lucella"
BINARY="lucella"
INSTALL_DIR="/usr/local/bin"
VERSION="${LUCELLA_VERSION:-latest}"
# ββ Color output ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
BOLD='\033[1m'; RESET='\033[0m'
info() { printf "${BOLD}[lucella]${RESET} %s\n" "$1"; }
success() { printf "${GREEN}[lucella]${RESET} %s\n" "$1"; }
warn() { printf "${YELLOW}[lucella]${RESET} %s\n" "$1"; }
error() { printf "${RED}[lucella] ERROR:${RESET} %s\n" "$1" >&2; exit 1; }
# ββ Detect OS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
detect_os() {
OS=$(uname -s)
case "$OS" in
Linux*) echo "linux" ;;
Darwin*) echo "macos" ;;
MINGW*|MSYS*|CYGWIN*) echo "windows" ;;
*) error "Unsupported OS: $OS. Install manually from https://github.com/$REPO/releases" ;;
esac
}
# ββ Detect Architecture βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
detect_arch() {
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) echo "x64" ;;
aarch64|arm64) echo "arm64" ;;
*) error "Unsupported architecture: $ARCH. Install manually from https://github.com/$REPO/releases" ;;
esac
}
# ββ Get latest version from GitHub API βββββββββββββββββββββββββββββββββββββββ
get_latest_version() {
if command -v curl >/dev/null 2>&1; then
curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" \
| grep '"tag_name"' | sed 's/.*"tag_name": *"\(.*\)".*/\1/'
elif command -v wget >/dev/null 2>&1; then
wget -qO- "https://api.github.com/repos/$REPO/releases/latest" \
| grep '"tag_name"' | sed 's/.*"tag_name": *"\(.*\)".*/\1/'
else
error "curl or wget required. Install one and try again."
fi
}
# ββ Download ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
download() {
URL="$1"
DEST="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$URL" -o "$DEST"
elif command -v wget >/dev/null 2>&1; then
wget -qO "$DEST" "$URL"
fi
}
# ββ Main ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
main() {
printf "\n${BOLD}π―οΈ Lucella Protocol Installer${RESET}\n"
printf " Faster than gRPC Β· Safer than REST\n\n"
OS=$(detect_os)
ARCH=$(detect_arch)
info "Detected: $OS / $ARCH"
# Get version
if [ "$VERSION" = "latest" ]; then
info "Fetching latest version..."
VERSION=$(get_latest_version)
[ -z "$VERSION" ] && error "Could not fetch latest version. Check your internet connection."
fi
info "Installing version: $VERSION"
# Build artifact name
if [ "$OS" = "windows" ]; then
ARTIFACT="lucella-windows-${ARCH}.exe.tar.gz"
else
ARTIFACT="lucella-${OS}-${ARCH}.tar.gz"
fi
URL="https://github.com/$REPO/releases/download/$VERSION/$ARTIFACT"
TMPDIR=$(mktemp -d)
ARCHIVE="$TMPDIR/$ARTIFACT"
info "Downloading $ARTIFACT..."
download "$URL" "$ARCHIVE" || error "Download failed: $URL\nCheck https://github.com/$REPO/releases for available versions."
info "Extracting..."
tar xzf "$ARCHIVE" -C "$TMPDIR"
rm "$ARCHIVE"
# Find the binary
if [ "$OS" = "windows" ]; then
BINARY_FILE=$(find "$TMPDIR" -name "lucella*.exe" | head -1)
else
BINARY_FILE=$(find "$TMPDIR" -name "lucella*" ! -name "*.tar.gz" | head -1)
chmod +x "$BINARY_FILE"
fi
# Install
info "Installing to $INSTALL_DIR/$BINARY..."
if [ -w "$INSTALL_DIR" ]; then
cp "$BINARY_FILE" "$INSTALL_DIR/$BINARY"
else
sudo cp "$BINARY_FILE" "$INSTALL_DIR/$BINARY"
fi
rm -rf "$TMPDIR"
# Verify
if command -v lucella >/dev/null 2>&1; then
INSTALLED_VER=$(lucella --version 2>/dev/null || echo "unknown")
success "Installed: lucella $INSTALLED_VER"
fi
printf "\n${GREEN}β
Lucella installed!${RESET}\n\n"
printf " ${BOLD}Start a server:${RESET}\n"
printf " $ lucella serve --port 7777\n\n"
printf " ${BOLD}Validate a schema:${RESET}\n"
printf " $ lucella check schema.lucella\n\n"
printf " ${BOLD}Scaffold a project:${RESET}\n"
printf " $ lucella init my-api\n\n"
printf " Docs: https://github.com/$REPO\n\n"
}
main "$@"