blob: e3087f0b754f1830a69da1855582e1c230e786b3 (
plain) (
blame)
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
|
![templ](https://github.com/a-h/templ/raw/main/templ.png)
## An HTML templating language for Go that has great developer tooling.
![templ](ide-demo.gif)
## Documentation
See user documentation at https://templ.guide
<p align="center">
<a href="https://pkg.go.dev/github.com/a-h/templ"><img src="https://pkg.go.dev/badge/github.com/a-h/templ.svg" alt="Go Reference" /></a>
<a href="https://xcfile.dev"><img src="https://xcfile.dev/badge.svg" alt="xc compatible" /></a>
<a href="https://raw.githack.com/wiki/a-h/templ/coverage.html"><img src="https://github.com/a-h/templ/wiki/coverage.svg" alt="Go Coverage" /></a>
<a href="https://goreportcard.com/report/github.com/a-h/templ"><img src="https://goreportcard.com/badge/github.com/a-h/templ" alt="Go Report Card" /></a<
</p>
## Tasks
### build
Build a local version.
```sh
go run ./get-version > .version
cd cmd/templ
go build
```
### nix-update-gomod2nix
```sh
gomod2nix
```
### install-snapshot
Build and install current version.
```sh
# Remove templ from the non-standard ~/bin/templ path
# that this command previously used.
rm -f ~/bin/templ
# Clear LSP logs.
rm -f cmd/templ/lspcmd/*.txt
# Update version.
go run ./get-version > .version
# Install to $GOPATH/bin or $HOME/go/bin
cd cmd/templ && go install
```
### build-snapshot
Use goreleaser to build the command line binary using goreleaser.
```sh
goreleaser build --snapshot --clean
```
### generate
Run templ generate using local version.
```sh
go run ./cmd/templ generate -include-version=false
```
### test
Run Go tests.
```sh
go run ./get-version > .version
go run ./cmd/templ generate -include-version=false
go test ./...
```
### test-short
Run Go tests.
```sh
go run ./get-version > .version
go run ./cmd/templ generate -include-version=false
go test ./... -short
```
### test-cover
Run Go tests.
```sh
# Create test profile directories.
mkdir -p coverage/fmt
mkdir -p coverage/generate
mkdir -p coverage/version
mkdir -p coverage/unit
# Build the test binary.
go build -cover -o ./coverage/templ-cover ./cmd/templ
# Run the covered generate command.
GOCOVERDIR=coverage/fmt ./coverage/templ-cover fmt .
GOCOVERDIR=coverage/generate ./coverage/templ-cover generate -include-version=false
GOCOVERDIR=coverage/version ./coverage/templ-cover version
# Run the unit tests.
go test -cover ./... -coverpkg ./... -args -test.gocoverdir="$PWD/coverage/unit"
# Display the combined percentage.
go tool covdata percent -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit
# Generate a text coverage profile for tooling to use.
go tool covdata textfmt -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit -o coverage.out
# Print total
go tool cover -func coverage.out | grep total
```
### test-cover-watch
```sh
gotestsum --watch -- -coverprofile=coverage.out
```
### benchmark
Run benchmarks.
```sh
go run ./cmd/templ generate -include-version=false && go test ./... -bench=. -benchmem
```
### fmt
Format all Go and templ code.
```sh
gofmt -s -w .
go run ./cmd/templ fmt .
```
### lint
```sh
golangci-lint run --verbose
```
### push-release-tag
Push a semantic version number to Github to trigger the release process.
```sh
./push-tag.sh
```
### docs-run
Run the development server.
Directory: docs
```sh
npm run start
```
### docs-build
Build production docs site.
Directory: docs
```sh
npm run build
```
|