forked from sailpoint-oss/sailpoint-api-guidelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (52 loc) · 1.97 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
DOCKER := asciidoctor/docker-asciidoctor:latest
DIRMOUNTS := /documents
DIRCONTENTS := chapters
DIRSCRIPTS := scripts
DIRBUILDS := docs
DIRWORK := $(shell pwd -P)
.PHONY: all clean pull check assets
.PHONY: rules html pdf epub force
all: clean html pdf epub rules
clean:
rm -rf $(DIRBUILDS);
pull:
docker pull $(DOCKER);
check: check-rules
check-rules: check-rules-duplicates check-rules-incorrects
check-rules-duplicates:
@DUPLICATED="$$(grep -roE "\[#[0-9]+]" $(DIRCONTENTS) | sort |uniq -d)"; \
if [ -n "$${DUPLICATED}" ]; then \
echo "Duplicated Rule IDs: $$(echo "$${DUPLICATED}" | tr -d '\n')"; \
echo "Please make sure the Rule ID anchors are unique"; \
exit 1; \
fi;
check-rules-incorrects:
@INCORRECT="$$(grep -rnE "(\[[0-9]+\]|\[ +#?[0-9]+ +\])" $(DIRCONTENTS))"; \
if [ -n "$${INCORRECT}" ]; then \
echo -e "Incorrect Rule IDs:\n $${INCORRECT}"; \
echo "Please make sure that the Rule ID anchors conform to '\[#[0-9]+\]'"; \
exit 1; \
fi;
next-rule-id:
@IFS=$$'\r\n' GLOBIGNORE='*' command eval \
"RULE_IDS=($$(grep -rh "^.*\[#[0-9]\{1,5\}.*$$" $(DIRCONTENTS) | sort -r))"; \
echo $$(($$(echo $${RULE_IDS[0]} | tr -d '\[' | tr -d '\]' | tr -d '#') + 1));
assets:
mkdir -p $(DIRBUILDS);
cp -r assets $(DIRBUILDS)/assets;
cp -r models/* $(DIRBUILDS);
cp -r -n legacy/* $(DIRBUILDS);
rules: check-rules
$(DIRSCRIPTS)/generate-rules-json.sh | \
jq -s '{rules: . | sort}' | tee $(DIRBUILDS)/rules >$(DIRBUILDS)/rules.json;
html: check assets pull
docker run -v $(DIRWORK):$(DIRMOUNTS)/ ${DOCKER} asciidoctor \
-D $(DIRMOUNTS)/$(DIRBUILDS) index.adoc;
pdf: check pull
docker run -v $(DIRWORK):$(DIRMOUNTS)/ ${DOCKER} asciidoctor-pdf \
-D $(DIRMOUNTS)/$(DIRBUILDS) index.adoc;
mv -f $(DIRBUILDS)/index.pdf $(DIRBUILDS)/sailpoint-guidelines.pdf;
epub: check pull
docker run -v $(DIRWORK):$(DIRMOUNTS)/ ${DOCKER} asciidoctor-epub3 \
-D $(DIRMOUNTS)/$(DIRBUILDS) index.adoc;
mv -f $(DIRBUILDS)/index.epub $(DIRBUILDS)/sailpoint-guidelines.epub;