cocoapods-pdk8 0.0.1

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: 2ea7db40c9f2d655a7336d0354f8e572cbacef7960b923662b77d7db2b327809
4
+ data.tar.gz: 195f947b1cc60e9174529026724b1bce3e51b04310453214280d1b75baa44e2d
5
+ SHA512:
6
+ metadata.gz: ed765e6538361a5a4db903ad719ae9b920329c095ac10174918dc591b909f55adb984cc102c729d41d3f0789a9b3fb86d7059ba51386a9d4d2b8fc2c758852e3
7
+ data.tar.gz: 7d2f678ca798100aa6f7659c356ee637f9a8b54aee3e3f64e549d9fdff4d58824dc81939b8f0cc71ace3b552557f28259f9564faab6ba74dc1cbdada4b6d0f28
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-pdk8.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 戴易超 <daiyichao@corp.netease.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,58 @@
1
+ # cocoapods-pdk8
2
+ > 因为精力有限,目前只兼容了`cocoapods 1.10.0`,如有其他版本的需求,可以提`issue`给我,在时间允许的情况下我会兼容的
3
+ `pdk8`的取名来自于保时捷`pdk`8速变速箱,也是我这边的期望,我们这个小工具可以让`pod install/update`的速度可以跟保时捷的跑车一样快。
4
+
5
+ ## Feature
6
+ - 减少文件IO和优化获取算法
7
+ - 多线程加载`Pods`
8
+ ## Installation
9
+
10
+ $ gem install cocoapods-pdk8
11
+
12
+ ## Usage
13
+
14
+ `Podfile`里面如果有的多个`source`,如果定义`force`,会优先匹配`force`的源
15
+ ```
16
+ force_source 'source2'
17
+ source 'source1'
18
+ ```
19
+
20
+ 然后就按照普通的`pod install/update`即可,就可以享受到加速,命令行看到`pkd8 enable`即享受到了加速
21
+ ```
22
+ pdk8 enable
23
+ Analyzing dependencies
24
+ Downloading dependencies
25
+ finish xxx cost: 0s
26
+ finish xxx cost: 0s
27
+ finish xxx cost: 0s
28
+ finish xxx cost: 0s
29
+ finish xxx cost: 0s
30
+ finish xxx cost: 0s
31
+ finish xxx cost: 0s
32
+ finish xxx cost: 0s
33
+ finish xxx cost: 0s
34
+ Generating Pods project
35
+ Integrating client project
36
+ Pod installation complete! There is 1 dependency from the Podfile and 14 total pods installed.
37
+ - total: 1s
38
+ -- prepare: 0s
39
+ -- resolve_dependencies: 0s
40
+ --- run_source_provider_hooks: 0s
41
+ --- create_analyzer: 0s
42
+ --- analyze: 1s
43
+ -- download_dependencies: 0s
44
+ --- install_pod_sources: 0s
45
+ --- run_podfile_pre_install_hooks: 0s
46
+ --- clean_pod_sources: 0s
47
+ -- validate_targets: 0s
48
+ -- integrate: 0s
49
+ --- generate_pods_project: 0s
50
+ --- integrate_user_project: 0s
51
+ -- write_lockfiles: 0s
52
+ -- perform_post_install_actions: 0s
53
+ ```
54
+ 不想享受加速直接卸载即可
55
+
56
+ ```
57
+ gem uninstall cocoapods-pdk8
58
+ ```
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-pdk8/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-pdk8'
8
+ spec.version = CocoapodsPdk8::VERSION
9
+ spec.authors = ['戴易超']
10
+ spec.email = ['804054226@qq.com']
11
+ spec.description = %q{pod install/update 加速}
12
+ spec.summary = %q{pod install/update 加速,详情请看readme}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-pdk8'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
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', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-pdk8/gem_version'
@@ -0,0 +1 @@
1
+ #require 'cocoapods-pdk8/command/pdk8'
@@ -0,0 +1,44 @@
1
+ module Pod
2
+ class Command
3
+ # This is an example of a cocoapods plugin adding a top-level subcommand
4
+ # to the 'pod' command.
5
+ #
6
+ # You can also create subcommands of existing or new commands. Say you
7
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
8
+ # (e.g. `pod list deprecated`), there are a few things that would need
9
+ # to change.
10
+ #
11
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
12
+ # the class to exist in the the Pod::Command::List namespace
13
+ # - change this class to extend from `List` instead of `Command`. This
14
+ # tells the plugin system that it is a subcommand of `list`.
15
+ # - edit `lib/cocoapods_plugins.rb` to require this file
16
+ #
17
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
18
+ # in the `plugins.json` file, once your plugin is released.
19
+ #
20
+ class Pdk8 < Command
21
+ self.summary = 'Short description of cocoapods-pdk8.'
22
+
23
+ self.description = <<-DESC
24
+ Longer description of cocoapods-pdk8.
25
+ DESC
26
+
27
+ self.arguments = 'NAME'
28
+
29
+ def initialize(argv)
30
+ @name = argv.shift_argument
31
+ super
32
+ end
33
+
34
+ def validate!
35
+ super
36
+ help! 'A Pod name is required.' unless @name
37
+ end
38
+
39
+ def run
40
+ UI.puts "Add your implementation for the cocoapods-pdk8 plugin in #{__FILE__}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsPdk8
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,9 @@
1
+ puts "pdk8 enable".yellow
2
+ require 'cocoapods-pdk8/hook/podfile'
3
+ require 'cocoapods-pdk8/hook/requirement'
4
+ require 'cocoapods-pdk8/hook/resolver'
5
+ require 'cocoapods-pdk8/hook/download'
6
+ require 'cocoapods-pdk8/hook/installer'
7
+ require 'cocoapods-pdk8/hook/analyzer'
8
+ require 'cocoapods-pdk8/hook/specification'
9
+ require 'cocoapods-pdk8/hook/sandbox'
@@ -0,0 +1,25 @@
1
+
2
+ module Pod
3
+ class Installer
4
+ # Analyzes the Podfile, the Lockfile, and the sandbox manifest to generate
5
+ # the information relative to a CocoaPods installation.
6
+ #
7
+ class Analyzer
8
+ alias origin_update_repositories update_repositories
9
+ def update_repositories
10
+ threads = []
11
+ sources.each do |source|
12
+ threads << Thread.new {
13
+ if source.updateable?
14
+ sources_manager.update(source.name, true)
15
+ else
16
+ UI.message "Skipping `#{source.name}` update because the repository is not an updateable repository."
17
+ end
18
+ }
19
+ end
20
+ threads.each {|thr| thr.join}
21
+ @specs_updated = true
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module Pod
2
+ module Downloader
3
+ # The class responsible for managing Pod downloads, transparently caching
4
+ # them in a cache directory.
5
+ #
6
+ class Cache
7
+ include SourceConfig::Mixin
8
+ def ensure_matching_version
9
+ version_file = root + 'VERSION'
10
+
11
+ source_config.mutex_for_downloader.synchronize {
12
+ version = version_file.read.strip if version_file.file?
13
+ root.rmtree if version != Pod::VERSION && root.exist?
14
+ root.mkpath
15
+
16
+ version_file.open('w') { |f| f << Pod::VERSION }
17
+ }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,300 @@
1
+ require 'thread'
2
+ require 'cocoapods-pdk8/hook/installer/pod_source_installer'
3
+
4
+ module Pod
5
+ class Installer
6
+ include SourceConfig::Mixin
7
+ attr_accessor :mutex
8
+ def install_pod_sources
9
+ @mutex = source_config.mutex_for_downloader
10
+ @installed_specs = []
11
+ pods_to_install = sandbox_state.added | sandbox_state.changed
12
+
13
+ download_queue = Queue.new
14
+ root_specs.sort_by(&:name).each do |spec|
15
+ download_queue.push spec
16
+ end
17
+
18
+ threads = []
19
+ (1..12).each do |thread_index|
20
+ threads << Thread.new {
21
+ while not download_queue.empty?
22
+ spec = download_queue.pop(true)
23
+ last_time = Time.new.to_i
24
+ if pods_to_install.include? spec.name
25
+ pods_to_install_include_download spec,thread_index
26
+ else
27
+ pods_to_install_exclude_download spec,thread_index
28
+ end
29
+ puts "finish #{spec.name} cost: #{Time.new.to_i - last_time}s".green
30
+ end
31
+ }
32
+ end
33
+ threads.map(&:join)
34
+ end
35
+
36
+ def title_options
37
+ { :verbose_prefix => '-> '.green }
38
+ end
39
+
40
+ def pods_to_install_include_download spec,thread_index
41
+ title = ""
42
+ if sandbox_state.changed.include?(spec.name) && sandbox.manifest
43
+ title = pods_to_install_include_changed_title spec
44
+ else
45
+ title = pods_to_install_include_added_title spec
46
+ end
47
+ UI.titled_section("#{thread_index}:#{title}".green, title_options) do
48
+ install_source_of_pod(spec.name)
49
+ end
50
+ end
51
+
52
+ def pods_to_install_include_changed_title spec
53
+ current_version = spec.version
54
+ previous_version = sandbox.manifest.version(spec.name)
55
+ has_changed_version = current_version != previous_version
56
+ current_repo = analysis_result.specs_by_source.detect { |key, values| break key if values.map(&:name).include?(spec.name) }
57
+ current_repo &&= (Pod::TrunkSource::TRUNK_REPO_NAME if current_repo.name == Pod::TrunkSource::TRUNK_REPO_NAME) || current_repo.url || current_repo.name
58
+ previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
59
+ has_changed_repo = !previous_spec_repo.nil? && current_repo && !current_repo.casecmp(previous_spec_repo).zero?
60
+ title = "Installing #{spec.name} #{spec.version}"
61
+ title << " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if has_changed_version && has_changed_repo
62
+ title << " (was #{previous_version})" if has_changed_version && !has_changed_repo
63
+ title << " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if !has_changed_version && has_changed_repo
64
+ title
65
+ end
66
+
67
+ def pods_to_install_include_added_title spec
68
+ title = "Installing #{spec}"
69
+ end
70
+
71
+ def pods_to_install_exclude_download spec,thread_index
72
+ UI.section("#{thread_index}:Using #{spec}", title_options[:verbose_prefix]) do
73
+ create_pod_installer(spec.name)
74
+ end
75
+ end
76
+
77
+ def create_pod_installer(pod_name)
78
+ specs_by_platform = specs_for_pod(pod_name)
79
+
80
+ if specs_by_platform.empty?
81
+ requiring_targets = pod_targets.select { |pt| pt.recursive_dependent_targets.any? { |dt| dt.pod_name == pod_name } }
82
+ message = "Could not install '#{pod_name}' pod"
83
+ message += ", dependended upon by #{requiring_targets.to_sentence}" unless requiring_targets.empty?
84
+ message += '. There is either no platform to build for, or no target to build.'
85
+ raise StandardError, message
86
+ end
87
+
88
+ pod_installer = PodSourceInstaller.new(sandbox, podfile, specs_by_platform, :can_cache => installation_options.clean?)
89
+ @mutex.synchronize {
90
+ pod_installers << pod_installer
91
+ }
92
+ pod_installer
93
+ end
94
+
95
+ def install_source_of_pod(pod_name)
96
+ pod_installer = create_pod_installer(pod_name)
97
+ pod_installer.install!
98
+ @mutex.synchronize {
99
+ @installed_specs.concat(pod_installer.specs_by_platform.values.flatten.uniq)
100
+ }
101
+ end
102
+
103
+ include TimeProfiler::Mixin
104
+ alias origin_prepare prepare
105
+
106
+ def prepare
107
+ time_profiler.add_milestone_start time_profiler.stage_prepare, time_profiler.default_step
108
+ origin_prepare
109
+ time_profiler.add_milestone_stop time_profiler.stage_prepare, time_profiler.default_step
110
+ end
111
+
112
+ alias origin_run_source_provider_hooks run_source_provider_hooks
113
+ def run_source_provider_hooks
114
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, "run_source_provider_hooks"
115
+ result=origin_run_source_provider_hooks
116
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, "run_source_provider_hooks"
117
+ result
118
+ end
119
+
120
+ alias origin_create_analyzer create_analyzer
121
+ def create_analyzer(plugin_sources)
122
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, "create_analyzer"
123
+ result=origin_create_analyzer(plugin_sources)
124
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, "create_analyzer"
125
+ result
126
+ end
127
+
128
+ class Analyzer
129
+ alias origin_update_repositories update_repositories
130
+ def update_repositories
131
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, "update_repositories"
132
+ result=origin_update_repositories
133
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, "update_repositories"
134
+ result
135
+ end
136
+ end
137
+
138
+ alias origin_analyze analyze
139
+ def analyze(analyzer)
140
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, "analyze"
141
+ result=origin_analyze(analyzer)
142
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, "analyze"
143
+ result
144
+ end
145
+
146
+ alias origin_validate_build_configurations validate_build_configurations
147
+ def validate_build_configurations
148
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, time_profiler.default_step
149
+ result=origin_validate_build_configurations
150
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, time_profiler.default_step
151
+ result
152
+ end
153
+
154
+ alias origin_verify_no_podfile_changes! verify_no_podfile_changes!
155
+ def verify_no_podfile_changes!
156
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, "verify_no_podfile_changes!"
157
+ result=origin_verify_no_podfile_changes!
158
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, "verify_no_podfile_changes!"
159
+ result
160
+ end
161
+
162
+ alias origin_verify_no_lockfile_changes! verify_no_lockfile_changes!
163
+ def verify_no_lockfile_changes!
164
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, "verify_no_lockfile_changes!"
165
+ result=origin_verify_no_lockfile_changes!
166
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, "verify_no_lockfile_changes!"
167
+ result
168
+ end
169
+
170
+ alias origin_resolve_dependencies resolve_dependencies
171
+ def resolve_dependencies
172
+ time_profiler.add_milestone_start time_profiler.stage_resolve_dependencies, time_profiler.default_step
173
+
174
+ plugin_sources = run_source_provider_hooks
175
+ analyzer = create_analyzer(plugin_sources)
176
+
177
+ UI.section 'Updating local specs repositories' do
178
+ analyzer.update_repositories
179
+ end if repo_update?
180
+
181
+ UI.section 'Analyzing dependencies' do
182
+ analyze(analyzer)
183
+ validate_build_configurations
184
+ end
185
+
186
+ UI.section 'Verifying no changes' do
187
+ verify_no_podfile_changes!
188
+ verify_no_lockfile_changes!
189
+ end if deployment?
190
+
191
+ time_profiler.add_milestone_stop time_profiler.stage_resolve_dependencies, time_profiler.default_step
192
+
193
+ analyzer
194
+ end
195
+
196
+ alias origin_install_pod_sources install_pod_sources
197
+ def install_pod_sources
198
+ time_profiler.add_milestone_start time_profiler.stage_download_dependencies, "install_pod_sources"
199
+ result=origin_install_pod_sources
200
+ time_profiler.add_milestone_stop time_profiler.stage_download_dependencies, "install_pod_sources"
201
+ result
202
+ end
203
+
204
+ alias origin_run_podfile_pre_install_hooks run_podfile_pre_install_hooks
205
+ def run_podfile_pre_install_hooks
206
+ time_profiler.add_milestone_start time_profiler.stage_download_dependencies, "run_podfile_pre_install_hooks"
207
+ result=origin_run_podfile_pre_install_hooks
208
+ time_profiler.add_milestone_stop time_profiler.stage_download_dependencies, "run_podfile_pre_install_hooks"
209
+ result
210
+ end
211
+
212
+ alias origin_clean_pod_sources clean_pod_sources
213
+ def clean_pod_sources
214
+ time_profiler.add_milestone_start time_profiler.stage_download_dependencies, "clean_pod_sources"
215
+ result=origin_clean_pod_sources
216
+ time_profiler.add_milestone_stop time_profiler.stage_download_dependencies, "clean_pod_sources"
217
+ result
218
+ end
219
+
220
+ alias origin_download_dependencies download_dependencies
221
+ def download_dependencies
222
+ time_profiler.add_milestone_start time_profiler.stage_download_dependencies, time_profiler.default_step
223
+ UI.section 'Downloading dependencies' do
224
+ install_pod_sources
225
+ run_podfile_pre_install_hooks
226
+ clean_pod_sources
227
+ end
228
+ time_profiler.add_milestone_stop time_profiler.stage_download_dependencies, time_profiler.default_step
229
+ end
230
+
231
+ alias origin_validate_targets validate_targets
232
+ def validate_targets
233
+ time_profiler.add_milestone_start time_profiler.stage_validate_targets, time_profiler.default_step
234
+ result=origin_validate_targets
235
+ result
236
+ time_profiler.add_milestone_stop time_profiler.stage_validate_targets, time_profiler.default_step
237
+ end
238
+
239
+ alias origin_show_skip_pods_project_generation_message show_skip_pods_project_generation_message
240
+ def show_skip_pods_project_generation_message
241
+ time_profiler.add_milestone_start time_profiler.stage_show_skip_pods_project_generation_message, time_profiler.default_step
242
+ result=origin_show_skip_pods_project_generation_message
243
+ time_profiler.add_milestone_stop time_profiler.stage_show_skip_pods_project_generation_message, time_profiler.default_step
244
+ result
245
+ end
246
+
247
+ alias origin_generate_pods_project generate_pods_project
248
+ def generate_pods_project
249
+ time_profiler.add_milestone_start time_profiler.stage_integrate, "generate_pods_project"
250
+ result=origin_generate_pods_project
251
+ time_profiler.add_milestone_stop time_profiler.stage_integrate, "generate_pods_project"
252
+ result
253
+ end
254
+
255
+ alias origin_integrate_user_project integrate_user_project
256
+ def integrate_user_project
257
+ time_profiler.add_milestone_start time_profiler.stage_integrate, "integrate_user_project"
258
+ result=origin_integrate_user_project
259
+ time_profiler.add_milestone_stop time_profiler.stage_integrate, "integrate_user_project"
260
+ result
261
+ end
262
+
263
+ alias origin_integrate integrate
264
+ def integrate
265
+ time_profiler.add_milestone_start time_profiler.stage_integrate, time_profiler.default_step
266
+ generate_pods_project
267
+ if installation_options.integrate_targets?
268
+ integrate_user_project
269
+ else
270
+ UI.section 'Skipping User Project Integration'
271
+ end
272
+ time_profiler.add_milestone_stop time_profiler.stage_integrate, time_profiler.default_step
273
+ end
274
+
275
+ alias origin_write_lockfiles write_lockfiles
276
+ def write_lockfiles
277
+ time_profiler.add_milestone_start time_profiler.stage_write_lockfiles, time_profiler.default_step
278
+ result=origin_write_lockfiles
279
+ time_profiler.add_milestone_stop time_profiler.stage_write_lockfiles, time_profiler.default_step
280
+ result
281
+ end
282
+
283
+ alias origin_run_plugins_post_install_hooks run_plugins_post_install_hooks
284
+ def run_plugins_post_install_hooks
285
+ time_profiler.add_milestone_start time_profiler.stage_perform_post_install_actions, time_profiler.default_step
286
+ result=origin_run_plugins_post_install_hooks
287
+ time_profiler.add_milestone_stop time_profiler.stage_perform_post_install_actions, time_profiler.default_step
288
+ result
289
+ end
290
+
291
+ alias :origin_install! :install!
292
+ def install!
293
+ time_profiler.add_milestone_start time_profiler.total_stage, time_profiler.default_step
294
+ rs = origin_install!
295
+ time_profiler.add_milestone_stop time_profiler.total_stage, time_profiler.default_step
296
+ puts time_profiler.format_prints.join("\n")
297
+ rs
298
+ end
299
+ end
300
+ end
@@ -0,0 +1,29 @@
1
+ module Pod
2
+ class Installer
3
+ # Controller class responsible of installing the activated specifications
4
+ # of a single Pod.
5
+ #
6
+ # @note This class needs to consider all the activated specs of a Pod.
7
+ #
8
+ class PodSourceInstaller
9
+ def download_source
10
+ if root_spec.source[:git] =~ /http/
11
+ source = root_spec.attributes_hash["source"]
12
+ # 替换
13
+ if source["git"].include? "https://g.hz.netease.com"
14
+ source["git"]["https://g.hz.netease.com"] = "ssh://git@g.hz.netease.com:22222"
15
+ end
16
+
17
+ if source["git"].include? "http://g.hz.netease.com"
18
+ source["git"]["http://g.hz.netease.com"] = "ssh://git@g.hz.netease.com:22222"
19
+ end
20
+ end
21
+ download_result = Downloader.download(download_request, root, :can_cache => can_cache?)
22
+
23
+ if (specific_source = download_result.checkout_options) && specific_source != root_spec.source
24
+ sandbox.store_checkout_source(root_spec.name, specific_source)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ module Pod
2
+ class Podfile
3
+ module DSL
4
+ include SourceConfig::Mixin
5
+
6
+ def force_source url
7
+ SourceConfig.instance.add_force_source url
8
+ source url
9
+ end
10
+
11
+ def speed_up_enable enable
12
+ SourceConfig.instance.speed_up_enable enable
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module Pod
2
+ # A Requirement is a set of one or more version restrictions of a
3
+ # {Dependency}.
4
+ #
5
+ # It is based on the RubyGems class adapted to support CocoaPods specific
6
+ # information.
7
+ #
8
+ # @todo Move support about external sources and head information here from
9
+ # the Dependency class.
10
+ #
11
+ class Requirement < Pod::Vendor::Gem::Requirement
12
+ # module Pod::Specification::Set - all_specifications[requirement]
13
+ # 如上所示,当requirement做为key的时候,实际上只需要requirements的内容是一样既可以认为是一样的,而不需要整个Requirement的对象一样
14
+ def eql? other
15
+ @requirements.eql? other.requirements
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-pdk8/hook/specification/set/lazy_specification'
@@ -0,0 +1 @@
1
+ require 'cocoapods-pdk8/hook/sandbox/path_list.rb'
@@ -0,0 +1,43 @@
1
+ module Pod
2
+ class Sandbox
3
+ # The PathList class is designed to perform multiple glob matches against
4
+ # a given directory. Basically, it generates a list of all the children
5
+ # paths and matches the globs patterns against them, resulting in just one
6
+ # access to the file system.
7
+ #
8
+ # @note A PathList once it has generated the list of the paths this is
9
+ # updated only if explicitly requested by calling
10
+ # {#read_file_system}
11
+ #
12
+ class PathList
13
+ def read_file_system
14
+
15
+ unless root.exist?
16
+ puts caller
17
+ raise Informative, "Attempt to read non existent folder `#{root}`."
18
+ end
19
+ dirs = []
20
+ files = []
21
+ root_length = root.cleanpath.to_s.length + File::SEPARATOR.length
22
+ escaped_root = escape_path_for_glob(root)
23
+ Dir.glob(escaped_root + '**/*', File::FNM_DOTMATCH).each do |f|
24
+ directory = File.directory?(f)
25
+ # Ignore `.` and `..` directories
26
+ next if directory && f =~ /\.\.?$/
27
+
28
+ f = f.slice(root_length, f.length - root_length)
29
+ next if f.nil?
30
+
31
+ (directory ? dirs : files) << f
32
+ end
33
+
34
+ dirs.sort_by!(&:upcase)
35
+ files.sort_by!(&:upcase)
36
+
37
+ @dirs = dirs
38
+ @files = files
39
+ @glob_cache = {}
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,57 @@
1
+ require 'cocoapods-pdk8/hook/specification/set'
2
+ module Pod
3
+ # The Specification provides a DSL to describe a Pod. A pod is defined as a
4
+ # library originating from a source. A specification can support detailed
5
+ # attributes for modules of code through subspecs.
6
+ #
7
+ # Usually it is stored in files with `podspec` extension.
8
+ #
9
+ $SPECIFICATION_HASH_CACHE = Hash.new
10
+ class Specification
11
+ def self.from_file(path, subspec_name = nil)
12
+ path = Pathname.new(path)
13
+ unless path.exist?
14
+ raise Informative, "No podspec exists at path `#{path}`."
15
+ end
16
+ return $SPECIFICATION_HASH_CACHE[path.expand_path] if $SPECIFICATION_HASH_CACHE[path.expand_path]
17
+
18
+ string = File.open(path, 'r:utf-8', &:read)
19
+ # Work around for Rubinius incomplete encoding in 1.9 mode
20
+ if string.respond_to?(:encoding) && string.encoding.name != 'UTF-8'
21
+ string.encode!('UTF-8')
22
+ end
23
+ specification = from_string(string, path, subspec_name)
24
+ $SPECIFICATION_HASH_CACHE[path.expand_path] = specification
25
+ return specification
26
+ end
27
+
28
+ $SPECIFICATION_FROM_STRING_HASH_CACHE = Hash.new
29
+
30
+ def self.from_string(spec_contents, path, subspec_name = nil)
31
+ path = Pathname.new(path).expand_path
32
+
33
+ key = "#{path}"
34
+ return $SPECIFICATION_FROM_STRING_HASH_CACHE[key] if $SPECIFICATION_FROM_STRING_HASH_CACHE[key]
35
+
36
+ spec = nil
37
+ case path.extname
38
+ when '.podspec'
39
+ Dir.chdir(path.parent.directory? ? path.parent : Dir.pwd) do
40
+ spec = ::Pod._eval_podspec(spec_contents, path)
41
+ unless spec.is_a?(Specification)
42
+ raise Informative, "Invalid podspec file at path `#{path}`."
43
+ end
44
+ end
45
+ when '.json'
46
+ spec = Specification.from_json(spec_contents)
47
+ else
48
+ raise Informative, "Unsupported specification format `#{path.extname}` for spec at `#{path}`."
49
+ end
50
+
51
+ spec.defined_in_file = path
52
+ spec.subspec_by_name(subspec_name, true)
53
+ $SPECIFICATION_FROM_STRING_HASH_CACHE[key] = spec
54
+ spec
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,33 @@
1
+ module Pod
2
+ class Specification
3
+ class Set
4
+ include SourceConfig::Mixin
5
+ alias origin_specification_name specification_name
6
+ def specification_name
7
+ ## 这里可能存在的风险,但是目前可以再是不关心
8
+ name
9
+ end
10
+
11
+ alias origin_versions_by_source versions_by_source
12
+ def versions_by_source
13
+ @fix_versions_by_source ||= begin
14
+ force_sources = []
15
+ vers_b_source = origin_versions_by_source
16
+ vers_b_source.keys.each do |key|
17
+ if source_config.force_sources.include? key.url
18
+ force_sources << key
19
+ end
20
+ end
21
+ result = {}
22
+ vers_b_source.each do |key, value|
23
+ result[key] = value
24
+ force_sources.each do |src|
25
+ result[key] = result[key] - vers_b_source[src] unless source_config.force_sources.include? key.url
26
+ end
27
+ end
28
+ result
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,56 @@
1
+ require 'cocoapods/resolver/lazy_specification'
2
+
3
+ # module Pod
4
+ # class Specification
5
+ # class Set
6
+ # include SourceConfig::Mixin
7
+
8
+ # # returns the highest versioned spec last
9
+ # # alias all_specifications_fix all_specifications
10
+ # def aall_specifications(warn_for_multiple_pod_sources, requirement)
11
+ # @all_specifications ||= {}
12
+ # @all_specifications[requirement] ||= begin
13
+ # sources_by_version = {}
14
+ # source_hash = {}
15
+ # versions_by_source.each do |source, versions|
16
+ # source_hash[source.url] ||= source
17
+ # versions.each do |v|
18
+ # next unless requirement.satisfied_by?(v)
19
+ # (sources_by_version[v] ||= []) << source
20
+ # if source_config.enable?
21
+ # if source_config.force_sources.include? source.url
22
+ # sources_by_version[v] = [source]
23
+ # else
24
+ # sources_by_version[v].each do |s|
25
+ # if source_config.force_sources.include? s.url
26
+ # sources_by_version[v] = [source]
27
+ # end
28
+ # end
29
+ # end
30
+ # end
31
+ # end
32
+ # end
33
+
34
+
35
+ # if warn_for_multiple_pod_sources
36
+ # duplicate_versions = sources_by_version.select { |_version, sources| sources.count > 1 }
37
+
38
+ # duplicate_versions.each do |version, sources|
39
+ # UI.warn "Found multiple specifications for `#{name} (#{version})`:\n" +
40
+ # sources.
41
+ # map { |s| s.specification_path(name, version) }.
42
+ # map { |v| "- #{v}" }.join("\n")
43
+ # end
44
+ # end
45
+
46
+ # # sort versions from high to low
47
+ # sources_by_version.sort_by(&:first).flat_map do |version, sources|
48
+ # # within each version, we want the prefered (first-specified) source
49
+ # # to be the _last_ one
50
+ # sources.reverse_each.map { |source| LazySpecification.new(name, version, source) }
51
+ # end
52
+ # end
53
+ # end
54
+ # end
55
+ # end
56
+ # end
@@ -0,0 +1,47 @@
1
+ module Pod
2
+ class SourceConfig
3
+
4
+ attr_accessor :force_xx_sources
5
+ def force_sources
6
+ @force_xx_sources ||= []
7
+ end
8
+
9
+ def add_force_source source
10
+ raise "Donot try add a nil source to force sources" if source.nil?
11
+ @force_xx_sources ||= []
12
+ @force_xx_sources << source
13
+ end
14
+
15
+ def enable?
16
+ !force_sources.empty?
17
+ end
18
+
19
+ attr_accessor :speed_up_enable
20
+
21
+ def speed_up_enable?
22
+ @speed_up_enable
23
+ end
24
+
25
+ def speed_up_enable enable
26
+ @speed_up_enable = enable
27
+ end
28
+
29
+ attr_accessor :mutex_for_downloader
30
+ def mutex_for_downloader
31
+ @mutex_for_downloader ||= Mutex.new
32
+ end
33
+
34
+ class << self
35
+ attr_writer :instance
36
+ def instance
37
+ @instance ||= new
38
+ end
39
+ end
40
+
41
+ module Mixin
42
+ def source_config
43
+ SourceConfig.instance
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,150 @@
1
+ module Pod
2
+ class TimeProfiler
3
+ #
4
+ # Hash {
5
+ # stage:{
6
+ # :start => Date,
7
+ # step => {
8
+ # :start
9
+ # :end
10
+ # }
11
+ # }
12
+ # }
13
+ attr_accessor :time_line
14
+ def add_milestone_start stage, step
15
+ @time_line ||= Hash.new
16
+ @time_line[stage] ||= begin
17
+ rs = Hash.new
18
+ rs
19
+ end
20
+ @time_line[stage][step] = {
21
+ :start => Time.new.getutc.to_i
22
+ }
23
+ end
24
+
25
+ def add_milestone_stop stage, step
26
+ raise "timeline is not start" unless @time_line
27
+ raise "stage #{stage} is not start" unless @time_line[stage]
28
+ raise "step #{step} is not start" unless @time_line[stage][step]
29
+ @time_line[stage][step][:stop] = Time.new.getutc.to_i
30
+ end
31
+ # - total: 1s
32
+ # -- prepare: 0s
33
+ # -- resolve_dependencies: 0s
34
+ # --- run_source_provider_hooks: 0s
35
+ # --- create_analyzer: 0s
36
+ # --- analyze: 1s
37
+ # -- download_dependencies: 0s
38
+ # --- install_pod_sources: 0s
39
+ # --- run_podfile_pre_install_hooks: 0s
40
+ # --- clean_pod_sources: 0s
41
+ # -- validate_targets: 0s
42
+ # -- integrate: 0s
43
+ # --- generate_pods_project: 0s
44
+ # --- integrate_user_project: 0s
45
+ # -- write_lockfiles: 0s
46
+ # -- perform_post_install_actions: 0s
47
+ def format_prints
48
+ result = []
49
+ total_line = @time_line[total_stage]
50
+ if total_line
51
+ result << "- total: #{total_line[default_step][:stop] - total_line[default_step][:start]}s".yellow
52
+ end
53
+ stages.each do |stage|
54
+ stage_line = @time_line[stage]
55
+ if stage_line
56
+ stage_cost = stage_line[default_step][:stop] - stage_line[default_step][:start]
57
+ result << "-- #{stage}: #{stage_cost}s".yellow
58
+ stage_line.each do |step, values|
59
+ if step != default_step
60
+ result << "--- #{step}: #{values[:stop] - values[:start]}s"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ result
66
+ end
67
+
68
+ def format
69
+ result = Hash.new
70
+ total_line = @time_line[total_stage]
71
+ if total_line
72
+ result["total"] = total_line[default_step][:stop] - total_line[default_step][:start]
73
+ end
74
+ stages.each do |stage|
75
+ stage_line = @time_line[stage]
76
+ if stage_line
77
+ stage_cost = stage_line[default_step][:stop] - stage_line[default_step][:start]
78
+ result[stage] = stage_cost
79
+ end
80
+ end
81
+ result
82
+ end
83
+
84
+ def total_stage
85
+ "total_stage"
86
+ end
87
+
88
+ def default_step
89
+ "default_step"
90
+ end
91
+
92
+ def stages
93
+ [
94
+ stage_prepare,
95
+ stage_resolve_dependencies,
96
+ stage_download_dependencies,
97
+ stage_validate_targets,
98
+ stage_show_skip_pods_project_generation_message,
99
+ stage_integrate,
100
+ stage_write_lockfiles,
101
+ stage_perform_post_install_actions
102
+ ]
103
+ end
104
+
105
+ def stage_prepare
106
+ "prepare"
107
+ end
108
+
109
+ def stage_resolve_dependencies
110
+ "resolve_dependencies"
111
+ end
112
+
113
+ def stage_download_dependencies
114
+ "download_dependencies"
115
+ end
116
+
117
+ def stage_validate_targets
118
+ "validate_targets"
119
+ end
120
+
121
+ def stage_show_skip_pods_project_generation_message
122
+ "show_skip_pods_project_generation_message"
123
+ end
124
+
125
+ def stage_integrate
126
+ "integrate"
127
+ end
128
+
129
+ def stage_write_lockfiles
130
+ "write_lockfiles"
131
+ end
132
+
133
+ def stage_perform_post_install_actions
134
+ "perform_post_install_actions"
135
+ end
136
+
137
+ class << self
138
+ attr_writer :instance
139
+ def instance
140
+ @instance ||= new
141
+ end
142
+ end
143
+
144
+ module Mixin
145
+ def time_profiler
146
+ return TimeProfiler.instance
147
+ end
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,5 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods-pdk8/source_config'
3
+ require 'cocoapods-pdk8/time_profiler'
4
+ require 'cocoapods-pdk8/hook'
5
+ require 'cocoapods-pdk8/command'
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Pdk8 do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ pdk8 }).should.be.instance_of Command::Pdk8
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-pdk8
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - 戴易超
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: pod install/update 加速
42
+ email:
43
+ - 804054226@qq.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - cocoapods-pdk8.gemspec
54
+ - lib/cocoapods-pdk8.rb
55
+ - lib/cocoapods-pdk8/command.rb
56
+ - lib/cocoapods-pdk8/command/pdk8.rb
57
+ - lib/cocoapods-pdk8/gem_version.rb
58
+ - lib/cocoapods-pdk8/hook.rb
59
+ - lib/cocoapods-pdk8/hook/analyzer.rb
60
+ - lib/cocoapods-pdk8/hook/download.rb
61
+ - lib/cocoapods-pdk8/hook/installer.rb
62
+ - lib/cocoapods-pdk8/hook/installer/pod_source_installer.rb
63
+ - lib/cocoapods-pdk8/hook/podfile.rb
64
+ - lib/cocoapods-pdk8/hook/requirement.rb
65
+ - lib/cocoapods-pdk8/hook/resolver.rb
66
+ - lib/cocoapods-pdk8/hook/sandbox.rb
67
+ - lib/cocoapods-pdk8/hook/sandbox/path_list.rb
68
+ - lib/cocoapods-pdk8/hook/specification.rb
69
+ - lib/cocoapods-pdk8/hook/specification/set.rb
70
+ - lib/cocoapods-pdk8/hook/specification/set/lazy_specification.rb
71
+ - lib/cocoapods-pdk8/source_config.rb
72
+ - lib/cocoapods-pdk8/time_profiler.rb
73
+ - lib/cocoapods_plugin.rb
74
+ - spec/command/pdk8_spec.rb
75
+ - spec/spec_helper.rb
76
+ homepage: https://github.com/EXAMPLE/cocoapods-pdk8
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubygems_version: 3.0.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: pod install/update 加速,详情请看readme
99
+ test_files:
100
+ - spec/command/pdk8_spec.rb
101
+ - spec/spec_helper.rb