-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (65 loc) · 2.26 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
# =============================================================================
# Project build
# =============================================================================
.EXPORT_ALL_VARIABLES:
# POSIX locale
LC_ALL = C
# ANSI formatting
B = [1m
U = [4m
RED = [0;31m
RST = [0m
TOP_DIR = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
# Primary targets
# =============================================================================
.PHONY: help
# -----------------------------------------------------------------------------
.DEFAULT_GOAL = help
help:
@ printf 'Usage: \e$(B)make\e$(RST) [ target ]\n\n'
@ printf 'Available targets:\n\n'
@ grep -E '^.PHONY: [a-z-]+ #' Makefile | \
sed -E 's,^.PHONY: ([a-z-]+) # (.*),\1#\2,' | \
column -s '#' -t | \
sed -E "s,^([a-z-]+), \x1b$(B)\1\x1b$(RST),"
.PHONY: install # Install the project dependencies
# -----------------------------------------------------------------------------
install: node_modules
node_modules: package.json
yarn install
touch $@
install: .git/config
.git/config: node_modules
yarn trunk git-hooks sync
touch $@
.PHONY: upgrade # Upgrade the project dependencies
# -----------------------------------------------------------------------------
upgrade: install
yarn trunk upgrade
.PHONY: check # Check new and changed files
# -----------------------------------------------------------------------------
check: install
yarn trunk check
.PHONY: check-all # Check all files in the repository
# -----------------------------------------------------------------------------
check-all: install
yarn trunk check --all
.PHONY: format # Format new and changed files
# -----------------------------------------------------------------------------
format: install
yarn trunk fmt
.PHONY: format-all # Format all files in the repository
# -----------------------------------------------------------------------------
format-all: install
yarn trunk fmt --all
# Clean
# -----------------------------------------------------------------------------
.PHONY: clean # Remove build artifacts
clean: _rm-empty-dirs
.PHONY: _rm-empty_-irs
_rm-empty-dirs: _git-clean
find . -type d -empty -delete
.PHONY: _git-clean
# Remove files that match `.gitignore` (but keep untracked files)
_git-clean:
git clean -f -d -X