-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
185 lines (154 loc) · 6.84 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
.PHONY: install-antq install-kondo-configs install-zprint-config install-gitignore repl-enrich repl check-cljkondo check-tagref check-zprint-config check-zprint check test test-all test-coverage upgrade-libs build serve deploy clean-projects clean
HOME := $(shell echo $$HOME)
HERE := $(shell echo $$PWD)
CLOJURE_SOURCES := $(shell find . -name '**.clj')
# Set bash instead of sh for the @if [[ conditions,
# and use the usual safety flags:
SHELL = /bin/bash -Eeu
.DEFAULT_GOAL := repl
help: ## A brief explanation of everything you can do
@awk '/^[a-zA-Z0-9_-]+:.*##/ { \
printf "%-25s # %s\n", \
substr($$1, 1, length($$1)-1), \
substr($$0, index($$0,"##")+3) \
}' $(MAKEFILE_LIST)
# The Clojure CLI aliases that will be selected for main options for `repl`.
# Feel free to upgrade this, or to override it with an env var named DEPS_MAIN_OPTS.
# Expected format: "-M:alias1:alias2"
DEPS_MAIN_OPTS ?= "-M:dev:test:logs-dev:cider-storm"
repl: ## Launch a REPL using the Clojure CLI
clojure $(DEPS_MAIN_OPTS);
# The enrich-classpath version to be injected.
# Feel free to upgrade this.
ENRICH_CLASSPATH_VERSION="1.19.3"
# Create and cache a `clojure` command. deps.edn is mandatory; the others are optional but are taken into account for cache recomputation.
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.
.enrich-classpath-repl: Makefile deps.edn $(wildcard $(HOME)/.clojure/deps.edn) $(wildcard $(XDG_CONFIG_HOME)/.clojure/deps.edn)
cd $$(mktemp -d -t enrich-classpath.XXXXXX); clojure -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version $(ENRICH_CLASSPATH_VERSION)}}}' -M -m cider.enrich-classpath.clojure "clojure" "$(HERE)" "true" $(DEPS_MAIN_OPTS) | grep "^clojure" > $(HERE)/$@
# Launches a repl, falling back to vanilla Clojure repl if something went wrong during classpath calculation.
repl-enrich: .enrich-classpath-repl ## Launch a repl enriched with Java source code paths
@if grep --silent "^clojure" .enrich-classpath-repl; then \
echo "Executing: $$(cat .enrich-classpath-repl)" && \
eval $$(cat .enrich-classpath-repl); \
else \
echo "Falling back to Clojure repl... (you can avoid further falling back by removing .enrich-classpath-repl)"; \
clojure $(DEPS_MAIN_OPTS); \
fi
.clj-kondo:
mkdir .clj-kondo
install-kondo-configs: .clj-kondo ## Install clj-kondo configs for all the currently installed deps
clj-kondo --lint "$$(clojure -A:dev:test:cider:build -Spath)" --copy-configs --skip-lint
check-zprint-config:
@echo "Checking (HOME)/.zprint.edn..."
@if [ ! -f "$(HOME)/.zprint.edn" ]; then \
echo "Error: ~/.zprint.edn not found"; \
echo "Please create ~/.zprint.edn with the content: {:search-config? true}"; \
exit 1; \
fi
@if ! grep -q "search-config?" "$(HOME)/.zprint.edn"; then \
echo "Warning: ~/.zprint.edn might not contain required {:search-config? true} setting"; \
echo "Please ensure this setting is present for proper functionality"; \
exit 1; \
fi
.zprint.edn:
@echo "Creating .zprint.edn..."
@echo '{:fn-map {"with-context" "with-meta"}, :map {:indent 0}}' > $@
.dir-locals.el:
@echo "Creating .dir-locals.el..."
@echo ';;; Directory Local Variables -*- no-byte-compile: t; -*-' > $@
@echo ';;; For more information see (info "(emacs) Directory Variables")' >> $@
@echo '((clojure-dart-ts-mode . ((apheleia-formatter . (zprint))))' >> $@
@echo ' (clojure-jank-ts-mode . ((apheleia-formatter . (zprint))))' >> $@
@echo ' (clojure-mode . ((apheleia-formatter . (zprint))))' >> $@
@echo ' (clojure-ts-mode . ((apheleia-formatter . (zprint))))' >> $@
@echo ' (clojurec-mode . ((apheleia-formatter . (zprint))))' >> $@
@echo ' (clojurec-ts-mode . ((apheleia-formatter . (zprint))))' >> $@
@echo ' (clojurescript-mode . ((apheleia-formatter . (zprint))))' >> $@
@echo ' (clojurescript-ts-mode . ((apheleia-formatter . (zprint)))))' >> $@
install-zprint-config: check-zprint-config .zprint.edn .dir-locals.el ## Install configuration for using the zprint formatter
@echo "zprint configuration files created successfully."
.gitignore:
@echo "Creating a .gitignore file"
@echo '# Artifacts' > $@
@echo '**/classes' >> $@
@echo '**/target' >> $@
@echo '**/.artifacts' >> $@
@echo '**/.cpcache' >> $@
@echo '**/.DS_Store' >> $@
@echo '**/.gradle' >> $@
@echo 'logs/' >> $@
@echo '' >> $@
@echo '# 12-factor App Configuration' >> $@
@echo '.envrc' >> $@
@echo '' >> $@
@echo '# User-specific stuff' >> $@
@echo '.idea/**/workspace.xml' >> $@
@echo '.idea/**/tasks.xml' >> $@
@echo '.idea/**/usage.statistics.xml' >> $@
@echo '.idea/**/shelf' >> $@
@echo '.idea/**/statistic.xml' >> $@
@echo '.idea/dictionaries/**' >> $@
@echo '.idea/libraries/**' >> $@
@echo '' >> $@
@echo '# File-based project format' >> $@
@echo '*.iws' >> $@
@echo '*.ipr' >> $@
@echo '' >> $@
@echo '# Cursive Clojure plugin' >> $@
@echo '.idea/replstate.xml' >> $@
@echo '*.iml' >> $@
@echo '' >> $@
@echo '/example/example/**' >> $@
@echo 'artifacts' >> $@
@echo 'projects/**/pom.xml' >> $@
@echo '' >> $@
@echo '# nrepl' >> $@
@echo '.nrepl-port' >> $@
@echo '' >> $@
@echo '# clojure-lsp' >> $@
@echo '.lsp/.cache' >> $@
@echo '' >> $@
@echo '# clj-kondo' >> $@
@echo '.clj-kondo/.cache' >> $@
@echo '' >> $@
@echo '# Calva VS Code Extension' >> $@
@echo '.calva/output-window/output.calva-repl' >> $@
@echo '' >> $@
@echo '# Metaclj tempfiles' >> $@
@echo '.antqtool.lastupdated' >> $@
@echo '.enrich-classpath-repl' >> $@
install-gitignore: .gitignore ## Install a meaningful .gitignore file
@echo ".gitignore added/exists in the project"
check-tagref:
tagref
check-cljkondo:
clj-kondo --lint .
check-zprint:
zprint -c $(CLOJURE_SOURCES)
check: check-tagref check-cljkondo check-zprint ## Check that the code is well linted and well formatted
@echo "All checks passed!"
test-all:
clojure -M:poly test :all
test-coverage:
clojure -X:dev:test:clofidence
test: ## Run Poly tests for the code
clojure -M:poly test
install-antq:
@if [ -f .antqtool.lastupdated ] && find .antqtool.lastupdated -mtime +15 -print | grep -q .; then \
echo "Updating antq tool to the latest version..."; \
clojure -Ttools install-latest :lib com.github.liquidz/antq :as antq; \
touch .antqtool.lastupdated; \
else \
echo "Skipping antq tool update..."; \
fi
.antqtool.lastupdated:
touch .antqtool.lastupdated
upgrade-libs: .antqtool.lastupdated install-antq ## Install all the deps to their latest versions
clojure -Tantq outdated :check-clojure-tools true :upgrade true
build: check ## Build the deployment artifact
@echo "Run deps-new build commands here!"
deploy: build ## Deploy the current code to production
@echo "Run fly.io deployment commands here!"
clean-projects:
rm -rf projects/*/target/public
clean: clean-projects ## Delete any existing artifacts