upgrade.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. module RimeDeploy
  2. module Upgrade
  3. class UpgradeRimeAutoDeployJob < Job
  4. def call
  5. puts "Upgrade `Rime Auto Deploy` script ..."
  6. project_path = File.expand_path(Dir.pwd)
  7. if File.directory?(File.join(project_path, ".git"))
  8. puts "Git repository found."
  9. system("cd #{project_path} && git remote get-url origin")
  10. puts "Try upgrading..."
  11. system("cd #{project_path} && git pull")
  12. else
  13. puts "You can download the latest version from here."
  14. puts "https://github.com/Mark24Code/rime-auto-deploy"
  15. end
  16. return :next
  17. end
  18. end
  19. class UpgradeRimeConfigJob < Job
  20. def call
  21. puts "Upgrade Rime Config"
  22. config_abs_path = File.expand_path(Store.config_path)
  23. if File.directory?(File.join(config_abs_path, ".git"))
  24. puts "Git repository found."
  25. system("cd #{config_abs_path} && git remote get-url origin")
  26. puts "Try upgrading..."
  27. system("cd #{config_abs_path} && git pull")
  28. else
  29. puts "Error:".yellow
  30. puts "Rime Config seems broken. You may delete the directory.".red
  31. puts "You can:"
  32. puts "Rerun the deploy script from start choose [Auto Mode] to reinstall."
  33. puts ""
  34. puts "After 5 seconds, will go to [Upgrade Mode].".yellow
  35. sleep 5
  36. throw :halt, :run_jobs_upgrade
  37. end
  38. return :next
  39. end
  40. end
  41. end
  42. end