class Tuya::TYLib

Public Class Methods

create_lib(name) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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