2011-11-24 15:05:22 +01:00
#!/bin/sh
2011-12-14 15:53:20 +01:00
cd ../media/src
2011-12-06 17:52:44 +01:00
# DEFAULTS
CLOSURE = "/usr/local/closure_compiler/compiler.jar"
2011-12-07 11:24:03 +01:00
JSDOC = "/usr/local/jsdoc/jsdoc"
2011-12-14 15:49:20 +01:00
CMD = $1
2011-12-06 17:52:44 +01:00
2011-12-14 15:49:20 +01:00
MAIN_FILE = "../js/jquery.dataTables.js"
MIN_FILE = "../js/jquery.dataTables.min.js"
2011-12-15 15:05:52 +01:00
VERSION = $( grep " * @version " DataTables.js | awk -F" " '{ print $3 }' )
2011-11-24 15:05:22 +01:00
2011-12-14 15:49:20 +01:00
echo ""
2011-12-14 15:53:20 +01:00
echo " DataTables build ( $VERSION ) "
2011-12-14 15:49:20 +01:00
echo ""
2011-11-24 15:05:22 +01:00
IFS = '%'
2011-12-14 15:49:20 +01:00
cp DataTables.js DataTables.js.build
echo " Building main script"
2011-11-24 15:05:22 +01:00
grep "require(" DataTables.js.build > /dev/null
while [ $? -eq 0 ] ; do
REQUIRE = $( grep "require(" DataTables.js.build | head -n 1)
SPACER = $( echo ${ REQUIRE } | cut -d r -f 1)
FILE = $( echo ${ REQUIRE } | sed -e "s#^.*require('##g" -e "s#');##" )
DIR = $( echo ${ FILE } | cut -d \. -f 1)
sed " s#^# ${ SPACER } # " < ${ DIR } /${ FILE } > ${ DIR } /${ FILE } .build
sed -e " / ${ REQUIRE } /r ${ DIR } / ${ FILE } .build " -e " / ${ REQUIRE } /d " < DataTables.js.build > DataTables.js.out
mv DataTables.js.out DataTables.js.build
rm ${ DIR } /${ FILE } .build
grep "require(" DataTables.js.build > /dev/null
done
2011-12-14 15:49:20 +01:00
mv DataTables.js.build $MAIN_FILE
if [ " $CMD " != "debug" ] ; then
2012-01-10 16:33:08 +01:00
if [ " $CMD " = "jshint" -o " $CMD " = "" -o " $CMD " = "cdn" ] ; then
2013-04-22 19:55:50 +02:00
echo " -- Skipping JS Hint"
# echo " JSHint"
# jshint --config ../../scripts/jshint.config $MAIN_FILE
# if [ $? -ne 0 ]; then
# echo " Errors occured - exiting"
# exit 1
# else
# echo " Pass"
# fi
2011-12-14 15:49:20 +01:00
fi
2012-01-10 16:33:08 +01:00
if [ " $CMD " = "compress" -o " $CMD " = "" -o " $CMD " = "cdn" ] ; then
2011-12-14 15:49:20 +01:00
echo " Minification"
2013-04-22 19:55:50 +02:00
echo " /*! DataTables $VERSION
* ©2008-2013 Allan Jardine - datatables.net/license
2011-12-14 15:53:20 +01:00
*/" > $MIN_FILE
java -jar $CLOSURE --js $MAIN_FILE >> $MIN_FILE
2011-12-14 15:49:20 +01:00
echo " Min JS file size: $( ls -l $MIN_FILE | awk -F" " '{ print $5 }' ) "
fi
if [ " $CMD " = "docs" -o " $CMD " = "" ] ; then
echo " Documentation"
$JSDOC -d ../../docs -t JSDoc-DataTables $MAIN_FILE
fi
2012-01-10 16:33:08 +01:00
if [ " $CMD " = "cdn" ] ; then
echo " CDN"
if [ -d ../../cdn ] ; then
rm -Rf ../../cdn
fi
mkdir ../../cdn
mkdir ../../cdn/css
cp $MAIN_FILE ../../cdn
cp $MIN_FILE ../../cdn
cp ../css/jquery.dataTables.css ../../cdn/css
cp ../css/jquery.dataTables_themeroller.css ../../cdn/css
cp -r ../images ../../cdn/
rm ../../cdn/images/Sorting\ icons.psd
fi
2011-12-14 15:49:20 +01:00
fi
2011-12-06 17:52:44 +01:00
2012-09-15 11:52:19 +02:00
# Back to DataTables root dir
cd ../..
#
# Packaging files
#
cat <<EOF > package.json
{
"name" : "DataTables" ,
"version" : " ${ VERSION } " ,
"title" : "DataTables" ,
"author" : {
"name" : "Allan Jardine" ,
"url" : "http://sprymedia.co.uk"
} ,
"licenses" : [
{
"type" : "BSD" ,
"url" : "http://datatables.net/license_bsd"
} ,
{
"type" : "GPLv2" ,
"url" : "http://datatables.net/license_gpl2"
}
] ,
"dependencies" : {
"jquery" : "1.4 - 1.8"
} ,
"description" : "DataTables enhances HTML tables with the ability to sort, filter and page the data in the table very easily. It provides a comprehensive API and set of configuration options, allowing you to consume data from virtually any data source." ,
"keywords" : [
"DataTables" ,
"DataTable" ,
"table" ,
"grid" ,
"filter" ,
"sort" ,
"page" ,
"internationalisable"
] ,
"homepage" : "http://datatables.net"
}
EOF
cat <<EOF > component.json
{
"name" : "DataTables" ,
"version" : " ${ VERSION } " ,
"main" : [
"./media/js/jquery.dataTables.js" ,
2012-10-28 17:35:57 +01:00
"./media/css/jquery.dataTables.css"
2012-09-15 11:52:19 +02:00
] ,
"dependencies" : {
"jquery" : "~1.8.0"
}
}
EOF
2011-12-14 15:49:20 +01:00
echo " Done\n"
2011-12-06 17:52:44 +01:00
2011-12-07 11:24:03 +01:00