cocoapods-archthin 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2fbd2a7d20f98de8b7bcd329f554c819b33930f2e3e15aa1a7f3e2f92525e526
4
+ data.tar.gz: 73d91ba6ec3595af07f736c2b46a5c1882133810b316c5fd8938dd9538bed25d
5
+ SHA512:
6
+ metadata.gz: 479c96020f0b9a09ff8734b1d5a48a28bc1c7412539a201beffa4d53ea9ce26a91ec044842a93b196d3171b471c1e658fcb5e2c10feeccb3dc6e377774996a30
7
+ data.tar.gz: 533bfb01d71e12ac535320ef32fc4e871583146f75c74bc8920cd6cd303cac3711c0c0d4d619e2ebafbbc10a5b77da2d1272716ee0992c1ef8d61c22108d1ae1
@@ -0,0 +1,49 @@
1
+ require 'digest'
2
+ require 'net/http'
3
+
4
+ module ArchThin_util
5
+
6
+ JFROG_API = 'http://jfrog.cloud.qiyi.domain/api/storage/' # api host 用于判断文件是否存在
7
+ JFROG_HOST = 'http://jfrog.cloud.qiyi.domain/' # 下载 host,用于下载 arch 文件
8
+ ARCH_FILE_PATH = 'iqiyi-generic-ios-ci/pods-arch/'
9
+
10
+ def ArchThin_util.has_arch_in_jfrog(arch, url)
11
+ # puts "-> has_arch_in_jfrog arch:#{arch} url:#{url}"
12
+ uri = URI(arch_api_file_url(arch, url))
13
+
14
+ req = Net::HTTP::Get.new(uri)
15
+ # 使用 autobuild4ios 账号的 jfrog apikey,该账号@冀睿哲 管理
16
+ req['X-JFrog-Art-Api'] = "AKCp8krAbJo2xD9fGg8rqSczPtbebaafNTJUHhPJdUXLFXAj6zovX2k6FsYtGk6tsuXXgE6S6"
17
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http|
18
+ http.request(req)
19
+ }
20
+
21
+ msg = res.message
22
+
23
+ if msg == 'OK'
24
+ # puts "找到对应的 #{arch} 架构包"
25
+ return true
26
+ else
27
+ # puts "\n没有找到对应的 #{arch} 架构包,#{url}\n".yellow
28
+ return false
29
+ end
30
+ end
31
+
32
+ def ArchThin_util.arch_file_name(arch, url)
33
+ url_md5 = Digest::MD5.hexdigest url
34
+ file_name = url_md5 + '-'+arch+'.tar.gz'
35
+ return file_name
36
+ end
37
+
38
+ def ArchThin_util.arch_api_file_url(arch, url)
39
+ file_name = arch_file_name(arch, url)
40
+ uri_str = JFROG_API+ARCH_FILE_PATH+file_name
41
+ return uri_str
42
+ end
43
+
44
+ def ArchThin_util.arch_file_url(arch, url)
45
+ file_name = arch_file_name(arch, url)
46
+ uri_str = JFROG_HOST+ARCH_FILE_PATH+file_name
47
+ return uri_str
48
+ end
49
+ end
@@ -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 Archthin < Command
21
+ self.summary = 'Short description of cocoapods-archthin.'
22
+
23
+ self.description = <<-DESC
24
+ Longer description of cocoapods-archthin.
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-archthin plugin in #{__FILE__}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-archthin/command/archthin'
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/ruby
2
+ require 'cocoapods'
3
+ require 'cocoapods-downloader'
4
+ require File.expand_path('../arch_thin_utils', __FILE__)
5
+
6
+
7
+ module Pod
8
+ module Downloader
9
+ # Concreted Downloader class that provides support for specifications with arch
10
+ #
11
+ class Http
12
+ include ArchThin_util
13
+ include Config::Mixin
14
+
15
+ attr_accessor :url
16
+
17
+
18
+ def download_with_arch(full_filename,arch)
19
+ UI.puts "【Arch-thin】下载 #{arch} 架构包"#.green
20
+ debug_log("目标arch: #{arch}")
21
+ debug_log("原始url: #{url}")
22
+
23
+ arch_file_url = ArchThin_util::arch_file_url(arch, url)
24
+ debug_log("arch file: #{arch_file_url}")
25
+ #base_url = url.chomp('.git').chomp('/')
26
+ #ref = options[:commit] || options[:tag] || options[:branch] || 'master'
27
+ #download_url = "#{base_url}/archive/#{ref.to_s}.tar.gz"
28
+
29
+ # parameters = ['-f', '-L', '-o', full_filename, arch_file_url, '--create-dirs', '--netrc-optional', '--retry', '2']
30
+ # parameters << user_agent_argument if headers.nil? ||
31
+ # headers.none? { |header| header.casecmp(USER_AGENT_HEADER).zero? }
32
+
33
+ # headers.each do |h|
34
+ # parameters << '-H'
35
+ # parameters << h
36
+ # end unless headers.nil?
37
+ # curl! parameters
38
+
39
+ @url = arch_file_url
40
+ orig_download(full_filename)
41
+
42
+
43
+ end
44
+
45
+ alias_method :orig_download, :download_file
46
+
47
+ def download_file(full_filename)
48
+ arch = ENV['arch'] ? ENV['arch'] : ENV['ARCH']
49
+ arch = arch.to_s
50
+
51
+
52
+
53
+ if arch.empty?
54
+ orig_download(full_filename)
55
+ else
56
+ arch = arch.downcase
57
+ if arch != 'arm64' && arch != 'armv7' && arch != 'i386' && arch != 'x86_64'
58
+ UI.puts "\narch=#{arch} 设置无效,目前只支持arch=arm64、arch=armv7、arch=x86_64、arch=i386\n".yellow
59
+ orig_download(full_filename)
60
+ # elsif url.include?('jfrog.cloud.qiyi.domain') && !url.end_with?(".zip") && has_arch(arch)
61
+ elsif ArchThin_util::has_arch_in_jfrog(arch, url)
62
+ download_with_arch(full_filename,arch)
63
+ else
64
+ UI.puts "【Arch-thin】没有找到对应 #{arch} 架构包".yellow
65
+ orig_download(full_filename)
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ def debug_log(str)
72
+ if config.verbose?
73
+ puts str
74
+ end
75
+ end
76
+ end
77
+
78
+
79
+ class Git
80
+ include Config::Mixin
81
+
82
+ def download_git_jfrog!(arch, git_file_url)
83
+ UI.puts "【Arch-thin】下载 #{arch} 架构包" #.green
84
+ debug_log("原始git 地址 -> url:#{url}")
85
+ debug_log("options->: #{options}")
86
+ # base_url = url.chomp('.git').chomp('/')
87
+ # ref = options[:commit] || options[:tag] || options[:branch] #|| 'master'
88
+ # download_url = "#{base_url}/archive/#{ref.to_s}.tar.gz"
89
+ # puts "git download -> url:#{url}"
90
+ # puts "ref -> #{ref}"
91
+
92
+ download_url = ArchThin_util::arch_file_url(arch, git_file_url)
93
+ debug_log("arch file: #{download_url}")
94
+ ENV['arch'] = nil
95
+ ENV['ARCH'] = nil
96
+ Http.new(target_path, download_url, {}).download
97
+ ENV['arch'] = arch
98
+ end
99
+
100
+ alias_method :orig_git_download!, :download!
101
+
102
+ def download!
103
+
104
+ # puts "tag-> #{options[:tag]}"
105
+ # puts "name-> #{name}"
106
+ # puts "target_path-> #{target_path}"
107
+
108
+
109
+ ref = options[:commit] || options[:tag] || options[:branch]
110
+
111
+ arch = ENV['arch'] ? ENV['arch'] : ENV['ARCH']
112
+ arch = arch.to_s
113
+
114
+ git_file_url=url+"#{ref}" # jfrog 上存储的名字是 git 地址和ref值拼接一起,取md5值
115
+ debug_log("git_file_key_url: #{git_file_url}")
116
+
117
+ if arch.empty?
118
+ orig_git_download!
119
+ else
120
+ arch = arch.downcase
121
+ if arch != 'arm64' && arch != 'armv7' && arch != 'i386' && arch != 'x86_64'
122
+ UI.puts "\narch=#{arch} 设置无效,目前只支持arch=arm64、arch=armv7、arch=x86_64、arch=i386\n".yellow
123
+ orig_git_download!
124
+ elsif ArchThin_util::has_arch_in_jfrog(arch, git_file_url)
125
+
126
+ # UI.puts "\nGit 转 jfrog 下载\n".green
127
+ debug_log("Git 转 jfrog 下载")
128
+ download_git_jfrog!(arch, git_file_url)
129
+ else
130
+ UI.puts "【Arch-thin】没有找到对应 #{arch} 架构包".yellow
131
+ orig_git_download!
132
+ end
133
+
134
+ end
135
+
136
+ end
137
+
138
+ def debug_log(str)
139
+ if config.verbose?
140
+ puts str
141
+ end
142
+ end
143
+
144
+ end
145
+
146
+
147
+
148
+ end
149
+ end
150
+
@@ -0,0 +1,3 @@
1
+ module CocoapodsArchthin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'cocoapods-archthin/gem_version'
2
+ require 'cocoapods-archthin/downloader_arch'
@@ -0,0 +1,2 @@
1
+ # require 'cocoapods-archthin/command'
2
+ require 'cocoapods-archthin'
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-archthin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Lin Pan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-05 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: A short description of cocoapods-archthin.
42
+ email:
43
+ - linpan@qiyi.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/cocoapods-archthin.rb
49
+ - lib/cocoapods-archthin/arch_thin_utils.rb
50
+ - lib/cocoapods-archthin/command.rb
51
+ - lib/cocoapods-archthin/command/archthin.rb
52
+ - lib/cocoapods-archthin/downloader_arch.rb
53
+ - lib/cocoapods-archthin/gem_version.rb
54
+ - lib/cocoapods_plugin.rb
55
+ homepage: https://github.com/EXAMPLE/cocoapods-archthin
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.0.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: A longer description of cocoapods-archthin.
78
+ test_files: []