cocoapods-mars 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 667404c9aaaffde3f4e5d6ac7b679b3bb2f1be1ad1fe5280f71cb3abef51d5ff
4
+ data.tar.gz: 22e2a4994423ad2ac7be931b6ae1d209d4ad0c2f14201f9362be0553c95c37d3
5
+ SHA512:
6
+ metadata.gz: bb195ba7c4deba11cd93fdb972921133cf8dfe09224589fc0589cb105d8c4adfc683ad35e66e991f1bb8aaafc514617a61609fbeb6cd6a1431e5b717be0e73a0
7
+ data.tar.gz: 315f5fc3dec95b70f9d2e979f937b1e158d7b881c62d4f34a46a1b46be90ab91909fc73ff5ce38b0b20b5eea28474490e5fa6003af733abc3dc85ac54032ae02
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ vendor
5
+ install
6
+ .bundle
7
+
8
+ *.gem
9
+ *.gemspec
10
+ ruby/
11
+ test/
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-vemars.gemspec
4
+ gemspec
5
+
6
+ gem 'plist', '~> 3.2'
7
+ gem 'rexml'
8
+ gem 'concurrent-ruby', require: 'concurrent'
9
+ gem 'xcodeproj'
10
+ gem 'json_pure'
11
+ gem 'cocoapods'
12
+ gem 'rubyzip', '>= 1.0.0'
13
+ gem 'open-uri'
14
+ group :debug do
15
+ gem 'ruby-debug-ide'
16
+ gem 'debase', '0.2.5.beta2'
17
+ end
18
+
19
+
data/Gemfile.lock ADDED
@@ -0,0 +1,122 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-mars (0.0.12)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (3.0.3)
10
+ activesupport (5.2.6)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ addressable (2.8.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
17
+ algoliasearch (1.27.5)
18
+ httpclient (~> 2.8, >= 2.8.3)
19
+ json (>= 1.5.1)
20
+ atomos (0.1.3)
21
+ claide (1.0.3)
22
+ cocoapods (1.10.2)
23
+ addressable (~> 2.6)
24
+ claide (>= 1.0.2, < 2.0)
25
+ cocoapods-core (= 1.10.2)
26
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
27
+ cocoapods-downloader (>= 1.4.0, < 2.0)
28
+ cocoapods-plugins (>= 1.0.0, < 2.0)
29
+ cocoapods-search (>= 1.0.0, < 2.0)
30
+ cocoapods-trunk (>= 1.4.0, < 2.0)
31
+ cocoapods-try (>= 1.1.0, < 2.0)
32
+ colored2 (~> 3.1)
33
+ escape (~> 0.0.4)
34
+ fourflusher (>= 2.3.0, < 3.0)
35
+ gh_inspector (~> 1.0)
36
+ molinillo (~> 0.6.6)
37
+ nap (~> 1.0)
38
+ ruby-macho (~> 1.4)
39
+ xcodeproj (>= 1.19.0, < 2.0)
40
+ cocoapods-core (1.10.2)
41
+ activesupport (> 5.0, < 6)
42
+ addressable (~> 2.6)
43
+ algoliasearch (~> 1.0)
44
+ concurrent-ruby (~> 1.1)
45
+ fuzzy_match (~> 2.0.4)
46
+ nap (~> 1.0)
47
+ netrc (~> 0.11)
48
+ public_suffix
49
+ typhoeus (~> 1.0)
50
+ cocoapods-deintegrate (1.0.5)
51
+ cocoapods-downloader (1.4.0)
52
+ cocoapods-plugins (1.0.0)
53
+ nap
54
+ cocoapods-search (1.0.1)
55
+ cocoapods-trunk (1.5.0)
56
+ nap (>= 0.8, < 2.0)
57
+ netrc (~> 0.11)
58
+ cocoapods-try (1.2.0)
59
+ colored2 (3.1.2)
60
+ concurrent-ruby (1.1.9)
61
+ debase (0.2.5.beta2)
62
+ debase-ruby_core_source (>= 0.10.12)
63
+ debase-ruby_core_source (0.10.12)
64
+ escape (0.0.4)
65
+ ethon (0.14.0)
66
+ ffi (>= 1.15.0)
67
+ ffi (1.15.3)
68
+ fourflusher (2.3.1)
69
+ fuzzy_match (2.0.4)
70
+ gh_inspector (1.1.3)
71
+ httpclient (2.8.3)
72
+ i18n (1.8.10)
73
+ concurrent-ruby (~> 1.0)
74
+ json (2.5.1)
75
+ json_pure (2.5.1)
76
+ minitest (5.14.4)
77
+ molinillo (0.6.6)
78
+ nanaimo (0.3.0)
79
+ nap (1.1.0)
80
+ netrc (0.11.0)
81
+ open-uri (0.1.0)
82
+ plist (3.6.0)
83
+ public_suffix (4.0.6)
84
+ rake (13.0.6)
85
+ rexml (3.2.5)
86
+ ruby-debug-ide (0.7.2)
87
+ rake (>= 0.8.1)
88
+ ruby-macho (1.4.0)
89
+ rubyzip (2.3.2)
90
+ thread_safe (0.3.6)
91
+ typhoeus (1.4.0)
92
+ ethon (>= 0.9.0)
93
+ tzinfo (1.2.9)
94
+ thread_safe (~> 0.1)
95
+ xcodeproj (1.21.0)
96
+ CFPropertyList (>= 2.3.3, < 4.0)
97
+ atomos (~> 0.1.3)
98
+ claide (>= 1.0.2, < 2.0)
99
+ colored2 (~> 3.1)
100
+ nanaimo (~> 0.3.0)
101
+ rexml (~> 3.2.4)
102
+
103
+ PLATFORMS
104
+ x86_64-darwin-19
105
+
106
+ DEPENDENCIES
107
+ bundler (~> 2.2.15)
108
+ cocoapods
109
+ cocoapods-mars!
110
+ concurrent-ruby
111
+ debase (= 0.2.5.beta2)
112
+ json_pure
113
+ open-uri
114
+ plist (~> 3.2)
115
+ rake
116
+ rexml
117
+ ruby-debug-ide
118
+ rubyzip (>= 1.0.0)
119
+ xcodeproj
120
+
121
+ BUNDLED WITH
122
+ 2.2.15
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 huangbomao@bytedance.com <huangbomao@bytedance.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cocoapods-vemars
2
+
3
+ A description of cocoapods-vemars.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-vemars
8
+
9
+ ## Usage
10
+
11
+ $ pod spec vemars POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-vemars/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-mars'
8
+ spec.version = CocoapodsVemars::VERSION
9
+ spec.authors = ['huangbomao@bytedance.com']
10
+ spec.email = ['huangbomao@bytedance.com']
11
+ spec.description = %q{A short description of cocoapods-mars.}
12
+ spec.summary = %q{A longer description of cocoapods-mars.}
13
+ spec.homepage = 'https://github.com/volcengine/ve_Template_iOS'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 2.2.15'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,52 @@
1
+ module Pod
2
+ class BasicInfo
3
+ attr_reader :app_key
4
+ attr_reader :name
5
+ attr_reader :bundle_id
6
+ attr_reader :version
7
+ attr_reader :string_replacements
8
+
9
+ def initialize(app_key, bundle_id=nil, name=nil, version=nil)
10
+ @app_key = app_key
11
+ @name = name
12
+ @bundle_id = bundle_id
13
+ @version = version
14
+
15
+ prefix = name[0..2].upcase
16
+ @string_replacements = {
17
+ "Bob" => "ByteDance",
18
+ "TODAYS_DATE" => date,
19
+ "TODAYS_YEAR" => year,
20
+ "${USER_NAME}" => user_name,
21
+ "${USER_EMAIL}" => user_email,
22
+ "${YEAR}" => year,
23
+ "${DATE}" => date,
24
+
25
+ "Template" => @name,
26
+ "Template_InHouse" => @name + "_InHouse",
27
+ "${POD_NAME}" => @name,
28
+ "CPD" => prefix,
29
+ "${APPKEY}" => @app_key,
30
+ "${MPAAS_VERSION}" => @version,
31
+ "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}" => @bundle_id
32
+ }
33
+ end
34
+
35
+ def date
36
+ Time.now.strftime "%m/%d/%Y"
37
+ end
38
+
39
+ def year
40
+ Time.now.year.to_s
41
+ end
42
+
43
+ def user_name
44
+ (`git config user.name` || "bytedance" ).strip
45
+ end
46
+
47
+ def user_email
48
+ (`git config user.email` || "bytedance@bytedance.com").strip
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,67 @@
1
+ module Pod
2
+ class Component
3
+ attr_reader :name
4
+ attr_reader :version
5
+ attr_reader :subspecs
6
+
7
+ # def initialize(name, version, subspecs = [])
8
+ # @name = name
9
+ # @version = version
10
+ # @subspecs = subspecs
11
+ # end
12
+
13
+ def initialize(json)
14
+ @name = json["name"]
15
+ @version = json["version"]
16
+ @subspecs = json["subspecs"]
17
+ if @name === "RangersAPM"
18
+ @subspecs = ['Crash',
19
+ 'WatchDog',
20
+ 'OOM',
21
+ 'LAG',
22
+ 'UserException',
23
+ 'Monitors',
24
+ 'UITrackers',
25
+ 'Hybrid',
26
+ 'MemoryGraph',
27
+ 'Network',
28
+ 'EventMonitor',
29
+ 'CN']
30
+ elsif @name == "RangersAppLog"
31
+ @subspecs = [
32
+ 'Core',
33
+ 'Host/CN',
34
+ 'OneKit',
35
+ 'UITracker',
36
+ 'Picker',
37
+ 'Log',
38
+ 'Unique'
39
+ ]
40
+ elsif @name == "VEAppUpdateHelper"
41
+ @subspecs = [
42
+ 'VEUpdateHelper',
43
+ 'VEUpdateView'
44
+ ]
45
+ elsif @name == "OneKit"
46
+ @subspecs = [
47
+ 'BaseKit',
48
+ 'Defaults',
49
+ 'Database',
50
+ 'MARS/Auth',
51
+ 'Reachability',
52
+ 'Service',
53
+ 'StartUp',
54
+ 'Screenshot'
55
+ ]
56
+ end
57
+ end
58
+
59
+ def to_s
60
+ puts "==================================="
61
+ puts "name: #{@name}\nversion: #{@version}\n"
62
+ if !@subspecs.nil? && @subspecs.length > 0
63
+ puts "subspecs: #{@subspecs}\n"
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,205 @@
1
+ require_relative '../services/components_api'
2
+ require_relative '../services/patcher'
3
+ require_relative '../services/tailor'
4
+ require_relative 'basicInfo'
5
+ require_relative '../services/renamer'
6
+ require 'zip'
7
+ require 'open-uri'
8
+ require 'json/pure'
9
+ module Pod
10
+
11
+ class VemarsProject
12
+
13
+ attr_reader :language
14
+ attr_reader :basicInfo
15
+ attr_reader :selected_components
16
+ attr_reader :git_url
17
+ attr_reader :service_url
18
+
19
+ attr_accessor :components_details
20
+ attr_accessor :sources
21
+ attr_accessor :demo_tag
22
+
23
+ def project_folder
24
+ File.join(Dir.pwd, "Project")
25
+ end
26
+
27
+ def initialize(app_key, components, config_json, version=nil, bundle_id=nil, name='', language='objc', git_url, service_url,sources)
28
+ @language = language
29
+ @basicInfo = BasicInfo.new(app_key, bundle_id, name, version)
30
+ @git_url = git_url
31
+ @config_json = config_json
32
+ @selected_components = components | (language == 'swift' ? %w[OneKit SwiftOneKit] : ['OneKit'])
33
+ @components_details = []
34
+ @service_url = service_url
35
+ @sources = sources
36
+ end
37
+
38
+ def generate
39
+ puts "generate project..."
40
+ collect_components
41
+ clone_template_project
42
+ Dir.chdir(basicInfo.name) do
43
+ language_switch
44
+ tailor_demos
45
+ Dir.chdir("Project") do
46
+ construct_podfile
47
+ if !@config_json.nil?
48
+ Dir.chdir("Template_InHouse") do
49
+ construct_plist
50
+ end
51
+ end
52
+ rename_project_files
53
+ # replace_internal_project_settings
54
+ end
55
+ reinitialize_git_repo
56
+ end
57
+ end
58
+
59
+ def patch(podfile_dir)
60
+ puts "patching project..."
61
+ collect_components
62
+ Dir.chdir(podfile_dir) do
63
+ construct_plist
64
+ patcher = Patcher.new(podfile_dir, @basicInfo.version, @components_details, @sources, @git_url, @demo_tag)
65
+ patcher.execute
66
+ end
67
+ end
68
+
69
+ def clone_template_project
70
+ # puts 'cloning template'
71
+ if File.directory?(basicInfo.name) || File.file?(basicInfo.name)
72
+ system("rm -rf #{basicInfo.name}")
73
+ end
74
+ if git_url.end_with?(".git")
75
+ cmd = ""
76
+ if @demo_tag.nil?
77
+ cmd = "git clone #{git_url} #{basicInfo.name}"
78
+ else
79
+ cmd = "git clone #{git_url} #{basicInfo.name} -b #{@demo_tag} --config advice.detachedHead=false"
80
+ end
81
+ system(cmd)
82
+ else
83
+ destination = basicInfo.name
84
+ FileUtils.mkdir_p(destination)
85
+ content = URI.open(git_url)
86
+
87
+ Zip::File.open_buffer(content) do |zip|
88
+ zip.each do |f|
89
+ fname = f.name
90
+ if fname.start_with?("ve_Template_iOS")
91
+ paths = fname.split("/")
92
+ fname = fname.sub(paths[0],"")
93
+ end
94
+ fpath = File.join(destination, fname)
95
+ zip.extract(f, fpath) unless File.exist?(fpath)
96
+ end
97
+ end
98
+
99
+ end
100
+ end
101
+
102
+ def language_switch
103
+ if language == 'swift'
104
+ puts "creating swift project..."
105
+ system("rm -fr objc")
106
+ system("mv swift/* ./")
107
+ system("rm -fr ./swift")
108
+ else
109
+ puts "creating objc project..."
110
+ system("rm -fr ./swift")
111
+ system("mv objc/* ./")
112
+ system("rm -fr objc")
113
+ end
114
+ end
115
+
116
+ def collect_components
117
+ components_api = Components_api.new(@basicInfo.version,@service_url)
118
+ all_components = components_api.getComponents
119
+ @selected_components.each do |com|
120
+ existed_com = all_components.find { |acom|
121
+ acom.name == com
122
+ }
123
+ @components_details.append existed_com unless existed_com.nil?
124
+ end
125
+
126
+ demo_com = all_components.find { |acom|
127
+ acom.name == "ve_Template_iOS"
128
+ }
129
+
130
+ if !demo_com.nil?
131
+ @demo_tag = demo_com.version
132
+ end
133
+
134
+ end
135
+
136
+ def construct_podfile
137
+ template = PodfileTemplate.new(@basicInfo.version, @components_details, @sources)
138
+
139
+ File.open('Podfile', "w") { |file| file.puts template.to_dsl }
140
+ end
141
+
142
+
143
+ def construct_plist
144
+ content = File.read(@config_json)
145
+ json = JSON.parse(content)
146
+ json["project_info"]["app_id"] = json["project_info"]["app_id"].to_s
147
+ services = json["services"]
148
+
149
+ if @selected_components.include?("BDHotfix")
150
+ hotfix = {"host" => "https://plugin-patch-api.bytedance.com"}
151
+ if services.include?("hotfix")
152
+ hotfix = services["hotfix"]
153
+ end
154
+ hotfix["dist_area"] = "cn"
155
+ hotfix["debug"] = true
156
+ services["hotfix"] = hotfix
157
+ end
158
+
159
+ if @selected_components.include?("VEH5Kit")
160
+ h5 = {"gecko_host" => "https://plugin-patch-api.bytedance.com","js_host" => "https://plugin-patch-api.bytedance.com"}
161
+ if services.include?("h5")
162
+ h5 = services["h5"]
163
+ end
164
+ h5["auth_enable"] = false
165
+ h5["pattern"] = ""
166
+ h5["gecko_channels"] = []
167
+ h5["gecko_access_key"] = ""
168
+ services["h5"] = h5
169
+ end
170
+
171
+ json["services"] = services
172
+ File.open(Dir.pwd + "/onekit-config.plist", 'w') { |file|
173
+ file.puts json.to_plist
174
+ }
175
+ end
176
+
177
+ def rename_project_files
178
+ renamer = ProjectRenamer.new("Template", basicInfo.name)
179
+ renamer.execute
180
+ end
181
+
182
+ def tailor_demos
183
+ tailor = DemoTailor.new(@components_details)
184
+ tailor.execute
185
+ end
186
+
187
+ def replace_internal_project_settings
188
+ Dir.glob(Dir.pwd + "/**/**/**/**").each do |name|
189
+ next if Dir.exists? name
190
+ text = File.read(name)
191
+ basicInfo.string_replacements.each { |find, replace|
192
+ text = text.gsub(find, replace)
193
+ }
194
+ File.open(name, "w") { |file| file.puts text }
195
+ end
196
+ end
197
+
198
+
199
+ def reinitialize_git_repo
200
+ `rm -rf .git/`
201
+ `git init`
202
+ end
203
+ end
204
+ end
205
+
@@ -0,0 +1,34 @@
1
+ require_relative '../../services/baselines_api'
2
+
3
+ module Pod
4
+ class Command
5
+ class Vemars
6
+ class Baselines < Vemars
7
+ include Concurrent::Async
8
+
9
+ self.summary = 'Query available baseline versions'
10
+ self.description = <<-DESC
11
+ Query what baseline versions are available in vemars.
12
+ DESC
13
+
14
+ def self.options
15
+ options = [
16
+ ['--service_url=SERVICE_URL', 'url of vemars CLI service.']
17
+ ]
18
+ end
19
+
20
+ def initialize(argv)
21
+ @service_url = argv.option('service_url',nil)
22
+ super
23
+ @additional_args = argv.remainder!
24
+ end
25
+
26
+ def run
27
+ api = Baselines_api.new(@service_url)
28
+ api.getBaselines
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,49 @@
1
+ require_relative '../../services/components_api'
2
+ require_relative '../../hook/podfile_template'
3
+
4
+ module Pod
5
+ class Command
6
+ class Vemars
7
+ class Components < Vemars
8
+
9
+ self.summary = 'Query all available components under certain baseline'
10
+ self.description = <<-DESC
11
+ Query what components are available under certain baseline version, return a list of components with name, version and maybe subspec if any.
12
+ DESC
13
+
14
+ self.arguments = [
15
+ CLAide::Argument.new('BASELINE', false)
16
+ ]
17
+
18
+ def self.options
19
+ options = [
20
+ ['--service_url=SERVICE_URL', 'url of vemars CLI service.']
21
+ ]
22
+ end
23
+
24
+ def initialize(argv)
25
+ baseline = argv.shift_argument
26
+ service_url = argv.option('service_url',nil)
27
+ @api = Components_api.new(baseline,service_url)
28
+ super
29
+ @additional_args = argv.remainder!
30
+ end
31
+
32
+ def validate!
33
+ @api.validate!
34
+ super
35
+ end
36
+
37
+ def run
38
+ components = @api.getComponents().select do |components|
39
+ components.name !~ /ve_Template_$/
40
+ end
41
+ components.each do |component| component.to_s() end
42
+ end
43
+
44
+
45
+ end
46
+ end
47
+ end
48
+ end
49
+