cocoapods-tdf-bin 0.0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +103 -0
  4. data/lib/cocoapods-tdf-bin.rb +2 -0
  5. data/lib/cocoapods-tdf-bin/command.rb +2 -0
  6. data/lib/cocoapods-tdf-bin/command/bin.rb +57 -0
  7. data/lib/cocoapods-tdf-bin/command/bin/archive.rb +222 -0
  8. data/lib/cocoapods-tdf-bin/command/bin/auto.rb +216 -0
  9. data/lib/cocoapods-tdf-bin/command/bin/code.rb +232 -0
  10. data/lib/cocoapods-tdf-bin/command/bin/imy.rb +46 -0
  11. data/lib/cocoapods-tdf-bin/command/bin/init.rb +69 -0
  12. data/lib/cocoapods-tdf-bin/command/bin/initHotKey.rb +70 -0
  13. data/lib/cocoapods-tdf-bin/command/bin/install.rb +44 -0
  14. data/lib/cocoapods-tdf-bin/command/bin/lib/lint.rb +69 -0
  15. data/lib/cocoapods-tdf-bin/command/bin/repo/update.rb +43 -0
  16. data/lib/cocoapods-tdf-bin/command/bin/spec/create.rb +73 -0
  17. data/lib/cocoapods-tdf-bin/command/bin/spec/push.rb +114 -0
  18. data/lib/cocoapods-tdf-bin/command/bin/update.rb +157 -0
  19. data/lib/cocoapods-tdf-bin/config/config.rb +138 -0
  20. data/lib/cocoapods-tdf-bin/config/config_asker.rb +57 -0
  21. data/lib/cocoapods-tdf-bin/config/config_builder.rb +238 -0
  22. data/lib/cocoapods-tdf-bin/config/config_hot_key.rb +103 -0
  23. data/lib/cocoapods-tdf-bin/config/config_hot_key_asker.rb +57 -0
  24. data/lib/cocoapods-tdf-bin/gem_version.rb +10 -0
  25. data/lib/cocoapods-tdf-bin/helpers.rb +5 -0
  26. data/lib/cocoapods-tdf-bin/helpers/Info.plist +0 -0
  27. data/lib/cocoapods-tdf-bin/helpers/build_helper.rb +162 -0
  28. data/lib/cocoapods-tdf-bin/helpers/build_utils.rb +101 -0
  29. data/lib/cocoapods-tdf-bin/helpers/framework.rb +85 -0
  30. data/lib/cocoapods-tdf-bin/helpers/framework_builder.rb +283 -0
  31. data/lib/cocoapods-tdf-bin/helpers/library.rb +54 -0
  32. data/lib/cocoapods-tdf-bin/helpers/library_builder.rb +90 -0
  33. data/lib/cocoapods-tdf-bin/helpers/sources_helper.rb +36 -0
  34. data/lib/cocoapods-tdf-bin/helpers/spec_creator.rb +168 -0
  35. data/lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb +77 -0
  36. data/lib/cocoapods-tdf-bin/helpers/spec_source_creator.rb +228 -0
  37. data/lib/cocoapods-tdf-bin/helpers/upload_helper.rb +89 -0
  38. data/lib/cocoapods-tdf-bin/native.rb +23 -0
  39. data/lib/cocoapods-tdf-bin/native/acknowledgements.rb +27 -0
  40. data/lib/cocoapods-tdf-bin/native/analyzer.rb +55 -0
  41. data/lib/cocoapods-tdf-bin/native/configuration.rb +26 -0
  42. data/lib/cocoapods-tdf-bin/native/file_accessor.rb +28 -0
  43. data/lib/cocoapods-tdf-bin/native/installation_options.rb +25 -0
  44. data/lib/cocoapods-tdf-bin/native/installer.rb +135 -0
  45. data/lib/cocoapods-tdf-bin/native/linter.rb +26 -0
  46. data/lib/cocoapods-tdf-bin/native/path_source.rb +33 -0
  47. data/lib/cocoapods-tdf-bin/native/pod_source_installer.rb +19 -0
  48. data/lib/cocoapods-tdf-bin/native/pod_target_installer.rb +94 -0
  49. data/lib/cocoapods-tdf-bin/native/podfile.rb +91 -0
  50. data/lib/cocoapods-tdf-bin/native/podfile_env.rb +37 -0
  51. data/lib/cocoapods-tdf-bin/native/podfile_generator.rb +199 -0
  52. data/lib/cocoapods-tdf-bin/native/podspec_finder.rb +25 -0
  53. data/lib/cocoapods-tdf-bin/native/resolver.rb +243 -0
  54. data/lib/cocoapods-tdf-bin/native/sandbox_analyzer.rb +34 -0
  55. data/lib/cocoapods-tdf-bin/native/source.rb +35 -0
  56. data/lib/cocoapods-tdf-bin/native/sources_manager.rb +20 -0
  57. data/lib/cocoapods-tdf-bin/native/specification.rb +31 -0
  58. data/lib/cocoapods-tdf-bin/native/target_validator.rb +41 -0
  59. data/lib/cocoapods-tdf-bin/native/validator.rb +40 -0
  60. data/lib/cocoapods-tdf-bin/source_provider_hook.rb +54 -0
  61. data/lib/cocoapods_plugin.rb +3 -0
  62. data/spec/command/bin_spec.rb +12 -0
  63. data/spec/spec_helper.rb +50 -0
  64. metadata +179 -0
@@ -0,0 +1,89 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ require 'cocoapods-tdf-bin/native/podfile'
6
+ require 'cocoapods/command/gen'
7
+ require 'cocoapods/generate'
8
+ require 'cocoapods-tdf-bin/helpers/framework_builder'
9
+ require 'cocoapods-tdf-bin/helpers/library_builder'
10
+ require 'cocoapods-tdf-bin/helpers/sources_helper'
11
+ require 'cocoapods-tdf-bin/command/bin/spec/push'
12
+
13
+ module CBin
14
+ class Upload
15
+ class Helper
16
+ include CBin::SourcesHelper
17
+
18
+ def initialize(spec,code_dependencies,sources)
19
+ @spec = spec
20
+ @code_dependencies = code_dependencies
21
+ @sources = sources
22
+ end
23
+
24
+ def upload
25
+ Dir.chdir(CBin::Config::Builder.instance.root_dir) do
26
+
27
+ # 创建binary-template.podsepc
28
+ # 上传二进制文件
29
+ # 上传二进制 podspec
30
+ res_framework = curl_framework
31
+ if res_framework
32
+ filename = spec_creator
33
+ push_binary_repo(filename)
34
+ end
35
+ res_framework
36
+ end
37
+ end
38
+
39
+ def spec_creator
40
+ spec_creator = CBin::SpecificationSource::Creator.new(@spec)
41
+ spec_creator.create
42
+ spec_creator.write_spec_file
43
+ spec_creator.filename
44
+ end
45
+
46
+ #推送二进制
47
+ # curl http://ci.xxx:9192/frameworks -F "name=IMYFoundation" -F "version=7.7.4.2" -F "annotate=IMYFoundation_7.7.4.2_log" -F "file=@bin-zip/bin_IMYFoundation_7.7.4.2.zip"
48
+ def curl_framework
49
+
50
+ zip_file = "#{CBin::Config::Builder.instance.zip_dir}/#{@spec.name}.framework.zip"
51
+ res = File.exist?(zip_file)
52
+ if res
53
+ command = "curl #{CBin.config.bin_upload_url} -F \"frameworkName=#{@spec.name}\" -F \"version=#{@spec.version}\" -F \"changelog=#{@spec.name}_#{@spec.version}_log\" -F \"framework=@#{zip_file}\""
54
+ print <<EOF
55
+ 上传二进制文件
56
+ #{command}
57
+ EOF
58
+ upload_result = `#{command}`
59
+ puts "#{upload_result}"
60
+ end
61
+
62
+ res
63
+ end
64
+
65
+
66
+ # 上传二进制 podspec
67
+ def push_binary_repo(binary_podsepc_json)
68
+ argvs = [
69
+ "#{binary_podsepc_json}",
70
+ "--binary",
71
+ "--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
72
+ "--skip-import-validation",
73
+ "--use-libraries",
74
+ "--allow-warnings",
75
+ "--verbose",
76
+ "--code-dependencies"
77
+ ]
78
+ if @verbose
79
+ argvs += ['--verbose']
80
+ end
81
+
82
+ push = Pod::Command::Bin::Repo::Push.new(CLAide::ARGV.new(argvs))
83
+ push.validate!
84
+ push.run
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,23 @@
1
+ require 'cocoapods'
2
+
3
+ if Pod.match_version?('~> 1.4')
4
+ require 'cocoapods-tdf-bin/native/podfile'
5
+ require 'cocoapods-tdf-bin/native/installation_options'
6
+ require 'cocoapods-tdf-bin/native/specification'
7
+ require 'cocoapods-tdf-bin/native/path_source'
8
+ require 'cocoapods-tdf-bin/native/analyzer'
9
+ require 'cocoapods-tdf-bin/native/installer'
10
+ require 'cocoapods-tdf-bin/native/podfile_generator'
11
+ require 'cocoapods-tdf-bin/native/pod_source_installer'
12
+ require 'cocoapods-tdf-bin/native/linter'
13
+ require 'cocoapods-tdf-bin/native/resolver'
14
+ require 'cocoapods-tdf-bin/native/source'
15
+ require 'cocoapods-tdf-bin/native/validator'
16
+ require 'cocoapods-tdf-bin/native/acknowledgements'
17
+ require 'cocoapods-tdf-bin/native/sandbox_analyzer'
18
+ require 'cocoapods-tdf-bin/native/podspec_finder'
19
+ require 'cocoapods-tdf-bin/native/file_accessor'
20
+ require 'cocoapods-tdf-bin/native/pod_target_installer'
21
+ require 'cocoapods-tdf-bin/native/target_validator'
22
+
23
+ end
@@ -0,0 +1,27 @@
1
+
2
+
3
+ module Pod
4
+ module Generator
5
+ class Acknowledgements
6
+ def license_text(spec)
7
+ return nil unless spec.license
8
+
9
+ text = spec.license[:text]
10
+ unless text
11
+ if license_file = spec.license[:file]
12
+ license_path = file_accessor(spec).root + license_file
13
+ if File.exist?(license_path)
14
+ text = IO.read(license_path)
15
+ else
16
+ # UI.warn "Unable to read the license file `#{license_file}` " \
17
+ # "for the spec `#{spec}`"
18
+ end
19
+ elsif license_file = file_accessor(spec).license
20
+ text = IO.read(license_file)
21
+ end
22
+ end
23
+ text
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,55 @@
1
+
2
+
3
+ require 'parallel'
4
+ require 'cocoapods'
5
+
6
+ module Pod
7
+ class Installer
8
+ class Analyzer
9
+ # > 1.6.0
10
+ # all_specs[dep.name] 为 nil 会崩溃
11
+ # 主要原因是 all_specs 分析错误
12
+ # 查看 source 是否正确
13
+ #
14
+ # def dependencies_for_specs(specs, platform, all_specs)
15
+ # return [] if specs.empty? || all_specs.empty?
16
+
17
+ # dependent_specs = Set.new
18
+
19
+ # specs.each do |s|
20
+ # s.dependencies(platform).each do |dep|
21
+ # all_specs[dep.name].each do |spec|
22
+ # dependent_specs << spec
23
+ # end
24
+ # end
25
+ # end
26
+
27
+ # dependent_specs - specs
28
+ # end
29
+
30
+ # > 1.5.3 版本
31
+ # rewrite update_repositories
32
+ #
33
+ alias old_update_repositories update_repositories
34
+ def update_repositories
35
+ if installation_options.update_source_with_multi_processes
36
+ # 并发更新私有源
37
+ # 这里多线程会导致 pod update 额外输出 --verbose 的内容
38
+ # 不知道为什么?
39
+ Parallel.each(sources.uniq(&:url), in_processes: 4) do |source|
40
+ if source.git?
41
+ config.sources_manager.update(source.name, true)
42
+ else
43
+ UI.message "Skipping `#{source.name}` update because the repository is not a git source repository."
44
+ end
45
+ end
46
+ @specs_updated = true
47
+ else
48
+ old_update_repositories
49
+ end
50
+ end
51
+
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,26 @@
1
+
2
+ module Pod
3
+ module Generate
4
+ class Configuration
5
+ =begin
6
+ 始终以静态 framework 的方式打包
7
+ =end
8
+ def use_frameworks?
9
+ {:linkage => :static}
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ module Pod
16
+ module Generate
17
+ class PodfileGenerator
18
+ =begin
19
+ 始终以静态 framework 的方式打包
20
+ =end
21
+ def use_frameworks_value
22
+ {:linkage => :static}
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ require 'macho'
2
+ require 'cocoapods'
3
+
4
+ module Pod
5
+ class Sandbox
6
+ class FileAccessor
7
+
8
+ # swift动态库 需要设置为true
9
+ def dynamic_binary?(binary)
10
+ @cached_dynamic_binary_results ||= {}
11
+ return @cached_dynamic_binary_results[binary] unless @cached_dynamic_binary_results[binary].nil?
12
+ return false unless binary.file?
13
+
14
+ @cached_dynamic_binary_results[binary] = MachO.open(binary).dylib?
15
+ rescue MachO::MachOError
16
+ @cached_dynamic_binary_results[binary] = true
17
+
18
+ end
19
+
20
+ # def expanded_paths(patterns, options = {})
21
+ # return [] if patterns.empty?
22
+ # path_list.glob(patterns, options).flatten.compact.uniq
23
+ # end
24
+
25
+ #-----------------------------------------------------------------------#
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+
2
+ require 'cocoapods'
3
+
4
+ module Pod
5
+ class Installer
6
+ class InstallationOptions
7
+ def self.env_option(key, default = true)
8
+ option key, ENV[key.to_s].nil? ? default : ENV[key.to_s] == 'true'
9
+ end
10
+
11
+ # 不同 source 存在相同 spec 名时,默认不警告
12
+ defaults.delete('warn_for_multiple_pod_sources')
13
+ env_option :warn_for_multiple_pod_sources, false
14
+
15
+ # 是否警告不安全 source (如 http )
16
+ env_option :warn_for_unsecure_source, false
17
+
18
+ # 是否多线程执行 install_pod_sources
19
+ env_option :install_with_multi_threads, true
20
+
21
+ # 是否多进程执行 update_repositories
22
+ env_option :update_source_with_multi_processes, true
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,135 @@
1
+ require 'cocoapods/installer/project_cache/target_metadata.rb'
2
+ require 'parallel'
3
+ require 'cocoapods'
4
+ require 'xcodeproj'
5
+ require 'cocoapods-tdf-bin/native/pod_source_installer'
6
+
7
+ module Pod
8
+ class Installer
9
+ alias old_create_pod_installer create_pod_installer
10
+ def create_pod_installer(pod_name)
11
+ installer = old_create_pod_installer(pod_name)
12
+ installer.installation_options = installation_options
13
+ installer
14
+ end
15
+
16
+ alias old_install_pod_sources install_pod_sources
17
+ def install_pod_sources
18
+ if installation_options.install_with_multi_threads
19
+ if Pod.match_version?('~> 1.4.0')
20
+ install_pod_sources_for_version_in_1_4_0
21
+ elsif Pod.match_version?('~> 1.5')
22
+ install_pod_sources_for_version_above_1_5_0
23
+ else
24
+ old_install_pod_sources
25
+ end
26
+ else
27
+ old_install_pod_sources
28
+ end
29
+ end
30
+
31
+ # rewrite install_pod_sources
32
+ def install_pod_sources_for_version_in_1_4_0
33
+ @installed_specs = []
34
+ pods_to_install = sandbox_state.added | sandbox_state.changed
35
+ title_options = { verbose_prefix: '-> '.green }
36
+ Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
37
+ if pods_to_install.include?(spec.name)
38
+ if sandbox_state.changed.include?(spec.name) && sandbox.manifest
39
+ previous = sandbox.manifest.version(spec.name)
40
+ title = "Installing #{spec.name} #{spec.version} (was #{previous})"
41
+ else
42
+ title = "Installing #{spec}"
43
+ end
44
+ UI.titled_section(title.green, title_options) do
45
+ install_source_of_pod(spec.name)
46
+ end
47
+ else
48
+ UI.titled_section("Using #{spec}", title_options) do
49
+ create_pod_installer(spec.name)
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def install_pod_sources_for_version_above_1_5_0
56
+ @installed_specs = []
57
+ pods_to_install = sandbox_state.added | sandbox_state.changed
58
+ title_options = { verbose_prefix: '-> '.green }
59
+ # 多进程下载,多线程时 log 会显著交叉,多进程好点,但是多进程需要利用文件锁对 cache 进行保护
60
+ # in_processes: 10
61
+ Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
62
+ if pods_to_install.include?(spec.name)
63
+ if sandbox_state.changed.include?(spec.name) && sandbox.manifest
64
+ current_version = spec.version
65
+ previous_version = sandbox.manifest.version(spec.name)
66
+ has_changed_version = current_version != previous_version
67
+ current_repo = analysis_result.specs_by_source.detect do |key, values|
68
+ break key if values.map(&:name).include?(spec.name)
69
+ end
70
+ current_repo &&= current_repo.url || current_repo.name
71
+ previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
72
+ has_changed_repo = !previous_spec_repo.nil? && current_repo && (current_repo != previous_spec_repo)
73
+ title = "Installing #{spec.name} #{spec.version}"
74
+ if has_changed_version && has_changed_repo
75
+ title += " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
76
+ end
77
+ if has_changed_version && !has_changed_repo
78
+ title += " (was #{previous_version})"
79
+ end
80
+ if !has_changed_version && has_changed_repo
81
+ title += " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
82
+ end
83
+ else
84
+ title = "Installing #{spec}"
85
+ end
86
+ UI.titled_section(title.green, title_options) do
87
+ install_source_of_pod(spec.name)
88
+ end
89
+ else
90
+ UI.titled_section("Using #{spec}", title_options) do
91
+ create_pod_installer(spec.name)
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ alias old_write_lockfiles write_lockfiles
98
+ def write_lockfiles
99
+ old_write_lockfiles
100
+ if File.exist?('Podfile_local')
101
+
102
+ project = Xcodeproj::Project.open(config.sandbox.project_path)
103
+ #获取主group
104
+ group = project.main_group
105
+ group.set_source_tree('SOURCE_ROOT')
106
+ #向group中添加 文件引用
107
+ file_ref = group.new_reference(config.sandbox.root + '../Podfile_local')
108
+ #podfile_local排序
109
+ podfile_local_group = group.children.last
110
+ group.children.pop
111
+ group.children.unshift(podfile_local_group)
112
+ #保存
113
+ project.save
114
+ end
115
+ end
116
+ end
117
+
118
+ module Downloader
119
+ class Cache
120
+ # 多线程锁
121
+ @@lock = Mutex.new
122
+
123
+ # 后面如果要切到进程的话,可以在 cache root 里面新建一个文件
124
+ # 利用这个文件 lock
125
+ # https://stackoverflow.com/questions/23748648/using-fileflock-as-ruby-global-lock-mutex-for-processes
126
+
127
+ # rmtree 在多进程情况下可能 Directory not empty @ dir_s_rmdir 错误
128
+ # old_ensure_matching_version 会移除不是同一个 CocoaPods 版本的组件缓存
129
+ alias old_ensure_matching_version ensure_matching_version
130
+ def ensure_matching_version
131
+ @@lock.synchronize { old_ensure_matching_version }
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,26 @@
1
+
2
+
3
+ require 'cocoapods-tdf-bin/native/specification'
4
+
5
+ module Pod
6
+ class Specification
7
+ class Linter
8
+ # !@group Lint steps
9
+
10
+ # Checks that the spec's root name matches the filename.
11
+ #
12
+ # @return [void]
13
+ #
14
+ def validate_root_name
15
+ if spec.root.name && file
16
+ acceptable_names = Specification::VALID_EXTNAME.map { |extname| "#{spec.root.name}#{extname}" }
17
+ names_match = acceptable_names.include?(file.basename.to_s)
18
+ unless names_match
19
+ results.add_error('name', 'The name of the spec should match the ' \
20
+ 'name of the file.')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end