-
Notifications
You must be signed in to change notification settings - Fork 2
/
install
executable file
·109 lines (100 loc) · 2.36 KB
/
install
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
#!/bin/sh
#
# specify dependencies as a list of {dir|file}:{symlink|spec} lines
# spec := COPY -- copy file; BUNDLE -- append file to a bundle
#
deps='
dvv/underscore/underscore.js:underscore.js
dvv/stereo:stereo
creationix/simple-mime/simple-mime.js:simple-mime.js
felixge/node-formidable:formidable
LearnBoost/Socket.IO-node:socket.io
samshull/node-proxy:node-proxy
flotype/now:now
'
#
# DO NOT CHANGE AFTER THIS LINE
#
WGET='wget -ct3 -q --progress=bar --no-check-certificate'
json() { # json, key
_node_tmp_=___node___
echo "for(d in JSON.parse(require('fs').readFileSync('$1','utf8')).$2){console.log(d)}" >${_node_tmp_}
node ${_node_tmp_}
rm -f ${_node_tmp_}
}
#
# download dependencies
#
lib=node_modules
COPY=public/js
BUNDLE=public/js/bundle.js
mkdir -p "$lib"
rm -f "$BUNDLE"
for dep in $deps; do
# skip comments
case "$dep" in
\#*) continue ;;
esac
# parse definition
path=${dep%:*}
link=${dep##*:}
author=${path%%/*}
path=${path#*/}
git=${path%%/*}
# fetch the package
echo -n "package ${author}'s $git: "
#continue
if ! test -d git/${git}; then
#git clone https://github.com/${author}/${git}.git git/${git}
mkdir -p git/${git}
$WGET http://nodeload.github.com/${author}/${git}/tarball/master -O- | tar -xzf- --strip 1 -C git/${git}
cd git/${git}
#if test -f Makefile; then
# make
#fi
if test -f wscript; then
node-waf distclean configure build
fi
# deps via package.json
#if test -f package.json; then
# json 'dependencies'
#fi
cd ../..
fi
# symlink entry point
if test "Q$link" = 'QBUNDLE'; then
echo "$path bundled into $BUNDLE"
cat "git/$path" >> "$BUNDLE"
elif test "Q$link" = 'QCOPY'; then
echo "$path copied to $COPY"
cp "git/$path" "$COPY"
elif test "Q$link" != 'Q'; then
echo "$path symlinked to $lib/$link"
test -e "$lib/$link" || ln -s "../git/$path" "$lib/$link"
fi
if false; then
cd git/${git}
# deps via package.json
if test -f package.json; then
json 'package.json' 'dependencies' | while read d; do
echo "depends on $d"
tmp1="___$d"
#wget "http://search.npmjs.org/api/$d" -O- | json '/dev/stdin' 'repository'
wget "http://search.npmjs.org/api/$d" -O ${tmp1}
json ${tmp1} 'repository' | while read drep; do
echo "DEPON $drep"
done
#rm -f ${tmp1}
done
fi
cd ../..
fi
done
#
# compile coffee
#
coffee -bc -o lib src
#
# minify client-side stuff
#
#jsmin "$BUNDLE"