-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
113 lines (83 loc) · 2.58 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
.DELETE_ON_ERROR:
BIN = ./node_modules/.bin
TESTS = $(shell find src -path '*/__tests__/*-test.js')
FIXTURES = $(shell find src -path '*/__tests__/*-fixture/*.js')
SRC = $(filter-out $(TESTS) $(FIXTURES), $(shell find src -name '*.js'))
SRC_CMD = $(shell find src/bin -type f -name '*')
LIB = $(SRC:src/%=lib/%)
LIB_DECL = $(SRC:src/%=lib/%.flow)
LIB_CMD = $(SRC_CMD:src/%=lib/%)
VERSION = $(shell node -e 'console.log(require("./package.json").version)')
build:: build-lib build-cmd build-decl
build-lib::
@$(MAKE) -j 8 $(LIB)
build-cmd::
@$(MAKE) -j 8 $(LIB_CMD)
build-decl::
@$(MAKE) -j 8 $(LIB_DECL)
lint::
@$(BIN)/eslint src
check::
@$(BIN)/flow --show-all-errors src
test::
@$(BIN)/jest
test-cov::
@$(BIN)/jest --coverage
ci::
@$(BIN)/jest --watch
sloc::
@$(BIN)/sloc -e __tests__ src
_publish-git:
git tag $(VERSION)
git push --tags origin HEAD:master
_publish-alpha-npm: build
npm publish --tag alpha
publish: _publish-git _publish-alpha-npm
site-build:
@$(MAKE) -C site build
site-develop:
@$(MAKE) -C site develop
site-publish: site-build
@$(BIN)/gh-pages -d ./site
version-major version-minor version-patch:: lint test
@npm version $(@:version-%=%)
push::
@git push --tags origin HEAD:master
clean::
@rm -rf lib
lib/%.js: src/%.js
@echo "Building $<"
@mkdir -p $(@D)
@$(BIN)/babel $(BABEL_OPTIONS) -o $@ $<
lib/%.js.flow: src/%.js
@echo "Building type declarations $<"
@mkdir -p $(@D)
@cp $< $@
lib/bin/%: src/bin/%
@echo "Building command $<"
@mkdir -p $(@D)
@$(BIN)/babel $(BABEL_OPTIONS) -o $@ $<
@chmod +x $@
PARSE_FIXTURES_MD := $(filter-out %.failure.md,$(shell find src/parse/__tests__ -name '*.md'))
PARSE_FIXTURES_JSON := $(PARSE_FIXTURES_MD:%.md=%.json)
build-parse-fixtures:: build $(PARSE_FIXTURES_JSON)
clean-parse-fixtures::
rm -f $(PARSE_FIXTURES_JSON)
src/parse/__tests__/%.json: src/parse/__tests__/%.md
@echo "Parsing $<"
@./lib/bin/reactdown-parse $< > $@
RENDER_FIXTURES_MD := $(shell find src/render/__tests__ -name '*.md')
RENDER_FIXTURES_JSON := $(RENDER_FIXTURES_MD:%.md=%.json)
RENDER_FIXTURES_JS := $(RENDER_FIXTURES_MD:%.md=%.js)
build-render-fixtures:: build $(RENDER_FIXTURES_JS) $(RENDER_FIXTURES_JSON)
clean-render-fixtures::
rm -f $(RENDER_FIXTURES_JSON) $(RENDER_FIXTURES_JS)
src/render/__tests__/%.json: src/render/__tests__/%.md
@echo "Parsing $<"
@./lib/bin/reactdown-parse $< > $@
src/render/__tests__/%.js: src/render/__tests__/%.md
@echo "Rendering $<"
@./lib/bin/reactdown-render \
--directive Block=lib?Block \
--directive SubBlock=lib/SubBlock \
$< > $@