make.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/bin/sh
  2. cd ../media/src
  3. # DEFAULTS
  4. CLOSURE="/usr/local/closure_compiler/compiler.jar"
  5. JSDOC="/usr/local/jsdoc/jsdoc"
  6. CMD=$1
  7. MAIN_FILE="../js/jquery.dataTables.js"
  8. MIN_FILE="../js/jquery.dataTables.min.js"
  9. VERSION=$(grep " * @version " DataTables.js | awk -F" " '{ print $3 }')
  10. echo ""
  11. echo " DataTables build ($VERSION)"
  12. echo ""
  13. IFS='%'
  14. cp DataTables.js DataTables.js.build
  15. echo " Building main script"
  16. grep "require(" DataTables.js.build > /dev/null
  17. while [ $? -eq 0 ]; do
  18. REQUIRE=$(grep "require(" DataTables.js.build | head -n 1)
  19. SPACER=$(echo ${REQUIRE} | cut -d r -f 1)
  20. FILE=$(echo ${REQUIRE} | sed -e "s#^.*require('##g" -e "s#');##")
  21. DIR=$(echo ${FILE} | cut -d \. -f 1)
  22. sed "s#^#${SPACER}#" < ${DIR}/${FILE} > ${DIR}/${FILE}.build
  23. sed -e "/${REQUIRE}/r ${DIR}/${FILE}.build" -e "/${REQUIRE}/d" < DataTables.js.build > DataTables.js.out
  24. mv DataTables.js.out DataTables.js.build
  25. rm ${DIR}/${FILE}.build
  26. grep "require(" DataTables.js.build > /dev/null
  27. done
  28. mv DataTables.js.build $MAIN_FILE
  29. if [ "$CMD" != "debug" ]; then
  30. if [ "$CMD" = "jshint" -o "$CMD" = "" -o "$CMD" = "cdn" ]; then
  31. echo " JSHint"
  32. jshint $MAIN_FILE --config ../../scripts/jshint.config
  33. if [ $? -ne 0 ]; then
  34. echo " Errors occured - exiting"
  35. exit 1
  36. else
  37. echo " Pass"
  38. fi
  39. fi
  40. if [ "$CMD" = "compress" -o "$CMD" = "" -o "$CMD" = "cdn" ]; then
  41. echo " Minification"
  42. echo "/*
  43. * File: jquery.dataTables.min.js
  44. * Version: $VERSION
  45. * Author: Allan Jardine (www.sprymedia.co.uk)
  46. * Info: www.datatables.net
  47. *
  48. * Copyright 2008-2012 Allan Jardine, all rights reserved.
  49. *
  50. * This source file is free software, under either the GPL v2 license or a
  51. * BSD style license, available at:
  52. * http://datatables.net/license_gpl2
  53. * http://datatables.net/license_bsd
  54. *
  55. * This source file is distributed in the hope that it will be useful, but
  56. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  57. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  58. */" > $MIN_FILE
  59. java -jar $CLOSURE --js $MAIN_FILE >> $MIN_FILE
  60. echo " Min JS file size: $(ls -l $MIN_FILE | awk -F" " '{ print $5 }')"
  61. fi
  62. if [ "$CMD" = "docs" -o "$CMD" = "" ]; then
  63. echo " Documentation"
  64. $JSDOC -d ../../docs -t JSDoc-DataTables $MAIN_FILE
  65. fi
  66. if [ "$CMD" = "cdn" ]; then
  67. echo " CDN"
  68. if [ -d ../../cdn ]; then
  69. rm -Rf ../../cdn
  70. fi
  71. mkdir ../../cdn
  72. mkdir ../../cdn/css
  73. cp $MAIN_FILE ../../cdn
  74. cp $MIN_FILE ../../cdn
  75. cp ../css/jquery.dataTables.css ../../cdn/css
  76. cp ../css/jquery.dataTables_themeroller.css ../../cdn/css
  77. cp -r ../images ../../cdn/
  78. rm ../../cdn/images/Sorting\ icons.psd
  79. fi
  80. fi
  81. # Back to DataTables root dir
  82. cd ../..
  83. #
  84. # Packaging files
  85. #
  86. cat <<EOF > package.json
  87. {
  88. "name": "DataTables",
  89. "version": "${VERSION}",
  90. "title": "DataTables",
  91. "author": {
  92. "name": "Allan Jardine",
  93. "url": "http://sprymedia.co.uk"
  94. },
  95. "licenses": [
  96. {
  97. "type": "BSD",
  98. "url": "http://datatables.net/license_bsd"
  99. },
  100. {
  101. "type": "GPLv2",
  102. "url": "http://datatables.net/license_gpl2"
  103. }
  104. ],
  105. "dependencies": {
  106. "jquery": "1.4 - 1.8"
  107. },
  108. "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.",
  109. "keywords": [
  110. "DataTables",
  111. "DataTable",
  112. "table",
  113. "grid",
  114. "filter",
  115. "sort",
  116. "page",
  117. "internationalisable"
  118. ],
  119. "homepage": "http://datatables.net"
  120. }
  121. EOF
  122. cat <<EOF > component.json
  123. {
  124. "name": "DataTables",
  125. "version": "${VERSION}",
  126. "main": [
  127. "./media/js/jquery.dataTables.js",
  128. "./media/css/jquery.dataTables.css",
  129. ],
  130. "dependencies": {
  131. "jquery": "~1.8.0"
  132. }
  133. }
  134. EOF
  135. echo " Done\n"