This repository has been archived by the owner on Oct 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
/
Makefile
194 lines (167 loc) · 6.11 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
.PHONY: build indentation htmlclass duk var node esm amd size hint clean test web preview pages dependencies
# repository name
REPO = document-register-element
# make var files
VAR = tmp/html-class.js tmp/$(REPO).js
# make var files
IE8 = src/$(REPO)-ie8.js
# make node files
NODE = $(VAR)
# make amd files
AMD = $(VAR)
# make innerHTML.js file
INNERHTML = src/innerHTML.js
# README constant
# default build task
build:
make clean
make htmlclass
make indentation
make var
make innerHTML
# make ie8
make dreie8
make node
make esm
make amd
make test
make hint
make size
rm -rf ./tmp
# build clean up htmlClass
htmlclass:
cat node_modules/html-class/index.js | sed -e "s/'use strict';//" | sed -e 's/try { module.exports = htmlClass; } catch(meh) {}//' > src/html-class.js
# build clean up htmlClass
indentation:
mkdir -p tmp
node -e 'require("fs").writeFileSync("tmp/html-class.js", require("fs").readFileSync("src/html-class.js").toString().replace(/^/mg," "))'
node -e 'require("fs").writeFileSync("tmp/document-register-element.js", require("fs").readFileSync("src/document-register-element.js").toString().replace(/^/mg," "))'
# build generic version
var:
mkdir -p build
cat template/var.before $(VAR) template/var.after >build/no-copy.$(REPO).max.js
node node_modules/uglify-js/bin/uglifyjs -m -c --verbose --support-ie8 build/no-copy.$(REPO).max.js >build/no-copy.$(REPO).js
cat template/license.before LICENSE.txt template/license.after build/no-copy.$(REPO).max.js >build/$(REPO).max.js
cat template/copyright build/no-copy.$(REPO).js >build/$(REPO).js
rm build/no-copy.$(REPO).max.js
rm build/no-copy.$(REPO).js
# build innerHTML function helper
innerHTML:
mkdir -p build
cat $(INNERHTML) >build/no-copy.innerHTML.max.js
node node_modules/uglify-js/bin/uglifyjs -m -c --verbose --support-ie8 build/no-copy.innerHTML.max.js >build/no-copy.innerHTML.js
cat template/license.before LICENSE.txt template/license.after build/no-copy.innerHTML.max.js >build/innerHTML.max.js
cat template/copyright build/no-copy.innerHTML.js >build/innerHTML.js
rm build/no-copy.innerHTML.max.js
rm build/no-copy.innerHTML.js
# build IE8 specific version
ie8:
mkdir -p build
cat template/var.before $(IE8) template/var.after >build/no-copy.$(REPO)-ie8.max.js
node node_modules/uglify-js/bin/uglifyjs -m -c --verbose --support-ie8 build/no-copy.$(REPO)-ie8.max.js >build/no-copy.$(REPO)-ie8.js
cat template/license.before LICENSE.txt template/license.after build/no-copy.$(REPO)-ie8.max.js >build/$(REPO)-ie8.max.js
cat template/copyright build/no-copy.$(REPO)-ie8.js >build/$(REPO)-ie8.js
rm build/no-copy.$(REPO)-ie8.max.js
rm build/no-copy.$(REPO)-ie8.js
dreie8:
mkdir -p build
cat src/dre-ie8-upfront-fix.js>build/no-copy.dre-ie8-upfront-fix.max.js
node node_modules/uglify-js/bin/uglifyjs -m -c --verbose --support-ie8 build/no-copy.dre-ie8-upfront-fix.max.js >build/no-copy.dre-ie8-upfront-fix.js
cat template/license.before LICENSE.txt template/license.after build/no-copy.dre-ie8-upfront-fix.max.js >build/dre-ie8-upfront-fix.max.js
cat template/copyright build/no-copy.dre-ie8-upfront-fix.js >build/dre-ie8-upfront-fix.js
rm build/no-copy.dre-ie8-upfront-fix.max.js
rm build/no-copy.dre-ie8-upfront-fix.js
# build node.js version
node:
mkdir -p build
mkdir -p pony
cat template/license.before LICENSE.txt template/license.after template/node.before $(NODE) template/node.after >build/$(REPO).node.js
cp build/$(REPO).node.js pony/index.js
echo 'installCustomElements(global);'>>build/$(REPO).node.js
# build ESM version
esm:
mkdir -p build
mkdir -p pony
cat template/license.before LICENSE.txt template/license.after template/esm.before $(NODE) template/esm.after >build/$(REPO).esm.js
cp build/$(REPO).esm.js pony/index.mjs
echo 'installCustomElements(window);'>>build/$(REPO).esm.js
# build AMD version
amd:
mkdir -p build
cat template/amd.before $(AMD) template/amd.after >build/no-copy.$(REPO).max.amd.js
node node_modules/uglify-js/bin/uglifyjs -m -c --verbose --support-ie8 build/no-copy.$(REPO).max.amd.js >build/no-copy.$(REPO).amd.js
cat template/license.before LICENSE.txt template/license.after build/no-copy.$(REPO).max.amd.js >build/$(REPO).max.amd.js
cat template/copyright build/no-copy.$(REPO).amd.js >build/$(REPO).amd.js
rm build/no-copy.$(REPO).max.amd.js
rm build/no-copy.$(REPO).amd.js
# build self executable for duktape
duk:
node -e 'var fs=require("fs");\
fs.writeFileSync(\
"test/duk.js",\
fs.readFileSync("node_modules/wru/build/wru.console.js") +\
"\n" +\
fs.readFileSync("build/$(REPO).js") +\
"\n" +\
fs.readFileSync("test/$(REPO).js").toString().replace(/^[^\x00]+?\/\/:remove\s*/,"")\
);'
size:
wc -c build/$(REPO).max.js
gzip -c build/$(REPO).js | wc -c
# hint built file
hint:
node node_modules/jshint/bin/jshint build/$(REPO).max.js
node node_modules/jshint/bin/jshint build/dre-ie8-upfront-fix.max.js
node node_modules/jshint/bin/jshint build/innerHTML.max.js
# clean/remove build folder
clean:
rm -rf build
# tests, as usual and of course
test:
npm test
# launch tiny-cdn (ctrl+click to open the page)
web:
node node_modules/tiny-cdn/tiny-cdn run -p=1337
# markdown the readme and view it
preview:
node_modules/markdown/bin/md2html.js README.md >README.md.htm
cat template/md.before README.md.htm template/md.after >README.md.html
open README.md.html
sleep 3
rm README.md.htm README.md.html
pages:
git pull --rebase
make htmlclass
make indentation
make var
make innerHTML
mkdir -p ~/tmp
mkdir -p ~/tmp/$(REPO)
cp .gitignore ~/tmp/
cp -rf src ~/tmp/$(REPO)
cp -rf build ~/tmp/$(REPO)
cp -rf test ~/tmp/$(REPO)
cp -rf examples ~/tmp/$(REPO)
cp index.html ~/tmp/$(REPO)
git checkout gh-pages
cp ~/tmp/.gitignore ./
mkdir -p test
rm -rf test
cp -rf ~/tmp/$(REPO) test
git add .gitignore
git add test
git add test/.
git commit -m 'automatic test generator'
git push
git checkout master
rm -r ~/tmp/$(REPO)
rm -rf ./tmp
# modules used in this repo
dependencies:
rm -rf node_modules
mkdir node_modules
npm install wru
npm install tiny-cdn
npm install uglify-js@2
npm install jshint
npm install markdown