cocoapods-tdfire-binary 1.1.0 → 1.2.0

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +16 -16
  5. data/README.md +15 -13
  6. data/Rakefile +4 -0
  7. data/cocoapods-tdfire-binary.gemspec +1 -1
  8. data/example/test/.gitignore +42 -0
  9. data/example/test/.gitlab-ci.yml +101 -0
  10. data/example/test/.travis.yml +14 -0
  11. data/example/test/Example/Podfile +22 -0
  12. data/example/test/Example/Podfile.lock +337 -0
  13. data/example/test/Example/Tests/Tests-Info.plist +22 -0
  14. data/example/test/Example/Tests/Tests-Prefix.pch +7 -0
  15. data/example/test/Example/Tests/Tests.m +35 -0
  16. data/example/test/Example/Tests/en.lproj/InfoPlist.strings +2 -0
  17. data/example/test/Example/test.xcodeproj/project.pbxproj +635 -0
  18. data/example/test/Example/test.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  19. data/example/test/Example/test.xcodeproj/xcshareddata/xcschemes/test-Example.xcscheme +101 -0
  20. data/example/test/Example/test.xcworkspace/contents.xcworkspacedata +10 -0
  21. data/example/test/Example/test.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  22. data/example/test/Example/test/Base.lproj/LaunchScreen.storyboard +31 -0
  23. data/example/test/Example/test/Base.lproj/Main.storyboard +50 -0
  24. data/example/test/Example/test/Images.xcassets/AppIcon.appiconset/Contents.json +98 -0
  25. data/example/test/Example/test/TDFAppDelegate.h +15 -0
  26. data/example/test/Example/test/TDFAppDelegate.m +46 -0
  27. data/example/test/Example/test/TDFViewController.h +13 -0
  28. data/example/test/Example/test/TDFViewController.m +29 -0
  29. data/example/test/Example/test/en.lproj/InfoPlist.strings +2 -0
  30. data/example/test/Example/test/main.m +17 -0
  31. data/example/test/Example/test/test-Info.plist +49 -0
  32. data/example/test/Example/test/test-Prefix.pch +16 -0
  33. data/example/test/LICENSE +19 -0
  34. data/example/test/README.md +29 -0
  35. data/example/test/test.podspec +56 -0
  36. data/example/test/test/Assets/.gitkeep +0 -0
  37. data/example/test/test/Classes/.gitkeep +0 -0
  38. data/example/test/test/Classes/ReplaceMe.m +1 -0
  39. data/lib/cocoapods-tdfire-binary.rb +0 -1
  40. data/lib/cocoapods-tdfire-binary/binary_cache_cleaner.rb +106 -0
  41. data/lib/cocoapods-tdfire-binary/binary_specification_refactor.rb +1 -0
  42. data/lib/cocoapods-tdfire-binary/command/binary.rb +1 -1
  43. data/lib/cocoapods-tdfire-binary/command/publish.rb +2 -0
  44. data/lib/cocoapods-tdfire-binary/gem_version.rb +1 -1
  45. data/lib/cocoapods-tdfire-binary/podfile_hook.rb +0 -1
  46. data/lib/cocoapods-tdfire-binary/specification_dsl.rb +6 -6
  47. data/lib/cocoapods_plugin.rb +1 -0
  48. metadata +36 -4
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleDisplayName</key>
8
+ <string>${PRODUCT_NAME}</string>
9
+ <key>CFBundleExecutable</key>
10
+ <string>${EXECUTABLE_NAME}</string>
11
+ <key>CFBundleIdentifier</key>
12
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13
+ <key>CFBundleInfoDictionaryVersion</key>
14
+ <string>6.0</string>
15
+ <key>CFBundleName</key>
16
+ <string>${PRODUCT_NAME}</string>
17
+ <key>CFBundlePackageType</key>
18
+ <string>APPL</string>
19
+ <key>CFBundleShortVersionString</key>
20
+ <string>1.0</string>
21
+ <key>CFBundleSignature</key>
22
+ <string>????</string>
23
+ <key>CFBundleVersion</key>
24
+ <string>1.0</string>
25
+ <key>LSRequiresIPhoneOS</key>
26
+ <true/>
27
+ <key>UILaunchStoryboardName</key>
28
+ <string>LaunchScreen</string>
29
+ <key>UIMainStoryboardFile</key>
30
+ <string>Main</string>
31
+ <key>UIRequiredDeviceCapabilities</key>
32
+ <array>
33
+ <string>armv7</string>
34
+ </array>
35
+ <key>UISupportedInterfaceOrientations</key>
36
+ <array>
37
+ <string>UIInterfaceOrientationPortrait</string>
38
+ <string>UIInterfaceOrientationLandscapeLeft</string>
39
+ <string>UIInterfaceOrientationLandscapeRight</string>
40
+ </array>
41
+ <key>UISupportedInterfaceOrientations~ipad</key>
42
+ <array>
43
+ <string>UIInterfaceOrientationPortrait</string>
44
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
45
+ <string>UIInterfaceOrientationLandscapeLeft</string>
46
+ <string>UIInterfaceOrientationLandscapeRight</string>
47
+ </array>
48
+ </dict>
49
+ </plist>
@@ -0,0 +1,16 @@
1
+ //
2
+ // Prefix header
3
+ //
4
+ // The contents of this file are implicitly included at the beginning of every source file.
5
+ //
6
+
7
+ #import <Availability.h>
8
+
9
+ #ifndef __IPHONE_5_0
10
+ #warning "This project uses features only available in iOS SDK 5.0 and later."
11
+ #endif
12
+
13
+ #ifdef __OBJC__
14
+ @import UIKit;
15
+ @import Foundation;
16
+ #endif
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 tripleCC <triplec.linux@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # test
2
+
3
+ ![CI Status](http://git.2dfire-inc.com/ios/test/pipelines)
4
+ ![Version](http://git.2dfire-inc.com/ios/cocoapods-spec/tree/master/test)
5
+ [![License](https://img.shields.io/cocoapods/l/test.svg?style=flat)](http://cocoapods.org/pods/test)
6
+ [![Platform](https://img.shields.io/cocoapods/p/test.svg?style=flat)](http://cocoapods.org/pods/test)
7
+
8
+ ## Example
9
+
10
+ To run the example project, clone the repo, and run `pod install` from the Example directory first.
11
+
12
+ ## Requirements
13
+
14
+ ## Installation
15
+
16
+ test is available through [CocoaPods](http://cocoapods.org). To install
17
+ it, simply add the following line to your Podfile:
18
+
19
+ ```ruby
20
+ pod 'test'
21
+ ```
22
+
23
+ ## Author
24
+
25
+ tripleCC, triplec.linux@gmail.com
26
+
27
+ ## License
28
+
29
+ test is available under the MIT license. See the LICENSE file for more info.
@@ -0,0 +1,56 @@
1
+ #
2
+ # Be sure to run `pod lib lint test.podspec' to ensure this is a
3
+ # valid spec before submitting.
4
+ #
5
+ # Any lines starting with a # are optional, but their use is encouraged
6
+ # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
7
+ #
8
+
9
+ Pod::Spec.new do |s|
10
+ s.name = 'test'
11
+ s.version = '0.1.0'
12
+ s.summary = 'A short description of test.'
13
+
14
+ # This description is used to generate tags and improve search results.
15
+ # * Think: What does it do? Why did you write it? What is the focus?
16
+ # * Try to keep it short, snappy and to the point.
17
+ # * Write the description between the DESC delimiters below.
18
+ # * Finally, don't worry about the indent, CocoaPods strips it!
19
+
20
+ s.description = <<-DESC
21
+ TODO: Add long description of the pod here.
22
+ DESC
23
+
24
+ s.homepage = 'http://git.2dfire-inc.com/ios/test'
25
+ s.license = { :type => 'MIT', :file => 'LICENSE' }
26
+ s.author = { 'tripleCC' => 'triplec.linux@gmail.com' }
27
+ s.source = { :git => 'http://git.2dfire-inc.com/ios/test.git', :tag => s.version.to_s }
28
+ s.ios.deployment_target = '8.0'
29
+
30
+ tdfire_source_configurator = lambda do |s|
31
+ # 源码依赖配置
32
+ s.source_files = 'test/Classes/**/*'
33
+ s.public_header_files = 'test/Classes/**/*.{h}'
34
+ # s.private_header_files =
35
+
36
+ # 资源依赖必须使用 bundle
37
+ # s.resource_bundles = {
38
+ # 'test' => ['test/Assets/*']
39
+ # }
40
+
41
+ # s.dependency 'TDFModuleKit'
42
+ end
43
+
44
+ unless %w[tdfire_set_binary_download_configurations tdfire_source tdfire_binary].reduce(true) { |r, m| s.respond_to?(m) & r }
45
+ tdfire_source_configurator.call s
46
+ else
47
+ s.tdfire_source tdfire_source_configurator
48
+ s.tdfire_binary tdfire_source_configurator
49
+
50
+ #s.tdfire_binary tdfire_source_configurator do |s|
51
+ # 额外配置 (一般不用)
52
+ #end
53
+
54
+ s.tdfire_set_binary_download_configurations
55
+ end
56
+ end
File without changes
File without changes
@@ -0,0 +1 @@
1
+ 故意写的,让 Xcode 报错,创建自己的文件后,记得删除 ReplaceMe.m
@@ -4,4 +4,3 @@ require 'cocoapods'
4
4
  require 'cocoapods-tdfire-binary/podfile_dsl'
5
5
  require 'cocoapods-tdfire-binary/specification_dsl'
6
6
 
7
-
@@ -0,0 +1,106 @@
1
+ require 'fileutils'
2
+ require 'colored2'
3
+ require 'cocoapods-tdfire-binary/specification_dsl'
4
+ require 'cocoapods-tdfire-binary/binary_url_manager'
5
+
6
+ module Pod
7
+ class Installer
8
+ old_resolve_dependencies = instance_method(:resolve_dependencies)
9
+ define_method(:resolve_dependencies) do
10
+ old_resolve_dependencies.bind(self).call()
11
+
12
+ cleaner = Pod::Tdfire::BinaryCacheCleaner.new(analysis_result)
13
+ cleaner.clean!
14
+
15
+ # 二进制不存在,强制进行源码依赖
16
+ if cleaner.no_binary_specs.any?
17
+ pods = cleaner.no_binary_specs.map { |s| s.root.name }
18
+ Pod::Tdfire::BinaryStateStore.use_source_pods += pods
19
+ UI.warn "Tdfire: 以下组件没有二进制版本,将强制使用源码依赖,添加以下代码至Podfile规避此警告: tdfire_use_source_pods #{pods}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ module Pod
26
+ module Tdfire
27
+ class BinaryCacheCleaner
28
+ attr_reader :use_binary_specs
29
+
30
+ def initialize(analysis_result)
31
+ @analysis_result = analysis_result
32
+ @use_binary_specs = analysis_result.specifications.uniq { |s| s.root.name }.reject(&:tdfire_use_source?)
33
+ end
34
+
35
+ def clean!
36
+ # 判断有效组件的 cache 中是否有二进制,没有的话,删除组件缓存
37
+ specs = use_binary_specs - no_binary_specs
38
+ specs.each do |s|
39
+ # 处理 cache
40
+ clean_pod_cache(s)
41
+
42
+ # 处理 Pods
43
+ clean_local_cache(s)
44
+ end
45
+ end
46
+
47
+ def no_binary_specs
48
+ @invalid_specs ||= begin
49
+ use_binary_specs.reject do |s|
50
+ json_string = Pod::Tdfire::BinaryUrlManager.search_binary(s.root.name)
51
+ pod = JSON.parse(json_string, object_class: OpenStruct)
52
+ versions = pod.versions || []
53
+ versions.include?(s.version.to_s)
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def cache_descriptors
61
+ @cache_descriptors ||= begin
62
+ cache = Downloader::Cache.new(Config.instance.cache_root + 'Pods')
63
+ cache_descriptors = cache.cache_descriptors_per_pod
64
+ end
65
+ end
66
+
67
+ def clean_local_cache(spec)
68
+ pod_dir = Config.instance.sandbox.pod_dir(spec.root.name)
69
+ framework_file = pod_dir + "#{spec.root.name}.framework"
70
+ if pod_dir.exist? && !framework_file.exist?
71
+ UI.message "Tdfire: 删除缺少二进制的组件 #{spec.root.name}".yellow
72
+
73
+ # 设置沙盒变动标记,去 cache 中拿
74
+ # 只有 :changed 、:added 两种状态才会重新去 cache 中拿
75
+ @analysis_result.sandbox_state.add_name(spec.name, :changed)
76
+ begin
77
+ FileUtils.rm_rf(pod_dir)
78
+ rescue
79
+ end
80
+ end
81
+ end
82
+
83
+ def clean_pod_cache(spec)
84
+ descriptors = cache_descriptors[spec.root.name]
85
+ return if descriptors.nil?
86
+
87
+ descriptors = descriptors.select { |d| d[:version] == spec.version}
88
+ descriptors.each do |d|
89
+ # pod cache 文件名由文件内容的 sha1 组成,由于生成时使用的是 podspec,获取时使用的是 podspec.json
90
+ # 导致生成的文件名不一致
91
+ # Downloader::Request slug
92
+ slug = d[:slug].dirname + "#{spec.version}-#{spec.checksum[0, 5]}"
93
+ framework_file = slug + "#{spec.root.name}.framework"
94
+ unless (framework_file.exist?)
95
+ UI.message "Tdfire: 删除缺少二进制的Cache #{spec.root.name}".magenta
96
+ begin
97
+ FileUtils.rm(descriptor[:spec_file])
98
+ FileUtils.rm_rf(descriptor[:slug])
99
+ rescue
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
@@ -1,3 +1,4 @@
1
+
1
2
  require 'cocoapods-tdfire-binary/binary_url_manager'
2
3
  require 'cocoapods-tdfire-binary/binary_state_store'
3
4
 
@@ -21,7 +21,7 @@ module Pod
21
21
  DESC
22
22
 
23
23
  def binary_config
24
- Tdfire::BinaryConfig.instance
24
+ Pod::Tdfire::BinaryConfig.instance
25
25
  end
26
26
 
27
27
  def first_podspec
@@ -48,6 +48,8 @@ module Pod
48
48
  push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
49
49
  push.validate!
50
50
  push.run
51
+
52
+ raise Pod::StandardError, "执行 pod repo push 失败,错误信息 #{$?}" if $?.exitstatus != 0
51
53
  end
52
54
  end
53
55
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsTdfireBinary
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  require 'cocoapods-tdfire-binary/binary_state_store'
2
- require 'cocoapods-tdfire-binary/source_chain_analyzer'
3
2
 
4
3
  module CocoapodsTdfireBinary
5
4
  Pod::HooksManager.register('cocoapods-tdfire-binary', :pre_install) do |context, _|
@@ -70,12 +70,6 @@ module Pod
70
70
  end
71
71
  end
72
72
 
73
- private
74
-
75
- def tdfire_reference_spec
76
- @tdfire_reference_spec || self
77
- end
78
-
79
73
  def tdfire_use_source?
80
74
  ((!Pod::Tdfire::BinaryStateStore.force_use_binary? &&
81
75
  (!Pod::Tdfire::BinaryStateStore.use_binary? || Pod::Tdfire::BinaryStateStore.real_use_source_pods.include?(root.name))) ||
@@ -83,6 +77,12 @@ module Pod
83
77
  (Pod::Tdfire::BinaryStateStore.lib_lint_binary_pod != root.name)
84
78
  end
85
79
 
80
+ private
81
+
82
+ def tdfire_reference_spec
83
+ @tdfire_reference_spec || self
84
+ end
85
+
86
86
  def tdfire_should_skip_download?
87
87
  (!Pod::Tdfire::BinaryStateStore.force_use_binary? && Pod::Tdfire::BinaryStateStore.unpublished_pods.include?(root.name)) ||
88
88
  (Pod::Tdfire::BinaryStateStore.lib_lint_binary_pod == root.name)
@@ -1,4 +1,5 @@
1
1
  require 'cocoapods-tdfire-binary/podfile_dsl'
2
2
  require 'cocoapods-tdfire-binary/specification_dsl'
3
+ require 'cocoapods-tdfire-binary/binary_cache_cleaner'
3
4
  require 'cocoapods-tdfire-binary/podfile_hook'
4
5
  require 'cocoapods-tdfire-binary/command'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-tdfire-binary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tripleCC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-05 00:00:00.000000000 Z
11
+ date: 2018-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.2'
47
+ version: 1.2.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.2'
54
+ version: 1.2.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cocoapods-packager
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -83,7 +83,39 @@ files:
83
83
  - README.md
84
84
  - Rakefile
85
85
  - cocoapods-tdfire-binary.gemspec
86
+ - example/test/.gitignore
87
+ - example/test/.gitlab-ci.yml
88
+ - example/test/.travis.yml
89
+ - example/test/Example/Podfile
90
+ - example/test/Example/Podfile.lock
91
+ - example/test/Example/Tests/Tests-Info.plist
92
+ - example/test/Example/Tests/Tests-Prefix.pch
93
+ - example/test/Example/Tests/Tests.m
94
+ - example/test/Example/Tests/en.lproj/InfoPlist.strings
95
+ - example/test/Example/test.xcodeproj/project.pbxproj
96
+ - example/test/Example/test.xcodeproj/project.xcworkspace/contents.xcworkspacedata
97
+ - example/test/Example/test.xcodeproj/xcshareddata/xcschemes/test-Example.xcscheme
98
+ - example/test/Example/test.xcworkspace/contents.xcworkspacedata
99
+ - example/test/Example/test.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
100
+ - example/test/Example/test/Base.lproj/LaunchScreen.storyboard
101
+ - example/test/Example/test/Base.lproj/Main.storyboard
102
+ - example/test/Example/test/Images.xcassets/AppIcon.appiconset/Contents.json
103
+ - example/test/Example/test/TDFAppDelegate.h
104
+ - example/test/Example/test/TDFAppDelegate.m
105
+ - example/test/Example/test/TDFViewController.h
106
+ - example/test/Example/test/TDFViewController.m
107
+ - example/test/Example/test/en.lproj/InfoPlist.strings
108
+ - example/test/Example/test/main.m
109
+ - example/test/Example/test/test-Info.plist
110
+ - example/test/Example/test/test-Prefix.pch
111
+ - example/test/LICENSE
112
+ - example/test/README.md
113
+ - example/test/test.podspec
114
+ - example/test/test/Assets/.gitkeep
115
+ - example/test/test/Classes/.gitkeep
116
+ - example/test/test/Classes/ReplaceMe.m
86
117
  - lib/cocoapods-tdfire-binary.rb
118
+ - lib/cocoapods-tdfire-binary/binary_cache_cleaner.rb
87
119
  - lib/cocoapods-tdfire-binary/binary_config.rb
88
120
  - lib/cocoapods-tdfire-binary/binary_specification_refactor.rb
89
121
  - lib/cocoapods-tdfire-binary/binary_state_store.rb