-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
146 lines (112 loc) · 3.09 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
include .env
ifneq (,$(filter grouped-target,$(.FEATURES)))
GROUPED_TARGET := On
endif
SHELL := /bin/bash -O globstar
BIN := node_modules/.bin
DIRS := public/app
VIEWSGLOB := src/**/*.svelte
VIEWS := $(shell echo $(VIEWSGLOB))
TRANSGLOB := locales/translation-*.json
TRANS := $(wildcard $(TRANSGLOB))
LOCALE ?= en
SRCS := $(shell find src -name *.ts -or -name *.svelte)
INPUTS := src/main.ts $(wildcard src/module/*Module.ts)
OUTPUTS := $(patsubst src/%.ts,public/app/%.js,$(INPUTS))
SCFLAGS := --fail-on-warnings
define sortjson
# sorting $1
@tmp=$(dir $1).$(notdir $1); \
jq -S . $1 > $$tmp && mv $$tmp $1
endef
ifdef CI
SCFLAGS += --output=machine
endif
ifndef GROUPED_TARGET
$(warning WARNING: This version of make does not support grouped-target, disabling parallel jobs.)
.NOTPARALLEL:
endif
.PHONY: all
all: export BUILD ?= production
all: public/app/config.json node_modules $(OUTPUTS);
.PHONY: watch
watch: BUILD ?= development
watch: public/app/config.json node_modules
$(BIN)/rollup --config --watch
.PHONY: start
start: node_modules
$(BIN)/sirv public --no-clear --dev
.PHONY: dev
dev: MAKEFLAGS += --no-print-directory
dev: node_modules
$(MAKE) watch & $(MAKE) start
.PHONY: test
test:
npm run test
.PHONY: analyse
analyse: src/main.svg
open $< &
.PHONY: mostlyclean
mostlyclean:
rm -f src/main.svg src/main.dot
rm -rf public/app public/fonts
.PHONY: clean
clean: mostlyclean
rm -rf node_modules
.PHONY: check
check: check-svelte check-eslint check-translations;
.PHONY: check-typescript
check-typescript: node_modules
$(BIN)/tsc --noEmit
.PHONY: check-svelte
check-svelte: node_modules
$(BIN)/svelte-check $(SCFLAGS)
.PHONY: check-eslint
check-eslint: node_modules
$(BIN)/eslint src eslint.config.mjs
.PHONY: check-translations
check-translations:
@for f in $(TRANSGLOB); do \
echo "# checking $$f"; \
jq -S . $$f | diff -q /dev/stdin $$f > /dev/null || (echo "incorrectly formatted" && exit 1); \
done
.PHONY: fix
fix: fix-eslint translations-sort;
.PHONY: fix-eslint
fix-eslint: node_modules
$(BIN)/eslint src --fix
.PHONY: translations-extract
translations-extract: translation-$(LOCALE)-extract;
.PHONY: translations-%-extract
translation-%-extract:
node_modules/.bin/svelte-i18n extract --shallow '$(VIEWSGLOB)' locales/translation-$*.json
$(call sortjson,locales/translation-$*.json)
.PHONY: translations-sort
translations-sort: $(TRANS:locales/%.json=%-sort)
.PHONY: translations-%-sort
translation-%-sort:
$(call sortjson,locales/translation-$*.json)
.PHONY: deploy
deploy:
rsync -av --del --exclude='.*' --exclude='config.json' public $(TARGET)
$(DIRS):
mkdir -p $@
ifdef GROUPED_TARGET
$(OUTPUTS) &: public/app/%.js: src/%.ts $(SRCS) rollup.config.mjs node_modules | public/app
else
$(OUTPUTS): public/app/%.js: src/%.ts $(SRCS) rollup.config.mjs node_modules | public/app
endif
$(BIN)/rollup --config
node_modules: package-lock.json package.json
npm install --include=dev
touch $@
public/app/config.json: config.json | public/app
cp $< $@
config.json:
cp config.sample.json $@
%.svg: %.dot
dot -T svg $< > $@
%.dot: %.ts
npx ts_dependency_graph --start $< > $@
.env:
touch $@