MacOS.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. module RimeDeploy
  2. class MacOSJobGroup < JobGroup
  3. InstallCmd = "brew install --cask squirrel"
  4. Store.config_path = "~/Library/Rime"
  5. class InstallRimeJob < Job
  6. def call
  7. puts intro
  8. system(InstallCmd)
  9. sleep 1
  10. return :next
  11. end
  12. end
  13. class BackupRimeConfigJob < Job
  14. def call
  15. puts intro
  16. system(
  17. "mv #{Store.config_path} #{Store.config_path}.#{Time.now.to_i}.old"
  18. )
  19. sleep 1
  20. return :next
  21. end
  22. end
  23. class CloneConfigJob < Job
  24. def call
  25. puts intro
  26. system(
  27. "git clone --depth=1 #{Config::RIME_CONFIG_REPO} #{Store.config_path}"
  28. )
  29. sleep 1
  30. return :next
  31. end
  32. end
  33. class CopyCustomConfigJob < Job
  34. def call
  35. puts intro
  36. system("cp ./custom/*.yaml #{Store.config_path}/")
  37. sleep 1
  38. system("cp ./custom/custom_phrase.txt #{Store.config_path}/")
  39. sleep 1
  40. return :next
  41. end
  42. end
  43. class FinishedJob < Job
  44. def call
  45. puts ""
  46. puts "Tips: When finished all jobs. You need to do follow:".yellow
  47. puts "1) Restart system."
  48. puts "2) open Rime input method setting pane and click " +
  49. "DEPLOY".yellow + " button."
  50. puts "Enjoy~ 🍻"
  51. puts "more info:".yellow
  52. puts "Config path: #{Store.config_path}/"
  53. return :next
  54. end
  55. end
  56. self.jobs = [
  57. InstallRimeJob,
  58. BackupRimeConfigJob,
  59. CloneConfigJob,
  60. CopyCustomConfigJob
  61. ]
  62. self.after_jobs = [FinishedJob]
  63. self.upgrade_jobs = [
  64. Upgrade::UpgradeRimeAutoDeployJob,
  65. Upgrade::UpgradeRimeConfigJob
  66. ]
  67. end
  68. end