-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
111 lines (99 loc) · 3.85 KB
/
Copy pathJustfile
File metadata and controls
111 lines (99 loc) · 3.85 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
# Build transpiler (release)
build:
cd {{justfile_directory()}}/rust && cargo build --release
# Compile .hyper files (debug build)
run *files:
cargo run -q --manifest-path {{justfile_directory()}}/rust/Cargo.toml -- generate {{files}}
# Run all checks (fmt, clippy, tests)
check:
cd {{justfile_directory()}}/rust && cargo fmt --check
cd {{justfile_directory()}}/rust && cargo clippy -- -D warnings
cd {{justfile_directory()}}/rust && cargo test
# Run transpiler tests
test:
cd {{justfile_directory()}}/rust && cargo test
# Format code
fmt:
cd {{justfile_directory()}}/rust && cargo fmt
# Auto-fix clippy warnings
fix:
cd {{justfile_directory()}}/rust && cargo clippy --fix --allow-dirty
# Preview compiled output as .preview.py files, clean up on Enter
test-preview *filter:
#!/usr/bin/env bash
set -euo pipefail
cd "{{justfile_directory()}}/rust"
previews=()
for f in $(find tests -name "*.hyper" ! -path "*/errors/*"); do
if [ -n "{{filter}}" ] && [[ "$f" != *"{{filter}}"* ]]; then continue; fi
name=$(basename "$f" .hyper)
out="${f%.hyper}.preview.py"
cargo run --bin hyper -q -- generate --stdin --name "$name" < "$f" 2>/dev/null > "$out" && previews+=("$out")
done
if [ ${#previews[@]} -eq 0 ]; then echo "No matching files."; exit 0; fi
echo "${#previews[@]} .preview.py file(s) written:"
printf " %s\n" "${previews[@]}"
read -p "Press Enter to clean up..."
for f in "${previews[@]}"; do rm -f "$f"; done
# Apply expected test updates (prompts for confirmation)
test-accept *filter:
cd {{justfile_directory()}}/rust && cargo run --bin accept_expected -- {{filter}} --apply
# Release a new version
release version:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! "{{version}}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: version must be semver (e.g. 0.2.0), got '{{version}}'"
exit 1
fi
if [ -n "$(git status --porcelain)" ]; then
echo "Error: working tree is dirty. Commit or stash changes first."
exit 1
fi
just check
sed -i '' 's/^version = ".*"/version = "{{version}}"/' pyproject.toml rust/Cargo.toml
sed -i '' 's/^pluginVersion = .*/pluginVersion = {{version}}/' editors/jetbrains/gradle.properties
cd rust && cargo check --quiet 2>/dev/null
git add pyproject.toml rust/Cargo.toml rust/Cargo.lock editors/jetbrains/gradle.properties
git commit -m "Release v{{version}}"
git tag "v{{version}}"
echo ""
echo "Ready to publish. Run:"
echo " git push && git push --tags"
# Build JetBrains plugin (builds transpiler + bundles binary + builds plugin)
build-plugin: build _bundle
#!/usr/bin/env bash
set -e
ROOT="{{justfile_directory()}}"
cd "$ROOT/editors/jetbrains" && ./gradlew clean buildPlugin
cp "$ROOT/editors/jetbrains/build/distributions"/*.zip "$ROOT/editors/jetbrains/"
# Run JetBrains plugin sandbox
run-plugin: build-plugin
cd {{justfile_directory()}}/editors/jetbrains && ./gradlew runIde
# Run JetBrains plugin tests
test-plugin:
cd {{justfile_directory()}}/rust && cargo build -q
cd {{justfile_directory()}}/editors/jetbrains && ./gradlew test
# Bundle transpiler binary into plugin resources
[private]
_bundle:
#!/usr/bin/env bash
set -e
ROOT="{{justfile_directory()}}"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
darwin) OS_NAME="darwin" ;;
linux) OS_NAME="linux" ;;
*) OS_NAME="$OS" ;;
esac
case "$ARCH" in
arm64|aarch64) ARCH_NAME="arm64" ;;
x86_64|amd64) ARCH_NAME="x64" ;;
*) ARCH_NAME="$ARCH" ;;
esac
BINARY_NAME="hyper-${OS_NAME}-${ARCH_NAME}"
SRC="$ROOT/rust/target/release/hyper"
DEST="$ROOT/editors/jetbrains/src/main/resources/bin/${BINARY_NAME}"
mkdir -p "$(dirname "$DEST")"
cp "$SRC" "$DEST"