Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
178 lines (155 loc) · 5.21 KB
/
Copy pathinstall.sh
File metadata and controls
178 lines (155 loc) · 5.21 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
#!/bin/bash
# krinry Installer
# One-line installation: curl -fsSL https://raw.githubusercontent.com/krinry/krinry-cli/dev/install.sh | bash
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
DIM='\033[2m'
NC='\033[0m'
print_success() { echo -e "${GREEN}✓${NC} $1"; }
print_error() { echo -e "${RED}✗${NC} $1"; }
print_warning() { echo -e "${YELLOW}⚠${NC} $1"; }
print_info() { echo -e "${BLUE}ℹ${NC} $1"; }
print_step() { echo -e "${CYAN}→${NC} $1"; }
# Banner
echo ""
echo -e "${BOLD}${CYAN}"
echo " _ _ "
echo " | | ___ __ (_)_ __ _ __ _ _ "
echo " | |/ / '__|| | '_ \| '__| | | | "
echo " | <| | | | | | | | | |_| | "
echo " |_|\_\_| |_|_| |_|_| \__, | "
echo " |___/ "
echo -e "${NC}"
echo -e "${BOLD}Multi-purpose CLI for mobile developers${NC}"
echo ""
# Detect Termux
is_termux() {
[[ -n "$PREFIX" && "$PREFIX" == *"com.termux"* ]]
}
# Check if command exists
check_cmd() {
command -v "$1" &>/dev/null
}
# Install directory
INSTALL_DIR="${HOME}/.krinry"
REPO_URL="https://github.com/krinry/krinry-cli.git"
# Detect environment
if is_termux; then
print_info "Detected: Termux on Android"
BIN_DIR="$PREFIX/bin"
else
print_info "Detected: $(uname -s)"
BIN_DIR="${HOME}/.local/bin"
fi
# ── Minimal global deps: only git and curl ──────────────────────────────────
print_step "Checking core dependencies..."
install_pkg() {
local pkg="$1"
if is_termux; then
pkg install -y "$pkg" 2>/dev/null || true
elif check_cmd apt-get; then
sudo apt-get install -y "$pkg" 2>/dev/null || true
elif check_cmd brew; then
brew install "$pkg" 2>/dev/null || true
fi
}
# git (needed to clone/update krinry itself)
if ! check_cmd git; then
print_step "Installing git..."
install_pkg git
fi
if check_cmd git; then
print_success "git ready"
else
print_error "Failed to install git"
exit 1
fi
# curl (needed for downloads)
if ! check_cmd curl; then
print_step "Installing curl..."
install_pkg curl
fi
if check_cmd curl; then
print_success "curl ready"
else
print_error "Failed to install curl"
exit 1
fi
# NOTE: gh, jq, termux-api are NOT installed here.
# They are installed on-demand by the tools that need them:
# gh → installed by: krinry flutter init / build
# jq → installed by: krinry flutter build
# termux-api → installed by: krinry flutter run web
# ────────────────────────────────────────────────────────────────────────────
# Clone or update repository
print_step "Installing krinry..."
if [[ -d "$INSTALL_DIR" ]]; then
print_info "Updating existing installation..."
cd "$INSTALL_DIR"
git fetch origin dev 2>/dev/null || true
git reset --hard origin/dev 2>/dev/null || git pull 2>/dev/null || true
else
print_info "Cloning repository..."
git clone "$REPO_URL" "$INSTALL_DIR"
fi
# Make scripts executable
chmod +x "$INSTALL_DIR/bin/krinry" 2>/dev/null || true
find "$INSTALL_DIR/lib" -name "*.sh" -exec chmod +x {} \; 2>/dev/null || true
# Create bin directory if needed
mkdir -p "$BIN_DIR"
# Create symlink
print_step "Creating symlink..."
ln -sf "$INSTALL_DIR/bin/krinry" "$BIN_DIR/krinry"
print_success "Symlink created at $BIN_DIR/krinry"
# Add to PATH if needed
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
print_step "Adding to PATH..."
SHELL_RC=""
if [[ -n "$BASH_VERSION" ]]; then
SHELL_RC="${HOME}/.bashrc"
elif [[ -n "$ZSH_VERSION" ]]; then
SHELL_RC="${HOME}/.zshrc"
else
SHELL_RC="${HOME}/.profile"
fi
if ! grep -q "$BIN_DIR" "$SHELL_RC" 2>/dev/null; then
echo "" >>"$SHELL_RC"
echo "# krinry" >>"$SHELL_RC"
echo "export PATH=\"$BIN_DIR:\$PATH\"" >>"$SHELL_RC"
print_success "Added to $SHELL_RC"
fi
export PATH="$BIN_DIR:$PATH"
fi
# Done!
echo ""
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}✓${NC} ${BOLD}krinry installed successfully!${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo "Quick start:"
echo " krinry --help Show all commands"
echo " krinry install flutter Install Flutter SDK"
echo " krinry install qwen Install Qwen AI Code CLI"
echo " krinry install shell-tools Install auto-suggestions"
echo ""
echo "In a Flutter project:"
echo " krinry flutter init Setup cloud build"
echo " krinry flutter build apk Build APK in cloud"
echo " krinry flutter run web Run web server locally"
echo ""
echo "Update:"
echo " krinry update"
echo ""
echo -e "${DIM}Powered by krinry • https://github.com/krinry/krinry-cli${NC}"
echo ""
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
print_warning "Please restart your terminal or run:"
echo " source ${SHELL_RC}"
echo ""
fi