-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·62 lines (58 loc) · 2.25 KB
/
Copy pathbuild
File metadata and controls
executable file
·62 lines (58 loc) · 2.25 KB
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
#!/usr/bin/env bash
rm -rf dist
mkdir -p dist
echo "build src/index.ls -> dist/index.js ..."
./node_modules/.bin/lsc -cp --no-header src/index.ls > dist/index.js
echo "minifying index.js ..."
./node_modules/.bin/uglifyjs dist/index.js -m -c > dist/index.min.js
echo "pdmaptw.register('county',{topo:" > dist/county.map.js
cat src/topojson/county.topo.json >> dist/county.map.js
echo ",meta:" >> dist/county.map.js
cat src/topojson/county.meta.json >> dist/county.map.js
echo "});" >> dist/county.map.js
echo "pdmaptw.register('town',{topo:" > dist/town.map.js
cat src/topojson/town.topo.json >> dist/town.map.js
echo ",meta:" >> dist/town.map.js
cat src/topojson/town.meta.json >> dist/town.map.js
echo "});" >> dist/town.map.js
echo "pdmaptw.register('village',{topo:" > dist/village.map.js
cat src/topojson/village.topo.json >> dist/village.map.js
echo ",meta:" >> dist/village.map.js
cat src/topojson/village.meta.json >> dist/village.map.js
echo "});" >> dist/village.map.js
mkdir -p dist/county
for f in src/topojson/county/*.topo.json; do
m="$(basename "$f" .topo.json)"
# `<county>` holds towns, `<county>.village` holds villages. each is registered under
# the type the frontend asks for; the town file also answers the explicit
# `county/<name>/town` so both levels can be addressed the same way.
case "$m" in
*.village)
n="${m%.village}"
meta=src/topojson/village.meta.json
reg="pdmaptw.register('county/$n/village',d);"
;;
*)
n="$m"
meta=src/topojson/town.meta.json
reg="pdmaptw.register('county/$n',d);pdmaptw.register('county/$n/town',d);"
;;
esac
echo "generate topojson for $m ..."
echo "(function(d){$reg})({topo:" > "dist/county/$m.map.js"
cat "$f" >> "dist/county/$m.map.js"
echo ",meta:" >> "dist/county/$m.map.js"
cat "$meta" >> "dist/county/$m.map.js"
echo "});" >> "dist/county/$m.map.js"
done
cp src/topojson/county.topo.json dist/
cp src/topojson/county.meta.json dist/
cp src/topojson/town.topo.json dist/
cp src/topojson/town.meta.json dist/
cp src/topojson/village.topo.json dist/
cp src/topojson/village.meta.json dist/
echo "deploy into local web ..."
rm -rf web/static/assets/lib/pdmaptw/dev
mkdir -p web/static/assets/lib/pdmaptw/dev
cp -R dist/* web/static/assets/lib/pdmaptw/dev
echo "done."