-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathMakefile
116 lines (99 loc) · 4.03 KB
/
Makefile
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
.PHONY: help serve clean build start setup update-deps prereqs
# Default Hugo port
PORT ?= 1313
# Colors for help text
BLUE := \033[34m
RESET := \033[0m
# Check for required commands
NPM := $(shell command -v npm 2> /dev/null)
CONVERT := $(shell command -v convert 2> /dev/null)
# Define Chrome path and common Chrome options
CHROME := /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
CHROME_OPTS := --headless --force-device-scale-factor=1 --default-background-color=00000000
# Target to check for npm
check-npm:
ifndef NPM
$(error "npm is required but not installed. Please visit https://nodejs.org/ to install")
endif
# Target to check for ImageMagick
check-imagemagick:
ifndef CONVERT
$(error "ImageMagick is required but not installed. Please run: brew install imagemagick")
endif
## Display this help message
help:
@echo "$(BLUE)Goa Documentation Site$(RESET)"
@echo "Available commands:"
@echo
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " $(BLUE)%-15s$(RESET) %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
@echo
## Initialize Hugo modules and install dependencies
setup:
hugo mod get -u
hugo mod tidy
## Start the Hugo server with live reload (alias for 'serve')
start: setup serve
## Start the Hugo server with live reload
serve:
@echo "Starting Hugo server on http://localhost:$(PORT)..."
hugo server -D -p $(PORT) --disableFastRender
## Clean generated files (public/ and resources/)
clean:
@echo "Cleaning generated files..."
rm -rf public/
rm -rf resources/
rm -rf .hugo_build.lock
## Build the site for production with minification
build: setup
@echo "Building site..."
hugo --minify
## Update npm dependencies
update-deps: check-npm ## Update npm dependencies
@echo "Updating npm dependencies..."
npm update
npm audit fix
@echo "Dependencies updated successfully"
## Install prerequisites (npm packages, hugo)
prereqs: check-npm ## Install prerequisites (npm, hugo)
@echo "Installing prerequisites..."
npm install
go install -tags extended github.com/gohugoio/hugo@latest
@echo "Prerequisites installed successfully"
## Create logo and variants
logo:
@echo "Creating logos..."
mkdir -p static/img/social
# Generate card image
$(CHROME) $(CHROME_OPTS) --screenshot="static/img/social/goa-card-temp.png" \
--window-size=1200,800 file://$(PWD)/static/logo.html
convert static/img/social/goa-card-temp.png -gravity north -crop 1200x630+0+0 static/img/social/goa-card.png
rm static/img/social/goa-card-temp.png
# Generate square image
$(CHROME) $(CHROME_OPTS) --screenshot="static/img/social/goa-square-temp.png" \
--window-size=400,500 file://$(PWD)/static/logo-square.html
convert static/img/social/goa-square-temp.png -gravity north -crop 400x400+0+0 static/img/social/goa-square.png
rm static/img/social/goa-square-temp.png
# Generate banner image
$(CHROME) $(CHROME_OPTS) --screenshot="static/img/social/goa-banner-temp.png" \
--window-size=1000,300 file://$(PWD)/static/logo-banner.html
convert static/img/social/goa-banner-temp.png -gravity north -crop 1000x250+0+0 static/img/social/goa-banner.png
rm static/img/social/goa-banner-temp.png
favicons: logo check-imagemagick
@echo "Generating favicons..."
mkdir -p static/favicons
convert static/img/social/goa-card.png -resize 16x16 static/favicons/favicon-16x16.png
convert static/img/social/goa-card.png -resize 32x32 static/favicons/favicon-32x32.png
convert static/img/social/goa-card.png -resize 192x192 static/favicons/android-chrome-192x192.png
convert static/img/social/goa-card.png -resize 512x512 static/favicons/android-chrome-512x512.png
convert static/img/social/goa-card.png -resize 180x180 static/favicons/apple-touch-icon.png
convert static/img/social/goa-card.png -resize 150x150 static/favicons/mstile-150x150.png
convert static/favicons/favicon-16x16.png static/favicons/favicon-32x32.png static/favicons/favicon.ico
.DEFAULT_GOAL := help