Skip to content

Commit

Permalink
chore: Smaller Taskfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmichaelchen committed Oct 20, 2023
1 parent 3492274 commit 4eb192e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 56 deletions.
67 changes: 11 additions & 56 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,37 @@
version: '3'

vars:
NPX:
sh: which -a bunx npx | grep -v "not found" | head -n 1
includes:
buf:
taskfile: ./taskfiles/buf.yml
go:
taskfile: ./taskfiles/golang.yml

tasks:
generate:
aliases:
- gen
desc: "Generate code (e.g., protobufs)"
deps:
- gen-buf

gen-buf:
internal: true
desc: "Generate protobufs"
cmds:
- buf generate
- buf:gen

lint:
desc: "Lints the code"
deps:
- lint-buf
- lint-go

lint-buf:
deps:
- format
cmds:
- buf lint
- buf format -w

lint-go:
deps:
- format
cmds:
- golangci-lint run --verbose
- buf:lint
- go:lint

format:
aliases: [fmt]
run: once
desc: "Formats all code"
deps:
- fmt-go
- buf:fmt
- go:fmt
- fmt-md

fmt-md:
run: once
internal: true
desc: "Format Markdown"
cmds:
- "{{.NPX}} prettier --write \"**/*.md\" --prose-wrap always"

fmt-go:
run: once
internal: true
desc: "Format Golang"
cmds:
- task: gofumpt
- task: gci

gofumpt:
run: once
internal: true
desc: "Format Go code"
cmds:
- "go install mvdan.cc/gofumpt@latest"
- "gofumpt -l -w ."

gci:
run: once
internal: true
desc: "Format Go imports"
cmds:
- |
go install github.com/daixiang0/gci@latest ; \
gci write --skip-generated \
-s standard \
-s default \
-s "prefix(github.com/kevinmichaelchen/temporal-saga-grpc)" \
.
- "pkgx bunx prettier --write \"**/*.md\" --prose-wrap always"
22 changes: 22 additions & 0 deletions taskfiles/buf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3'

tasks:
gen:
run: once
aliases:
- generate
internal: true
desc: "Generate protobufs"
cmd: pkgx buf@latest generate

format:
run: once
aliases:
- fmt
cmd: pkgx buf@latest format -w

lint:
run: once
deps:
- format
cmd: pkgx buf@latest lint
36 changes: 36 additions & 0 deletions taskfiles/golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'

tasks:
lint:
run: once
deps:
- format
cmd: pkgx golangci-lint@latest run --verbose

fmt:
aliases:
- format
run: once
internal: true
desc: "Format Golang"
cmds:
- task: gofumpt
- task: gci

gofumpt:
run: once
internal: true
desc: "Format Go code"
cmd: "pkgx gofumpt@latest -l -w ."

gci:
run: once
internal: true
desc: "Format Go imports"
cmds:
- |
pkgx gci@latest write --skip-generated \
-s standard \
-s default \
-s "prefix(github.com/kevinmichaelchen/temporal-saga-grpc)" \
.

0 comments on commit 4eb192e

Please sign in to comment.