Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
indaco committed Mar 15, 2024
0 parents commit a79087c
Show file tree
Hide file tree
Showing 53 changed files with 4,372 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[core]
hooksPath = .githooks
13 changes: 13 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# https://github.com/leoroese/blog-tube/blob/main/.husky/commit-msg
if ! head -1 "$1" | grep -qE "^(feat|fix|ci|chore|docs|test|style|refactor|perf|build|revert|breaking)(\(.+?\))?: .{1,}$"; then
echo ""
printf "\n\x1b[31;1m✘ Aborting commit! Your commit message is not valid.\x1b[0m\n" >&2
exit 1
fi
if ! head -1 "$1" | grep -qE "^.{1,88}$"; then
echo ""
printf "\x1b[31;1m✘ Aborting commit! Your commit message is too long.\x1b[0m\n" >&2
exit 1
fi
3 changes: 3 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

make test
3 changes: 3 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

make _go_tools
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Go
go.work
*.exe
*.so
*.test
*.out

# GoLand #
.idea

# OSX
.DS_Store
.AppleDouble
.LSOverride
Icon

# VisualStudioCode
.vscode/*
.history/

#
*.log
tmp
.air.toml
_examples/**/*_templ.go
sync.sh
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 indaco (Mirco Veltri)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
93 changes: 93 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
color_red := $(shell printf "\e[1;31m")
color_green := $(shell printf "\e[1;32m")
color_yellow := $(shell printf "\e[1;33m")
color_blue := $(shell printf "\e[1;34m")
color_magenta := $(shell printf "\e[1;35m")
color_cyan := $(shell printf "\e[1;36m")
color_reset := $(shell printf "\e[0m")

EXAMPLES := \
_examples/a-h-templ \
_examples/custom-animations \
_examples/custom-button-icon \
_examples/go-html-template \
_examples/icon-only-button \
_examples/positioning \
_examples/theming \

# ==================================================================================== #
# HELPERS
# ==================================================================================== #
.PHONY: help
help: ## Print this help message
@echo ""
@echo "Usage: make [action]"
@echo ""
@echo "Available Actions:"
@echo ""
@awk -F ':|##' '/^[^\t].+?:.*?##/ {printf " \033[36m%-15s\033[0m %s\n", $$1, $$NF}' $(MAKEFILE_LIST) | sort
@echo ""

# ==================================================================================== #
# PRIVATE BUILDERS
# ==================================================================================== #
_process_templ_files:
@echo "$(color_magenta)Process TEMPL files$(color_reset)"

@echo "$(color_cyan) * Formatting templ files...$(color_reset)"
@templ fmt .

@echo "$(color_cyan) * Generating templ funcs...$(color_reset)"
@templ generate

@echo "$(color_green)Done!$(color_reset)"

_go_tools:
@echo ""
@echo "$(color_magenta)Run go tools...$(color_reset)"

@echo "$(color_cyan) * Downloading modules...$(color_reset)"
@go mod download; go mod tidy
@go build -v ./...
@echo "$(color_cyan) * Running golangci-lint...$(color_reset)"
@golangci-lint run ./...
@echo "$(color_cyan) * Running tests...$(color_reset)"
@$(MAKE) _test

@echo "$(color_green)Done!$(color_reset)"

_test:
@go test -race -covermode=atomic ./...

# ==================================================================================== #
# BUILDERS
# ==================================================================================== #

examples: ## Process templ files in the _examples folder
@for example in $(EXAMPLES); do \
pushd $$example && templ fmt . && templ generate && popd; \
done

test: ## Run go tests
@$(MAKE) _test

templ: ## Process TEMPL files
@$(MAKE) _process_templ_files

report-card: ## Run goreportcard-cli
@$(MAKE) build
@if [ -x $$(command -v goreportcard-cli) ]; then \
echo "$(color_cyan) * Running goreportcard-cli...$(color_reset)"; \
goreportcard-cli -v; \
fi
@$(MAKE) clean

clean:
@echo ""
@echo "$(color_magenta)Clean up$(color_reset)"
@find . -type f -name '*.grc.bk' -exec rm -f {} +
@find . -type f -name '*_templ.txt' -exec rm -f {} +
@echo "$(color_green)Done!$(color_reset)"

build: ## The main build target
@$(MAKE) templ _go_tools
Loading

0 comments on commit a79087c

Please sign in to comment.