rakefile.rb 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. require 'fileutils'
  2. siteurl = "https://www.sharelatex.com"
  3. desc "Compile JavaScirpt into CoffeeScript"
  4. namespace 'setup' do
  5. desc "installes npm packages json and global stuff like less"
  6. task :installDependencys do
  7. sh %{npm install}
  8. sh %{npm install -g coffee-script}
  9. sh %{git submodule init}
  10. sh %{git submodule update}
  11. end
  12. end
  13. namespace 'run' do
  14. desc "compiles and runs the javascirpt version of the app"
  15. task :app => ["compile:app"] do
  16. sh %{node app.js | bunyan} do |ok, res|
  17. if ! ok
  18. raise "error compiling app folder tests : #{res}"
  19. end
  20. puts 'finished app compile'
  21. end
  22. end
  23. end
  24. namespace 'compile' do
  25. desc "compiles main app folder"
  26. task :app do
  27. puts "Compiling app folder to JS"
  28. FileUtils.rm_rf "app/js"
  29. sh %{coffee -c -o app/js/ app/coffee/} do |ok, res|
  30. if ! ok
  31. raise "error compiling app folder tests : #{res}"
  32. end
  33. puts 'finished app compile'
  34. end
  35. sh %{coffee -c app.coffee} do |ok, res|
  36. if ! ok
  37. raise "error compiling root app file: #{res}"
  38. end
  39. puts 'finished root app file compile'
  40. end
  41. end
  42. desc "compiles unit tests"
  43. task :unittests => ["compile:app"] do
  44. puts "Compiling Unit Tests to JS"
  45. `coffee -c -o test/unit/js/ test/unit/coffee/`
  46. end
  47. desc "compiles acceptance tests"
  48. task :acceptancetests => ["compile:app"] do
  49. puts "Compiling Acceptance Tests to JS"
  50. sh %{coffee -c -o test/acceptance/js/ test/acceptance/coffee/} do |ok, res|
  51. if ! ok
  52. raise "error compiling acceptance tests: #{res}"
  53. end
  54. end
  55. end
  56. end
  57. namespace 'test' do
  58. desc "runs all test"
  59. task :all => ["test:unit", "test:acceptance"] do
  60. puts "testing everything"
  61. end
  62. desc "Run Acceptance Tests"
  63. task :acceptance => ["compile:acceptancetests"]do
  64. puts "Running Acceptance Tests"
  65. feature = ENV['feature']
  66. if feature.nil?
  67. featureFlags = ""
  68. else
  69. featureFlags = "-g \"#{feature}\""
  70. end
  71. sh %{mocha -R spec #{featureFlags} test/acceptance/js/*} do |ok, res|
  72. if ! ok
  73. raise "error running acceptance tests: #{res}"
  74. end
  75. end
  76. end
  77. desc "run unit tests"
  78. task :unit => ["compile:unittests"]do
  79. puts "Running Unit Tests"
  80. featurePath = ENV['feature']
  81. puts featurePath
  82. if featurePath.nil?
  83. featurePath = ''
  84. elsif featurePath.include? '/'
  85. elsif !featurePath.include? '/'
  86. featurePath +='/'
  87. else
  88. featurePath = ''
  89. end
  90. sh %{mocha -R spec test/unit/js/#{featurePath}* --ignore-leaks} do |ok, res|
  91. if ! ok
  92. raise "error running unit tests : #{res}"
  93. end
  94. end
  95. end
  96. end
  97. namespace 'deploy' do
  98. desc "safley deploys app"
  99. task :live do
  100. sh %{git push origin}
  101. sh %{cap live deploy}
  102. end
  103. end