-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
186 lines (159 loc) · 6.15 KB
/
justfile
File metadata and controls
186 lines (159 loc) · 6.15 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
# Formula Metadata Crawler Justfile
# Crawl formula metadata and git hosting stats (GitHub/GitLab/Codeberg)
# Default recipe - show help
default:
@just --list
# Generate formula metadata report
status:
python3 formula-status/generate_formula_status.py --output formula-status/formula-status.md
# Generate with verbose logging
status-verbose:
python3 formula-status/generate_formula_status.py --output formula-status/formula-status.md --verbose
# Refresh git stats cache
status-refresh:
python3 formula-status/generate_formula_status.py --output formula-status/formula-status.md --refresh
# Run with custom number of workers
status-workers WORKERS="10":
python3 formula-status/generate_formula_status.py --output formula-status/formula-status.md --workers {{WORKERS}}
# Run in background with logging
status-background:
#!/usr/bin/env bash
nohup python3 formula-status/generate_formula_status.py --output formula-status/formula-status.md --verbose > formula-status.log 2>&1 &
echo "Crawler running in background (PID: $!)"
echo "Follow logs with: just status-logs"
# Watch progress in real-time
status-watch:
#!/usr/bin/env bash
while true; do
clear
echo "=== Formula Metadata Crawler Progress ==="
echo ""
date
echo ""
if pgrep -f "generate_formula_status.py" > /dev/null; then
echo "✓ Running"
echo ""
if [ -f formula-status/formula-status.md ]; then
echo "formula-status/formula-status.md:"
echo " Last modified: $(stat -f "%Sm" formula-status/formula-status.md)"
echo " Size: $(wc -c < formula-status/formula-status.md) bytes"
FORMULAS=$(grep -c '^| [a-z]' formula-status/formula-status.md 2>/dev/null || echo 0)
echo " Formulas processed: $FORMULAS"
fi
if [ -f .cache/formula_metadata.json ]; then
echo ""
echo "Cache:"
CACHED=$(jq 'keys | length' .cache/formula_metadata.json 2>/dev/null || echo 0)
echo " Repos cached: $CACHED"
fi
else
echo "✗ Not running"
break
fi
echo ""
echo "Press Ctrl+C to stop watching"
sleep 2
done
# Check if crawler is running
status-check:
#!/usr/bin/env bash
if pgrep -f "generate_formula_status.py" > /dev/null; then
echo "✓ Formula metadata crawler is running"
pgrep -f "generate_formula_status.py" | xargs ps -p
echo ""
if [ -f formula-status/formula-status.md ]; then
echo "formula-status/formula-status.md:"
echo " Last modified: $(stat -f "%Sm" formula-status/formula-status.md)"
FORMULAS=$(grep -c '^| [a-z]' formula-status/formula-status.md 2>/dev/null || echo 0)
echo " Formulas processed: $FORMULAS"
fi
else
echo "✗ Formula metadata crawler is not running"
fi
# Kill running crawler
status-kill:
#!/usr/bin/env bash
if pgrep -f "generate_formula_status.py" > /dev/null; then
pkill -f "generate_formula_status.py"
echo "✓ Killed formula metadata crawler"
else
echo "✗ No running crawler found"
fi
# Follow logs
status-logs:
#!/usr/bin/env bash
if [ -f formula-status.log ]; then
tail -f formula-status.log
else
echo "No log file found. Run 'just status-background' first."
fi
# View generated report
view:
cat formula-status/formula-status.md
# Count formulas
count:
#!/usr/bin/env bash
if [ ! -f formula-status/formula-status.md ]; then
echo "formula-status/formula-status.md not found. Run 'just status' first."
exit 1
fi
TOTAL=$(grep -c '^| [a-z]' formula-status/formula-status.md 2>/dev/null || echo 0)
echo "Total formulas: $TOTAL"
# Show top formulas by stars
top N="10":
#!/usr/bin/env bash
if [ ! -f formula-status/formula-status.md ]; then
echo "formula-status/formula-status.md not found. Run 'just status' first."
exit 1
fi
echo "Top {{N}} formulas by stars:"
grep '^| [a-z]' formula-status/formula-status.md | head -{{N}}
# Clean cache
clean-cache:
rm -rf .cache/formula_metadata.json
@echo "Cache cleaned"
# Clean reports
clean-reports:
rm -f formula-status/formula-status.md
@echo "Reports cleaned"
# Clean logs
clean-logs:
rm -f formula-status.log nohup.out
@echo "Logs cleaned"
# Clean everything
clean: clean-cache clean-reports clean-logs
@echo "All artifacts cleaned"
# Validate generated report
validate:
#!/usr/bin/env bash
if [ ! -f formula-status/formula-status.md ]; then
echo "❌ formula-status/formula-status.md not found"
exit 1
fi
SIZE=$(wc -c < formula-status/formula-status.md)
if [ "$SIZE" -lt 500 ]; then
echo "❌ formula-status/formula-status.md seems too small ($SIZE bytes)"
exit 1
fi
if ! grep -q "# Formula Metadata" formula-status/formula-status.md; then
echo "❌ Missing header"
exit 1
fi
echo "✅ formula-status/formula-status.md validation passed"
echo " Size: $SIZE bytes"
FORMULAS=$(grep -c '^| [a-z]' formula-status/formula-status.md 2>/dev/null || echo 0)
echo " Formulas: $FORMULAS"
# Example output
example:
@echo "Example Formula Metadata Table:"
@echo ""
@echo "| Formula | Description | Stars | Forks | Last Commit | Last Release | License | Bottle | Livecheck | Homepage |"
@echo "| ------- | ----------- | ----- | ----- | ----------- | ------------ | ------- | ------ | --------- | -------- |"
@echo "| awesome-tool | An awesome CLI tool for developers | 1234 | 56 | 2024-12-10 | 2024-11-20 | MIT | ✓ | ✓ | [link](https://github.com/user/awesome-tool) |"
@echo "| cool-app | A cool application | 567 | 23 | 2024-12-12 | - | Apache-2.0 | ✓ | - | [link](https://gitlab.com/user/cool-app) |"
# Install dependencies check
install-deps:
@echo "Checking dependencies..."
@which python3 > /dev/null || (echo "❌ python3 not found" && exit 1)
@which gh > /dev/null || (echo "❌ gh CLI not found" && exit 1)
@echo "✅ All dependencies installed"