forked from kurtbuilds/libninja
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
139 lines (109 loc) · 3.44 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
132
133
134
135
136
137
138
139
set positional-arguments
set dotenv-load := true
help:
@just --list --unsorted
build:
cargo build
alias b := build
run *args:
cargo run -- "$@"
alias r := run
release:
cargo build --release
example EXAMPLE:
cargo run --example {{ EXAMPLE }}
alias e := example
install:
just clean release
cargo install --path libninja --force
check:
cargo check
alias c := check
watch:
cargo watch
fix:
cargo clippy --fix
# Bump version. level=major,minor,patch
version level:
git diff-index --exit-code HEAD > /dev/null || ! echo You have untracked changes. Commit your changes before bumping the version.
cargo set-version --bump {{level}}
cargo update # This bumps Cargo.lock
VERSION=$(rg "version = \"([0-9.]+)\"" -or '$1' Cargo.toml | head -n1) && \
git commit -am "Bump version {{level}} to $VERSION" && \
git tag v$VERSION && \
git push origin v$VERSION
git push
serve:
cargo run --example petstore-server -F actix
publish:
cargo publish
patch: test
just version patch
just publish
clean MODE='debug':
checkexec ${CARGO_TARGET_DIR:-target}/{{MODE}}/libninja $(fd . -H core/template) -- cargo clean --package libninja
rust: clean
cargo run -- gen --name PetStore --output-dir gen/rust --generator rust data/openapi-spec/petstore/petstore.yaml --github libninjacom/petstore-rs --version 0.1.0
python: clean
cargo run -- gen --name PetStore --output-dir gen/python --generator python --version 0.1.0 --github libninjacom/petstore-py spec/petstore.yaml
python-example:
#!/bin/bash -euxo pipefail
cd gen/python
eval "$(pdm --pep582)"
python3 -m examples.list_pets
typescript: clean
cargo run -- gen --name PetStore --output-dir gen/typescript --generator typescript data/openapi-spec/petstore/petstore.yaml
java:
just gen/java/build
just gen/java/run
go:
rm -rf gen/petstore-go
checkexec ${CARGO_TARGET_DIR:-target}/debug/ocg $(fd . ocg/template) -- cargo clean --package ocg
cargo run -- gen --name PetStore --output-dir gen/petstore-go --generator go spec/petstore.yaml --github libninjacom/petstore-go --version 0.1.0
create:
bash ocg/script/create.sh
generate:
#!/bin/bash -euxo pipefail
if [ -n "${LIBRARY:-}" ]; then
export LIBRARY="--library $LIBRARY"
else
export LIBRARY=""
fi
REPO_DIR=$DIR/$(basename $REPO)
# rm -rf "$REPO_DIR"/*
cargo run -- gen --name $SERVICE --output-dir $REPO_DIR --generator $SOURCEGEN --github $REPO --version $VERSION $LIBRARY $SPEC
test *ARGS:
checkexec commercial -- just dummy_commercial
cd core && cargo test -- "$@"
cd libninja && cargo test -- "$@"
alias t := test
integration *ARGS:
cd libninja && cargo test -F integration -- "$@"
alias int := integration
# Test the library we just generated
test-lib:
#!/bin/bash -euxo pipefail
REPO_DIR=$DIR/$(basename $REPO)
cd $REPO_DIR
just bootstrap
just check
just test
alias tt := test-lib
clean-gen:
#!/bin/bash -euxo pipefail
if [ -z "$DIR" ]; then
echo "DIR is empty"
exit 1
fi
rm -rf $DIR/*
delete *ARG:
gh repo delete $REPO {{ARG}}
push:
bash ocg/script/push.sh
commercial:
rm -rf commercial
git clone https://github.com/kurtbuilds/libninja-commercial commercial
# Create a dummy commercial repo that lets the workspace work
# without the commericial code
dummy_commercial:
cargo new --lib commercial --name libninja_commercial