-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
132 lines (112 loc) · 2.95 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
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
set shell := ["zsh", "-uc"]
set positional-arguments
# List all available recipes
@help:
just --list
# Install dependencies
@install:
{{just_executable()}} needs npm npx pdm
npm install
pdm install
print "⚠️ A manual step is required to deploy the slideshow to GitHub Pages:"
print "Go to the repository Settings -> Pages -> Source and select GitHub Actions."
# Update dependencies
@update:
npm update
# Create a git and GitHub repo, install dependencies
@init: ensure-git ensure-github install
# Format the slides
@fmt *args="slides.md":
npx slidev format -- "$@"
# Display a live-preview of the slideshow
@preview slides="slides.md":
npx slidev --open -- "$1"
# Build the slides to HTML
@build:
npx slidev build --base=/pymi-cookiecutter
# Clean build dir
@clean:
rm -rf dist
# Test whether slides can be built to HTML
@test-build: build clean
# Test the release bump
@test-bump:
{{just_executable()}} needs cz
cz bump --check-consistency --dry-run
# Test the release workflow
@test-release: fmt test-build test-bump
# Bump the slideshow version
@release: test-release
cz bump
git push
git push --tag
# Assert a command is available
[private]
needs *commands:
#!/usr/bin/env zsh
set -euo pipefail
for cmd in "$@"; do
if ! command -v $cmd &> /dev/null; then
print "$cmd binary not found. Did you forget to install it?"
exit 1
fi
done
# Create a local git repo if not in one
[private]
@ensure-git:
#! /usr/bin/env zsh
{{just_executable()}} needs git
if ! git rev-parse --is-inside-work-tree &> /dev/null; then
git init
fi
# Ask to create a remote repo if not exists
[private]
ensure-github:
#! /usr/bin/env zsh
if ! gh repo list baggiponte | grep --quiet "/\bpymi-cookiecutter\b"; then
while true; do
print -n "No remote repository found. Do you want to create a new repository? (y/n): "
read -r REPLY
case $REPLY in
[Yy])
print -n "Do you want to create a private repository? (y/n): "
read -r PRIVATE
case $PRIVATE in
[Yy])
gh repo create baggiponte/pymi-cookiecutter --private --source=.
;;
[Nn])
gh repo create baggiponte/pymi-cookiecutter --public --source=.
;;
*)
print "Invalid input. Please enter 'y' or 'n'."
;;
esac
break
;;
[Nn])
break
;;
*)
print "Invalid input. Please enter 'y' or 'n'."
;;
esac
done
else
while true; do
print -n "A repo with this name already exists. Do you want to add it as a remote? (y/n): "
read -r REPLY
case $REPLY in
[Yy])
git remote add origin [email protected]:baggiponte/pymi-cookiecutter
break
;;
[Nn])
break
;;
*)
print "Invalid input. Please enter 'y' or 'n'."
;;
esac
done
fi