forked from riot/riot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
148 lines (120 loc) · 3.87 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# if no "v" var given, default to package version
v ?= $(shell node -pe "require('./package.json').version")
# expand variable (so we can use it on branches w/o package.json)
VERSION := $(v)
# get x.x.* part of the version number
MINOR_VERSION = `echo $(VERSION) | sed 's/\.[^.]*$$//'`
# Command line paths
C8 = ./node_modules/c8/bin/c8.js
WDIO = ./node_modules/.bin/wdio
SERVE = ./node_modules/.bin/serve
START_SERVER_AND_TEST = ./node_modules/.bin/start-server-and-test
ESLINT = ./node_modules/eslint/bin/eslint.js
MOCHA = ./node_modules/mocha/bin/_mocha
ROLLUP = ./node_modules/.bin/rollup
PRETTIER = ./node_modules/.bin/prettier
MINIFY = ./node_modules/.bin/terser
RIOT_CLI = ./node_modules/.bin/riot
TSC = ./node_modules/.bin/tsc
# folders
DIST = dist/riot/
SRC = src
CONFIG = config/
GENERATED_FILES = riot.js riot+compiler.js
# Options needed to generate the rollup esm bundle
ROLLUP_ESM_OPTIONS = --format esm \
--output.preserveModules \
--amd.forceJsExtensionForImports \
--preserveModulesRoot src \
--config rollup.config.js \
--dir $(DIST)esm
# Options we will pass to the minifier
MINIFY_OPTIONS = --comments false \
--toplevel \
--compress pure_funcs=['panic'],unsafe=true,unsafe_symbols=true,passes=5 \
--mangle \
test: lint unit-test test-typing
unit-test:
@ $(START_SERVER_AND_TEST) $(SERVE) 3000 "$(C8) -r lcov -r text $(MOCHA) -r test/setup.js test/**/*.spec.js"
e2e-test:
# build the e2e bundle
@ $(ROLLUP) -c test/e2e/rollup.config.js
@ $(START_SERVER_AND_TEST) $(SERVE) 3000 "$(WDIO) run ./wdio.conf.js"
lint:
# check if the code looks pretty
@ $(PRETTIER) --check ./
# check code style
@ $(ESLINT) src test
test-typing:
# silent compile typescript
@ $(TSC) -p ./test
raw:
# build riot
@ mkdir -p $(DIST)
# Default builds UMD
@ $(ROLLUP) src/riot.js --format umd --config rollup.config.js --file $(DIST)riot.js
@ HAS_VISUALIZER=1 $(ROLLUP) src/riot+compiler.js --format umd --config rollup.config.js --file $(DIST)riot+compiler.js
@ $(ROLLUP) src/riot.js $(ROLLUP_ESM_OPTIONS)
@ $(ROLLUP) src/riot+compiler.js $(ROLLUP_ESM_OPTIONS)
# alias the common js files renaming the umd js -> cjs
@ mkdir -p $(DIST)/cjs
@ cp $(DIST)/riot.js $(DIST)/cjs/riot.cjs
@ cp $(DIST)/riot+compiler.js $(DIST)/cjs/riot+compiler.cjs
clean:
# delete old esm folder
@ rm -rf esm
# clean $(DIST)
@ rm -rf $(DIST)
riot: clean raw test
min:
# minify riot
@ $(MINIFY) $(DIST)riot.js $(MINIFY_OPTIONS) -o $(DIST)riot.min.js;
# minify the riot+compiler
@ $(MINIFY) $(DIST)riot+compiler.js $(MINIFY_OPTIONS) -o $(DIST)riot+compiler.min.js;
build:
# generate riot.js & riot.min.js
@ make min
@ cp -r dist/riot/* .
# write version in riot.js
@ sed -i '' 's/WIP/v$(VERSION)/g' riot*.js esm/*.js esm/**/*.js
bump:
# grab all latest changes to main
# (if there's any uncommited changes, it will stop here)
# bump version in *.json files
@ sed -i '' 's/\("version": "\)[^"]*/\1'$(VERSION)'/' package.json
# update the lock file as well
@ npm i
@ make build
@ git status --short
bump-undo:
# remove all uncommited changes
@ git reset --hard
version:
# @ git checkout main
# create version commit
@ git status --short
@ git add --all
@ git commit -am "$(VERSION)"
@ git log --oneline -2
# create version tag
@ git tag -a 'v'$(VERSION) -m $(VERSION)
@ git describe
version-undo:
# remove the version tag
@ git tag -d 'v'$(VERSION)
@ git describe
# remove the version commit
@ git reset `git rev-parse :/$(VERSION)`
@ git reset HEAD^
@ git log --oneline -2
release: riot min bump version
release-undo:
make version-undo
make bump-undo
publish:
# push new version to npm and github
# (github tag will also trigger an update in bower, component, cdnjs, etc)
@ npm publish
@ git push origin main
@ git push origin main --tags
.PHONY: test unit-test e2e-test min lint raw riot build bump bump-undo version version-undo release-undo publish