MacOS.rb 1.7 KB

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