Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (114 loc) · 2.69 KB
/
Copy pathMakefile
File metadata and controls
135 lines (114 loc) · 2.69 KB
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
APP_NAME=liveClass
TAG=latest
GO_LINT=golangci/golangci-lint
GO_LINT_VERSION=v1.64.6
BINARY_DIR=bin
BINARY_PATH=$(BINARY_DIR)/$(APP_NAME)
.PHONY: all test lint fmt vet clean build run deps check dev air lint-fe lint-go lint-html lint-js
# Default target
all: deps lint test build
# Run all linting checks
lint: lint-go lint-fe
# Frontend linting (HTML and JS)
lint-fe: lint-html lint-js
# Go linting
lint-go:
@if ! command -v golangci-lint &> /dev/null; then \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
fi
golangci-lint run -v
# HTML linting (includes HTMX attributes)
lint-html:
@if ! command -v html-validate &> /dev/null; then \
npm install -g html-validate; \
fi
@echo "Linting HTML files..."
@find ./template -name "*.html" -exec html-validate {} \;
# JavaScript linting (includes Alpine.js)
lint-js:
@if ! command -v eslint &> /dev/null; then \
npm install -g eslint eslint-plugin-alpine; \
fi
@if [ ! -f .eslintrc.json ]; then \
echo '{\
"extends": ["eslint:recommended"],\
"plugins": ["alpine"],\
"env": {\
"browser": true,\
"es6": true\
},\
"parserOptions": {\
"ecmaVersion": 2022\
},\
"rules": {\
"alpine/no-undefined-properties": "error"\
}\
}' > .eslintrc.json; \
fi
@echo "Linting JavaScript files..."
@find ./static -name "*.js" -exec eslint {} \;
# Install all dependencies
deps: deps-go deps-fe
# Install Go dependencies
deps-go:
go mod download
go mod tidy
go mod verify
# Install frontend dependencies
deps-fe:
@if ! command -v npm &> /dev/null; then \
echo "Please install Node.js and npm first"; \
exit 1; \
fi
@if [ ! -f package.json ]; then \
npm init -y; \
fi
npm install --save-dev \
eslint \
eslint-plugin-alpine \
html-validate
# Run tests
test:
go test -v -race -cover ./...
# Format code
fmt: fmt-go fmt-fe
# Format Go code
fmt-go:
go fmt ./...
# Format frontend code
fmt-fe:
@if ! command -v prettier &> /dev/null; then \
npm install -g prettier; \
fi
@echo "Formatting HTML files..."
@find ./template -name "*.html" -exec prettier --write {} \;
@echo "Formatting JavaScript files..."
@find ./static -name "*.js" -exec prettier --write {} \;
# Run go vet
vet:
go vet ./...
# Clean build artifacts
clean:
go clean
rm -rf $(BINARY_DIR)
rm -rf node_modules
# Build the application
build: clean
@mkdir -p $(BINARY_DIR)
go build -o $(BINARY_PATH)
# Run the application
run: build
$(BINARY_PATH)
# Run all checks
check: fmt vet lint test
# Development with hot reload
dev: deps
@if ! command -v air &> /dev/null; then \
go install github.com/cosmtrek/air@latest; \
fi
air
# Create necessary directories
init:
@mkdir -p $(BINARY_DIR)
@mkdir -p static/js
@mkdir -p template