Class: Pindo::Command::Jps::Resign

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Resign

Returns a new instance of Resign.



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pindo/command/jps/resign.rb', line 50

def initialize(argv)

    @args_login_flag = argv.flag?('login', false)
    @args_list_flag = argv.flag?('list', false)
    @args_send_flag = argv.flag?('send', false)
    @args_proj_name = argv.option('proj')

    @args_cert_id = argv.option('certid')

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

Class Method Details

.optionsObject



39
40
41
42
43
44
45
46
47
# File 'lib/pindo/command/jps/resign.rb', line 39

def self.options
  [
    ['--login', '强制再次登录jps网站'],
    ['--proj', '指定哪个项目(忽略大小写空格等等字符),用法:pindo jps resign  --proj=prancksoundv4'],
    ['--list', '列出上传记录并选择,用法:pindo jps resign --list'],
    ['--send',  '发送消息到项目群(注意:不带此参数也会发送给自己),用法:pindo jps resign --send'],
    ['--certid',  '设置重签名的正式id,用法:pindo jps resign --resignid=com.test.bundleid'],
  ].concat(super)
end

Instance Method Details

#runObject



67
68
69
70
71
72
73
74
75
76
77
78
79
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
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/pindo/command/jps/resign.rb', line 67

def run

    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, "#{proj_name} 错误, 请输入正确的App代号名称, jps网站没有该App"
    end


    version_item_obj = PgyerHelper.share_instace.get_versioon_history_item(app_info_obj:app_info_obj, list_select_flat:@args_list_flag)

    if version_item_obj.nil?
        raise Informative, "没有找到上传记录"
    end

    cert_List = PgyerHelper.share_instace.get_cert_list()

    if cert_List.nil? || cert_List.empty?
        raise Informative, "没有找到上传记录"
    end

    if @args_cert_id.nil? && cert_List.size > 0

        bundle_id_list = cert_List.map { |cert| [cert["certType"],cert["mainBundleId"]].join("_") }
        cli = HighLine.new
        @args_cert_id = cli.choose do |menu|
            menu.prompt = "请选择重签名的证书:"
            menu.choices(*bundle_id_list)
        end

        cert_item = cert_List.select{|certitem| [certitem["certType"],certitem["mainBundleId"]].join("_") == @args_cert_id}.first
    else
        cert_item = cert_List.select{|certitem| certitem["mainBundleId"] == @args_cert_id && certitem["certType"].downcase.include?("adhoc")}.first
    end



    result = PgyerHelper.share_instace.resign(package_id:version_item_obj["id"], cert_id:cert_item["id"])

    if result
        version_item_obj = PgyerHelper.share_instace.get_versioon_history_item(app_info_obj:app_info_obj, list_select_flat:false)

        if version_item_obj.nil?
            raise Informative, "没有找到上传记录"
        end
        PgyerHelper.share_instace.print_app_version_info(
            app_info_obj: app_info_obj,
            app_version_info_obj: version_item_obj
        )

        # 始终发送给自己
        PgyerHelper.share_instace.send_apptest_msg(
            app_info_obj: app_info_obj,
            app_version_info_obj: version_item_obj,
            receiveType: "self"
        )

        # 如果有 --send 参数,额外发送到测试群
        if @args_send_flag
            PgyerHelper.share_instace.send_apptest_msg(
                app_info_obj: app_info_obj,
                app_version_info_obj: version_item_obj,
                chatEnv: "DevTest",
                receiveType: "chat"
            )
        end
    end



end

#validate!Object



63
64
65
# File 'lib/pindo/command/jps/resign.rb', line 63

def validate!
    super
end