-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
78 lines (64 loc) · 2.01 KB
/
justfile
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
# Use `just <recipe>` to run a recipe
# https://just.systems/man/en/
# By default, run the `--list` command
default:
@just --list
# Variables
zellijSession := "cabinet-app"
# Open a terminal with the cabinet-app session
[group('dev')]
term-run:
zellij --layout term.kdl attach {{ zellijSession }} -c
# Kill the cabinet-app session
[group('dev')]
term-kill:
-zellij delete-session {{ zellijSession }} -f
# Kill and run a terminal with the cabinet-app session
[group('dev')]
term: term-kill term-run
# Open a browser with the application
[group('dev')]
open-browser:
xdg-open http://localhost:8001
# Interactive npm watch script selector
[group('dev')]
watch:
#!/usr/bin/env bash
set -euo pipefail
# Define the watch scripts with descriptions
watch_scripts=(
"watch: Whitelabel app"
"watch-custom: TU Graz app"
)
# Use fzf to select a script
selected_script=$(printf '%s\n' "${watch_scripts[@]}" | fzf \
--height 40% \
--layout=reverse \
--border \
--prompt='Select NPM watch script > ' \
--preview='echo "Will run: npm run $(echo {} | cut -d: -f1)"' \
--preview-window=up:1 \
| cut -d: -f1)
# Check if a script was selected
if [[ -n "$selected_script" ]]; then
# Get the full line for the selected script
full_text=$(printf '%s\n' "${watch_scripts[@]}" | grep "^$selected_script:")
# Set Zellij pane name
if command -v zellij &> /dev/null; then
zellij action rename-pane "$full_text"
fi
echo "Running: npm run $selected_script"
npm run "$selected_script"
else
echo "No script selected. Exiting."
exit 1
fi
# Format all justfiles
[group('linter')]
just-format:
#!/usr/bin/env bash
# Find all files named "justfile" recursively and run just --fmt --unstable on them
find . -type f -name "justfile" -print0 | while IFS= read -r -d '' file; do
echo "Formatting $file"
just --fmt --unstable -f "$file"
done