Class: Tuya::TYLib
- Inherits:
-
Object
- Object
- Tuya::TYLib
- Defined in:
- lib/tycli/lib.rb
Class Method Summary collapse
- .create_lib(name) ⇒ Object
- .push_lib(config) ⇒ Object
- .remote_lib_exist?(url) ⇒ Boolean
- .repair_podfile_source ⇒ Object
- .repair_podspec(path, file, config) ⇒ Object
Class Method Details
.create_lib(name) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tycli/lib.rb', line 3 def self.create_lib(name) require 'tycli/config' require 'tycli/system' system = Tuya::System.instance group = system.group config = Tuya::ConfigLib.new(group.name, name) if remote_lib_exist? config.url puts "remote #{config.name} exist".yellow else puts "\npushing #{name} to remote...".yellow push_lib config end puts "#{config.name}".green puts "URL- #{config.url}".green end |
.push_lib(config) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tycli/lib.rb', line 25 def self.push_lib(config) origin_path = FileUtils.pwd target_path = "#{origin_path}/#{config.name}" if File.exist? target_path FileUtils.cd target_path git_path = "#{target_path}/.git" require 'tycli/executable' if File.exist? git_path rm_commands = [ %W(-rf #{git_path}) ] Tuya::EXE.multi_exe('rm', rm_commands, true) end repair_podspec(target_path, "#{config.name}.podspec", config) FileUtils.cd "Example" repair_podfile_source FileUtils.cd ".." git_commands = [ %W(init), %W(add -A), %W(commit -am init\ #{config.name}\ by\ tuya-cli), %W(remote add origin #{config.url}), %W(push --set-upstream origin master) ] Tuya::EXE.multi_exe('git', git_commands, true) end FileUtils.cd origin_path end |
.remote_lib_exist?(url) ⇒ Boolean
81 82 83 84 85 86 87 88 |
# File 'lib/tycli/lib.rb', line 81 def self.remote_lib_exist?(url) require 'tycli/executable' result = Tuya::EXE.exe('git', %W(ls-remote #{url}), false , false ) result.include? "refs/heads/master" end |
.repair_podfile_source ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/tycli/lib.rb', line 63 def self.repair_podfile_source require 'tuya/ci/core' require 'tycli/system' system = Tuya::System.instance group = system.group podfile = TYCiCore::Podfile.new podfile.source_replace("# source '@{GROUP_SPEC}'", "source '#{group.url}'") podfile.save end |
.repair_podspec(path, file, config) ⇒ Object
76 77 78 79 |
# File 'lib/tycli/lib.rb', line 76 def self.repair_podspec(path, file, config) require 'tycli/repo/spec' Tuya::PodSpec.repair_lib_spec(path, file, config) end |