1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-12 00:08:48 +01:00
DataTables/scripts/make.sh

151 lines
3.2 KiB
Bash
Raw Normal View History

#!/bin/sh
2011-12-14 15:53:20 +01:00
cd ../media/src
# DEFAULTS
CLOSURE="/usr/local/closure_compiler/compiler.jar"
JSDOC="/usr/local/jsdoc/jsdoc"
CMD=$1
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 }')
echo ""
2011-12-14 15:53:20 +01:00
echo " DataTables build ($VERSION)"
echo ""
IFS='%'
cp DataTables.js DataTables.js.build
echo " Building main script"
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
mv DataTables.js.build $MAIN_FILE
if [ "$CMD" != "debug" ]; then
if [ "$CMD" = "jshint" -o "$CMD" = "" -o "$CMD" = "cdn" ]; then
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
fi
if [ "$CMD" = "compress" -o "$CMD" = "" -o "$CMD" = "cdn" ]; then
echo " Minification"
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
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
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
fi
# 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",
"./media/css/jquery.dataTables.css"
],
"dependencies": {
"jquery": "~1.8.0"
}
}
EOF
echo " Done\n"