forked from react-grid-layout/react-grid-layout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (67 loc) · 1.99 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
.DELETE_ON_ERROR:
export BIN := $(shell npm bin)
PATH := $(BIN):$(PATH)
DIST = ./dist
BUILD = ./build
LIB = ./lib
TEST = ./test
MIN = $(DIST)/react-grid-layout.min.js
MIN_MAP = $(DIST)/react-grid-layout.min.js.map
.PHONY: test dev lint build clean install link
build: clean build-js copy-flow $(MIN)
clean:
rm -rf $(BUILD) $(DIST)
dev:
echo 'Open http://localhost:4002'
@$(BIN)/webpack-dev-server --config webpack-dev-server.config.js --hot --progress --colors --port 4002 --content-base .
# Allows usage of `make install`, `make link`
install link:
@npm $@
# Build browser module
dist/%.min.js: $(LIB) $(BIN)
@$(BIN)/webpack
# find/exec is more cross-platform compatible than `rename`
build-js:
@$(BIN)/babel --stage 0 --out-dir $(BUILD) $(LIB)
build-example:
webpack --config webpack-examples.config.js
node ./examples/generate.js
# Copy original source as `.js.flow` for use with flow
copy-flow:
# Create tmpdir & copy
$(eval TMP := $(shell mktemp -d))
cp -R $(LIB)/ $(TMP)
# Rename extensions
find $(TMP) -type f -name '*.js*' -exec sh -c 'mv -f "$$0" "$${0%.*}.js.flow"' {} \;
# Copy into build
cp -R $(TMP)/ $(BUILD)
# Remove tmpdir
rm -rf $(TMP)
# FIXME flow is usually global
lint:
flow
@$(BIN)/eslint --ext .js,.jsx $(LIB) $(TEST)
@$(BIN)/valiquire $(LIB)
release-patch: build
@$(call release,patch)
release-minor: build
@$(call release,minor)
release-major: build
@$(call release,major)
publish:
git push --tags origin HEAD:master
npm publish
define release
VERSION=`node -pe "require('./package.json').version"` && \
NEXT_VERSION=`node -pe "require('semver').inc(\"$$VERSION\", '$(1)')"` && \
node -e "\
['./package.json'].forEach(function(fileName) {\
var j = require(fileName);\
j.version = \"$$NEXT_VERSION\";\
var s = JSON.stringify(j, null, 2);\
require('fs').writeFileSync(fileName, s);\
});" && \
git add package.json CHANGELOG.md $(MIN) $(MIN_MAP) && \
git commit -m "release $$NEXT_VERSION" && \
git tag "$$NEXT_VERSION" -m "release $$NEXT_VERSION"
endef