This repository has been archived by the owner on Jul 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
129 lines (105 loc) · 2.46 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
#!/usr/bin/env make
#
#
# Default target
#
#
dev: dependencies dump test lint
pull-request: clean test
#
#
# System variables
#
#
ROOT ?= $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
TEST_CONFIG = tests/kiosk.yml
#
#
# Generic configuration
#
#
# https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_7.html
# https://stackoverflow.com/a/26936855/1954789
SHELL := /bin/bash
.SECONDEXPANSION:
NPM_BIN=$(shell npm root)/.bin
PATH := $(NPM_BIN):$(PATH)
dump:
$(info ROOT: $(ROOT))
$(info PATH: $(PATH))
$(info TEST_CONFIG: $(TEST_CONFIG))
type firefox 2>/dev/null || echo "Firefox not found"
#
#
# Generic functions
#
#
# See https://coderwall.com/p/cezf6g/define-your-own-function-in-a-makefile
# 1: folder where to look
# 2: base file to have files newer than, to limit the length of the output
define recursive-dependencies
$(shell \
if [ -r "$(2)" ]; then \
find "$(1)" -name tests_data -prune -o -name tmp -prune -o -newer "$(2)"; \
else \
echo "$(1)";\
fi \
)
endef
# See https://git-scm.com/docs/git-ls-files
# 1: folder
define git-files
$(shell git ls-files --cached --modified --others --full-name "$(ROOT)/$(1)" )
endef
######################
#
# Runtime
#
######################
clean:
rm -fr parts tmp
rm -fr node_modules
rm -fr built
.PHONY: start
start: build stop-previous
bin/server.js -f $(TEST_CONFIG)
.PHONY: start-prod
start-prod: build stop-previous
bin/server.js
stop-previous:
jh-kill-by-port 5454
.PHONY: dependencies
dependencies: node_modules/.packages-installed.json
node_modules/.packages-installed.json: package.json
npm ci
$(NPM_BIN)/browserslist --update-db
touch package-lock.json
touch "$@"
.PHONY: build
build: node_modules/.packages-installed.json \
var/photos/index.json \
var/fire
var/photos/index.json: bin/photos-selector.js node_modules/.packages-installed.json
$< -f $(TEST_CONFIG)
var/fire: bin/fire-selector node_modules/.packages-installed.json
$< $(TEST_CONFIG)
built/importmap.json: node_modules/.packages-installed.json
mkdir $(dir $@)
$(NPM_BIN)/importly < package-lock.json > built/importmap.json
.PHONY: test
test: dependencies
karma start tests/client/karma.conf.cjs --single-run
.PHONY: test-continuously
test-continuously: dependencies
karma start tests/client/karma.conf.cjs
.PHONY: lint
lint: dependencies
eslint .
stylelint **/*.css
prettier --list-different .
.PHONY: lint-fix
lint-fix: dependencies
lint . --fix
.PHONY: depcheck
depcheck:
depcheck