Class: Pindo::Command::Deploy::Updateconfig

Inherits:
Pindo::Command::Deploy show all
Includes:
Appselect, Pindo::Command::DeployOptions, Hashhelper
Defined in:
lib/pindo/command/deploy/updateconfig.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

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 Hashhelper

#deepcopy_hash, #deepcopy_hash_struct, #init_hash_value_wihtout_add_key, #init_hash_value_wihtout_exludekeys, #minus_hash

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, #initialize, options, #print_params_info, #validate!

Methods inherited from Pindo::Command

#initialize, options, 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!

Instance Method Details

#runObject



24
25
26
27
28
29
# File 'lib/pindo/command/deploy/updateconfig.rb', line 24

def run
    
    update_common_struct

    
end

#update_common_structObject



32
33
34
35
36
37
38
39
40
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
# File 'lib/pindo/command/deploy/updateconfig.rb', line 32

def update_common_struct
    app_default_config_dir = clong_buildconfig_repo(repo_name: pindo_single_config.demo_bundle_id)
    default_config_file = File.join(app_default_config_dir, "config.json")
    default_config_json = nil
    if !default_config_file.empty? && File::file?(default_config_file)   
        default_config_json=JSON.parse(File.read(default_config_file))
        unless default_config_json
            puts "Default json not found !!!"
        end
    else
        puts "Default json not found !!!"
    end
    
    puts "\n\n=========用新模板更新后的config=============="
    empty_new_config = deepcopy_hash_struct(src_hash:default_config_json, key_value:"__________config_")
    new_config_json = init_hash_value_wihtout_add_key(hash1:empty_new_config, hash2:@config_json)                    
    new_config_json['config_version'] = default_config_json['config_version']

    puts JSON.pretty_generate(new_config_json)
    if !@args_appconfig_fullname.empty? && File::file?(@args_appconfig_fullname)  
        File.open(@args_appconfig_fullname, "w") do |f|
            f.write(JSON.pretty_generate(new_config_json))
        end
    else
        puts "Update config.json error!!!"
    end

    puts "\n\n=========删除的Key=============="
    del_key_json = minus_hash(hash1:@config_json, hash2:new_config_json)
    puts JSON.pretty_generate(del_key_json)

    puts "\n\n=========新增的Key=============="
    add_key_json = minus_hash(hash1:new_config_json, hash2:@config_json)
    puts JSON.pretty_generate(add_key_json)

end

#update_mainapp_configObject



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

def update_mainapp_config

    cli = HighLine.new

    menu_choice = select_main_app
    
    if menu_choice == "None" || menu_choice == "IdeaApp"
        puts "Do not need fixed config!"
    else

        deploy_repo_name = get_deploy_setting_repo(tagname:menu_choice)
        puts "deploy_repo_name: #{deploy_repo_name}"

        mainapp_config_dir = clong_buildconfig_repo(repo_name: deploy_repo_name)
        mainapp_config_file = File.join(mainapp_config_dir, "config.json")
        mainapp_config_json = nil
        if !mainapp_config_file.empty? && File::file?(mainapp_config_file)   
            mainapp_config_json=JSON.parse(File.read(mainapp_config_file))
            unless mainapp_config_json
                puts "Default json not found !!!"
            end
        else
            puts "Default json not found !!!"
        end

        if !@args_appconfig_fullname.empty? && File::file?(@args_appconfig_fullname)  

            currentapp_config_json=JSON.parse(File.read(@args_appconfig_fullname))

            currentapp_config_json['project_info']['ios_deployment_targe'] = mainapp_config_json['project_info']['ios_deployment_targe']
            currentapp_config_json['project_info']['app_type'] = mainapp_config_json['project_info']['app_type']
            currentapp_config_json['project_info']['build_type'] = mainapp_config_json['project_info']['build_type']
            currentapp_config_json['project_info']['project_module'] = mainapp_config_json['project_info']['project_module']
            
            currentapp_config_json['app_setting']['kGUKeyAppsFlyerDevKey'] = 'dN3s94tzJN3e8M3R9EMSbc'
   

            if menu_choice == "AddMe" 
                desc_location_use = currentapp_config_json['app_info']['desc_location_use']
                if desc_location_use.nil? || desc_location_use == "" || desc_location_use.empty? || desc_location_use == "++++++++"
                    currentapp_config_json['app_info']['desc_location_use'] = "So that you can know people near you!"
                end
            end

            File.open(@args_appconfig_fullname, "w") do |f|
                f.write(JSON.pretty_generate(currentapp_config_json))
            end
            puts "Update config.json with #{menu_choice} !!!"
        else
            puts "Update config.json error!!!"
        end


    end
    
end