generated from customcommander/project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (59 loc) · 2.17 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
CC=java -jar /devtools/closure-compiler/compiler.jar
src_files = $(shell find src -type f -name "*.js")
dist_files = $(patsubst src/%,dist/%,$(src_files))
cookbook_files = $(shell find docs/cookbook -type f -name "*.js")
clean:; rm -rf dist
.PHONY: build/docs
build/docs: api.json build/docs/manual/cookbook.md build/mkdocs.yml
mkdir -p $(@D)
jq --raw-output '.[].function_name' $< | xargs -I {} $(MAKE) build/docs/api/{}.md
build/api.json: api.json
mkdir -p $(@D)
jq 'map(.function_name) | sort_by(ascii_downcase) | map({(.): "api/\(.).md"})' $< >$@
build/mkdocs.json: docs/mkdocs.yml.json build/api.json
mkdir -p $(@D)
jq --slurpfile api build/api.json '.nav += [{"Flight Manual": $$api[0]}]' $< >$@
build/mkdocs.yml: build/mkdocs.json
mkdir -p $(@D)
npx js-yaml $< >$@
build/docs/api/%.md: api.json docs/rtfm.ejs
mkdir -p $(@D)
FUNC=$* npx ejs --no-with -f $^ >$@
build/cookbook.raw.json: $(cookbook_files)
yarn -s jsdoc -X $^ >$@
build/cookbook.json: cookbook.jq build/cookbook.raw.json
jq -f $^ >$@
build/docs/manual/cookbook.md: build/cookbook.json docs/cookbook.ejs
yarn -s ejs --no-with -f $^ >$@
api.json: api.jq $(dist_files)
npx jsdoc -c jsdoc.json -X $^ | jq -f $< >$@
.PHONY: test
test: dist
yarn -s tape test/*.test.js
yarn -s tape docs/cookbook/*.js
.PHONY: dist
dist: $(dist_files) dist/index.js dist/browser.min.js
dist/%: src/%
mkdir -p $(@D)
cp $< $@
dist/_externs.js: api.json
mkdir -p $(@D)
jq --raw-output '"/** @externs */", "var __________;", (.[].function_name | "var \(.);")' $< >$@
dist/_exports.js: api.json
mkdir -p $(@D)
jq --raw-output '"window.__________ = {", (.[].function_name | " \(.): require(\"./\(.)\"),"),"};"' $< >$@
dist/_compiled.js: $(dist_files) dist/_exports.js dist/_externs.js
mkdir -p $(@D)
$(CC) --compilation_level ADVANCED_OPTIMIZATIONS \
--language_in ECMASCRIPT_NEXT \
--module_resolution NODE \
--process_common_js_modules \
--isolation_mode IIFE \
--js $^ \
--js_output_file $@
dist/index.js: dist/_compiled.js
mkdir -p $(@D)
sed 's/window.__________/module.exports/' $< > $@
dist/browser.min.js: dist/_compiled.js
mkdir -p $(@D)
sed 's#window.__________#window["$(LIBRARY_NAMESPACE)"]#' $< > $@