-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
justfile
101 lines (82 loc) · 2.73 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Use `just <recipe>` to run a recipe
# https://just.systems/man/en/
# By default, run the `--list` command
default:
@just --list
# Variables
zellijSession := "qon-web-companion"
projectName := "qon-web-companion"
transferDir := `if [ -d "$HOME/NextcloudPrivate/Transfer" ]; then echo "$HOME/NextcloudPrivate/Transfer"; else echo "$HOME/Nextcloud/Transfer"; fi`
# Aliases
alias dev := run
# Open a terminal with the project session
[group('dev')]
term-run:
zellij --layout term.kdl attach {{ zellijSession }} -c
# Kill the project session
[group('dev')]
term-kill:
-zellij delete-session {{ zellijSession }} -f
# Kill and run a terminal with the project session
[group('dev')]
term: term-kill term-run
# Apply the patch to the project repository
[group('patch')]
git-apply-patch:
git apply {{ transferDir }}/{{ projectName }}.patch
# Create a patch from the staged changes in the project repository
[group('patch')]
@git-create-patch:
echo "transferDir: {{ transferDir }}"
git diff --no-ext-diff --staged --binary > {{ transferDir }}/{{ projectName }}.patch
ls -l1t {{ transferDir }}/ | head -2
# Download the translations from Crowdin
[group('translations')]
translations-download:
crowdin download
# Upload the translations to Crowdin
[group('translations')]
translations-upload:
crowdin upload
# Interactive npm run dev script selector
[group('dev')]
run:
#!/usr/bin/env bash
set -euo pipefail
# Define the watch scripts with descriptions
watch_scripts=(
"dev-chrome: Google Chrome"
"dev-firefox: Mozilla Firefox"
)
# Use fzf to select a script
selected_script=$(printf '%s\n' "${watch_scripts[@]}" | fzf \
--height 40% \
--layout=reverse \
--border \
--prompt='Select NPM run 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