Class: Pod::Command::Bin::Tag

Inherits:
Pod::Command::Bin show all
Defined in:
lib/cocoapods-bb-bin/command/bin/tag.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CBin::SpecFilesHelper

#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files

Methods included from CBin::SourcesHelper

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

Constructor Details

#initialize(argv) ⇒ Tag

Returns a new instance of Tag.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cocoapods-bb-bin/command/bin/tag.rb', line 27

def initialize(argv)
  @help = argv.flag?('help', false )
  if @help
  else
    @env = argv.option('env') || 'dev'
    CBin.config.set_configuration_env(@env)
  
    @podspec = argv.shift_argument || find_podspec
    @sources = argv.option('sources') || []
    @clean = argv.flag?('no-clean', false)
    @skip_build_project = argv.flag?('skip-build-project', false)
    @is_debug = argv.flag?('debug', false)
    @platform = Platform.new(:ios)
  end
  super
end

Class Method Details

.optionsObject



18
19
20
21
22
23
24
25
# File 'lib/cocoapods-bb-bin/command/bin/tag.rb', line 18

def self.options
  [
    ['--sources', '私有源地址,多个用分号区分'],
    ['--no-clean', '保留构建中间产物'],
    ['--skip-build-project', '跳过编译工程文件操作(直接推送假标签,操作慎重!!!)'],
    ['--debug', 'debug环境只是验证工程编译是否ok,不进行标签推送操作'],
  ].concat(Pod::Command::Gen.options).concat(super).uniq
end

Instance Method Details

#check_build_workspaceObject

编译工程目录



88
89
90
91
92
# File 'lib/cocoapods-bb-bin/command/bin/tag.rb', line 88

def check_build_workspace
  generate_project
  swift_pods_buildsetting
  return build_root_spec
end

#find_podspecObject

Dir.glob 可替代

Raises:

  • (Informative)


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/cocoapods-bb-bin/command/bin/tag.rb', line 70

def find_podspec
    name = nil
    Pathname.pwd.children.each do |child|
      # puts child
      if File.file?(child)
        if child.extname == '.podspec' || child.basename.to_s.include?('.podspec.json')
          name = File.basename(child)
          unless name.include?("binary-template")
            return name
          end
        end
      end
    end
    raise Informative,  "podspec File no exist, please check" unless name
    return name
end

#runObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/cocoapods-bb-bin/command/bin/tag.rb', line 49

def run
  # 清除之前的缓存
  CBin::Config::Builder.instance.clean
  @spec = Specification.from_file(@podspec)

  if @skip_build_project
    # 跳过工程编译
    is_build_ok = true
    Pod::UI.warn "请注意⚠️正在推送假标签!!!#{@podspec}==>#{@spec.name}(#{@spec.version})"
  elsif
    # step.1 工程编译
    is_build_ok = check_build_workspace
  end
  if is_build_ok && !@is_debug
    # step.2 工程编译ok,进行标签推送
    push_helper = CBin::Push::Helper.new()
    push_helper.push_source_repo(@podspec)
  end
end

#validate!Object



44
45
46
47
# File 'lib/cocoapods-bb-bin/command/bin/tag.rb', line 44

def validate!
  help! "未找到 podspec文件" unless @podspec
  super
end