Windows.rb 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. module RimeDeploy
  2. class WindowsJobGroup < JobGroup
  3. Store.config_path = ENV["APPDATA"] + '\\Rime'
  4. def clear_screen
  5. system("cls")
  6. end
  7. class CheckInstallRimeJob < Job
  8. def call
  9. puts "==== Rime auto deploy ====".green
  10. puts "Before Check Rime Installed Staus".yellow
  11. tips = <<-TIP
  12. Windows system doesn't have it's own package manager, so make sure you had installed Rime before.
  13. You can download Rime from: https://rime.im/download/
  14. TIP
  15. puts tips
  16. puts ""
  17. ChooseSession.new(
  18. [
  19. ["I have installed Rime. Let's go next.", -> {}],
  20. [
  21. "I'll quit first.After installed Rime by myself then run this program again.",
  22. -> { exit 0 }
  23. ]
  24. ]
  25. ).call
  26. sleep 1
  27. return :next
  28. end
  29. end
  30. class BackupRimeConfigJob < Job
  31. def call
  32. puts intro
  33. system(
  34. "move #{Store.config_path} #{Store.config_path}.#{Time.now.to_i}.old"
  35. )
  36. sleep 1
  37. return :next
  38. end
  39. end
  40. class CloneConfigJob < Job
  41. def call
  42. puts intro
  43. system(
  44. "git clone #{Config::RIME_CONFIG_REPO} #{Store.config_path}"
  45. )
  46. sleep 1
  47. return :next
  48. end
  49. end
  50. class CopyCustomConfigJob < Job
  51. def call
  52. puts intro
  53. ## 复制custom下所有文件, 包括空文件夹
  54. system("xcopy \"custom\" \"#{Store.config_path}\" /E /I /Y")
  55. sleep 1
  56. return :next
  57. end
  58. end
  59. class FinishedJob < Job
  60. def call
  61. puts ""
  62. puts "Tips: When finished all jobs. You need to do follow:".yellow
  63. puts "1) Restart system."
  64. puts "2) open Rime input method setting pane and click " +
  65. "DEPLOY".yellow + " button."
  66. puts "Enjoy~"
  67. puts "more info:".yellow
  68. puts "Config path: #{Store.config_path}"
  69. return :next
  70. end
  71. end
  72. self.before_jobs = [CheckInstallRimeJob]
  73. self.jobs = [BackupRimeConfigJob, CloneConfigJob, CopyCustomConfigJob]
  74. self.after_jobs = [FinishedJob]
  75. self.upgrade_jobs = [
  76. Upgrade::UpgradeRimeAutoDeployJob,
  77. Upgrade::UpgradeRimeConfigJob
  78. ]
  79. end
  80. end