MacOS.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. return :next
  39. end
  40. end
  41. class FinishedJob < Job
  42. def call
  43. puts ""
  44. puts "Tips: When finished all jobs. You need to do follow:".yellow
  45. puts "1) Restart system."
  46. puts "2) open Rime input method setting pane and click " +
  47. "DEPLOY".yellow + " button."
  48. puts "Enjoy~ 🍻"
  49. puts "more info:".yellow
  50. puts "Config path: #{Store.config_path}/"
  51. return :next
  52. end
  53. end
  54. self.jobs = [
  55. InstallRimeJob,
  56. BackupRimeConfigJob,
  57. CloneConfigJob,
  58. CopyCustomConfigJob
  59. ]
  60. self.after_jobs = [FinishedJob]
  61. self.upgrade_jobs = [
  62. Upgrade::UpgradeRimeAutoDeployJob,
  63. Upgrade::UpgradeRimeConfigJob
  64. ]
  65. end
  66. end