| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- module RimeDeploy
- class WindowsJobGroup < JobGroup
- Store.config_path = ENV["APPDATA"] + '\\Rime'
- def clear_screen
- system("cls")
- end
- class CheckInstallRimeJob < Job
- def call
- puts "==== Rime auto deploy ====".green
- puts "Before Check Rime Installed Staus".yellow
- tips = <<-TIP
- Windows system doesn't have it's own package manager, so make sure you had installed Rime before.
- You can download Rime from: https://rime.im/download/
- TIP
- puts tips
- puts ""
- ChooseSession.new(
- [
- ["I have installed Rime. Let's go next.", -> {}],
- [
- "I'll quit first.After installed Rime by myself then run this program again.",
- -> { exit 0 }
- ]
- ]
- ).call
- sleep 1
- return :next
- end
- end
- class BackupRimeConfigJob < Job
- def call
- puts intro
- system(
- "move #{Store.config_path} #{Store.config_path}.#{Time.now.to_i}.old"
- )
- sleep 1
- return :next
- end
- end
- class CloneConfigJob < Job
- def call
- puts intro
- system(
- "git clone #{Config::RIME_CONFIG_REPO} #{Store.config_path}"
- )
- sleep 1
- return :next
- end
- end
- class CopyCustomConfigJob < Job
- def call
- puts intro
- ## 复制custom下所有文件, 包括空文件夹
- system("xcopy \"custom\" \"#{Store.config_path}\" /E /I /Y")
- sleep 1
- return :next
- end
- end
- class FinishedJob < Job
- def call
- puts ""
- puts "Tips: When finished all jobs. You need to do follow:".yellow
- puts "1) Restart system."
- puts "2) open Rime input method setting pane and click " +
- "DEPLOY".yellow + " button."
- puts "Enjoy~"
- puts "more info:".yellow
- puts "Config path: #{Store.config_path}"
- return :next
- end
- end
- self.before_jobs = [CheckInstallRimeJob]
- self.jobs = [BackupRimeConfigJob, CloneConfigJob, CopyCustomConfigJob]
- self.after_jobs = [FinishedJob]
- self.upgrade_jobs = [
- Upgrade::UpgradeRimeAutoDeployJob,
- Upgrade::UpgradeRimeConfigJob
- ]
- end
- end
|