Class: Pindo::Command::Deploy::Getitcinfo

Inherits:
Pindo::Command::Deploy show all
Includes:
AppstoreMetadataConnectApiHelper, Pindo::Command::DeployOptions, XcodeCertHelper
Defined in:
lib/pindo/command/deploy/getitcinfo.rb

Constant Summary

Constants inherited from Pindo::Command

Pindo::Command::DEFAULT_OPTIONS, Pindo::Command::DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes included from Pindo::Command::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 AppstoreMetadataConnectApiHelper

#all_languages, #camel_case_lower, #change_img_sort, #check_attributes, #display_type_dir_name, #download_screenshots_exe, #fastlane_download_app_info, #fastlane_download_app_screenshot_exe, #fastlane_download_app_screenshots, #fastlane_download_app_version_info, #fastlane_login, #fastlane_process_lang_screenshots, #fastlane_update_app_info_localizations, #fastlane_update_app_info_metadata, #fastlane_update_app_metadata, #fastlane_update_app_version_info_metadata, #update_age_rating, #update_app_categories, #update_app_info_localizations, #update_privacy_useagedata, #update_review_info, #update_version_info_localizations, #verify_app_info_localizations, #verify_app_version_info_localizations, #write_app_version_info_localization_to_txt

Methods included from XcodeCertHelper

#config_infoplist_cert, #config_project_cert, #create_provisioning_info_array, #create_upload_cert_info, #create_upload_provisioning_info, #get_target_name_map, #modify_entitlements_plist, #modify_info_plist_icloud

Methods included from Pindo::Command::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) ⇒ Getitcinfo

Returns a new instance of Getitcinfo.



36
37
38
39
40
41
42
43
44
# File 'lib/pindo/command/deploy/getitcinfo.rb', line 36

def initialize(argv)
  
  @upload_metadata_flag = argv.flag?('metadata', false)
  @upload_screenshots_flag = argv.flag?('screenshots', false)

  @over_write = argv.flag?('overwrite', false)

  super
end

Class Method Details

.optionsObject



29
30
31
32
33
34
# File 'lib/pindo/command/deploy/getitcinfo.rb', line 29

def self.options
    [
        ['--metadata', '获取metadata信息.'],
        ['--screenshots', '下载商店截屏.'],
    ].concat(super)
end

Instance Method Details

#download_iap_info(temp_bundle_id: nil) ⇒ Object



240
241
242
# File 'lib/pindo/command/deploy/getitcinfo.rb', line 240

def download_iap_info(temp_bundle_id:nil)   

end

#fastlane_download_metadata(temp_bundle_id: nil) ⇒ Object



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
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
# File 'lib/pindo/command/deploy/getitcinfo.rb', line 73

def (temp_bundle_id:nil)   

    app_itunes_dir = File.join(@app_config_dir,  "fastlane") 
    app_itunes_file = File.join(app_itunes_dir,  "app_itunes.json")

    app_itunes_json = {}
    # if File.exist?(app_itunes_file)
    #     app_itunes_json = JSON.parse(File.read(app_itunes_file))  
    # else 
    #     app_itunes_json = {}
    # end
    

    app = Spaceship::ConnectAPI::App.find(temp_bundle_id)
    
    # app_itunes_json["prices"] = app.prices
    app_itunes_json["primary_locale"] = app.primary_locale
    # app_itunes_json["is_opted_in_to_distribute_ios_app_on_mac_app_store"] = app.is_opted_in_to_distribute_ios_app_on_mac_app_store
    app_itunes_json["content_rights_declaration"] = app.content_rights_declaration



    all_usages = Spaceship::ConnectAPI::AppDataUsage.all(app_id: app.id, includes: "category,grouping,purpose,dataProtection", limit: 500)
    if !all_usages.nil? && all_usages.size > 0
        app_itunes_json["privacy_data"] = []

        all_usages_config = {}

        all_usages.each do |privacy_usage|

            if !privacy_usage.category.nil? 
                category= privacy_usage.category.id
                all_usages_config[category] = all_usages_config[category] || {}
                all_usages_config[category]["category"] = category

                if !privacy_usage.purpose.nil? 
                    all_usages_config[category]["purposes"] = all_usages_config[category]["purposes"] || [] 
                    all_usages_config[category]["purposes"] << privacy_usage.purpose.id

                end

                if !privacy_usage.data_protection.nil?
                    all_usages_config[category]["data_protections"] = all_usages_config[category]["data_protections"] || [] 
                    all_usages_config[category]["data_protections"] << privacy_usage.data_protection.id
                end

            else
                usages_config = {}
                usages_config["data_protections"] = usages_config["data_protections"] || []
                if !privacy_usage.data_protection.nil?
                    usages_config["data_protections"] = usages_config["data_protections"] || [] 
                    usages_config["data_protections"] << privacy_usage.data_protection.id
                end
                 app_itunes_json["privacy_data"] << usages_config
            end
        end

        all_usages_config.each do |k, item| 
            app_itunes_json["privacy_data"] << item
        end

    end

    


    app_itunes_json["app_info"] = app_itunes_json["app_info"] || {}
    
    platforms = ["IOS", "MAC_OS", "TV_OS", "XR_OS"]

    platforms.each do |platform|

        app_itunes_json["app_edit_version_info"] = app_itunes_json["app_edit_version_info"] || {}

        app_edit_version_info = app.get_edit_app_store_version(platform: platform, includes: 'appStoreVersionSubmission,build,appStoreVersionPhasedRelease,appStoreVersionLocalizations')


        if app_edit_version_info.nil? 

            if File.exist?(File.join(app_itunes_dir, platform.downcase))
                FileUtils.rm_rf(File.join(app_itunes_dir, platform.downcase))
            end


            app_itunes_json["app_edit_version_info"].delete(platform)
            app_itunes_json["app_edit_version_info"].delete(platform.downcase)
            
        else

            fastlane_download_app_version_info(app_version_info: app_edit_version_info, platform:platform, app_itunes_json:app_itunes_json, app_itunes_dir:app_itunes_dir)    

        end


    end                    

    app_itunes_json["app_info"]["app_info_localization"] = {}
    fastlane_download_app_info(app: app, app_itunes_json:app_itunes_json, app_itunes_dir:app_itunes_dir)    



    File.open(app_itunes_file, "w") do |file|
        file.write(JSON.pretty_generate(app_itunes_json))
        file.close
    end

end

#fastlane_download_screenshots(temp_bundle_id: nil) ⇒ Object



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
# File 'lib/pindo/command/deploy/getitcinfo.rb', line 183

def fastlane_download_screenshots(temp_bundle_id:nil) 

    app_screenshots_dir = File.join(@app_config_dir,  "fastlane/screenshots") 
    app = Spaceship::ConnectAPI::App.find(temp_bundle_id)
    platforms = ["IOS", "MAC_OS", "TV_OS", "XR_OS"]

    if !File.exist?(app_screenshots_dir)
        FileUtils.rm_rf(app_screenshots_dir)
    end
    platforms.each do |platform|

        app_edit_version_info = app.get_edit_app_store_version(platform: platform)

        if app_edit_version_info.nil? 

            if File.exist?(File.join(app_screenshots_dir, platform.downcase))
                FileUtils.rm_rf(File.join(app_screenshots_dir, platform.platform.downcase))
            end
        else
            fastlane_download_app_screenshots(app_version_info: app_edit_version_info, platform:platform, app_screenshots_dir:app_screenshots_dir, over_write:@over_write)    
        end

    end

end

#runObject



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
# File 'lib/pindo/command/deploy/getitcinfo.rb', line 47

def run
    current_project_dir = Dir.pwd
    pindo_dir = File::expand_path(pindo_single_config.pindo_dir)
    @app_config_dir = File.join(pindo_dir, @deploy_repo_name)
    app_itunes_dir = File.join(@app_config_dir,  "fastlane") 
    begin
        FileUtils.mkdir_p(File.join(app_itunes_dir))
    rescue
         # if it's already there
    end

    (apple_id:@apple_id)

    if @upload_metadata_flag 
        (temp_bundle_id:@bundle_id)
    end


    if @upload_screenshots_flag 
        fastlane_download_screenshots(temp_bundle_id:@bundle_id)
        valid_screenshots_html
    end

    puts "Done !!!"
end

#valid_screenshots_htmlObject



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/pindo/command/deploy/getitcinfo.rb', line 210

def valid_screenshots_html()

    app_screenshots_dir = File.join(@app_config_dir,  "fastlane/screenshots")               
    screenshots_path = File.join(app_screenshots_dir,  "ios") 
    screenshots = Deliver::Loader.load_app_screenshots(screenshots_path, true)


    app_itunes_dir = File.join(@app_config_dir,  "fastlane") 
    app_itunes_file = File.join(app_itunes_dir,  "app_itunes.json")
    app_itunes_json = JSON.parse(File.read(app_itunes_file))

    

    # Validate
    options = {}
    options[:name] = {} 
    options[:name]["en-US"] = app_itunes_json["app_info"]["app_info_localization"]["en-US"]["name"]
    options[:description] = {} 

    app_itunes_json["app_info"]["app_info_localization"].each do |lang , data|
        options[:description][lang] = ""
    end
    
    html_path = Deliver::HtmlGenerator.new.render(options, screenshots, app_itunes_dir)
    system("open '#{html_path}'")
end