-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·78 lines (64 loc) · 2.53 KB
/
build.sh
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
#!/bin/bash
source scripts/util.sh # does set +e; provides 'has_flag' and 'resolved_args'
# Allow for using binaries in node_modules/:
export PATH="`pwd`/node_modules/.bin/:$PATH"
if has_flag "--help" ; then
echo "Usage: Use one or more of the following
--client:
Build HTML client."
exit
fi
######################################################
# SETUP SECTION
######################################################
# Run 'npm install'; clone submodules:
if has_flag "--setup" ; then
# Run 'npm install'
npm install
# Clone submodules, in 'scripts/' (a bit of a hijack of purpose, but all well)
pushd src
if [ ! -d DefinitelyTyped ] ; then
# In theory we would want to check out a specific commit,
# but while development is still experimental I see nothing
# wrong for now.
git clone --depth=1 https://github.com/borisyankov/DefinitelyTyped/
# HERE BE HACK
# Since we in general strive to use very up-to-date JavaScript tech,
# lets patch an issue with using TypeScript HEAD with ES6 export enabled.
for file in DefinitelyTyped/*/*.ts ; do
sed -i "s@import *\(.*\)= *require(\([\"'].*[\"']))@import * as \1from \2@g" "$file";
done
fi
popd
fi
if [ ! -d node_modules ] ; then
echo "Node.js dependencies have not been installed; please use './build.sh --setup'."
exit
fi
if [ ! -d src/DefinitelyTyped ] ; then
echo "DefinitelyTyped has not been cloned; please use './build.sh --setup'."
exit
fi
######################################################
# BUILD SECTION
######################################################
rm -rf ./build/ && mkdir -p ./build
echo "Running TypeScript compiler on src/... (fills ./build/es6)"
node ./scripts/tsc-bundled/tsc.js -project src
echo "Running Babel compiler on ./build/es6 (fills ./build/)"
pushd ./build/es6 && babel --optional runtime --loose all -d ../ `find -name '*.js'` && popd
# Copy over non-coffee files
cp -r src/client/*.html src/client/libs src/client/models src/client/css src/client/images build/client
mkdir -p build/client/jmarine && cp -r src/client/jmarine/*.js build/client/jmarine/
cp -r src/native/*.html build/client
cp -r build/native/*.js build/client
rm -f build/client/bin.js # Prevent mistakes if build fails
# Compile over coffee files
# pushd src
# coffee -o build/client -c models/*.coffee
# popd
# TODO revisit flag business
if has_flag "--client" ; then
# Run browserify:
browserify build/client/loader.js --outfile build/client/bin.js
fi