├── Readme.md ├── cloc.mk ├── static ├── stats.mk ├── netlify.mk ├── postcss.mk ├── s3.mk ├── imgix.mk └── hugo.mk ├── neutrino.mk ├── todo.mk ├── golang.mk └── gopherjs.mk /Readme.md: -------------------------------------------------------------------------------- 1 | Personal makefiles for [Modern Make](https://github.com/tj/mmake). 2 | -------------------------------------------------------------------------------- /cloc.mk: -------------------------------------------------------------------------------- 1 | 2 | # Output source statistics. 3 | cloc: 4 | @cloc --exclude-dir=client,vendor . 5 | .PHONY: cloc 6 | -------------------------------------------------------------------------------- /static/stats.mk: -------------------------------------------------------------------------------- 1 | STATS_DIR ?= . 2 | 3 | # Output file size stats. 4 | stats: 5 | @find $(STATS_DIR) -type f | xargs du -h | gsort -rh 6 | .PHONY: stats 7 | -------------------------------------------------------------------------------- /static/netlify.mk: -------------------------------------------------------------------------------- 1 | 2 | # Deploy to Netlify. 3 | netlify.deploy: 4 | @echo "==> deploying" 5 | @netlify deploy 6 | @echo "==> deployed" 7 | .PHONY: netlify.deploy 8 | -------------------------------------------------------------------------------- /neutrino.mk: -------------------------------------------------------------------------------- 1 | 2 | NEUTRINO=node_modules/.bin/neutrino 3 | 4 | # Start app. 5 | start: 6 | @$(NEUTRINO) start 7 | .PHONY: start 8 | 9 | # Build app. 10 | build: 11 | @$(NEUTRINO) build 12 | .PHONY: build 13 | -------------------------------------------------------------------------------- /todo.mk: -------------------------------------------------------------------------------- 1 | 2 | # Output to-do items per file. 3 | todo: 4 | @grep \ 5 | --exclude-dir=./vendor \ 6 | --exclude-dir=./client/node_modules \ 7 | --text \ 8 | --color \ 9 | -nRo ' TODO:.*' . 10 | .PHONY: todo 11 | -------------------------------------------------------------------------------- /static/postcss.mk: -------------------------------------------------------------------------------- 1 | ifndef POSTCSS_SRC 2 | $(error POSTCSS_SRC is required) 3 | endif 4 | 5 | # Compile stylesheets with Postcss. 6 | postcss.compile: 7 | @echo "==> compile stylesheets" 8 | @$(POSTCSS) \ 9 | --no-map \ 10 | --use postcss-import \ 11 | --use cssnano \ 12 | --output $(POSTCSS_SRC) \ 13 | $(POSTCSS_SRC) 14 | .PHONY: postcss.compile 15 | -------------------------------------------------------------------------------- /static/s3.mk: -------------------------------------------------------------------------------- 1 | 2 | ifndef S3_BUCKET 3 | $(error S3_BUCKET is required) 4 | endif 5 | 6 | ifndef S3_SYNC_DIR 7 | $(error S3_SYNC_DIR is required, and should point to the static files directory for syncing) 8 | endif 9 | 10 | # Sync static site to S3. 11 | s3.sync: 12 | @echo "==> syncing $(S3_SYNC_DIR) to $(S3_BUCKET)" 13 | @aws s3 sync $(S3_SYNC_DIR) s3://$(S3_BUCKET) 14 | .PHONY: static.sync 15 | -------------------------------------------------------------------------------- /static/imgix.mk: -------------------------------------------------------------------------------- 1 | ifndef IMGIX_SOURCE_NAME 2 | $(error IMGIX_SOURCE_NAME is required, for example apex-inc, used for the domain.) 3 | endif 4 | 5 | IMGIX_HOST = https://$(IMGIX_SOURCE_NAME).imgix.net 6 | IMGIX_DIR ?= build 7 | 8 | # Imgix image replacement. 9 | imgix.replace: 10 | @echo "==> replace images in $(IMGIX_DIR) to $(IMGIX_HOST)" 11 | @find build -type f -name "*.html" | xargs sed -i '' 's|src="/images|src="$(IMGIX_HOST)/images|g' 12 | @find build -type f -name "*.html" | xargs sed -i '' 's|href="/images|href="$(IMGIX_HOST)/images|g' 13 | .PHONY: imgix.replace 14 | -------------------------------------------------------------------------------- /golang.mk: -------------------------------------------------------------------------------- 1 | include github.com/tj/make/cloc 2 | include github.com/tj/make/todo 3 | 4 | # Run all tests. 5 | test: 6 | @go test -cover ./... 7 | .PHONY: test 8 | 9 | # Install the commands. 10 | install: 11 | @go install ./cmd/... 12 | .PHONY: install 13 | 14 | # Release binaries to GitHub. 15 | release: 16 | @goreleaser --rm-dist --config .goreleaser.yml 17 | .PHONY: release 18 | 19 | # Show size of imports. 20 | size: 21 | @curl -sL https://gist.githubusercontent.com/tj/04e0965e23da00ca33f101e5b2ed4ed4/raw/9aa16698b2bc606cf911219ea540972edef05c4b/gistfile1.txt | bash 22 | .PHONY: size 23 | -------------------------------------------------------------------------------- /static/hugo.mk: -------------------------------------------------------------------------------- 1 | 2 | ifndef HUGO_DOMAIN 3 | $(error HUGO_DOMAIN is required, and should be a schemaless domain name such as example.com) 4 | endif 5 | 6 | HUGO_BUILD_DIR ?= build 7 | HUGO_PROTOCOL ?= https 8 | HUGO_BASE_URL = $(HUGO_PROTOCOL)://$(HUGO_DOMAIN) 9 | HUGO_PORT ?= 3000 10 | 11 | # Start hugo server. 12 | hugo.start: 13 | @hugo serve -v -w --quiet --forceSyncStatic -p $(HUGO_PORT) 14 | .PHONY: start 15 | 16 | # Build hugo site. 17 | hugo.build: 18 | @echo "==> building" 19 | @hugo --quiet --baseURL $(HUGO_BASE_URL) -d $(HUGO_BUILD_DIR) 20 | .PHONY: build 21 | 22 | # Clean hugo build artifacts. 23 | hugo.clean: 24 | rm -fr $(HUGO_BUILD_DIR) 25 | .PHONY: clean 26 | -------------------------------------------------------------------------------- /gopherjs.mk: -------------------------------------------------------------------------------- 1 | GOPHERJS_PKG = $(subst $(GOPATH)/src/,,$(PWD)) 2 | GOPHERJS_BUILD_FILE ?= client.js 3 | BUILD_DIR ?= build 4 | 5 | # Start client dev server. 6 | client.start: 7 | @gopherjs serve -v -m --http :3000 $(GOPHERJS_PKG)/client 8 | .PHONY: client.start 9 | 10 | # Build client javascript bundle. 11 | client.build: 12 | @gopherjs build $(GOPHERJS_PKG)/client -m -o $(BUILD_DIR)/$(GOPHERJS_BUILD_FILE) 13 | .PHONY: client.build 14 | 15 | # Output client dependency graph. 16 | client.deps.graph: 17 | @godepgraph --tags js -d $(GOPHERJS_PKG)/client | dot -Tsvg | browser 18 | .PHONY: client.deps.graph 19 | 20 | # Output client dependency sizes. 21 | client.deps.size: 22 | @gopherjs build client/*.go -m -o /tmp/out.js 23 | @du -h /tmp/out.js 24 | @gopher-count /tmp/out.js | sort -nr 25 | .PHONY: client.deps.size 26 | --------------------------------------------------------------------------------