cocoapods-mtxx-bin 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df7e5b2628a85abdfb8c632ce10affd45eceef978f17030cc8fa587a55937052
|
4
|
+
data.tar.gz: 8ce6a4a89a75c32075f406d9ec8c929eac12b9b3b63e114f61b37ab56112a576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bb9deccb62a75ca54db13fb02f2b1c43b0a0cd5f945fd18bcfd34858b1a16c35df4d4214f5942dd1480fe9bfae9035687989db60c53e1d000ebc51654749491
|
7
|
+
data.tar.gz: dff8ecc36300ffd1e885d1f968f43276a9c055b24fb8dc791b4d568ac985928e468ae2e46d198d1589bfabf17fc0f390557ee083b3377de10e5a34b08d263de2
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Upload < Bin
|
7
|
+
include Pod
|
8
|
+
|
9
|
+
self.summary = "上传二进制文件及podspec"
|
10
|
+
self.description = <<-DESC
|
11
|
+
#{self.summary}
|
12
|
+
|
13
|
+
`NAME`: 库名【必填】\n
|
14
|
+
`VERSION`: 版本号【必填】\n
|
15
|
+
`FILE`: 需要压缩的二进制文件或目录【必填】\n
|
16
|
+
`REPO`: 上传podspec的仓库,可以通过`pod repo list`查看【必填】\n
|
17
|
+
|
18
|
+
e.g.:\n
|
19
|
+
pod bin upload Pod1 1.0.0 Pod1.framework mtxxspecs --spec=Pod1.podspec
|
20
|
+
DESC
|
21
|
+
|
22
|
+
self.arguments = [
|
23
|
+
CLAide::Argument.new('NAME', true ),
|
24
|
+
CLAide::Argument.new('VERSION', true),
|
25
|
+
CLAide::Argument.new('FILE', true),
|
26
|
+
CLAide::Argument.new('REPO', true)
|
27
|
+
]
|
28
|
+
|
29
|
+
def self.options
|
30
|
+
[
|
31
|
+
%w[--spec=SPEC 指定podspec文件路径,如果不指定,将在当前目录下查找]
|
32
|
+
].concat(super)
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(argv)
|
36
|
+
@name = argv.shift_argument
|
37
|
+
@version = argv.shift_argument
|
38
|
+
@file = argv.shift_argument
|
39
|
+
@repo = argv.shift_argument
|
40
|
+
@spec = argv.option('spec', nil)
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def run
|
45
|
+
# 参数检查
|
46
|
+
argvsCheck
|
47
|
+
# 压缩文件
|
48
|
+
zip_file
|
49
|
+
# 上传文件
|
50
|
+
upload_zip_file
|
51
|
+
# 修改podspec
|
52
|
+
modify_spec
|
53
|
+
# 上传podspec
|
54
|
+
upload_spec
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# 参数检查
|
60
|
+
def argvsCheck
|
61
|
+
raise Informative, "name不能为空" if @name.nil?
|
62
|
+
raise Informative, "version不能为空" if @version.nil?
|
63
|
+
raise Informative, "repo不能为空" if @repo.nil?
|
64
|
+
raise Informative, "未找到需要压缩的二进制文件" if @file.nil?
|
65
|
+
raise Informative, "未找到podspec文件" unless File.exist?(podspec)
|
66
|
+
end
|
67
|
+
|
68
|
+
# 压缩文件
|
69
|
+
def zip_file
|
70
|
+
UI.title "压缩二进制文件`#{zip_file_name}`".yellow do
|
71
|
+
output_zip_file = File.join(Dir.pwd, zip_file_name)
|
72
|
+
FileUtils.rm_f(output_zip_file) if File.exist?(output_zip_file)
|
73
|
+
command = "zip --symlinks -r #{zip_file_name} #{@file}"
|
74
|
+
UI.info "#{command}"
|
75
|
+
`#{command}`
|
76
|
+
raise Informative, "压缩二进制文件失败" unless File.exist?(output_zip_file)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# 压缩后的zip包名
|
81
|
+
def zip_file_name
|
82
|
+
@zip_file_name ||= begin
|
83
|
+
"#{@name}_#{@version}.zip"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# 上传文件
|
88
|
+
def upload_zip_file
|
89
|
+
UI.title "上传二进制文件`#{zip_file_name}`".yellow do
|
90
|
+
zip_file = File.join(Dir.pwd, zip_file_name)
|
91
|
+
raise Informative, "`#{@zip_file_name}`不存在" unless File.exist?(zip_file)
|
92
|
+
upload_url = CBin.config.binary_upload_url_str
|
93
|
+
command = "curl -F \"name=#{@name}\" -F \"version=#{@version}\" -F \"file=@#{zip_file}\" #{upload_url}"
|
94
|
+
UI.info "#{command}"
|
95
|
+
json = `#{command}`
|
96
|
+
UI.info json
|
97
|
+
begin
|
98
|
+
error_code = JSON.parse(json)["error_code"]
|
99
|
+
raise Informative, "`#{zip_file_name}`上传失败" unless error_code == 0
|
100
|
+
UI.info "`#{zip_file_name}`上传成功".green
|
101
|
+
rescue JSON::ParserError => e
|
102
|
+
raise Informative, "`#{zip_file_name}`上传失败\n#{e.to_s}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# 修改podspec
|
108
|
+
def modify_spec
|
109
|
+
UI.title "修改podspec:`#{podspec}`".yellow do
|
110
|
+
spec = Specification.from_file(podspec)
|
111
|
+
spec_hash = spec.to_hash
|
112
|
+
spec_hash['version'] = @version
|
113
|
+
spec_hash['source'] = source
|
114
|
+
spec = Specification.from_hash(spec_hash)
|
115
|
+
write_podspec_json(spec)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# 写入podspec
|
120
|
+
def write_podspec_json(spec)
|
121
|
+
FileUtils.rm_f(podspec_json_file) if File.exist?(podspec_json_file)
|
122
|
+
File.open(podspec_json_file, "w+") do |f|
|
123
|
+
f.write(spec.to_pretty_json)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def source
|
128
|
+
url = "#{CBin.config.binary_download_url_str}/#{@name}/#{@version}/#{zip_file_name}"
|
129
|
+
{ http: url, type: 'zip' }
|
130
|
+
end
|
131
|
+
|
132
|
+
# 上传podspec
|
133
|
+
def upload_spec
|
134
|
+
UI.title "推送podspec:`#{podspec_json_file_name}`".yellow do
|
135
|
+
raise Informative, "`#{podspec_json_file_name}`不存在" unless File.exist?(podspec_json_file)
|
136
|
+
argvs = %W[#{@repo} #{podspec_json_file} --skip-import-validation --use-libraries --allow-warnings --verbose]
|
137
|
+
|
138
|
+
begin
|
139
|
+
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
140
|
+
push.validate!
|
141
|
+
push.run
|
142
|
+
rescue Pod::StandardError => e
|
143
|
+
raise Informative, "推送podspec:`#{podspec_json_file_name}失败\n#{e.to_s}"
|
144
|
+
end
|
145
|
+
# 上传完成后,清理工作目录
|
146
|
+
FileUtils.rm_f(podspec_json_file) if File.exist?(podspec_json_file)
|
147
|
+
FileUtils.rm_r('binary') if File.exist?('binary')
|
148
|
+
FileUtils.rm_f(zip_file_name) if File.exist?(zip_file_name)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def binary_dir
|
153
|
+
File.join(Dir.pwd, 'binary')
|
154
|
+
end
|
155
|
+
|
156
|
+
def podspec_json_file_name
|
157
|
+
"#{@name}.podspec.json"
|
158
|
+
end
|
159
|
+
|
160
|
+
def podspec_json_file
|
161
|
+
File.join(Dir.pwd, podspec_json_file_name)
|
162
|
+
end
|
163
|
+
|
164
|
+
def podspec
|
165
|
+
@spec ||= begin
|
166
|
+
"#{@name}.podspec"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -9,6 +9,7 @@ require 'cocoapods-mtxx-bin/command/bin/install'
|
|
9
9
|
require 'cocoapods-mtxx-bin/command/bin/repo'
|
10
10
|
require 'cocoapods-mtxx-bin/command/bin/spec'
|
11
11
|
require 'cocoapods-mtxx-bin/command/bin/buildAll'
|
12
|
+
require 'cocoapods-mtxx-bin/command/bin/upload'
|
12
13
|
require 'cocoapods-mtxx-bin/helpers'
|
13
14
|
# require 'cocoapods-mtxx-bin/native'
|
14
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-mtxx-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: cocoapods
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.10.2
|
34
|
+
- - "<="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.11.2
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- -
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 1.10.2
|
44
|
+
- - "<="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.11.2
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: cocoapods-generate
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,6 +115,7 @@ files:
|
|
109
115
|
- lib/cocoapods-mtxx-bin/command/bin/spec/create.rb
|
110
116
|
- lib/cocoapods-mtxx-bin/command/bin/spec/lint.rb
|
111
117
|
- lib/cocoapods-mtxx-bin/command/bin/update.rb
|
118
|
+
- lib/cocoapods-mtxx-bin/command/bin/upload.rb
|
112
119
|
- lib/cocoapods-mtxx-bin/config/config.rb
|
113
120
|
- lib/cocoapods-mtxx-bin/config/config_asker.rb
|
114
121
|
- lib/cocoapods-mtxx-bin/config/config_builder.rb
|