/wrmldoc/build.sh

https://github.com/wrml/wrml · Shell · 264 lines · 66 code · 74 blank · 124 comment · 0 complexity · 4ea1812241de75617805bdd50c449f1f MD5 · raw file

  1. #! /bin/bash
  2. ##########################################################################################
  3. # #
  4. # WRML - Web Resource Modeling Language #
  5. # __ __ ______ __ __ __ #
  6. # /\ \ _ \ \ /\ == \ /\ "-./ \ /\ \ #
  7. # \ \ \/ ".\ \\ \ __< \ \ \-./\ \\ \ \____ #
  8. # \ \__/".~\_\\ \_\ \_\\ \_\ \ \_\\ \_____\ #
  9. # \/_/ \/_/ \/_/ /_/ \/_/ \/_/ \/_____/ #
  10. # #
  11. # http://www.wrml.org #
  12. # #
  13. # Copyright 2011 - 2013 Mark Masse (OSS project WRML.org) #
  14. # #
  15. # Licensed under the Apache License, Version 2.0 (the "License"); #
  16. # you may not use this file except in compliance with the License. #
  17. # You may obtain a copy of the License at #
  18. # #
  19. # http://www.apache.org/licenses/LICENSE-2.0 #
  20. # #
  21. # Unless required by applicable law or agreed to in writing, software #
  22. # distributed under the License is distributed on an "AS IS" BASIS, #
  23. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
  24. # See the License for the specific language governing permissions and #
  25. # limitations under the License. #
  26. # #
  27. ##########################################################################################
  28. ##################################################
  29. # Dependencies
  30. ##################################################
  31. ########################
  32. # CoffeeScript
  33. # http://coffeescript.org
  34. #
  35. # Add "coffee" command to your path
  36. # npm install -g coffee-script
  37. ########################
  38. ########################
  39. # ECO Templates (Embedded CoffeeScript)
  40. # https://github.com/sstephenson/eco
  41. #
  42. # Add "eco" command to your path
  43. # On MacOS, the NODE_PATH env var is needed for eco command line to work.
  44. # NODE_PATH=/usr/local/lib/node:/usr/local/lib/node_modules
  45. #######################
  46. #######################
  47. # Closure Compiler
  48. # https://developers.google.com/closure/compiler
  49. #
  50. # Download Closure Compiler: http://closure-compiler.googlecode.com/files/compiler-latest.zip
  51. # Unzip and configure the CLOSURE_JAR_PATH variable below
  52. #######################
  53. #######################
  54. # YUI Compressor
  55. # https://github.com/yui/yuicompressor
  56. #
  57. # Download YUI Compressor: https://github.com/yui/yuicompressor/downloads
  58. # Decompress and configure the YUI_COMPRESSOR_JAR_PATH variable below
  59. #######################
  60. #######################
  61. # Sass
  62. # http://sass-lang.com/
  63. #
  64. # gem install sass
  65. # Download Sass: http://sass-lang.com/download.html
  66. #######################
  67. ##################################################
  68. # Script Variables
  69. ##################################################
  70. APP_NAME=wrmldoc
  71. JS_PATH=js
  72. JS_LIB_PATH=${JS_PATH}/lib
  73. JS_APP_PATH=${JS_PATH}/app
  74. COMPILED_LIB_JS=${JS_PATH}/lib.js
  75. COMPILED_LIB_MIN_JS=${JS_PATH}/lib.min.js
  76. COMPILED_APP_JS=${JS_PATH}/${APP_NAME}.js
  77. COMPILED_APP_MIN_JS=${JS_PATH}/${APP_NAME}.min.js
  78. CSS_PATH=css
  79. CSS_LIB_PATH=${CSS_PATH}/lib
  80. CSS_APP_PATH=${CSS_PATH}/app
  81. COMPILED_LIB_CSS=${CSS_PATH}/lib.css
  82. COMPILED_APP_SCSS=${CSS_PATH}/${APP_NAME}.scss
  83. COMPILED_APP_CSS=${CSS_PATH}/${APP_NAME}.tmp.css
  84. COMPILED_FINAL_CSS=${CSS_PATH}/${APP_NAME}.css
  85. COMPILED_FINAL_MIN_CSS=${CSS_PATH}/${APP_NAME}.min.css
  86. ##################################################
  87. # Environment Variables
  88. ##################################################
  89. TOOLS_PATH=~/bin
  90. CLOSURE_JAR_PATH=${TOOLS_PATH}/closure/compiler.jar
  91. YUI_COMPRESSOR_JAR_PATH=${TOOLS_PATH}/yuicompressor/build/yuicompressor-2.4.8.jar
  92. ##################################################
  93. # Clean previous run
  94. ##################################################
  95. # Remove the previous compilation
  96. rm ${COMPILED_LIB_JS}
  97. rm ${COMPILED_LIB_MIN_JS}
  98. rm ${COMPILED_APP_JS}
  99. rm ${COMPILED_APP_MIN_JS}
  100. rm ${COMPILED_LIB_CSS}
  101. rm ${COMPILED_APP_SCSS}
  102. rm ${COMPILED_APP_CSS}
  103. rm ${COMPILED_FINAL_CSS}
  104. rm ${COMPILED_FINAL_MIN_CSS}
  105. ##################################################
  106. # Compile the lib.js file
  107. ##################################################
  108. # Concat all of the lib/ .js files
  109. #######################
  110. # jQuery
  111. #######################
  112. cat ${JS_LIB_PATH}/jquery.js > ${COMPILED_LIB_JS}
  113. #######################
  114. # Marionette
  115. #######################
  116. # TODO: Replace this with xargs and a file that lists the files in order
  117. cat ${JS_LIB_PATH}/underscore.js >> ${COMPILED_LIB_JS}
  118. cat ${JS_LIB_PATH}/json2.js >> ${COMPILED_LIB_JS}
  119. cat ${JS_LIB_PATH}/backbone.js >> ${COMPILED_LIB_JS}
  120. cat ${JS_LIB_PATH}/marionette.js >> ${COMPILED_LIB_JS}
  121. cat ${JS_LIB_PATH}/syphon.js >> ${COMPILED_LIB_JS}
  122. # TODO: This produces errors for some reason
  123. #cat ${JS_LIB_PATH}/jstree.js >> ${COMPILED_LIB_JS}
  124. #######################
  125. # Bootstrap
  126. #######################
  127. cat ${JS_LIB_PATH}/bootstrap.js >> ${COMPILED_LIB_JS}
  128. echo "Compiled ${COMPILED_LIB_JS}"
  129. ##################################################
  130. # Minify the lib.js with YUI Compressor
  131. ##################################################
  132. java -jar ${YUI_COMPRESSOR_JAR_PATH} ${COMPILED_LIB_JS} -o ${COMPILED_LIB_MIN_JS}
  133. ##################################################
  134. # Compile App's CoffeeScript
  135. ##################################################
  136. # Compile the .coffee files to .js
  137. coffee -b -c ${JS_APP_PATH}
  138. echo "Compiled all CoffeeScript files found here: ${JS_APP_PATH}"
  139. ##################################################
  140. # Compile App's ECO templates
  141. ##################################################
  142. # Compile the .eco files to .js
  143. eco ${JS_APP_PATH}
  144. echo "Compiled all ECO templates found here: ${JS_APP_PATH}"
  145. ##################################################
  146. # Compile the App's .js file
  147. ##################################################
  148. # TODO: Replace this with xargs and a file that lists the files/paths in order
  149. cat $(find ${JS_APP_PATH}/config -name *.js) > ${COMPILED_APP_JS}
  150. cat ${JS_APP_PATH}/*.js >> ${COMPILED_APP_JS}
  151. cat $(find ${JS_APP_PATH}/views -name *.js) >> ${COMPILED_APP_JS}
  152. cat $(find ${JS_APP_PATH}/entities -name *.js) >> ${COMPILED_APP_JS}
  153. cat $(find ${JS_APP_PATH}/controllers -name *.js) >> ${COMPILED_APP_JS}
  154. cat $(find ${JS_APP_PATH}/components -name *.js) >> ${COMPILED_APP_JS}
  155. cat $(find ${JS_APP_PATH}/apps -name *.js) >> ${COMPILED_APP_JS}
  156. echo "Compiled ${COMPILED_APP_JS}"
  157. ##################################################
  158. # Clean up App's temporary .js files
  159. ##################################################
  160. # Remove all of the compiled CoffeeScript and ECO JS files
  161. find ${JS_APP_PATH} -name *.js -exec rm -f {} \;
  162. ##################################################
  163. # Minify the App's .js with Closure Compiler
  164. ##################################################
  165. java -jar ${CLOSURE_JAR_PATH} --js ${COMPILED_APP_JS} --js_output_file ${COMPILED_APP_MIN_JS}
  166. echo "Minified ${COMPILED_APP_JS} to ${COMPILED_APP_MIN_JS} with ${CLOSURE_JAR_PATH}"
  167. ##################################################
  168. # Compile the App .scss
  169. ##################################################
  170. # TODO: Replace this with xargs and a file that lists the paths in order
  171. cat ${CSS_APP_PATH}/*.scss > ${COMPILED_APP_SCSS}
  172. cat $(find ${CSS_APP_PATH}/components -name *.scss) >> ${COMPILED_APP_SCSS}
  173. cat $(find ${CSS_APP_PATH}/apps -name *.scss) >> ${COMPILED_APP_SCSS}
  174. echo "Compiled ${COMPILED_APP_SCSS}"
  175. ##################################################
  176. # Compile the App .css
  177. ##################################################
  178. cat $(find ${CSS_LIB_PATH} -name *.css) > ${COMPILED_LIB_CSS}
  179. echo "Compiled ${COMPILED_LIB_CSS} from ${CSS_LIB_PATH} .css files"
  180. cat ${COMPILED_LIB_CSS} > ${COMPILED_FINAL_CSS}
  181. echo "Appended ${COMPILED_LIB_CSS} file to ${COMPILED_FINAL_CSS}"
  182. sass -scss --update ${COMPILED_APP_SCSS}:${COMPILED_APP_CSS}
  183. echo "Compiled ${COMPILED_APP_SCSS} to ${COMPILED_APP_CSS} with sass"
  184. cat ${COMPILED_APP_CSS} >> ${COMPILED_FINAL_CSS}
  185. echo "Appended ${COMPILED_APP_CSS} file to ${COMPILED_FINAL_CSS}"
  186. ##################################################
  187. # Minify the App .css with YUI Compressor
  188. ##################################################
  189. java -jar ${YUI_COMPRESSOR_JAR_PATH} ${COMPILED_FINAL_CSS} -o ${COMPILED_FINAL_MIN_CSS}
  190. echo "Minified ${COMPILED_FINAL_CSS} to ${COMPILED_FINAL_MIN_CSS} with ${YUI_COMPRESSOR_JAR_PATH}"