Class: Pod::Command::Vemars::Prompt
- Inherits:
-
Pod::Command::Vemars
- Object
- Pod::Command
- Pod::Command::Vemars
- Pod::Command::Vemars::Prompt
- Defined in:
- lib/cocoapods-vemars/command/vemars/prompt.rb
Class Method Summary collapse
Instance Method Summary collapse
- #getComponents ⇒ Object
-
#initialize(argv) ⇒ Prompt
constructor
A new instance of Prompt.
- #openXcodeWorkSpaceInPatchProcess ⇒ Object
- #openXcodeWorkSpacelInCreateProcess ⇒ Object
- #podInstallInCreateProcess ⇒ Object
- #podInstallInPatchProcess ⇒ Object
- #promptAskWithCache(message, key, store, prompt) ⇒ Object
- #run ⇒ Object
Methods inherited from Pod::Command::Vemars
Constructor Details
#initialize(argv) ⇒ Prompt
Returns a new instance of Prompt.
27 28 29 30 31 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 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 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 27 def initialize(argv) store = Moneta.new(:File, dir: 'moneta') api = Baselines_api.new(@service_url) api.getBaselines(true) if api.result.length() == 0 help! "获取基线失败,检查网络连接" end baselines = api.result prompt = TTY::Prompt.new(prefix: "[MARS] ") # types = [ {name: "创建新工程", value: 1},{name:"既有工程接入", value: 2},{name:"查询基线", value: 3,disable:true},{name:"查询组件", value: 4,disable:true}] types = [ {name: "创建新工程", value: 1},{name:"既有工程接入", value: 2}] @prompt_type = prompt.select("选择操作类型:", types) if @prompt_type == 1 @name = prompt.ask("请输入工程名:", default: "MarsDemo") elsif @prompt_type == 2 promptAskWithCache("请输入Podfile所在的工程目录","podfile-path",store,prompt) end languages = [ {name: "Objective-C", value: "objc"},{name:"Swift", value: "swift"}] @language = prompt.select("选择开发语言:", languages) promptAskWithCache("请输入config.json配置文件路径","config-path",store,prompt) select_baseline = prompt.ask("是否需要选择基线?(默认使用最新版本)", convert: :boolean, default: "no") if select_baseline @version = prompt.select("选择基线:", baselines) else @version = baselines.first puts "将使用最新基线版本: " + @version end @selected_components = prompt.multi_select("选择组件:",getComponents,per_page: 10) #toDO git_url = argv.option('git', 'https://github.com/volcengine/ve_Template_iOS.git') @repo_no_update = false service_url = nil sources = 'https://github.com/volcengine/volcengine-specs.git,https://cdn.cocoapods.org/' @silent = false @appkey = '' @bundle_id = nil private_configs = prompt.ask("是否进行私有化配置?",convert: :boolean,default:"no") if private_configs service_url = prompt.ask('请输入基线服务的URL地址:',default: 'https://mars-fwk.vemarsdev.com/mpaas') git_url = prompt.ask('请输入脚手架Demo仓库的地址:',default: 'https://github.com/volcengine/ve_Template_iOS.git') sources = prompt.ask('请输入Cocoapods源的地址的URL地址:',default: 'https://github.com/volcengine/volcengine-specs.git,https://cdn.cocoapods.org/') @repo_no_update = prompt.ask("是否跳过更新本地Pod仓库?",convert: :boolean,default:"no") end #save Configs store['config-path'] = @config_json if !@path.nil? && @path.length > 0 store['podfile-path'] = @path end store.close super @additional_args = argv.remainder! if @prompt_type == 1 @project = VemarsProject.new(@appkey, @selected_components, @config_json, @version, @bundle_id, @name, @language, git_url,service_url,sources) elsif @prompt_type == 2 @project = VemarsProject.new(@appkey, @selected_components, @config_json, @baseline, git_url, service_url,sources) end end |
Class Method Details
.options ⇒ Object
21 22 23 24 25 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 21 def self. = [ ] .concat(super.reject { |option, _| option == '--silent' }) end |
Instance Method Details
#getComponents ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 115 def getComponents comp_api = Components_api.new(@version,@service_url) components = comp_api.getComponents().select do |components| components.name != "ve_Template_iOS" end components = components.map {|c| c.name}.select {|c| c.length > 0} components.insert(0, components.delete('RangersAPM')) components.insert(0, components.delete('RangersAppLog')) components.insert(0, components.delete('VEAppUpdateHelper')) components.insert(0, components.delete('VERemoteConfig')) components.insert(0, components.delete('BDHotfix')) components.insert(0, components.delete('VEH5Kit')) components end |
#openXcodeWorkSpaceInPatchProcess ⇒ Object
182 183 184 185 186 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 182 def openXcodeWorkSpaceInPatchProcess workspaces = Dir.entries(@path).select { |e| e.end_with?(".xcworkspace") } full_path = File.join(@path, workspaces.first) system("open -a /Applications/Xcode.app '#{full_path}'") end |
#openXcodeWorkSpacelInCreateProcess ⇒ Object
177 178 179 180 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 177 def openXcodeWorkSpacelInCreateProcess workspace_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project","'#{@project.basicInfo.name}'.xcworkspace"]) system("open -a /Applications/Xcode.app '#{workspace_dir}'") end |
#podInstallInCreateProcess ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 130 def podInstallInCreateProcess puts "[MARS] Current dir: #{Dir.pwd}" project_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project"]) puts "[MARS] Pod install directory: #{project_dir}" if @silent puts "Pod install skipped!" puts "You can run Pod install in '#{project_dir}' later!" puts "You can run Pod install in '#{project_dir}' later!" puts "You can run Pod install in '#{project_dir}' later!" return end Dir.chdir(project_dir) do # system('bundle install') # system('bundle exec pod install --repo-update') if @repo_no_update puts "[MARS] pod install with no repo update" system('pod install --no-repo-update') else system('pod install --repo-update') end end end |
#podInstallInPatchProcess ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 154 def podInstallInPatchProcess puts "[MARS] Current dir: #{Dir.pwd}" project_dir = @path puts "[MARS] Pod install directory: #{project_dir}" if @silent puts "Pod install skipped!" puts "You can run Pod install in '#{project_dir}' later!" return end Dir.chdir(project_dir) do # system('bundle install') # system('bundle exec pod install --repo-update') if @repo_no_update puts "[MARS] pod install with no repo update" system('pod install --no-repo-update') else system('pod install --repo-update') end end end |
#promptAskWithCache(message, key, store, prompt) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 107 def promptAskWithCache(,key,store,prompt) if store.key?(key) @config_json = prompt.ask(,default:store[key]) elsif @config_json = prompt.ask() end end |
#run ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/cocoapods-vemars/command/vemars/prompt.rb', line 94 def run puts('[MARS] Hi, welcome to vemars!') if @prompt_type == 1 @project.generate podInstallInCreateProcess openXcodeWorkSpacelInCreateProcess elsif @prompt_type == 2 @project.patch @path podInstallInPatchProcess openXcodeWorkSpaceInPatchProcess end end |