detached 61d242c

chore(helpers): update helper scripts for architecture refactoring

commit
61d242c66a9f774b3b75be56edf350c6c36c3f2d
author
bnema · · 2025-10-21 06:14 UTC
parent
7cca084
signature
unsigned
4 files · +60 -76
M install/bootstrap.sh +9 -0
@@ -33,6 +33,15 @@ else
3333 echo "[OK] gum already available"
3434 fi
3535
36+# Install jq for JSON parsing (presets)
37+if ! command -v jq &>/dev/null; then
38+ echo "Installing jq for preset JSON parsing..."
39+ pacman -S --needed --noconfirm jq
40+ echo "[OK] jq installed"
41+else
42+ echo "[OK] jq already available"
43+fi
44+
3645 # Any other critical dependencies that preflight needs can go here
3746 # Example: pacman -S --needed --noconfirm other-tool
3847
@@ -33,6 +33,15 @@ else
33 echo "[OK] gum already available"33 echo "[OK] gum already available"
34 fi34 fi
35 35
36+# Install jq for JSON parsing (presets)
37+if ! command -v jq &>/dev/null; then
38+ echo "Installing jq for preset JSON parsing..."
39+ pacman -S --needed --noconfirm jq
40+ echo "[OK] jq installed"
41+else
42+ echo "[OK] jq already available"
43+fi
44+
36 # Any other critical dependencies that preflight needs can go here45 # Any other critical dependencies that preflight needs can go here
37 # Example: pacman -S --needed --noconfirm other-tool46 # Example: pacman -S --needed --noconfirm other-tool
38 47
M install/helpers/cleanup.sh +10 -8
@@ -15,7 +15,6 @@ CLEANUP_MODE="${1:-default}"
1515 # Color codes for output
1616 RED='\033[0;31m'
1717 GREEN='\033[0;32m'
18-YELLOW='\033[0;33m'
1918 NC='\033[0m' # No Color
2019
2120 log_cleanup() {
@@ -187,13 +186,16 @@ cleanup_full() {
187186
188187 if [ -d /mnt ]; then
189188 log_cleanup "Removing all files and directories in /mnt..."
190- if rm -rf /mnt/* 2>/dev/null; then
191- log_success "Removed /mnt content"
192- else
193- # Try alternate approach
194- log_cleanup "Retry: Using find to remove /mnt content..."
195- find /mnt -mindepth 1 -delete 2>/dev/null || true
196- log_success "Removed /mnt content (with find)"
189+ # Safety check: only remove if /mnt exists and is not empty
190+ if [ -d "/mnt" ] && [ "$(ls -A /mnt 2>/dev/null)" ]; then
191+ if rm -rf /mnt/./* /mnt/..?* /mnt/.[!.]* 2>/dev/null; then
192+ log_success "Removed /mnt content"
193+ else
194+ # Try alternate approach
195+ log_cleanup "Retry: Using find to remove /mnt content..."
196+ find /mnt -mindepth 1 -delete 2>/dev/null || true
197+ log_success "Removed /mnt content (with find)"
198+ fi
197199 fi
198200 fi
199201
@@ -15,7 +15,6 @@ CLEANUP_MODE="${1:-default}"
15 # Color codes for output15 # Color codes for output
16 RED='\033[0;31m'16 RED='\033[0;31m'
17 GREEN='\033[0;32m'17 GREEN='\033[0;32m'
18-YELLOW='\033[0;33m'
19 NC='\033[0m' # No Color18 NC='\033[0m' # No Color
20 19
21 log_cleanup() {20 log_cleanup() {
@@ -187,13 +186,16 @@ cleanup_full() {
187 186
188 if [ -d /mnt ]; then187 if [ -d /mnt ]; then
189 log_cleanup "Removing all files and directories in /mnt..."188 log_cleanup "Removing all files and directories in /mnt..."
190- if rm -rf /mnt/* 2>/dev/null; then189+ # Safety check: only remove if /mnt exists and is not empty
191- log_success "Removed /mnt content"190+ if [ -d "/mnt" ] && [ "$(ls -A /mnt 2>/dev/null)" ]; then
192- else191+ if rm -rf /mnt/./* /mnt/..?* /mnt/.[!.]* 2>/dev/null; then
193- # Try alternate approach192+ log_success "Removed /mnt content"
194- log_cleanup "Retry: Using find to remove /mnt content..."193+ else
195- find /mnt -mindepth 1 -delete 2>/dev/null || true194+ # Try alternate approach
196- log_success "Removed /mnt content (with find)"195+ log_cleanup "Retry: Using find to remove /mnt content..."
196+ find /mnt -mindepth 1 -delete 2>/dev/null || true
197+ log_success "Removed /mnt content (with find)"
198+ fi
197 fi199 fi
198 fi200 fi
199 201
M install/helpers/logging.sh +8 -53
@@ -1,60 +1,15 @@
11 #!/bin/bash
2-# Logging system for ArchUp installer - fixes variable export issues
3-# Uses background process for log display instead of exec redirection
2+# Logging system for ArchUp installer
3+# All output logged to $ARCHUP_INSTALL_LOG_FILE
4+# Spinners handle display, errors shown automatically via --show-error
45
5-# Global variable for monitor background process
6-monitor_pid=""
7-
8-# Background process to monitor and display log in real-time
6+# No-op stubs for compatibility (log monitor removed)
97 start_log_output() {
10- local ANSI_SAVE_CURSOR="\033[s"
11- local ANSI_RESTORE_CURSOR="\033[u"
12- local ANSI_CLEAR_BELOW="\033[0J"
13- local ANSI_HIDE_CURSOR="\033[?25l"
14- local ANSI_RESET="\033[0m"
15- local ANSI_GRAY="\033[90m"
16-
17- printf $ANSI_SAVE_CURSOR
18- printf $ANSI_HIDE_CURSOR
19-
20- (
21- local log_lines=20
22- local max_line_width=$((LOGO_WIDTH - 4))
23-
24- while true; do
25- mapfile -t current_lines < <(tail -n $log_lines "$ARCHUP_INSTALL_LOG_FILE" 2>/dev/null)
26-
27- printf "${ANSI_RESTORE_CURSOR}${ANSI_CLEAR_BELOW}"
28-
29- for ((i = 0; i < log_lines; i++)); do
30- line="${current_lines[i]:-}"
31-
32- if [ ${#line} -gt $max_line_width ]; then
33- line="${line:0:$max_line_width}..."
34- fi
35-
36- if [ -n "$line" ]; then
37- printf "${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"
38- else
39- printf "${PADDING_LEFT_SPACES}\n"
40- fi
41- done
42-
43- sleep 0.1
44- done
45- ) &
46- monitor_pid=$!
8+ true
479 }
4810
4911 stop_log_output() {
50- if [ -n "${monitor_pid:-}" ]; then
51- kill $monitor_pid 2>/dev/null || true
52- wait $monitor_pid 2>/dev/null || true
53- unset monitor_pid
54-
55- # Clean up terminal state
56- printf "\033[?25h" # Show cursor
57- fi
12+ true
5813 }
5914
6015 start_install_log() {
@@ -98,8 +53,8 @@ run_logged() {
9853 echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting: $script" >> "$ARCHUP_INSTALL_LOG_FILE"
9954
10055 # Don't start/stop log monitor here - it runs continuously once started
101- # Use bash -c to create a clean subshell and redirect output to log
102- bash -c "source '$script'" </dev/null >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1
56+ # Source helpers in subshell before running the script so functions are available
57+ bash -c "source '$ARCHUP_INSTALL/helpers/all.sh' && source '$script'" </dev/null >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1
10358
10459 local exit_code=$?
10560
@@ -1,60 +1,15 @@
1 #!/bin/bash1 #!/bin/bash
2-# Logging system for ArchUp installer - fixes variable export issues2+# Logging system for ArchUp installer
3-# Uses background process for log display instead of exec redirection3+# All output logged to $ARCHUP_INSTALL_LOG_FILE
4+# Spinners handle display, errors shown automatically via --show-error
4 5
5-# Global variable for monitor background process6+# No-op stubs for compatibility (log monitor removed)
6-monitor_pid=""
7-
8-# Background process to monitor and display log in real-time
9 start_log_output() {7 start_log_output() {
10- local ANSI_SAVE_CURSOR="\033[s"8+ true
11- local ANSI_RESTORE_CURSOR="\033[u"
12- local ANSI_CLEAR_BELOW="\033[0J"
13- local ANSI_HIDE_CURSOR="\033[?25l"
14- local ANSI_RESET="\033[0m"
15- local ANSI_GRAY="\033[90m"
16-
17- printf $ANSI_SAVE_CURSOR
18- printf $ANSI_HIDE_CURSOR
19-
20- (
21- local log_lines=20
22- local max_line_width=$((LOGO_WIDTH - 4))
23-
24- while true; do
25- mapfile -t current_lines < <(tail -n $log_lines "$ARCHUP_INSTALL_LOG_FILE" 2>/dev/null)
26-
27- printf "${ANSI_RESTORE_CURSOR}${ANSI_CLEAR_BELOW}"
28-
29- for ((i = 0; i < log_lines; i++)); do
30- line="${current_lines[i]:-}"
31-
32- if [ ${#line} -gt $max_line_width ]; then
33- line="${line:0:$max_line_width}..."
34- fi
35-
36- if [ -n "$line" ]; then
37- printf "${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"
38- else
39- printf "${PADDING_LEFT_SPACES}\n"
40- fi
41- done
42-
43- sleep 0.1
44- done
45- ) &
46- monitor_pid=$!
47 }9 }
48 10
49 stop_log_output() {11 stop_log_output() {
50- if [ -n "${monitor_pid:-}" ]; then12+ true
51- kill $monitor_pid 2>/dev/null || true
52- wait $monitor_pid 2>/dev/null || true
53- unset monitor_pid
54-
55- # Clean up terminal state
56- printf "\033[?25h" # Show cursor
57- fi
58 }13 }
59 14
60 start_install_log() {15 start_install_log() {
@@ -98,8 +53,8 @@ run_logged() {
98 echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting: $script" >> "$ARCHUP_INSTALL_LOG_FILE"53 echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting: $script" >> "$ARCHUP_INSTALL_LOG_FILE"
99 54
100 # Don't start/stop log monitor here - it runs continuously once started55 # Don't start/stop log monitor here - it runs continuously once started
101- # Use bash -c to create a clean subshell and redirect output to log56+ # Source helpers in subshell before running the script so functions are available
102- bash -c "source '$script'" </dev/null >> "$ARCHUP_INSTALL_LOG_FILE" 2>&157+ bash -c "source '$ARCHUP_INSTALL/helpers/all.sh' && source '$script'" </dev/null >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1
103 58
104 local exit_code=$?59 local exit_code=$?
105 60
M install/helpers/presentation.sh +33 -15
@@ -43,23 +43,26 @@ export GUM_TABLE_PADDING="$PADDING"
4343 export GUM_CONFIRM_PADDING="$PADDING"
4444
4545 clear_logo() {
46- printf "\033[H\033[2J" # Clear screen and move cursor to top-left
46+ # Redirect all output to stderr to prevent capture by command substitution
47+ {
48+ printf "\033[H\033[2J" # Clear screen and move cursor to top-left
4749
48- # ANSI color codes: cyan=36, white=37
49- local CYAN="\033[36m"
50- local WHITE="\033[37m"
51- local RESET="\033[0m"
52- local split_pos=34
50+ # ANSI color codes: cyan=36, white=37
51+ local CYAN="\033[36m"
52+ local WHITE="\033[37m"
53+ local RESET="\033[0m"
54+ local split_pos=34
5355
54- # Print with padding and color split
55- printf "\n" # Top padding
56- while IFS= read -r line; do
57- if [ -n "$line" ]; then
58- printf "%s${CYAN}%s${WHITE}%s${RESET}\n" "$PADDING_LEFT_SPACES" "${line:0:$split_pos}" "${line:$split_pos}"
59- else
60- printf "\n"
61- fi
62- done < "$LOGO_PATH"
56+ # Print with padding and color split
57+ printf "\n" # Top padding
58+ while IFS= read -r line; do
59+ if [ -n "$line" ]; then
60+ printf "%s${CYAN}%s${WHITE}%s${RESET}\n" "$PADDING_LEFT_SPACES" "${line:0:$split_pos}" "${line:$split_pos}"
61+ else
62+ printf "\n"
63+ fi
64+ done < "$LOGO_PATH"
65+ } >&2
6366 }
6467
6568 # Show cursor (used in cleanup)
@@ -71,3 +74,18 @@ show_cursor() {
7174 hide_cursor() {
7275 printf "\033[?25l"
7376 }
77+
78+# Run a command with a gum spinner, logging output to file
79+# Usage: run_with_spinner "Title text" "command to run"
80+run_with_spinner() {
81+ local title="$1"
82+ local command="$2"
83+
84+ # Redirect only stderr to terminal for gum display
85+ # Command output goes to log file, spinner animation displays on terminal
86+ if gum spin --spinner dot --title "$title" -- bash -c "$command >> \"$ARCHUP_INSTALL_LOG_FILE\" 2>&1" 2>/dev/tty; then
87+ return 0
88+ else
89+ return 1
90+ fi
91+}
@@ -43,23 +43,26 @@ export GUM_TABLE_PADDING="$PADDING"
43 export GUM_CONFIRM_PADDING="$PADDING"43 export GUM_CONFIRM_PADDING="$PADDING"
44 44
45 clear_logo() {45 clear_logo() {
46- printf "\033[H\033[2J" # Clear screen and move cursor to top-left46+ # Redirect all output to stderr to prevent capture by command substitution
47+ {
48+ printf "\033[H\033[2J" # Clear screen and move cursor to top-left
47 49
48- # ANSI color codes: cyan=36, white=3750+ # ANSI color codes: cyan=36, white=37
49- local CYAN="\033[36m"51+ local CYAN="\033[36m"
50- local WHITE="\033[37m"52+ local WHITE="\033[37m"
51- local RESET="\033[0m"53+ local RESET="\033[0m"
52- local split_pos=3454+ local split_pos=34
53 55
54- # Print with padding and color split56+ # Print with padding and color split
55- printf "\n" # Top padding57+ printf "\n" # Top padding
56- while IFS= read -r line; do58+ while IFS= read -r line; do
57- if [ -n "$line" ]; then59+ if [ -n "$line" ]; then
58- printf "%s${CYAN}%s${WHITE}%s${RESET}\n" "$PADDING_LEFT_SPACES" "${line:0:$split_pos}" "${line:$split_pos}"60+ printf "%s${CYAN}%s${WHITE}%s${RESET}\n" "$PADDING_LEFT_SPACES" "${line:0:$split_pos}" "${line:$split_pos}"
59- else61+ else
60- printf "\n"62+ printf "\n"
61- fi63+ fi
62- done < "$LOGO_PATH"64+ done < "$LOGO_PATH"
65+ } >&2
63 }66 }
64 67
65 # Show cursor (used in cleanup)68 # Show cursor (used in cleanup)
@@ -71,3 +74,18 @@ show_cursor() {
71 hide_cursor() {74 hide_cursor() {
72 printf "\033[?25l"75 printf "\033[?25l"
73 }76 }
77+
78+# Run a command with a gum spinner, logging output to file
79+# Usage: run_with_spinner "Title text" "command to run"
80+run_with_spinner() {
81+ local title="$1"
82+ local command="$2"
83+
84+ # Redirect only stderr to terminal for gum display
85+ # Command output goes to log file, spinner animation displays on terminal
86+ if gum spin --spinner dot --title "$title" -- bash -c "$command >> \"$ARCHUP_INSTALL_LOG_FILE\" 2>&1" 2>/dev/tty; then
87+ return 0
88+ else
89+ return 1
90+ fi
91+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close