Class: Pindo::Command::Dev::Createbuild
- Inherits:
-
Pindo::Command::Dev
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Dev
- Pindo::Command::Dev::Createbuild
- Includes:
- Appselect
- Defined in:
- lib/pindo/command/dev/createbuild.rb
Constant Summary
Constants inherited from Pindo::Command
Pindo::Command::DEFAULT_OPTIONS, Pindo::Command::DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Createbuild
constructor
A new instance of Createbuild.
- #modify_build_config_json ⇒ Object
- #modify_build_setting ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
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 inherited from Pindo::Command
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
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) ⇒ Createbuild
Returns a new instance of Createbuild.
29 30 31 32 |
# File 'lib/pindo/command/dev/createbuild.rb', line 29 def initialize(argv) @args_deploy_flag = argv.flag?('deploy', false) super end |
Class Method Details
.options ⇒ Object
23 24 25 26 27 |
# File 'lib/pindo/command/dev/createbuild.rb', line 23 def self. [ ['--deploy', '默认用开发的bundle id,使用--deploy设置使用发布bundle id来重签名, 用法: --deploy'], ].concat(super) end |
Instance Method Details
#modify_build_config_json ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/pindo/command/dev/createbuild.rb', line 126 def modify_build_config_json pindo_dir = pindo_single_config.pindo_dir app_config_dir = File.join(pindo_dir, @git_repo_name) selected_config_dir = clong_buildconfig_repo(repo_name: @selected_bundleid) if File.exist?(File.join(selected_config_dir, "config.json")) FileUtils.cp_r(File.join(selected_config_dir, "config.json"), app_config_dir) end app_config_file = File.join(app_config_dir, "config.json") app_config_json = JSON.parse(File.read(app_config_file)) app_config_json = app_config_json || {} app_config_json["project_info"]["app_type"] = @app_type app_config_json["project_info"]["app_desc"] = @app_desc app_config_json["app_setting"]["kGUKeyAppPlatform"] = @platform_name File.open(app_config_file, "w") do |f| f.write(JSON.pretty_generate(app_config_json)) end git_addpush_repo(path:app_config_dir, message:"更新配置") end |
#modify_build_setting ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/pindo/command/dev/createbuild.rb', line 106 def modify_build_setting pindo_setting_dir = clone_pindo_env_config_repo(force_delete:false) setting_file = 'dev_build_setting.json' if @args_deploy_flag setting_file = 'deploy_build_setting.json' end setting_file_fullname = File.join(pindo_setting_dir, setting_file) setting_file_json = JSON.parse(File.read(setting_file_fullname)) setting_file_json[@app_type] = {} setting_file_json[@app_type]['git_repo_name'] = @git_repo_name setting_file_json[@app_type]['build_desc'] = @app_desc setting_file_json = Hash[setting_file_json.sort] File.open(setting_file_fullname, "w") do |f| f.write(JSON.pretty_generate(setting_file_json)) end git_addpush_repo(path:pindo_setting_dir, message:"add app_type: #{@app_type}", commit_file_params:[setting_file]) end |
#run ⇒ Object
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 |
# File 'lib/pindo/command/dev/createbuild.rb', line 59 def run @gitee_client = GiteeClient.new(access_token:pindo_single_config.gitee_api_key) pindo_setting_dir = pindo_single_config.pindo_env_configdir setting_file = 'dev_build_setting.json' if @args_deploy_flag setting_file = 'deploy_build_setting.json' end setting_file_fullname = File.join(pindo_setting_dir, setting_file) setting_file_json = JSON.parse(File.read(setting_file_fullname)) if setting_file_json[@app_type] answer = agree("输入的App代号已存,重新创建?(Y/n):") unless answer raise Informative, "输入的App代号已存在!!!" end end puts "=========================" puts "=========================" puts puts puts "App的代号: #{@app_type}" puts "Boss平台名称: #{@platform_name}" puts "App选择的bundle id: #{@selected_bundleid}" puts "仓库名称: #{@git_repo_name}" puts "App的描述: #{@app_desc}" puts answer = agree("请确认上面信息是否正确(Y/n):") unless answer raise Informative, "重新输入 !!!" end args_temp = [@git_repo_name] args_temp << "--test" Pindo::Command::Deploy::Initconfig::run(args_temp) modify_build_setting modify_build_config_json end |
#validate! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pindo/command/dev/createbuild.rb', line 34 def validate! super @app_type = ask('App的代号(必填): ') help! '需要一个唯一的代号' if @app_type.nil? || @app_type.empty? @platform_name = ask('使用的Boss平台名称(必填): ') help! '需要指定Boss平台' if @platform_name.nil? || @platform_name.empty? @git_repo_name = @platform_name @app_desc = ask('请填写App代号的描述(可不填): ') @selected_bundleid= nil if @args_deploy_flag @selected_bundleid = get_selected_deploy_bundleid() else @selected_bundleid = get_selected_dev_bundleid() end puts "选择使用的bundle id: #{@selected_bundleid}" end |