cocoapods-mars 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 926b0d106af20acd57150a7ac34885111978cc5ff4d58a4e99fcc9cb0746ebc9
4
- data.tar.gz: 0e4d7c99e733fc96a6f79688f133b657980c38347adf7079313e100e6c142840
3
+ metadata.gz: ec365556b257eb08c48b114818d18c061aa6928eb620c997a5d135832de187b1
4
+ data.tar.gz: a69fc8c96861b24be94bb01fbe360b3f3b1f49d5e1cd088ace14945b595a92d8
5
5
  SHA512:
6
- metadata.gz: 1e5c51e964a32221d0a5bf297b4d9873d4b7d75aa707aad9589087646810a3c03b86615e3eab9473bca20d5f419dff80ccd413230c6064cf86b38ddb28f2ed67
7
- data.tar.gz: baa8e41992af300b0e7f45a11423795af0e37c0dbd428486b79c93207c145c0f7da6736b4522f666ab04d1f43d24f1b2acb6006e95aa8129405ced568c2590a3
6
+ metadata.gz: 0fb8787bb95ba63924685406916a22f3866f4e1946377bf13cdbf8cc7cd355a2d6c3dbcb707c8c52a930baf8fc99a95143412649fac1fcbe45976fc7db7c7aaf
7
+ data.tar.gz: 78c31abc76850709d3690f5671dbf1b6202a5c6353d5fc508a6cd38de73ee2877e7c4c078aac20929eefc084137b005a587b8c9e6f2d39ecd787dcab9ad20aa6
data/Gemfile CHANGED
@@ -11,6 +11,8 @@ gem 'json_pure'
11
11
  gem 'cocoapods'
12
12
  gem 'rubyzip', '>= 1.0.0'
13
13
  gem 'open-uri'
14
+ gem "tty-prompt"
15
+ gem "moneta"
14
16
  group :debug do
15
17
  gem 'ruby-debug-ide'
16
18
  gem 'debase', '0.2.5.beta2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-mars (0.0.13)
4
+ cocoapods-mars (0.0.14)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -75,10 +75,13 @@ GEM
75
75
  json_pure (2.5.1)
76
76
  minitest (5.14.4)
77
77
  molinillo (0.6.6)
78
+ moneta (1.4.2)
78
79
  nanaimo (0.3.0)
79
80
  nap (1.1.0)
80
81
  netrc (0.11.0)
81
82
  open-uri (0.1.0)
83
+ pastel (0.8.0)
84
+ tty-color (~> 0.5)
82
85
  plist (3.6.0)
83
86
  public_suffix (4.0.6)
84
87
  rake (13.0.6)
@@ -88,10 +91,21 @@ GEM
88
91
  ruby-macho (1.4.0)
89
92
  rubyzip (2.3.2)
90
93
  thread_safe (0.3.6)
94
+ tty-color (0.6.0)
95
+ tty-cursor (0.7.1)
96
+ tty-prompt (0.23.1)
97
+ pastel (~> 0.8)
98
+ tty-reader (~> 0.8)
99
+ tty-reader (0.9.0)
100
+ tty-cursor (~> 0.7)
101
+ tty-screen (~> 0.8)
102
+ wisper (~> 2.0)
103
+ tty-screen (0.8.1)
91
104
  typhoeus (1.4.0)
92
105
  ethon (>= 0.9.0)
93
106
  tzinfo (1.2.9)
94
107
  thread_safe (~> 0.1)
108
+ wisper (2.0.1)
95
109
  xcodeproj (1.21.0)
96
110
  CFPropertyList (>= 2.3.3, < 4.0)
97
111
  atomos (~> 0.1.3)
@@ -110,12 +124,14 @@ DEPENDENCIES
110
124
  concurrent-ruby
111
125
  debase (= 0.2.5.beta2)
112
126
  json_pure
127
+ moneta
113
128
  open-uri
114
129
  plist (~> 3.2)
115
130
  rake
116
131
  rexml
117
132
  ruby-debug-ide
118
133
  rubyzip (>= 1.0.0)
134
+ tty-prompt
119
135
  xcodeproj
120
136
 
121
137
  BUNDLED WITH
@@ -28,6 +28,7 @@ module Pod
28
28
  @language = language
29
29
  @basicInfo = BasicInfo.new(app_key, bundle_id, name, version)
30
30
  @git_url = git_url
31
+ config_json.strip!
31
32
  @config_json = config_json
32
33
  @selected_components = components | (language == 'swift' ? %w[OneKit SwiftOneKit] : ['OneKit'])
33
34
  @components_details = []
@@ -59,6 +60,8 @@ module Pod
59
60
  def patch(podfile_dir)
60
61
  puts "patching project..."
61
62
  collect_components
63
+ podfile_dir.strip!
64
+ podfile_dir.delete_suffix!("Podfile")
62
65
  Dir.chdir(podfile_dir) do
63
66
  construct_plist
64
67
  patcher = Patcher.new(podfile_dir, @basicInfo.version, @components_details, @sources, @git_url, @demo_tag)
@@ -0,0 +1,179 @@
1
+ # require 'json'
2
+ require 'plist'
3
+ require_relative '../project'
4
+ require "tty-prompt"
5
+ require_relative '../../services/baselines_api'
6
+ require_relative '../../services/components_api'
7
+ require "moneta"
8
+
9
+ module Pod
10
+ class Command
11
+ class Vemars
12
+ class Prompt < Vemars
13
+ self.summary = 'Inteactive CLI'
14
+ self.description = <<-DESC
15
+ Inteactive CLI
16
+ DESC
17
+
18
+ self.arguments = [
19
+ ]
20
+
21
+ def self.options
22
+ options = [
23
+ ]
24
+ options.concat(super.reject { |option, _| option == '--silent' })
25
+ end
26
+
27
+ def initialize(argv)
28
+ store = Moneta.new(:File, dir: 'moneta')
29
+
30
+ api = Baselines_api.new(@service_url)
31
+ api.getBaselines(true)
32
+ if api.result.length() == 0
33
+ help! "获取基线失败,检查网络连接"
34
+ end
35
+ baselines = api.result
36
+
37
+ prompt = TTY::Prompt.new(prefix: "[MARS] ")
38
+ # types = [ {name: "创建新工程", value: 1},{name:"既有工程接入", value: 2},{name:"查询基线", value: 3,disable:true},{name:"查询组件", value: 4,disable:true}]
39
+ types = [ {name: "创建新工程", value: 1},{name:"既有工程接入", value: 2}]
40
+ @prompt_type = prompt.select("选择操作类型:", types)
41
+ if @prompt_type == 1
42
+ @name = prompt.ask("请输入工程名:", default: "MarsDemo")
43
+ elsif @prompt_type == 2
44
+ if store.key?('podfile-path')
45
+ @path = prompt.ask("请输入Podfile所在的工程目录",default:store["podfile-path"])
46
+ elsif
47
+ @path = prompt.ask("请输入Podfile所在的工程目录")
48
+ end
49
+ end
50
+ languages = [ {name: "Objective-C", value: "objc"},{name:"Swift", value: "swift"}]
51
+ @language = prompt.select("选择开发语言:", languages)
52
+
53
+ if store.key?('config-path')
54
+ @config_json = prompt.ask("请输入config.json配置文件路径",default:store["config-path"])
55
+ elsif
56
+ @config_json = prompt.ask("请输入config.json配置文件路径")
57
+ end
58
+ @version = prompt.select("选择基线:", baselines)
59
+
60
+ comp_api = Components_api.new(@version,@service_url)
61
+ components = comp_api.getComponents().select do |components|
62
+ components.name != "ve_Template_iOS"
63
+ end
64
+ components = components.map {|c| c.name}.select {|c| c.length > 0}
65
+ components.insert(0, components.delete('RangersAPM'))
66
+ components.insert(0, components.delete('RangersAppLog'))
67
+ components.insert(0, components.delete('VEAppUpdateHelper'))
68
+ components.insert(0, components.delete('VERemoteConfig'))
69
+ components.insert(0, components.delete('BDHotfix'))
70
+ components.insert(0, components.delete('VEH5Kit'))
71
+ @selected_components = prompt.multi_select("选择组件:",components,per_page: 10)
72
+
73
+
74
+
75
+ #toDO
76
+ # private_configs = prompt.ask("是否进行私有化配置?",convert:boolean,default:"no")
77
+ # if private_configs
78
+ git_url = argv.option('git', 'https://github.com/volcengine/ve_Template_iOS.git')
79
+ @repo_no_update = argv.flag?('pod_repo_no_update',false)
80
+ service_url = argv.option('service_url',nil)
81
+ sources = argv.option('sources','https://github.com/volcengine/volcengine-specs.git,https://cdn.cocoapods.org/')
82
+ @silent = argv.flag?('silent', false)
83
+ @appkey = argv.option('appkey', '')
84
+ @bundle_id = argv.option('bundle_id', nil)
85
+
86
+ #save Configs
87
+ store['config-path'] = @config_json
88
+ if !@path.nil? && @path.length > 0
89
+ store['podfile-path'] = @path
90
+ end
91
+ store.close
92
+
93
+ super
94
+ @additional_args = argv.remainder!
95
+
96
+
97
+ if @prompt_type == 1
98
+ @project = VemarsProject.new(@appkey, @selected_components, @config_json, @version, @bundle_id, @name, @language, git_url,service_url,sources)
99
+ elsif @prompt_type == 2
100
+ @project = VemarsProject.new(@appkey, @selected_components, @config_json, @baseline, git_url, service_url,sources)
101
+ end
102
+
103
+ end
104
+
105
+ def run
106
+ puts('[MARS] Hi, welcome to vemars!')
107
+ if @prompt_type == 1
108
+ @project.generate
109
+ podInstallInCreateProcess
110
+ openXcodeWorkSpacelInCreateProcess
111
+ elsif @prompt_type == 2
112
+ @project.patch @path
113
+ podInstallInPatchProcess
114
+ openXcodeWorkSpaceInPatchProcess
115
+ end
116
+ end
117
+
118
+ def podInstallInCreateProcess
119
+ puts "Current dir: #{Dir.pwd}"
120
+ project_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project"])
121
+ puts "Pod install directory: #{project_dir}"
122
+ if @silent
123
+ puts "Pod install skipped!"
124
+ puts "You can run Pod install in '#{project_dir}' later!"
125
+ puts "You can run Pod install in '#{project_dir}' later!"
126
+ puts "You can run Pod install in '#{project_dir}' later!"
127
+ return
128
+ end
129
+
130
+ Dir.chdir(project_dir) do
131
+ # system('bundle install')
132
+ # system('bundle exec pod install --repo-update')
133
+ if @repo_no_update
134
+ puts "pod install with no repo update"
135
+ system('pod install --no-repo-update')
136
+ else
137
+ system('pod install --repo-update')
138
+ end
139
+ end
140
+ end
141
+
142
+ def podInstallInPatchProcess
143
+ puts "Current dir: #{Dir.pwd}"
144
+ project_dir = @path
145
+ puts "Pod install directory: #{project_dir}"
146
+ if @silent
147
+ puts "Pod install skipped!"
148
+ puts "You can run Pod install in '#{project_dir}' later!"
149
+ return
150
+ end
151
+
152
+ Dir.chdir(project_dir) do
153
+ # system('bundle install')
154
+ # system('bundle exec pod install --repo-update')
155
+ if @repo_no_update
156
+ puts "pod install with no repo update"
157
+ system('pod install --no-repo-update')
158
+ else
159
+ system('pod install --repo-update')
160
+ end
161
+ end
162
+ end
163
+
164
+
165
+ def openXcodeWorkSpacelInCreateProcess
166
+ workspace_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project","'#{@project.basicInfo.name}'.xcworkspace"])
167
+ system("open -a /Applications/Xcode.app '#{workspace_dir}'")
168
+ end
169
+
170
+ def openXcodeWorkSpaceInPatchProcess
171
+ workspaces = Dir.entries(@path).select { |e| e.end_with?(".xcworkspace") }
172
+ full_path = File.join(@path, workspaces.first)
173
+ system("open -a /Applications/Xcode.app '#{full_path}'")
174
+ end
175
+
176
+ end
177
+ end
178
+ end
179
+ end
@@ -5,6 +5,7 @@ module Pod
5
5
  require_relative 'vemars/baselines'
6
6
  require_relative 'vemars/components'
7
7
  require_relative 'vemars/patch'
8
+ require_relative 'vemars/prompt'
8
9
 
9
10
  self.summary = 'vemars iOS project generation tool'
10
11
  self.description = <<-DESC
@@ -12,7 +13,7 @@ module Pod
12
13
  DESC
13
14
 
14
15
  self.abstract_command = true
15
- # self.default_subcommand = 'create'
16
+ self.default_subcommand = 'prompt'
16
17
  self.command = 'mars'
17
18
 
18
19
  # 解析命令别名
@@ -1,3 +1,3 @@
1
1
  module CocoapodsVemars
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -11,7 +11,7 @@ module Pod
11
11
  @baseline_url = (url.blank? ? BASELINES_URL : url + "mpaas/baseline/baselines")
12
12
  end
13
13
 
14
- def getBaselines
14
+ def getBaselines(silent=false)
15
15
  body= "{\"technology_stack\": \"iOS\"}"
16
16
  header = {"ContentType" => 'application/json'}
17
17
  response = REST.post(@baseline_url, body, header)
@@ -21,7 +21,9 @@ module Pod
21
21
  if error_code == 0
22
22
  @result = json["data"]['baselines']
23
23
  @result = @result.sort.reverse
24
- puts "Version list: #{@result}"
24
+ if !silent
25
+ puts "Version list: #{@result}"
26
+ end
25
27
  else
26
28
  puts "Error #{error_code}(#{json["error_msg"]}): #{json["err_detail"]}}"
27
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-mars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - huangbomao@bytedance.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,6 +62,7 @@ files:
62
62
  - lib/cocoapods-vemars/command/vemars/components.rb
63
63
  - lib/cocoapods-vemars/command/vemars/create.rb
64
64
  - lib/cocoapods-vemars/command/vemars/patch.rb
65
+ - lib/cocoapods-vemars/command/vemars/prompt.rb
65
66
  - lib/cocoapods-vemars/gem_version.rb
66
67
  - lib/cocoapods-vemars/hook/podfile.rb
67
68
  - lib/cocoapods-vemars/hook/podfile_template.rb