Class: Pindo::Command::Ipa::Import

Inherits:
Pindo::Command::Ipa show all
Includes:
DeployOptions, XcodeAppConfig, XcodeBuildHelper
Defined in:
lib/pindo/command/ipa/import.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_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 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 XcodeAppConfig

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

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

Returns a new instance of Import.



40
41
42
43
44
45
# File 'lib/pindo/command/ipa/import.rb', line 40

def initialize(argv)
    @build_flag = argv.flag?('build', false)
    @args_increase_flag = argv.flag?('increase', false)

    super
end

Class Method Details

.optionsObject



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

def self.options
    [
        ['--proj', '指定哪个项目(忽略大小写空格等等字符): --proj=\"prancksoundv4\"'],
        ['--upload', '编译完成后是否上传ipa到pyger: 用法:pindo ipa import --upload'],
        ['--build', '修改完工程之后直接编译,用法:pindo ipa import --build'],
        ['--increase', '自动增加编译的app版本号,用法:pindo ipa import --increase'],

    ].concat(super)
end

Instance Method Details

#import_funObject



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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/pindo/command/ipa/import.rb', line 77

def import_fun

    current_dir = Dir.pwd
    pindo_dir = File::expand_path(pindo_single_config.pindo_dir)
    app_config_dir = File.join(pindo_dir, @deploy_identifier)

    args_temp = []
    args_temp << @args_appconfig
    args_temp = args_temp | @args_array

    @args_appstore_flag = true
    args = get_build_type_args()
    args_temp = args_temp | args

    pindo_new_project_dir = Dir.pwd

    if @args_increase_flag
        auto_increase_buildnumber(File.join(pindo_new_project_dir, "config.json"))
        app_config_repo_dir = File.join(pindo_single_config.pindo_dir, @deploy_identifier)
        auto_increase_buildnumber(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



    build_verify_file = File.join(app_config_dir, "build_verify.json")
    build_verify_json = nil

    begin
        build_verify_json = JSON.parse(File.read(build_verify_file))
    rescue => error
        build_verify_json = nil
    end

    release_code_commit = git_latest_commit_id(local_repo_dir:pindo_new_project_dir)
    if !release_code_commit.nil? && !build_verify_json.nil? && !build_verify_json["output_code_commit"].nil?
        output_code_commit = build_verify_json["output_code_commit"]
        if !release_code_commit.eql?(output_code_commit)

            puts
            puts
            puts "不是最新代码,请更新代码 !!!"
            puts "不是最新代码,请更新代码 !!!"
            puts
            answer = agree("请确认要用当前代码编译:(commit: #{release_code_commit}) (Y/n):")
            if answer

            else
                raise Informative,  "请更新代码重新打包!!!"
            end

        end
    end

    Dir.chdir(pindo_new_project_dir)

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

    Pindo::Command::Deploy::Configproj::run(args_temp)

    if File.exist?(File.join(pindo_new_project_dir, "Podfile"))

        pull_podfile_lock(project_dir:pindo_new_project_dir, app_config_dir:app_config_dir)
        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
    end

    if @args_quswark_flag
        Dir.chdir(pindo_new_project_dir)
        Pindo::Command::Deploy::Quswark::run([])
    end
    Dir.chdir(pindo_new_project_dir)
    Pindo::Command::Deploy::Cert::run(args_temp)
    Pindo::Command::Deploy::Tag::run(args_temp)


    pod_lock_json = Pod::YAMLHelper.load_file(pod_lock_file)
    pods_array = []
    if !pod_lock_json["SPEC REPOS"].nil?
        pod_lock_json["SPEC REPOS"].each do |source, pod_items|
            pods_array += pod_items
        end
    end

    if pods_array.include?("FancyAD") || pods_array.include?("AppLovinSDK")
        puts
        puts "Run Applovin Script ..."
        Dir.chdir(pindo_new_project_dir)
        applovin_args = []
        applovin_args << "--appstore"
        applovin_args << "--install"
        Pindo::Command::Utils::Applovin::run(applovin_args)
    end


    if @build_flag
        Dir.chdir(pindo_new_project_dir)
        Pindo::Command::Deploy::Build::run(args_temp)
    end


    Dir.chdir(current_dir)
    puts "Buiid Done !!!"
    puts "#{pindo_new_project_dir}"
    system "open #{pindo_new_project_dir}"

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
72
73
74
75
# File 'lib/pindo/command/ipa/import.rb', line 47

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



    clone_pindo_common_config_repo(force_delete:false)
    clone_pindo_env_config_repo(force_delete:false)

    Pindo::VersionCheck::check_pindo_force_upgrade()

    import_fun

end