#!/usr/bin/env bash # TODO: rewrite in node set -e current_dir=$(cd $(dirname $0) && pwd) cd ${current_dir} unameStr=`uname` if [[ "${unameStr}" == 'Linux' ]]; then SED='sed -i_orig ' CURL='wget ' elif [[ "${unameStr}" == 'Darwin' ]]; then SED='sed -i _orig' CURL='curl -O ' fi set +e head ./node_modules/bson/ext/bson.h | grep "#define USE_MISALIGNED_MEMORY_ACCESS 1" rebuild_bson=$? set -e arch=`uname -m` if [[ "${arch}" == 'armv6l' && "${rebuild_bson}" == 0 ]]; then # ARM support: https://github.com/mongodb/js-bson/issues/37 rm -rf ./node_modules/bson/build ${SED} -e "s/#define USE_MISALIGNED_MEMORY_ACCESS 1/#define USE_MISALIGNED_MEMORY_ACCESS 0/g" ./node_modules/bson/ext/bson.h head ./node_modules/bson/ext/bson.h | grep USE_MISALIGNED_MEMORY_ACCESS # npm does not let itself be called while running, so the following # does not work when this script is called by npm install # npm rebuild bson fi # patch ShareJS client if [ ! -f ./node_modules/share/webclient/share.js_orig ]; then ${SED} -e s/removeListener/removeEventListener/g ./node_modules/share/webclient/ace.js ${SED} -e s/removeListener/removeEventListener/g ./node_modules/share/webclient/share.js ${SED} -e s/removeListener/removeEventListener/g ./node_modules/share/webclient/share-ace.js ${SED} -e s/removeListener/removeEventListener/g ./node_modules/share/webclient/share.uncompressed.js fi if [[ -d ${HOME}/.prototyper-cache/lib && ! -d ./public/lib ]];then mkdir -p ./public/lib cp -r ${HOME}/.prototyper-cache/lib ./public fi # Knockout mkdir -p ./public/lib/knockout cd ./public/lib/knockout if [ ! -f ./knockout-min.js ]; then ${CURL} https://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.1/knockout-min.js fi if [ ! -f ./knockout-2.2.1.debug.js ]; then ${CURL} http://knockoutjs.com/downloads/knockout-2.2.1.debug.js fi if [ ! -f ./knockout.mapping-latest.js ]; then ${CURL} https://raw.github.com/SteveSanderson/knockout.mapping/master/build/output/knockout.mapping-latest.js fi if [ ! -f ./knockout.mapping-latest.debug.js ]; then ${CURL} https://raw.github.com/SteveSanderson/knockout.mapping/master/build/output/knockout.mapping-latest.debug.js fi if [ ! -f ./knockout-bootstrap.min.js ]; then ${CURL} https://raw.github.com/billpull/knockout-bootstrap/master/build/knockout-bootstrap.min.js fi if [ ! -f ./knockout.validation.min.js ]; then ${CURL} http://cdnjs.cloudflare.com/ajax/libs/knockout-validation/1.0.2/knockout.validation.min.js fi if [ ! -f ./knockout-sortable.js ]; then ${CURL} https://raw.github.com/rniemeyer/knockout-sortable/master/build/knockout-sortable.js fi if [ ! -f ./knockout-sortable.min.js ]; then ${CURL} https://raw.github.com/rniemeyer/knockout-sortable/master/build/knockout-sortable.min.js fi cd ${current_dir} # Bootstrap mkdir -p ./public/lib/bootstrap cd ./public/lib/bootstrap if [ ! -f ./bootstrap-combined.min.css ]; then ${CURL} http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css fi if [ ! -f ./bootstrap.min.js ]; then ${CURL} http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js fi cd ${current_dir} # http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/img/glyphicons-halflings.png mkdir -p ./public/lib/img cd ./public/lib/img if [ ! -f ./glyphicons-halflings.png ]; then ${CURL} http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/img/glyphicons-halflings.png fi if [ ! -f ./glyphicons-halflings-white.png ]; then ${CURL} http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/img/glyphicons-halflings-white.png fi cd ${current_dir} # JQuery mkdir -p ./public/lib/jquery cd ./public/lib/jquery if [ ! -f ./jquery.min.js ]; then ${CURL} http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js fi cd ${current_dir} # SockJS mkdir -p ./public/lib/sockjs cd ./public/lib/sockjs if [ ! -f ./sockjs-0.3.min.js ]; then ${CURL} http://cdn.sockjs.org/sockjs-0.3.min.js fi cd ${current_dir} # Underscore mkdir -p ./public/lib/underscore cd ./public/lib/underscore if [ ! -f ./underscore-min.js ]; then ${CURL} http://underscorejs.org/underscore-min.js fi cd ${current_dir} # //cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js mkdir -p ./public/lib/modernizr cd ./public/lib/modernizr if [ ! -f ./modernizr.min.js ]; then ${CURL} http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js fi cd ${current_dir} # //netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css mkdir -p ./public/lib/font-awesome cd ./public/lib/font-awesome if [ ! -f ./font-awesome.css ]; then ${CURL} http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css fi cd ${current_dir} # https://raw.github.com/cloudhead/less.js/master/dist/less-1.3.3.min.js mkdir -p ./public/lib/lessjs cd ./public/lib/lessjs if [ ! -f ./less-1.3.3.min.js ]; then ${CURL} https://raw.github.com/cloudhead/less.js/master/dist/less-1.3.3.min.js fi cd ${current_dir} if [ ! -d ${HOME}/.prototyper-cache ];then mkdir -p ${HOME}/.prototyper-cache fi cp -r ./public/lib ${HOME}/.prototyper-cache if [[ "${arch}" == 'armv6l' && ! -d ./node_modules/bson/build ]]; then echo "need to rebuild bson: 'npm rebuild bson' before running" fi