Class: Pindo::Command::Pgyer::Upload

Inherits:
Pindo::Command::Pgyer show all
Defined in:
lib/pindo/command/pgyer/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

run

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from Githelper

#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag

Methods included from Executable

capture_command, #executable, execute_command, which, which!

Constructor Details

#initialize(argv) ⇒ Upload

Returns a new instance of Upload.



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
# File 'lib/pindo/command/pgyer/upload.rb', line 41

def initialize(argv)

    @args_ipa_file = argv.shift_argument
    @ipa_file = argv.option('ipa')

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

    @args_login_flag = argv.flag?('login', false)
    @args_send_flag = argv.flag?('send', false)
    @args_resign_flag = argv.flag?('resign', false)

    @args_proj_name = argv.option('proj')
    @args_attach_name = argv.option('attach')
    @args_upload_desc = argv.option('desc')
    @args_cert_id = argv.option('certid')



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


    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

.optionsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pindo/command/pgyer/upload.rb', line 26

def self.options
  [
    ['--login', '强制再次登录pgyer网站,用法: pindo pgyer upload --login'],
    ['--ipa', '强制指定上传的ipa文件: pindo pgyer upload --ipa=path/to/demo.ipa'],
    ['--proj', '指定哪个项目(忽略大小写空格等等字符),用法:pindo pgyer upload --proj=prancksoundv4'],
    ['--attach', '指定需要和ipa一起上传的附件: pindo pgyer upload --attach=path/to/attach.zip'],
    ['--send',  '上传到之后是否发送测试信息,用法:pindo pgyer upload --send'],
    ['--desc', '指定上传的备注信息: -pindo pgyer upload -desc="1.upload message"'],
    ['--resign',  '上传到之后是否重签名,用法:pindo pgyer upload --resign'],
    ['--certid',  '设置重签名的正式id,用法:pindo pgyer upload --certid=com.test.bundleid'],

  ].concat(super)
end

Instance Method Details

#runObject



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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/pindo/command/pgyer/upload.rb', line 85

def run

    current_project_dir = Dir.pwd
    if @args_ipa_file.nil? || !File.exist?(@args_ipa_file)
        build_path = File.join(current_project_dir, "build", "*.{ipa,app}")
        @args_ipa_file = Dir.glob(build_path).max_by {|f| File.mtime(f)}
        if @args_ipa_file.nil?
            build_path = File.join(current_project_dir, "*.ipa")
            @args_ipa_file = Dir.glob(build_path).max_by {|f| File.mtime(f)}
        end

        if !@args_ipa_file.nil?
            answer = agree("需要上传的ipa文件是: #{@args_ipa_file} ?(Y/n)")
            if !answer
                @args_ipa_file = nil
            end
        end

        if !@args_ipa_file.nil? && File.exist?(@args_ipa_file)
        else
            @args_ipa_file = ask('需要上传的IPA文件:') || nil
            @args_ipa_file = @args_ipa_file.strip.gsub(/\\ /, ' ')
        end
    end

    if !File.exist?(@args_ipa_file)
        raise Informative, "#{@args_ipa_file} 文件不存在"
    end

    PgyerHelper.share_instace.setForeLogin(beforeLogin:@args_login_flag)
    app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:@args_proj_name)

    if app_info_obj.nil?
        raise Informative, "#{@args_proj_name} 错误, 请输入正确的App代号名称, pgyer网站没有该App"
    end

    result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:@args_ipa_file, description:@args_upload_desc)
    if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
        msg_data = PgyerHelper.share_instace.make_msg_data(app_info_obj:app_info_obj, app_version_info_obj:result_data["data"])
        PgyerHelper.share_instace.print_app_version_info(msg_data:msg_data)


        if @args_send_flag
           if @args_resign_flag
                args = []
                args << "--send"
                if !@args_cert_id.nil? && !@args_cert_id.empty?
                    args << "--certid=#{@args_cert_id}"
                end
                if !@args_proj_name.nil? && !@args_proj_name.empty?
                    args << "--proj=#{@args_proj_name}"
                end
                Pindo::Command::Pgyer::Resign::run(args)
            else
                PgyerHelper.share_instace.send_apptest_wechat_msg(msg_data:msg_data)
            end
        end
    end




end

#validate!Object



80
81
82
83
# File 'lib/pindo/command/pgyer/upload.rb', line 80

def validate!

    super
end