Class: CBin::Upload::Helper

Inherits:
Object
  • Object
show all
Includes:
SourcesHelper
Defined in:
lib/cocoapods-bb-bin/helpers/upload_helper.rb

Instance Method Summary collapse

Methods included from SourcesHelper

#binary_source, #code_source, #sources_manager, #sources_option, #sources_optionV2, #valid_sources, #valid_sourcesV2

Constructor Details

#initialize(spec, code_dependencies, sources, pushsourcespec = false) ⇒ Helper

Returns a new instance of Helper.



18
19
20
21
22
23
# File 'lib/cocoapods-bb-bin/helpers/upload_helper.rb', line 18

def initialize(spec,code_dependencies,sources, pushsourcespec = false)
  @spec = spec
  @code_dependencies = code_dependencies
  @sources = sources
  @pushsourcespec = pushsourcespec # 推送源码
end

Instance Method Details

#upload(isGenDylib = false, isUpRes = false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cocoapods-bb-bin/helpers/upload_helper.rb', line 25

def upload(isGenDylib=false, isUpRes=false)
  Dir.chdir(CBin::Config::Builder.instance.root_dir) do
    zip_file=nil
    if isUpRes
      zip_file = own_res_binary_file(restype)
    else
      zip_file = own_source_binary_file
    end
    return upload_binary_file(zip_file, isGenDylib, @spec.name, isUpRes)
  end
end

#upload_binary_file(zip_file, isGenDylib = false, vendored_framework_name = nil, isUpRes = false) ⇒ Object



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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cocoapods-bb-bin/helpers/upload_helper.rb', line 37

def upload_binary_file(zip_file, isGenDylib=false, vendored_framework_name=nil, isUpRes=false)
  Dir.chdir(CBin::Config::Builder.instance.root_dir) do
    res_type = "zip"
    extension = File.extname(zip_file)
    if extension == '.gz' || extension == '.tgz'
      res_type = "tgz"
    end
    puts "res extension:#{res_type} isUpRes:#{isUpRes}".red
    # 创建binary-template.podsepc
    # 上传二进制文件
    # 上传二进制 podspec
    puts "开始准备上传二进制文件 zip:#{zip_file}".yellow
    isupload = binary_upload(zip_file)
    puts "上传二进制文件完成 状态:#{isupload}".green
    if isupload
      is_xcframework = false
      if isUpRes
        is_xcframework = false
      else 
        [
          "xcframework.zip", # 三方库
          "xcframework_#{@spec.version}.zip", # 自有库
        ].each do |name|
          is_xcframework = zip_file.include?(name)
          if is_xcframework == true
            break
          end
        end
      end
      # is_xcframework = zip_file.include?('xcframework.zip')
      filename = spec_creator(vendored_framework_name, is_xcframework, isUpRes)
      Pod::UI.puts "上传二进制 podspec: #{filename} zip:#{zip_file} 是否动态库: #{isGenDylib} vendored_framework_name:#{vendored_framework_name} is_xcframework:#{is_xcframework} isUpRes:#{isUpRes}"
      push_helper = CBin::Push::Helper.new()
      push_helper.push_binary_repo(filename,isGenDylib)
      # 上传源码 podspec
      if @pushsourcespec
        Pod::UI.puts "上传源码 podspec: #{@spec_creator.sourceSpecFilePath}"
        push_helper.push_source_repo(@spec_creator.sourceSpecFilePath)
      end
    end
    isupload
  end
end