-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: cimg/go:1.21 | ||
steps: | ||
- checkout | ||
- run: go install github.com/mitchellh/gox@latest | ||
- run: go install github.com/tcnksm/[email protected] | ||
- run: sudo apt-get update && sudo apt-get install p7zip-full | ||
- run: make dist | ||
- run: | ||
name: create release | ||
command: | | ||
if [ "$CIRCLE_TAG" ]; then | ||
mkdir -p dist | ||
mv apexfmt*.zip dist | ||
ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace $CIRCLE_TAG dist/ | ||
else | ||
echo "No tag" | ||
fi | ||
workflows: | ||
version: 2 | ||
build-workflow: # the name of our workflow | ||
jobs: # the jobs that we are sequencing. | ||
- build: | ||
filters: | ||
tags: | ||
only: /^v.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,60 @@ | ||
VERSION=$(shell git describe --abbrev=0 --always) | ||
LDFLAGS = -ldflags "-X github.com/octoberswimmer/apexfmt/cmd.version=${VERSION}" | ||
GCFLAGS = -gcflags="all=-N -l" | ||
EXECUTABLE=apexfmt | ||
WINDOWS=$(EXECUTABLE)_windows_amd64.exe | ||
LINUX=$(EXECUTABLE)_linux_amd64 | ||
OSX_AMD64=$(EXECUTABLE)_osx_amd64 | ||
OSX_ARM64=$(EXECUTABLE)_osx_arm64 | ||
ALL=$(WINDOWS) $(LINUX) $(OSX_AMD64) $(OSX_ARM64) | ||
|
||
default: | ||
go build ${LDFLAGS} | ||
|
||
install: | ||
go install ${LDFLAGS} | ||
|
||
install-debug: | ||
go install ${LDFLAGS} ${GCFLAGS} | ||
|
||
$(WINDOWS): | ||
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -v -o $(WINDOWS) ${LDFLAGS} | ||
|
||
$(LINUX): | ||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o $(LINUX) ${LDFLAGS} | ||
|
||
$(OSX_AMD64): | ||
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -o $(OSX_AMD64) ${LDFLAGS} | ||
|
||
$(OSX_ARM64): | ||
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -v -o $(OSX_ARM64) ${LDFLAGS} | ||
|
||
$(basename $(WINDOWS)).zip: $(WINDOWS) | ||
zip $@ $< | ||
7za rn $@ $< $(EXECUTABLE)$(suffix $<) | ||
|
||
%.zip: % | ||
zip $@ $< | ||
7za rn $@ $< $(EXECUTABLE) | ||
|
||
docs: | ||
go run docs/mkdocs.go | ||
|
||
dist: test $(addsuffix .zip,$(basename $(ALL))) | ||
|
||
fmt: | ||
go fmt ./... | ||
|
||
test: | ||
test -z "$(go fmt)" | ||
go vet | ||
go test ./... | ||
go test -race ./... | ||
|
||
clean: | ||
-rm -f $(EXECUTABLE) $(EXECUTABLE)_* | ||
|
||
.PHONY: default dist clean docs | ||
|
||
generate: | ||
go generate ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# apexfmt | ||
|
||
Apexfmt formats | ||
[Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dev_guide.htm) | ||
code. It uses tabs for indentation. | ||
|
||
Given a file, it writes the formatted code to standard output by default. The | ||
`--write`/`-w` flag can be used to overwrite the original file(s). The | ||
`--list`/`-l` flag can be used to list files with formatting different from | ||
apexfmt's. | ||
|
||
# Usage | ||
|
||
``` | ||
$ apexfmt -w sfdx/main/default/classes/*.cls sfdx/main/default/triggers/*.trigger | ||
``` | ||
|
||
# Thanks | ||
|
||
apexfmt is inspired by [gofmt](https://pkg.go.dev/cmd/gofmt). | ||
|
||
The antlr4 grammar is based on the @nawforce's | ||
[apex-parser](https://github.com/nawforce/apex-parser) grammar, which is | ||
originally based on the grammer used by @neowit's | ||
[tooling-force.com](https://github.com/neowit/tooling-force.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## apexfmt | ||
|
||
Format Apex | ||
|
||
``` | ||
apexfmt [file...] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for apexfmt | ||
-l, --list list files whose formatting differs from apexfmt's | ||
-w, --write write result to (source) file instead of stdout | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
cmd "github.com/octoberswimmer/apexfmt/cmd" | ||
|
||
"github.com/spf13/cobra/doc" | ||
) | ||
|
||
func main() { | ||
cmd.RootCmd.DisableAutoGenTag = true | ||
err := doc.GenMarkdownTree(cmd.RootCmd, "./docs") | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters