class Tuya::TYGroup
Public Class Methods
create_spec(group)
click to toggle source
# File lib/tycli/group.rb, line 42 def self.create_spec(group) require 'tycli/config' config = Tuya::Config.new(group.name) local_spec_path = "#{config.path}spec/#{group.spec}" if File.exist? local_spec_path `rm -rf #{local_spec_path}` end `mkdir -p #{local_spec_path}` # `touch #{local_spec_path}/README.md` fh = File.new("#{local_spec_path}/README.md", 'w') fh.puts 'create by tuya-cli' fh.close origin_path = FileUtils.pwd FileUtils.cd "#{local_spec_path}" require 'tycli/executable' commands = [ %W(init), %W(add -A), %W(commit -am init\ repo\ spec), %W(remote add origin #{group.url}), %W(push --set-upstream origin master) ] Tuya::EXE.multi_exe('git', commands, true) FileUtils.cd origin_path end
create_tuya_public_inc()
click to toggle source
# File lib/tycli/group.rb, line 118 def self.create_tuya_public_inc `pod repo add TYPublicSpecs https://github.com/TuyaInc/TYPublicSpecs.git` end
create_tuya_public_inc_if_need()
click to toggle source
# File lib/tycli/group.rb, line 114 def self.create_tuya_public_inc_if_need create_tuya_public_inc unless is_tuya_public_inc_exist? end
is_local_repo_exist?(group_spec)
click to toggle source
# File lib/tycli/group.rb, line 102 def self.is_local_repo_exist?(group_spec) system = Tuya::System.instance local_path = system.pod_config.repos_dir + group_spec File.directory?(local_path) end
is_tuya_public_inc_exist?()
click to toggle source
# File lib/tycli/group.rb, line 110 def self.is_tuya_public_inc_exist? is_local_repo_exist? 'TYPublicSpecs' end
remote_spec_exist?(group)
click to toggle source
# File lib/tycli/group.rb, line 78 def self.remote_spec_exist?(group) require 'tycli/executable' result = Tuya::EXE.exe('git', %W(ls-remote #{group.url})) result.include? "refs/heads/master" end
setup_local_repo(group)
click to toggle source
# File lib/tycli/group.rb, line 87 def self.setup_local_repo(group) if is_local_repo_exist?(group.spec) system = Tuya::System.instance local_path = system.pod_config.repos_dir + group.spec FileUtils.rm_rf(local_path) end repo_add = "pod repo add #{group.spec} #{group.url}" `#{repo_add}` require 'tycli/config' puts "update local config: #{group.name}".yellow config = Tuya::Config.new(group.name) config.update_local_config end
setup_spec(group)
click to toggle source
# File lib/tycli/group.rb, line 37 def self.setup_spec(group) create_spec group unless remote_spec_exist? group setup_local_repo group end
status()
click to toggle source
# File lib/tycli/group.rb, line 10 def self.status system = Tuya::System.instance group = system.group puts "can not find tuya group, please use 'tuya group create --name=group_name'".red unless group if group puts "#{group.name}".yellow puts "- Repo: #{group.spec}".green puts "- URL: #{group.url}".green puts "\ncan not find #{group.spec}, please use 'tuya group create --name=group_name'".red unless is_local_repo_exist? group.spec end tuya_pub = is_tuya_public_inc_exist? puts "\ncan not find TYPublicSpecs please use 'pod repo add TYPublicSpecs https://github.com/TuyaInc/TYPublicSpecs.git'".red unless tuya_pub if tuya_pub puts "\nTYPublic".yellow puts "- Repo: TYPublicSpecs".green puts "- URL: https://github.com/TuyaInc/TYPublicSpecs.git".green end end
update_tuya_public_inc()
click to toggle source
# File lib/tycli/group.rb, line 122 def self.update_tuya_public_inc puts "\nUpdate TYPublicSpecs".yellow `pod repo update TYPublicSpecs` end