Class: Pindo::Command::Ipa::Output

Inherits:
Pindo::Command::Ipa show all
Includes:
Appselect, DeployOptions, XcodeAppConfig, XcodeBuildHelper
Defined in:
lib/pindo/command/ipa/output.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes included from DeployOptions

#additional_args, #apple_id, #args_adhoc_flag, #args_appconfig, #args_appconfig_dir, #args_appconfig_fullname, #args_apple_id, #args_appstore_flag, #args_array, #args_bundle_id, #args_dev_flag, #args_macos_flag, #args_repo_name, #argv_temp, #bundle_id, #bundle_id_extension, #bundle_id_extensionad, #bundle_id_extensionporn, #bundle_id_imessage, #bundle_id_keyboard, #bundle_id_pushcontent, #bundle_id_pushservice, #bundle_id_siri, #bundle_id_siriui, #bundle_id_watchapp, #bundle_id_watchapp_extension, #bundle_id_widget, #config_json, #deploy_acount_id, #deploy_group_id, #deploy_icloud_id, #deploy_identifier, #deploy_identifier_extension, #deploy_identifier_extensionad, #deploy_identifier_extensionporn, #deploy_identifier_imessage, #deploy_identifier_keyboard, #deploy_identifier_pushcontent, #deploy_identifier_pushservice, #deploy_identifier_siri, #deploy_identifier_siriui, #deploy_identifier_watchapp, #deploy_identifier_watchapp_extension, #deploy_identifier_widget, #deploy_repo_name, #group_id, #icloud_id, #newconfuse_flag, #oldconfuse_flag

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Appselect

#all_dev_bundleid, #all_itc_bundleid, #all_release_bundleid, #all_tool_bundleid, #deploy_build_setting_json, #dev_build_setting_json, #get_deploy_repo_with_modul_name, #get_deploy_setting_repo, #get_dev_setting_repo, #get_selected_deploy_bundleid, #get_selected_dev_bundleid, #get_setting_bundleid_withdir, #load_setting, #select_main_app

Methods included from XcodeAppConfig

#add_pod_modue, #add_project_modue, #auto_increase_buildnumber, #find_group, #modify_appprefix_plist, #remove_test_pod_modue

Methods included from XcodeBuildHelper

#backup_podfile_lock, #install_google_plist, #modify_info_plist, #modify_infoplist_version, #modify_maintarget_info_plist, #modify_project_config, #pull_podfile_lock

Methods included from DeployOptions

#check_config_version, #get_build_type_args, #get_bundle_id_map, #get_confuse_type_args, #init_deploy_params, #init_develop_params, #print_params_info, #validate!

Methods inherited from Pindo::Command

run, #validate!

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) ⇒ Output

Returns a new instance of Output.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pindo/command/ipa/output.rb', line 41

def initialize(argv)

    @args_proj_name = argv.option('proj')
    @args_upload_flag = argv.flag?('upload', false)
    @args_send_flag = argv.flag?('send', false)
    @args_increase_flag = argv.flag?('increase', false)


    if @args_send_flag
        @args_upload_flag = true
    end

    super
end

Class Method Details

.optionsObject



31
32
33
34
35
36
37
38
39
# File 'lib/pindo/command/ipa/output.rb', line 31

def self.options
    [
        ['--proj', '指定哪个项目(忽略大小写空格等等字符): --proj=\"prancksoundv4\"'],
        ['--upload', '编译完成后是否上传ipa到pyger: 用法:pindo ipa output --upload'],
        ['--send',  '上传到之后是否发送测试信息,用法:pindo ipa output --send'],
        ['--increase', '自动增加编译的app版本号,用法:pindo ipa output --increase'],

    ].concat(super)
end

Instance Method Details

#get_release_build_argsObject



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/pindo/command/ipa/output.rb', line 214

def get_release_build_args
    args_temp = []
    unless @apple_id.eql?(pindo_single_config.demo_apple_id)
        @args_apple_id = pindo_single_config.demo_apple_id
        args_temp << "--u=#{@args_apple_id}"
    end

    unless @apple_id.eql?(pindo_single_config.demo_apple_id) && @apple_id.eql?(@deploy_acount_id)
        if @args_bundle_id.nil? || @args_bundle_id.empty?
            if  @config_json && @config_json['project_info'] && @config_json['project_info']['app_type']
                @output_repo_name = get_deploy_repo_with_modul_name(module_name:@config_json['project_info']['app_type'])
                if @output_repo_name.nil? || @output_repo_name == ""
                    raise Informative, "config.json app_type is error!!!"
                end
                @output_config_dir = clong_buildconfig_repo(repo_name: @output_repo_name)
                @args_bundle_id = get_setting_bundleid_withdir(repo_dir:@output_config_dir)
            end
            args_temp << "--a=#{@args_bundle_id}"
        else
            args_temp << "--a=#{@args_bundle_id}"
        end
    end
    return args_temp
end

#modify_release_config(project_dir: nil, config_json: nil) ⇒ Object



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/pindo/command/ipa/output.rb', line 256

def modify_release_config(project_dir:nil, config_json:nil)

    if  config_json && config_json['project_info'] && config_json['project_info']['app_type']
        @output_repo_name = get_deploy_repo_with_modul_name(module_name:config_json['project_info']['app_type'])
        if @output_repo_name.nil? || @output_repo_name == ""
            raise Informative, "config.json app_type is error!!!"
        end
        @output_config_dir = clong_buildconfig_repo(repo_name: @output_repo_name)
        @args_bundle_id = get_setting_bundleid_withdir(repo_dir:@output_config_dir)
    end


    @output_config_json_file=File::join(@output_config_dir, "config.json")
    @output_config_json=JSON.parse(File.read(@output_config_json_file))
    @config_json["app_info"]["facebook_app_id"] = @output_config_json["app_info"]["facebook_app_id"]
    @config_json["app_info"]["facebook_client_token"] = @output_config_json["app_info"]["facebook_client_token"]

    if !@config_json["app_info"]["admob_app_id"].nil? && !@output_config_json["app_info"]["admob_app_id"].nil?
        @config_json["app_info"]["admob_app_id"] = @output_config_json["app_info"]["admob_app_id"]
    end
    if !@config_json["app_info"]["applovin_app_id"].nil? && !@output_config_json["app_info"]["applovin_app_id"].nil?
        @config_json["app_info"]["applovin_app_id"] = @output_config_json["app_info"]["applovin_app_id"]
    end

    # puts " @config_json[ app_setting] ================12"
    # puts  @config_json["app_setting"]

    @config_json["app_setting"].each do |k, v|
        if k.eql?("kGUKeyAppClientHost") ||  k.eql?("kGUKeyResBaseUrl") ||  k.eql?("app_web_host") || k.eql?("app_client_url") ||  k.eql?("app_client_url") then

        else
            if !@output_config_json["app_setting"][k].nil?
                @config_json["app_setting"][k] = @output_config_json["app_setting"][k]
            end
        end
    end

    current_config_file = File.join(project_dir, "config.json")
    File.open(current_config_file, "w") do |f|
        f.write(JSON.pretty_generate(@config_json))
    end

end

#modify_release_firebase(project_dir: nil, config_json: nil) ⇒ Object



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/pindo/command/ipa/output.rb', line 239

def modify_release_firebase(project_dir:nil, config_json:nil)

    if  config_json && config_json['project_info'] && config_json['project_info']['app_type']
        @output_repo_name = get_deploy_repo_with_modul_name(module_name:config_json['project_info']['app_type'])
        if @output_repo_name.nil? || @output_repo_name == ""
            raise Informative, "config.json app_type is error!!!"
        end
        @output_config_dir = clong_buildconfig_repo(repo_name: @output_repo_name)
        @args_bundle_id = get_setting_bundleid_withdir(repo_dir:@output_config_dir)
    end

    pindo_dir = File::expand_path(pindo_single_config.pindo_dir)
    google_info_config_dir = File.join(pindo_dir, @args_bundle_id)
    install_google_plist(project_dir:project_dir, app_config_dir:google_info_config_dir)

end

#output_funObject



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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/pindo/command/ipa/output.rb', line 111

def output_fun

    currentDir = Dir.pwd
    pindo_dir = File::expand_path(pindo_single_config.pindo_dir)
    app_config_dir = File.join(pindo_dir, @deploy_identifier)
    app_config_dir = clong_buildconfig_repo(repo_name: @deploy_repo_name)


    args_temp = []
    args_temp << @args_appconfig

    args = get_build_type_args()
    args_temp = args_temp | args

    args = get_release_build_args()
    args_temp = args_temp | args


    pindo_new_project_dir = Dir.pwd
    unless @args_nocreate_flag
        Pindo::Command::Utils::Renewproj::run(args_temp)
        pindo_new_project_dir = ENV["pindo_new_project_dir"]
        system "open #{pindo_new_project_dir}"
        puts "New Project: #{pindo_new_project_dir}"
    end


    Dir.chdir(pindo_new_project_dir)
    begin
        FileUtils.rm_rf(File.join(pindo_new_project_dir, "Podfile.lock"))
        FileUtils.rm_rf(File.join(pindo_new_project_dir, "Pods"))
    rescue StandardError => e
    end


    Dir.chdir(pindo_new_project_dir)
    modify_release_config(project_dir:pindo_new_project_dir, config_json:@config_json)
    Pindo::Command::Deploy::Configproj::run(args_temp)
    modify_release_firebase(project_dir:pindo_new_project_dir, config_json:@config_json)


    if File.exist?(File.join(pindo_new_project_dir, "Podfile"))
        Pindo::Command::Lib::Update::run([])

        begin
            remove_test_pod_modue(project_dir:pindo_new_project_dir)
            Pod::Command::Install::run([]) 
        rescue => error
            puts(error.to_s)
            raise Informative, "pod install失败!!先pod install 完成后成编译 !"
        end


        pod_lock_file = File.join(pindo_new_project_dir, "Podfile.lock")
        if !File.exist?(pod_lock_file)
            raise Informative, "pod install失败!!先pod install 完成后成编译 !"
        end

        backup_podfile_lock(project_dir:pindo_new_project_dir, app_config_dir:app_config_dir, appversion:@config_json["app_info"]["app_build_version"])

    end

    if @args_quswark_flag
        Dir.chdir(pindo_new_project_dir)
        quark_temp = ["./config.json", "--adhoc"]
        Pindo::Command::Deploy::Quswark::run(quark_temp)
    end

    unless @args_normal_flag
        Dir.chdir(pindo_new_project_dir)
        Pindo::Command::Dev::Confuseproj::run(args_temp)
    end

    Dir.chdir(pindo_new_project_dir)
    Pindo::Command::Deploy::Cert::run(args_temp)

    Dir.chdir(pindo_new_project_dir)
    Pindo::Command::Deploy::Build::run(args_temp)


    build_path = File.join(pindo_new_project_dir, "build", "*.ipa")
    ipa_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}

    unless @args_normal_flag
        if !ipa_file.nil? && File.exist?(ipa_file_upload)
            if @args_quswark_flag
                Dir.chdir(pindo_new_project_dir)
                quark_temp = ["./config.json", "--adhoc"]
                Pindo::Command::Deploy::Quswark::run(quark_temp)
            end

            args_temp << "--push"
            Dir.chdir(pindo_new_project_dir)
            Pindo::Command::Deploy::Confusecode::run(args_temp)

            Dir.chdir(pindo_new_project_dir)
            Pindo::Command::Deploy::Build::run(args_temp)

        end
    end

end

#runObject



57
58
59
60
61
62
63
64
65
66
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
# File 'lib/pindo/command/ipa/output.rb', line 57

def run

    build_type_array = @config_json["project_info"]["xcode_build_type"].split("_") || []
    @args_nocreate_flag = false
    @args_quswark_flag = false
    @args_normal_flag = false

    if build_type_array.include?("nocreate")
        @args_nocreate_flag = true
    end
    if build_type_array.include?("normal")
        @args_normal_flag = true
    end
    if build_type_array.include?("quark") || build_type_array.include?("swark")
        @args_quswark_flag = true
    end

    if @args_increase_flag
        auto_increase_buildnumber(app_config_file:File.join(Dir.pwd, "config.json"))
        app_config_repo_dir = File.join(pindo_single_config.pindo_dir, @deploy_identifier)
        auto_increase_buildnumber(app_config_file:File.join(app_config_repo_dir, "config.json"))
        git_addpush_repo(path:app_config_repo_dir, message:"increate build number", commit_file_params:["config.json"])
    end

    app_info_obj = nil
    if @args_upload_flag || @args_send_flag
        proj_name = @args_proj_name
        app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
    end



    output_fun()

    pindo_new_project_dir = Dir.pwd
    build_path = File.join(pindo_new_project_dir, "build", "*.ipa")
    ipa_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}

    if !ipa_file_upload.nil? && !app_info_obj.nil? 
        result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:ipa_file_upload, description:nil)
        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
                PgyerHelper.share_instace.send_apptest_wechat_msg(msg_data:msg_data)    
            end
        end
    end

    system "open #{pindo_new_project_dir}"

end