rakefile.rb 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. end
  36. desc "compiles unit tests"
  37. task :unittests => ["compile:app"] do
  38. puts "Compiling Unit Tests to JS"
  39. `coffee -c -o test/unit/js/ test/unit/coffee/`
  40. end
  41. desc "compiles acceptance tests"
  42. task :acceptancetests => ["compile:app"] do
  43. puts "Compiling Acceptance Tests to JS"
  44. sh %{coffee -c -o test/acceptance/js/ test/acceptance/coffee/} do |ok, res|
  45. if ! ok
  46. raise "error compiling acceptance tests: #{res}"
  47. end
  48. end
  49. end
  50. end
  51. namespace 'test' do
  52. desc "runs all test"
  53. task :all => ["test:unit", "test:acceptance"] do
  54. puts "testing everything"
  55. end
  56. desc "Run Acceptance Tests"
  57. task :acceptance => ["compile:acceptancetests"]do
  58. puts "Running Acceptance Tests"
  59. feature = ENV['feature']
  60. if feature.nil?
  61. featureFlags = ""
  62. else
  63. featureFlags = "-g \"#{feature}\""
  64. end
  65. sh %{mocha -R spec #{featureFlags} test/acceptance/js/*} do |ok, res|
  66. if ! ok
  67. raise "error running acceptance tests: #{res}"
  68. end
  69. end
  70. end
  71. desc "run unit tests"
  72. task :unit => ["compile:unittests"]do
  73. puts "Running Unit Tests"
  74. featurePath = ENV['feature']
  75. puts featurePath
  76. if featurePath.nil?
  77. featurePath = ''
  78. elsif featurePath.include? '/'
  79. elsif !featurePath.include? '/'
  80. featurePath +='/'
  81. else
  82. featurePath = ''
  83. end
  84. sh %{mocha -R spec test/unit/js/#{featurePath}* --ignore-leaks} do |ok, res|
  85. if ! ok
  86. raise "error running unit tests : #{res}"
  87. end
  88. end
  89. end
  90. end
  91. namespace 'deploy' do
  92. desc "safley deploys app"
  93. task :live do
  94. sh %{git push origin}
  95. sh %{cap live deploy}
  96. end
  97. end