-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
72 lines (54 loc) · 2.34 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
COMMONMARK=node_modules/.bin/commonform-commonmark
CRITIQUE=node_modules/.bin/commonform-critique
DOCX=node_modules/.bin/commonform-docx
HTML=node_modules/.bin/commonform-html
JSON=node_modules/.bin/json
LINT=node_modules/.bin/commonform-lint
TOOLS=$(COMMONMARK) $(CRITIQUE) $(DOCX) $(HTML) $(JSON) $(LINT)
SOURCES=terms.md
FORMS=$(addprefix build/,$(SOURCES:.md=.form.json))
.PHONY: all markdown html docx pdf
all: json markdown html docx pdf
json: $(FORMS)
markdown: $(addprefix build/,$(SOURCES))
html: $(addprefix build/,$(SOURCES:.md=.html))
docx: $(addprefix build/,$(SOURCES:.md=.docx))
pdf: $(addprefix build/,$(SOURCES:.md=.pdf))
build/%.docx: build/%.form.json build/%.title build/%.edition styles.json | build $(DOCX)
$(DOCX) --title "$(shell cat build/$*.title)" --edition "$(shell cat build/$*.edition)" --number outline --indent-margins --left-align-title --styles styles.json $< > $@
build/%.md: build/%.form.json build/%.title build/%.edition | build $(COMMONMARK)
$(COMMONMARK) stringify --title "$(shell cat build/$*.title)" --edition "$(shell cat build/$*.edition)" --ordered --ids < $< > $@
build/%.html: build/%.form.json build/%.title build/%.edition | build $(COMMONMARK)
$(HTML) stringify --title "$(shell cat build/$*.title)" --edition "$(shell cat build/$*.edition)" --html5 --lists < $< > $@
%.pdf: %.docx
soffice --headless --convert-to pdf --outdir build "$<"
build/%.form.json: %.md | build $(COMMONMARK)
$(COMMONMARK) parse --only form < $< > $@
build/%.title: %.md | build $(COMMONMARK) $(JSON)
$(COMMONMARK) parse < $< | $(JSON) frontMatter.title > $@
build/%.edition: %.md | build $(COMMONMARK) $(JSON)
$(COMMONMARK) parse < $< | $(JSON) frontMatter.edition > $@
$(TOOLS):
npm ci
build:
mkdir -p build
.PHONY: clean lint critique docker
clean:
rm -rf build
lint: $(FORMS) | $(COMMONMARK) $(LINT) $(JSON)
@for form in $(FORMS); do \
echo ; \
echo $$form; \
cat $$form | $(LINT) | $(JSON) -a message | sort -u; \
done; \
critique: $(FORMS) | $(CRITIQUE) $(JSON)
@for form in $(FORMS); do \
echo ; \
echo $$form ; \
cat $$form | $(CRITIQUE) | $(JSON) -a message | sort -u; \
done
docker:
docker build -t indie-open-source-paid-license .
docker run --name indie-open-source-paid-license indie-open-source-paid-license
docker cp indie-open-source-paid-license:/workdir/build .
docker rm indie-open-source-paid-license