-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·274 lines (234 loc) · 6.61 KB
/
Copy pathinstall
File metadata and controls
executable file
·274 lines (234 loc) · 6.61 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/usr/bin/env bash
set -euo pipefail
# Colors
RED='\033[0;31m'
ORANGE='\033[38;5;214m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
APP=flowsight
REPO=TbusOS/flowsight
usage() {
cat <<EOF
FlowSight Installer
Usage: install.sh [options]
Options:
-h, --help Display this help message
-v, --version <version> Install a specific version (e.g., 0.1.0)
-s, --source Build from source (default)
--no-desktop Skip Tauri desktop app, CLI only
--no-modify-path Don't modify shell config files
Examples:
# Build from source (default)
curl -fsSL https://flowsight.ai/install | bash
# Install specific version
curl -fsSL https://flowsight.ai/install | bash -s -- --version 0.1.0
# CLI only (no desktop app)
curl -fsSL https://flowsight.ai/install | bash -s -- --no-desktop
EOF
}
# Parse arguments
version=""
no_desktop=false
no_modify_path=false
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
exit 0
;;
-v|--version)
if [[ -n "${2:-}" ]]; then
version="$2"
shift 2
else
echo -e "${RED}Error: --version requires a version argument${NC}"
exit 1
fi
;;
-s|--source)
# Source build is default, no-op for compatibility
shift
;;
--no-desktop)
no_desktop=true
shift
;;
--no-modify-path)
no_modify_path=true
shift
;;
*)
echo -e "${ORANGE}Warning: Unknown option '$1'${NC}" >&2
shift
;;
esac
done
# Detect OS
raw_os=$(uname -s)
os=$(echo "$raw_os" | tr '[:upper:]' '[:lower:]')
case "$raw_os" in
Darwin*) os="darwin" ;;
Linux*) os="linux" ;;
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
esac
# Detect architecture
arch=$(uname -m)
if [[ "$arch" == "aarch64" ]]; then
arch="arm64"
elif [[ "$arch" == "x86_64" ]]; then
arch="x64"
fi
echo -e "${GREEN}FlowSight Installer${NC}"
echo -e "${NC}Platform: $os-$arch"
echo ""
# Check prerequisites
check_prerequisites() {
local missing=()
# Check Rust
if ! command -v cargo >/dev/null 2>&1; then
missing+=("Rust (cargo)")
fi
# Check Node.js (for desktop app)
if [[ "$no_desktop" == "false" ]]; then
if ! command -v node >/dev/null 2>&1; then
missing+=("Node.js")
fi
if ! command -v pnpm >/dev/null 2>&1; then
missing+=("pnpm (npm install -g pnpm)")
fi
fi
# Check Git
if ! command -v git >/dev/null 2>&1; then
missing+=("Git")
fi
if [[ ${#missing[@]} -gt 0 ]]; then
echo -e "${RED}Missing prerequisites:${NC}"
for item in "${missing[@]}"; do
echo -e " - $item"
done
echo ""
echo "Please install the missing dependencies and try again."
echo "Visit https://flowsight.ai/docs/install for detailed instructions."
exit 1
fi
}
# Print message
print_message() {
local level=$1
local message=$2
local color=""
case $level in
info) color="${NC}" ;;
success) color="${GREEN}" ;;
warning) color="${ORANGE}" ;;
error) color="${RED}" ;;
esac
echo -e "${color}${message}${NC}"
}
# Install directory
INSTALL_DIR=$HOME/.flowsight/bin
mkdir -p "$INSTALL_DIR"
# Build from source
build_from_source() {
print_message info "Building FlowSight from source..."
local build_dir="${TMPDIR:-/tmp}/flowsight_build_$$"
mkdir -p "$build_dir"
cd "$build_dir"
# Clone repository
if [[ -n "$version" ]]; then
print_message info "Cloning repository at version $version..."
git clone --depth 1 --branch "v$version" "https://github.com/$REPO.git" .
else
print_message info "Cloning repository (main branch)..."
git clone --depth 1 "https://github.com/$REPO.git" .
fi
# Build CLI
print_message info "Building CLI..."
cargo build --release -p flowsight-cli
# Copy CLI binary
cp "target/release/flowsight" "$INSTALL_DIR"
chmod 755 "$INSTALL_DIR/flowsight"
# Build desktop app (optional)
if [[ "$no_desktop" == "false" ]]; then
print_message info "Building desktop app..."
cd app
pnpm install
pnpm tauri build
cp "src-tauri/target/release/bundle/"*/*"$app"* "$INSTALL_DIR" 2>/dev/null || true
fi
# Cleanup
cd /
rm -rf "$build_dir"
print_message success "Build complete!"
}
# Add to PATH
add_to_path() {
local config_file=$1
local command=$2
if grep -Fxq "$command" "$config_file" 2>/dev/null; then
print_message info "Command already exists in $config_file, skipping."
elif [[ -w $config_file ]]; then
echo -e "\n# flowsight" >> "$config_file"
echo "$command" >> "$config_file"
print_message info "Added flowsight to PATH in $config_file"
else
print_message warning "Cannot write to $config_file"
print_message info "Manually add: $command"
fi
}
# Main
check_prerequisites
if [[ "$no_desktop" == "true" ]]; then
print_message info "Building CLI only (no desktop app)..."
fi
build_from_source
# Add to PATH (if not already)
if [[ "$no_modify_path" != "true" ]]; then
current_shell=$(basename "$SHELL")
local add_cmd="export PATH=\$HOME/.flowsight/bin:\$PATH"
case $current_shell in
fish)
add_cmd="fish_add_path \$HOME/.flowsight/bin"
;;
zsh|bash|sh)
add_cmd="export PATH=\$HOME/.flowsight/bin:\$PATH"
;;
*)
add_cmd="export PATH=\$HOME/.flowsight/bin:\$PATH"
;;
esac
config_files=""
case $current_shell in
fish)
config_files="$HOME/.config/fish/config.fish"
;;
zsh)
config_files="$HOME/.zshrc $HOME/.zshenv"
;;
bash)
config_files="$HOME/.bashrc $HOME/.bash_profile"
;;
sh)
config_files="$HOME/.profile"
;;
*)
config_files="$HOME/.bashrc"
;;
esac
for file in $config_files; do
if [[ -f $file ]]; then
add_to_path "$file" "$add_cmd"
break
fi
done
fi
echo ""
echo -e "${GREEN}Installation complete!${NC}"
echo ""
echo -e "${NC}To get started:${NC}"
echo ""
echo -e " flowsight --help ${MUTED}# Show CLI options${NC}"
echo -e " flowsight analyze <file> ${MUTED}# Analyze a C file${NC}"
echo ""
echo -e "${MUTED}For more information visit ${NC}https://flowsight.ai/docs"
echo ""