-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathjustfile
More file actions
187 lines (160 loc) · 4.83 KB
/
justfile
File metadata and controls
187 lines (160 loc) · 4.83 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
187
NAME := 'television'
# List all available commands
default:
just --list
alias r := run-staging
# Run the program in debug mode with logs enabled
@run:
echo "Running {{ NAME }}..."
RUST_LOG=debug cargo run
echo "Done"
# Run the program in staging mode (optimized but no lto)
@run-staging:
echo "Running {{ NAME }} in staging mode..."
cargo run --profile staging
echo "Done"
# Setup the project environment for local development
@setup:
echo "Setting up {{ NAME }}..."
echo "Installing git hooks..."
mkdir -p .git/hooks
echo "just fix" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo "Installing dependencies..."
cargo build
echo "Done"
# Clean up cargo build artifacts
@clean:
echo "Cleaning up {{ NAME }}..."
echo "Removing git hooks..."
rm -f .git/hooks/pre-commit
echo "Done"
alias c := check
# Check the project for errors and warnings
@check:
echo "Checking {{ NAME }}..."
cargo check
echo "Done"
# Format the code using cargo fmt
@format:
echo "Formatting {{ NAME }}..."
cargo fmt --all
echo "Done"
# Lint the code using cargo clippy
@lint:
echo "Linting {{ NAME }}..."
cargo clippy --all-targets --all-features -- -D warnings
echo "Done"
alias f := fix
# Fix linting and formatting errors
@fix:
echo "Fixing {{ NAME }}..."
cargo fix --allow-dirty --allow-staged
just format
just lint
alias t := test
# Run the tests for the project
@test:
echo "Running {{ NAME }}'s test suite..."
cargo test --all --all-features -- --nocapture
echo "Done"
# Run tests with faster delays for local development
@test-fast:
echo "Running {{ NAME }}'s test suite (fast mode)..."
TV_TEST_DELAY_MS=50 cargo test --all --all-features -- --nocapture
echo "Done"
alias b := build
# Build the project with the specified profile (dev by default)
@build profile='dev':
echo "Building {{ NAME }} for profile: {{ profile }}..."
cargo build --profile {{ profile }}
echo "Done"
# Build the project in release mode
br: (build 'release')
# Generate a dev shell integration script for local development
@generate-dev-shell-integration shell='zsh':
cargo run -- init {{ shell }} | sed 's/tv /.\/target\/debug\/tv /' > dev_shell_integration.{{ shell }}
echo 'To activate {{ shell }} dev integration, run: `source dev_shell_integration.{{ shell }}`'
# Update the project's changelog
@update-changelog:
echo "Updating changelog..."
git cliff -o CHANGELOG.md
echo "Done"
alias m := update-man
# Update the project's manpages
update-man: build
#!/usr/bin/env sh
echo "Checking for manpages updates..."
if ! diff ./man/tv.1 ./target/assets/tv.1 > /dev/null;
then cp ./target/assets/tv.1 ./man/tv.1 && git add ./man/tv.1 && echo "Updated manpages"
else echo "No changes to manpages"
fi
@publish:
echo "Publishing {{ NAME }}..."
cargo publish --all-features
echo "Done"
@commit-release:
#!/usr/bin/env sh
version=$(grep -E '^\s*version\s*=' Cargo.toml | cut -d '"' -f 2)
git commit -am "chore: release version $version"
git tag "$version"
@push-release:
#!/usr/bin/env sh
echo "Pushing changes and tags to remote..."
git push origin main --tags
echo "Done"
alias rl := release
# Publish a new release (major, minor, or patch)
@release kind='patch':
echo "Releasing {{ NAME }} (kind: {{ kind }})..."
just bump-version {{ kind }}
just update-man
just commit-release
just publish
# Bump version
bump-version kind='patch':
#!/usr/bin/env sh
echo "Bumping version (kind: {{ kind }})..."
# bump version (major, minor, patch)
version=$(grep -E '^\s*version\s*=' Cargo.toml | cut -d '"' -f 2)
kind="{{ kind }}"
echo "Current version is: $version"
if [ "$kind" = "major" ]; then
new_version=$(echo $version | awk -F. -v OFS=. '{$1++; $2=0; $3=0} 1')
elif [ "$kind" = "minor" ]; then
new_version=$(echo $version | awk -F. -v OFS=. '{$2++; $3=0} 1')
elif [ "$kind" = "patch" ]; then
new_version=$(echo $version | awk -F. -v OFS=. '{$3++} 1')
else
echo "Invalid kind: $kind"
exit 1
fi
echo "Bumping to: $new_version"
echo "Updating version in Cargo.toml..."
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/version = \"$version\"/version = \"$new_version\"/" Cargo.toml
else
sed -i "s/version = \"$version\"/version = \"$new_version\"/" Cargo.toml
fi
git add Cargo.toml
echo "Done"
# Start a local development server for the project's website
@start-website:
cd website && pnpm install && pnpm start
# Generate cable channel docs
@generate-cable-docs:
echo "Generating cable channel docs..."
python -m venv .venv && \
source .venv/bin/activate && \
python -m ensurepip && \
python -m pip install toml && \
python scripts/generate_cable_docs.py
echo "Docs generated in docs/cable_channels.md"
rm -rf .venv
# Update CLI docs from tv --help
@update-cli-help:
sh -ec 'help_output=$(cargo run --quiet -- --help); { \
printf "%s\n" '\''```text'\''; \
printf "%s\n" "$help_output"; \
printf "%s\n" '\''```'\''; \
} > docs/reference/01-cli.md'