Class: Pindo::Command::Jps::Upload

Inherits:
Pindo::Command::Jps show all
Defined in:
lib/pindo/command/jps/upload.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pindo::Command

command_name, #initialize_options, run, use_cache?

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Constructor Details

#initialize(argv) ⇒ Upload

Returns a new instance of Upload.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/pindo/command/jps/upload.rb', line 80

def initialize(argv)
    @args_ipa_file = argv.shift_argument

    # 使用 Options 系统解析参数
    @options = initialize_options(argv)

    file_option = @options[:file]
    if !file_option.nil?
        @args_ipa_file = file_option
    end
    if @args_ipa_file && !@args_ipa_file.empty?
        @args_ipa_file = @args_ipa_file.strip.gsub(/\"/, '')
    end

    @args_login_flag = @options[:login] || false
    @args_attach_name = @options[:attach]
    @args_types = @options[:types]

    # JPS 参数
    @args_conf = @options[:conf]
    @args_send_flag = @options[:send] || false
    @args_resign_flag = @options[:resign] || false
    @args_upload_desc = @options[:desc]
    @args_cert_id = @options[:certid]

    if @args_upload_desc && !@args_upload_desc.empty?
        @args_upload_desc = @args_upload_desc.strip.gsub(/\"/, '')
    end

    # Git 参数
    @args_release_branch = @options[:release_branch] || 'master'
    @args_ver_inc = Pindo::Options::GitOptions.parse_version_increase_type(@options[:ver_inc])
    @args_tag_type = Pindo::Options::GitOptions.parse_create_tag_type(@options[:tag_type])
    @args_tag_pre = @options[:tag_pre] || 'v'
    @args_git_commit = Pindo::Options::GitOptions.parse_git_commit_type(@options[:git_commit])

    if !@args_cert_id.nil? && !@args_cert_id.empty?
        @args_resign_flag = true
    end
    if @args_resign_flag
        @args_send_flag = true
    end

    super(argv)
    @additional_args = argv.remainder!
end

Class Method Details

.option_itemsObject

定义此命令使用的参数项



67
68
69
70
71
72
73
# File 'lib/pindo/command/jps/upload.rb', line 67

def self.option_items
  @option_items ||= Pindo::Options::OptionGroup.merge(
    Pindo::Options::BuildOptions.select(:types),
    Pindo::Options::JPSOptions.select(:conf, :send, :desc, :resign, :login, :file, :attach),
    Pindo::Options::GitOptions.all
  )
end

.optionsObject



75
76
77
# File 'lib/pindo/command/jps/upload.rb', line 75

def self.options
  option_items.map(&:to_claide_option).concat(super)
end

Instance Method Details

#runObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/pindo/command/jps/upload.rb', line 132

def run
    current_project_dir = Dir.pwd

    # 创建任务列表
    tasks = make_upload_tasks(current_project_dir)

    # 执行任务
    task_manager = Pindo::TaskSystem::TaskManager.instance
    task_manager.clear_all
    tasks.each { |task| task_manager.add_task(task) }
    task_manager.start

    # 如果需要重签名,在所有上传任务完成后执行
    if @args_resign_flag
        args = []
        if @args_send_flag
            args << "--send"
        end
        if !@args_cert_id.nil? && !@args_cert_id.empty?
            args << "--certid=#{@args_cert_id}"
        end
        if !@args_conf.nil? && !@args_conf.empty?
            args << "--conf=#{@args_conf}"
        end
        Pindo::Command::Jps::Resign::run(args)
    end
end

#validate!Object



127
128
129
130
# File 'lib/pindo/command/jps/upload.rb', line 127

def validate!

    super
end