Skip to content

Commit 1d90b76

Browse files
authored
👣 [just] gh-process v4.4 fixes bugs and adds install script for prereqs (#17)
1 parent 67f9e5c commit 1d90b76

File tree

2 files changed

+345
-4
lines changed

2 files changed

+345
-4
lines changed

‎.just/gh-process.just‎

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ sync:
1313
git pull
1414
git status --porcelain # stp
1515

16-
# PR create v4.0
16+
# PR create v4.4
1717
[group('Process')]
1818
pr: _has_commits && pr_checks
1919
#!/usr/bin/env bash
@@ -143,10 +143,12 @@ _on_a_pull_request: _on_a_branch
143143
[group('Process')]
144144
release rel_version:
145145
gh release create {{rel_version}} --generate-notes
146+
sleep 1
147+
git pull
146148

147149
# watch GHAs then check for Copilot suggestions
148150
[group('Process')]
149-
pr_checks: _on_a_pull_request
151+
pr_checks: _on_a_pull_request && claude_review
150152
#!/usr/bin/env bash
151153

152154
gh pr checks --watch -i 5
@@ -185,6 +187,13 @@ pr_checks: _on_a_pull_request
185187
}
186188
'
187189

190+
# chains to claude_review
191+
192+
# Claude's latest PR code review
193+
[group('Process')]
194+
claude_review: _on_a_pull_request
195+
#!/usr/bin/env bash
196+
188197
# did Claude comment?
189198
echo -e "\n\n🟧🟠🔶🔸 Claude:"
190199
gh pr view --json comments --jq '[.comments[] | select(.author.login == "claude")] | last | .body'
@@ -219,8 +228,8 @@ pr_update: _on_a_pull_request
219228
# look for content after the Done section's commit list
220229
awk 'BEGIN {in_done=0; after_done=0; empty_count=0}
221230
/^## Done/ {in_done=1; next}
222-
in_done && /^$/ {empty_count++; if (empty_count >= 2) after_done=1; next}
223-
in_done && /^- / {next}
231+
in_done && !after_done && /^$/ {empty_count++; if (empty_count >= 2) after_done=1; next}
232+
in_done && !after_done && /^- / {next}
224233
after_done {print}' "$bodyfile" > "$other_sections"
225234
fi
226235

@@ -317,3 +326,77 @@ pr_verify: _on_a_pull_request
317326

318327
# cleanup
319328
rm "$stdin_content" "$bodyfile" "$updated_body"
329+
330+
# check how long ago the last release was
331+
[group('Process')]
332+
release_age:
333+
#!/usr/bin/env bash
334+
set -euo pipefail # strict mode
335+
336+
echo "{{BLUE}}Checking last release age...{{NORMAL}}"
337+
echo ""
338+
339+
# Get the latest release tag using JSON for robustness
340+
release_tag=$(gh release list --limit 1 --json tagName -q '.[0].tagName' 2>/dev/null)
341+
342+
if [[ -z "$release_tag" ]]; then
343+
echo "{{YELLOW}}No releases found{{NORMAL}}"
344+
exit 0
345+
fi
346+
347+
# Get release date using JSON
348+
release_date=$(gh release view "$release_tag" --json publishedAt -q .publishedAt 2>/dev/null | cut -d'T' -f1)
349+
350+
if [[ -z "$release_date" ]]; then
351+
echo "{{RED}}Could not determine release date{{NORMAL}}"
352+
exit 1
353+
fi
354+
355+
# Convert release date to epoch seconds (cross-platform)
356+
# Try GNU date first (Linux), then BSD date (macOS)
357+
if release_epoch=$(date -d "$release_date" +%s 2>/dev/null); then
358+
# GNU date (Linux)
359+
current_epoch=$(date +%s)
360+
elif release_epoch=$(date -j -f "%Y-%m-%d" "$release_date" +%s 2>/dev/null); then
361+
# BSD date (macOS)
362+
current_epoch=$(date +%s)
363+
else
364+
echo "{{RED}}Could not parse release date: $release_date{{NORMAL}}"
365+
exit 1
366+
fi
367+
368+
days_old=$(( (current_epoch - release_epoch) / 86400 ))
369+
370+
# Count commits since last release on main/master branch
371+
if git rev-parse --verify main >/dev/null 2>&1; then
372+
main_branch="main"
373+
elif git rev-parse --verify master >/dev/null 2>&1; then
374+
main_branch="master"
375+
else
376+
echo "{{RED}}Could not find main or master branch{{NORMAL}}"
377+
exit 1
378+
fi
379+
380+
commits_since=$(git rev-list --count "${release_tag}..${main_branch}" 2>/dev/null || echo "0")
381+
382+
# Display results with color coding
383+
echo "Latest release: {{CYAN}}$release_tag{{NORMAL}}"
384+
echo "Published: {{CYAN}}$release_date{{NORMAL}}"
385+
386+
if [[ $days_old -gt 60 ]]; then
387+
echo "Age: {{YELLOW}}$days_old days old{{NORMAL}}"
388+
echo "Commits since release: {{YELLOW}}$commits_since{{NORMAL}}"
389+
echo ""
390+
echo "{{YELLOW}}âš  Release is more than 60 days old - consider creating a new release{{NORMAL}}"
391+
else
392+
echo "Age: {{GREEN}}$days_old days old{{NORMAL}}"
393+
echo "Commits since release: {{GREEN}}$commits_since{{NORMAL}}"
394+
fi
395+
396+
# push changes, update PR description, and watch GHAs
397+
[group('Process')]
398+
again:
399+
git push
400+
just pr_update
401+
sleep 2
402+
just pr_checks
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
#!/usr/bin/env bash
2+
# Install prerequisites for just recipes
3+
#
4+
# Usage: ./.just/install-prerequisites.sh
5+
#
6+
# This script checks for required tools (just, gh, shellcheck, markdownlint-cli2, jq)
7+
# and helps install them:
8+
#
9+
# - macOS: Automatically installs missing tools using Homebrew
10+
# - Linux: Displays installation commands for manual execution
11+
# - Other: Shows links to installation documentation
12+
#
13+
# Run multiple times to verify installations completed successfully.
14+
15+
set -euo pipefail # strict mode
16+
17+
# ANSI color codes
18+
RED='\033[0;31m'
19+
GREEN='\033[0;32m'
20+
YELLOW='\033[1;33m'
21+
BLUE='\033[0;34m'
22+
CYAN='\033[0;36m'
23+
MAGENTA='\033[0;35m'
24+
NC='\033[0m' # No Color
25+
26+
echo -e "${MAGENTA}Checking prerequisites for just recipes...${NC}"
27+
echo ""
28+
29+
MISSING=()
30+
INSTALLED=()
31+
32+
# check each prerequisite
33+
if command -v just &> /dev/null; then
34+
INSTALLED+=("just")
35+
else
36+
MISSING+=("just")
37+
fi
38+
39+
if command -v gh &> /dev/null; then
40+
INSTALLED+=("gh")
41+
else
42+
MISSING+=("gh")
43+
fi
44+
45+
if command -v shellcheck &> /dev/null; then
46+
INSTALLED+=("shellcheck")
47+
else
48+
MISSING+=("shellcheck")
49+
fi
50+
51+
if command -v markdownlint-cli2 &> /dev/null; then
52+
INSTALLED+=("markdownlint-cli2")
53+
else
54+
MISSING+=("markdownlint-cli2")
55+
fi
56+
57+
if command -v jq &> /dev/null; then
58+
INSTALLED+=("jq")
59+
else
60+
MISSING+=("jq")
61+
fi
62+
63+
# report what's already installed
64+
if [[ ${#INSTALLED[@]} -gt 0 ]]; then
65+
echo -e "${GREEN}Already installed:${NC}"
66+
for tool in "${INSTALLED[@]}"; do
67+
echo -e " ${GREEN}✓${NC} $tool"
68+
done
69+
echo ""
70+
fi
71+
72+
# if everything is installed, we're done
73+
if [[ ${#MISSING[@]} -eq 0 ]]; then
74+
echo -e "${GREEN}All prerequisites are installed!${NC}"
75+
exit 0
76+
fi
77+
78+
# report what's missing
79+
echo -e "${YELLOW}Missing prerequisites:${NC}"
80+
for tool in "${MISSING[@]}"; do
81+
echo -e " ${YELLOW}✗${NC} $tool"
82+
done
83+
echo ""
84+
85+
# detect OS and provide installation instructions
86+
if [[ "$OSTYPE" == "darwin"* ]]; then
87+
echo -e "${BLUE}Detected macOS. Installing with Homebrew...${NC}"
88+
echo ""
89+
90+
if ! command -v brew &> /dev/null; then
91+
echo -e "${RED}Homebrew is not installed!${NC}"
92+
echo "Install Homebrew first: https://brew.sh"
93+
exit 1
94+
fi
95+
96+
INSTALL_SUCCESS=()
97+
INSTALL_FAILED=()
98+
99+
for tool in "${MISSING[@]}"; do
100+
case "$tool" in
101+
just)
102+
echo -e "${CYAN}Installing just...${NC}"
103+
if brew install just; then
104+
INSTALL_SUCCESS+=("just")
105+
else
106+
INSTALL_FAILED+=("just")
107+
echo -e "${RED}Failed to install just${NC}"
108+
fi
109+
;;
110+
gh)
111+
echo -e "${CYAN}Installing GitHub CLI...${NC}"
112+
if brew install gh; then
113+
INSTALL_SUCCESS+=("gh")
114+
echo -e "${YELLOW}Don't forget to authenticate: gh auth login${NC}"
115+
else
116+
INSTALL_FAILED+=("gh")
117+
echo -e "${RED}Failed to install gh${NC}"
118+
fi
119+
;;
120+
shellcheck)
121+
echo -e "${CYAN}Installing shellcheck...${NC}"
122+
if brew install shellcheck; then
123+
INSTALL_SUCCESS+=("shellcheck")
124+
else
125+
INSTALL_FAILED+=("shellcheck")
126+
echo -e "${RED}Failed to install shellcheck${NC}"
127+
fi
128+
;;
129+
markdownlint-cli2)
130+
echo -e "${CYAN}Installing markdownlint-cli2...${NC}"
131+
if ! command -v npm &> /dev/null; then
132+
echo -e "${RED}npm is not installed! Install Node.js first.${NC}"
133+
echo "Install Node.js: brew install node"
134+
INSTALL_FAILED+=("markdownlint-cli2")
135+
elif npm install -g markdownlint-cli2; then
136+
INSTALL_SUCCESS+=("markdownlint-cli2")
137+
else
138+
INSTALL_FAILED+=("markdownlint-cli2")
139+
echo -e "${RED}Failed to install markdownlint-cli2${NC}"
140+
fi
141+
;;
142+
jq)
143+
echo -e "${CYAN}Installing jq...${NC}"
144+
if brew install jq; then
145+
INSTALL_SUCCESS+=("jq")
146+
else
147+
INSTALL_FAILED+=("jq")
148+
echo -e "${RED}Failed to install jq${NC}"
149+
fi
150+
;;
151+
esac
152+
done
153+
154+
echo ""
155+
if [[ ${#INSTALL_SUCCESS[@]} -gt 0 ]]; then
156+
echo -e "${GREEN}Successfully installed:${NC}"
157+
for tool in "${INSTALL_SUCCESS[@]}"; do
158+
echo -e " ${GREEN}✓${NC} $tool"
159+
done
160+
fi
161+
162+
if [[ ${#INSTALL_FAILED[@]} -gt 0 ]]; then
163+
echo ""
164+
echo -e "${RED}Failed to install:${NC}"
165+
for tool in "${INSTALL_FAILED[@]}"; do
166+
echo -e " ${RED}✗${NC} $tool"
167+
done
168+
echo ""
169+
echo -e "${YELLOW}Run this script again to retry or install manually.${NC}"
170+
exit 1
171+
fi
172+
173+
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
174+
echo -e "${BLUE}Detected Linux. Showing installation commands...${NC}"
175+
echo ""
176+
177+
# detect package manager
178+
if command -v apt-get &> /dev/null; then
179+
PKG_MGR="apt-get"
180+
echo -e "${BLUE}Using apt-get package manager${NC}"
181+
elif command -v dnf &> /dev/null; then
182+
PKG_MGR="dnf"
183+
echo -e "${BLUE}Using dnf package manager${NC}"
184+
elif command -v pacman &> /dev/null; then
185+
PKG_MGR="pacman"
186+
echo -e "${BLUE}Using pacman package manager${NC}"
187+
else
188+
echo -e "${YELLOW}Could not detect package manager. Manual installation required.${NC}"
189+
PKG_MGR="manual"
190+
fi
191+
192+
for tool in "${MISSING[@]}"; do
193+
case "$tool" in
194+
just)
195+
if [[ "$PKG_MGR" == "apt-get" ]]; then
196+
echo -e "${CYAN}Install just:${NC}"
197+
echo " wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null"
198+
echo " echo \"deb [arch=all,\$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr \$(lsb_release -cs)\" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list"
199+
echo " sudo apt update && sudo apt install just"
200+
elif [[ "$PKG_MGR" == "dnf" ]]; then
201+
echo -e "${CYAN}Install just:${NC} sudo dnf install just"
202+
elif [[ "$PKG_MGR" == "pacman" ]]; then
203+
echo -e "${CYAN}Install just:${NC} sudo pacman -S just"
204+
else
205+
echo -e "${CYAN}Install just:${NC} See https://github.com/casey/just#installation"
206+
fi
207+
;;
208+
gh)
209+
echo -e "${CYAN}Install GitHub CLI:${NC} See https://github.com/cli/cli/blob/trunk/docs/install_linux.md"
210+
echo -e "${YELLOW}Don't forget to authenticate: gh auth login${NC}"
211+
;;
212+
shellcheck)
213+
if [[ "$PKG_MGR" == "apt-get" ]]; then
214+
echo -e "${CYAN}Install shellcheck:${NC} sudo apt-get install shellcheck"
215+
elif [[ "$PKG_MGR" == "dnf" ]]; then
216+
echo -e "${CYAN}Install shellcheck:${NC} sudo dnf install shellcheck"
217+
elif [[ "$PKG_MGR" == "pacman" ]]; then
218+
echo -e "${CYAN}Install shellcheck:${NC} sudo pacman -S shellcheck"
219+
fi
220+
;;
221+
markdownlint-cli2)
222+
echo -e "${CYAN}Install markdownlint-cli2:${NC} npm install -g markdownlint-cli2"
223+
echo -e "${YELLOW}(Requires Node.js/npm)${NC}"
224+
;;
225+
jq)
226+
if [[ "$PKG_MGR" == "apt-get" ]]; then
227+
echo -e "${CYAN}Install jq:${NC} sudo apt-get install jq"
228+
elif [[ "$PKG_MGR" == "dnf" ]]; then
229+
echo -e "${CYAN}Install jq:${NC} sudo dnf install jq"
230+
elif [[ "$PKG_MGR" == "pacman" ]]; then
231+
echo -e "${CYAN}Install jq:${NC} sudo pacman -S jq"
232+
fi
233+
;;
234+
esac
235+
done
236+
237+
echo ""
238+
echo -e "${YELLOW}Note: Commands shown above for manual execution.${NC}"
239+
echo -e "${YELLOW}Run this script again after installing to verify.${NC}"
240+
241+
else
242+
echo -e "${YELLOW}Unsupported OS: $OSTYPE${NC}"
243+
echo -e "${YELLOW}Please install these tools manually:${NC}"
244+
for tool in "${MISSING[@]}"; do
245+
echo " - $tool"
246+
done
247+
echo ""
248+
echo -e "${CYAN}Installation resources:${NC}"
249+
echo " just: https://github.com/casey/just#installation"
250+
echo " gh: https://cli.github.com/manual/installation"
251+
echo " shellcheck: https://github.com/koalaman/shellcheck#installing"
252+
echo " markdownlint-cli2: npm install -g markdownlint-cli2"
253+
echo " jq: https://stedolan.github.io/jq/download/"
254+
exit 1
255+
fi
256+
257+
echo ""
258+
echo -e "${GREEN}Installation complete! Run this script again to verify.${NC}"

0 commit comments

Comments
 (0)