cocoapods-nexus 0.0.1 → 0.0.6
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 +4 -4
- data/.github/workflows/main.yml +2 -0
- data/README.md +81 -5
- data/cocoapods-nexus.gemspec +2 -1
- data/lib/cocoapods-nexus/api/components.rb +34 -7
- data/lib/cocoapods-nexus/command/nexus/list.rb +1 -1
- data/lib/cocoapods-nexus/command/nexus/push.rb +10 -5
- data/lib/cocoapods-nexus/downloader.rb +3 -3
- data/lib/cocoapods-nexus/hook/specification.rb +19 -0
- data/lib/cocoapods-nexus/nexus_source.rb +24 -3
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f26e201f54fc7fa7527ced7f39be79211ea312640a2080b1cf9dad3f27d32b8e
|
4
|
+
data.tar.gz: eea1a06b6eb1eb14f80b63961c37d2ed1abfcdc1e83e126a8659cf0e19b76095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 472e4c8da17a58c0f3dc9067a968308727b24f97da71f31da0bd276a1bdc86574bf5a6dcc659cc5122e5125ccd0d0efc2ee665f85f3a1f4f9d691b752964d159
|
7
|
+
data.tar.gz: 525daa7f70e4fe069c0d83ffa6ac68bf20ebaa8bea43c7dd9762d0245a59f0e79d2fff83b29bf950eb07cfdc0e3670520050a7ce97c19751485883e3efe5c0d5
|
data/.github/workflows/main.yml
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,87 @@
|
|
1
1
|
# cocoapods-nexus
|
2
|
+
[](https://badge.fury.io/rb/cocoapods-nexus)
|
2
3
|
|
3
|
-
|
4
|
+
让[CocoaPods](https://cocoapods.org/)支持[Nexus](https://www.sonatype.com/nexus)的插件.
|
4
5
|
|
5
|
-
##
|
6
|
+
## 背景
|
6
7
|
|
7
|
-
|
8
|
+
多数管理podspec都是通过git来维护私有库,而随着项目越来越大,cocoapods安装慢、编译慢也成为了问题。常见的解决方式是提前预编译framework来加速。常见的方案有[cocoapods-binary](https://github.com/leavez/cocoapods-binary)、[Rome](https://github.com/tmspzz/Rome)等工具。
|
8
9
|
|
9
|
-
|
10
|
+
考虑团队现有的环境,感觉都不适合现状,团队以有nexus服务器,考虑是否能复用nexus,因此整理出该插件。通过nexus来管理podspec和预编译framework。
|
10
11
|
|
11
|
-
|
12
|
+
## 安装
|
13
|
+
|
14
|
+
```shell
|
15
|
+
$ gem install cocoapods-nexus
|
16
|
+
```
|
17
|
+
|
18
|
+
## 使用
|
19
|
+
|
20
|
+
### 常用命令
|
21
|
+
|
22
|
+
#### Add
|
23
|
+
|
24
|
+
添加一个nexus的repo,类似**pod repo add**
|
25
|
+
|
26
|
+
```shell
|
27
|
+
$ pod nexus add RepoName NexusHostUrl
|
28
|
+
# 例如:
|
29
|
+
# pod nexus add ios_release http://ip:port
|
30
|
+
```
|
31
|
+
|
32
|
+
#### List
|
33
|
+
|
34
|
+
显示已有nexus的repo,类似**pod repo list**
|
35
|
+
|
36
|
+
```shell
|
37
|
+
$ pod nexus list
|
38
|
+
```
|
39
|
+
|
40
|
+
#### Push
|
41
|
+
|
42
|
+
推送podspec到nexus的repo,类似**pod repo push**。其中artifact为可选参数
|
43
|
+
|
44
|
+
```shell
|
45
|
+
$ pod nexus push path/to/podspec --url=NexusHostUrl --repo=RepoName --artifact=path/to/预编译文件
|
46
|
+
|
47
|
+
# 例如:
|
48
|
+
# pod nexus push ~/demo.podspec --url=http://ip:port --repo=ios_release --artifact=~/demo.zip
|
49
|
+
```
|
50
|
+
|
51
|
+
### Podfile配置
|
52
|
+
|
53
|
+
通过如下代码添加nexus的repo
|
54
|
+
```ruby
|
55
|
+
plugin 'cocoapods-nexus', :sources => [
|
56
|
+
{
|
57
|
+
:name => "ios",
|
58
|
+
:url => "http://ip:port",
|
59
|
+
}
|
60
|
+
]
|
61
|
+
|
62
|
+
# 其中name为repo的name,url为nexus的地址
|
63
|
+
# 添加以上代码后执行pod install,插件会从nexus查询podspec
|
64
|
+
```
|
65
|
+
|
66
|
+
## 注意事项
|
67
|
+
|
68
|
+
### 1.如何鉴权
|
69
|
+
|
70
|
+
考虑到nexus会私有部署、通过[~/.netrc](https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html)文件配置权限
|
71
|
+
|
72
|
+
```shell
|
73
|
+
machine nexusip
|
74
|
+
login nexus_user
|
75
|
+
password nexus_password
|
76
|
+
```
|
77
|
+
|
78
|
+
### 2.服务器地址
|
79
|
+
|
80
|
+
插件关于nexus的相关操作只需要配置ip和port,后续的mount地址默认为nexus,暂时不支持修改。
|
81
|
+
|
82
|
+
## 致谢
|
83
|
+
|
84
|
+
- [cocoapods-art](https://github.com/jfrog/cocoapods-art)
|
85
|
+
- [cocoapods-repo-svn](https://github.com/dustywusty/cocoapods-repo-svn)
|
86
|
+
- [nexus_api](https://github.com/Cisco-AMP/nexus_api)
|
87
|
+
- 等其他
|
data/cocoapods-nexus.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'cocoapods-nexus'
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.6"
|
8
8
|
spec.authors = ['mrdaios']
|
9
9
|
spec.email = ['mrdaios@gmail.com']
|
10
10
|
spec.description = 'a cocoapods plugin for nexus.'
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'cocoapods', '>= 1.9.3'
|
22
22
|
spec.add_runtime_dependency 'rest-client', '~> 2.1.0'
|
23
|
+
spec.add_runtime_dependency 'versionomy', '~> 0.5.0'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
26
|
spec.add_development_dependency 'rake', '~> 13.0'
|
@@ -6,22 +6,49 @@ module CocoapodsNexus
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# 上传组件
|
9
|
-
def upload_maven_component(artifact_id:, version:, group_id:, podspec:, artifact:, files:)
|
9
|
+
def upload_maven_component(artifact_id:, version:, group_id:, podspec:, artifact:, podspec_hook:, files:)
|
10
10
|
parameters = {
|
11
11
|
'maven2.artifactId' => artifact_id,
|
12
12
|
'maven2.version' => version,
|
13
13
|
'maven2.groupId' => group_id,
|
14
14
|
'maven2.generate-pom' => true,
|
15
|
-
'maven2.packaging' => artifact.nil? ? 'podspec' : File.extname(artifact).delete(
|
15
|
+
'maven2.packaging' => artifact.nil? ? 'podspec' : File.extname(artifact).delete('.')
|
16
16
|
}
|
17
17
|
upload_files = []
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
unless podspec.nil?
|
19
|
+
upload_files << {
|
20
|
+
'file' => podspec,
|
21
|
+
'extension' => 'podspec',
|
22
|
+
# 'classifier' => 'podspec'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
unless artifact.nil?
|
26
|
+
upload_files << {
|
27
|
+
'file' => artifact,
|
28
|
+
'extension' => File.extname(artifact).delete('.')
|
29
|
+
}
|
30
|
+
end
|
31
|
+
unless podspec_hook.nil?
|
32
|
+
upload_files << {
|
33
|
+
'file' => podspec_hook,
|
34
|
+
'extension' => 'rb',
|
35
|
+
'classifier' => 'podspec_hook'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
unless files.nil?
|
40
|
+
upload_files |= files.map do |file|
|
41
|
+
{
|
42
|
+
'file' => file,
|
43
|
+
'extension' => File.extname(file).delete('.'),
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
21
47
|
|
22
48
|
upload_files.each_index do |index|
|
23
|
-
parameters["maven2.asset#{index + 1}"] = File.open(upload_files[index], 'r:utf-8')
|
24
|
-
parameters["maven2.asset#{index + 1}.extension"] =
|
49
|
+
parameters["maven2.asset#{index + 1}"] = File.open(upload_files[index]['file'], 'r:utf-8')
|
50
|
+
parameters["maven2.asset#{index + 1}.extension"] = upload_files[index]['extension'] unless upload_files[index]['extension'].nil?
|
51
|
+
parameters["maven2.asset#{index + 1}.classifier"] = upload_files[index]['classifier'] unless upload_files[index]['classifier'].nil?
|
25
52
|
end
|
26
53
|
@connection.post(endpoint: "components?repository=#{@repo}", parameters: parameters, headers: {})
|
27
54
|
end
|
@@ -16,9 +16,10 @@ module Pod
|
|
16
16
|
|
17
17
|
def self.options
|
18
18
|
[
|
19
|
-
[
|
20
|
-
[
|
21
|
-
[
|
19
|
+
%w[--url=url nexus服务器地址(http://ip:port)],
|
20
|
+
%w[--repo=repo nexus的仓库名称],
|
21
|
+
%w[--artifact=artifact 制品文件],
|
22
|
+
%w[--podspec_hook=podspec_hook. podspec动态修改脚本文件]
|
22
23
|
].concat(super)
|
23
24
|
end
|
24
25
|
|
@@ -27,6 +28,7 @@ module Pod
|
|
27
28
|
@url = argv.option('url')
|
28
29
|
@repo = argv.option('repo')
|
29
30
|
@artifact = argv.option('artifact')
|
31
|
+
@podspec_hook = argv.option('podspec_hook')
|
30
32
|
super
|
31
33
|
end
|
32
34
|
|
@@ -40,8 +42,10 @@ module Pod
|
|
40
42
|
def run
|
41
43
|
podspec_path = File.expand_path(@podspec)
|
42
44
|
artifact_path = File.expand_path(@artifact) unless @artifact.nil?
|
45
|
+
podspec_hook_path = File.expand_path(@podspec_hook) unless @podspec_hook.nil?
|
43
46
|
|
44
|
-
|
47
|
+
|
48
|
+
UI.section("开始发布 #{File.basename(@podspec)} -> #{File.join(@url,"/nexus/#browse/browse:",@repo)}") do
|
45
49
|
spec = Specification.from_file(podspec_path)
|
46
50
|
artifact_id = spec.attributes_hash['name']
|
47
51
|
version = spec.attributes_hash['version']
|
@@ -52,7 +56,8 @@ module Pod
|
|
52
56
|
group_id: group_id,
|
53
57
|
podspec: podspec_path,
|
54
58
|
artifact: artifact_path,
|
55
|
-
|
59
|
+
podspec_hook: podspec_hook_path,
|
60
|
+
files: nil)
|
56
61
|
UI.puts "成功发布 #{artifact_id}(#{version})"
|
57
62
|
else
|
58
63
|
raise Informative, "发布失败 #{artifact_id}(#{version}),请检查~/.netrc文件或#{@repo}类型"
|
@@ -12,7 +12,7 @@ module Pod
|
|
12
12
|
executable :curl
|
13
13
|
|
14
14
|
def download!
|
15
|
-
@filename = "#{options[:name]}.#{
|
15
|
+
@filename = "#{options[:name]}.#{options[:type]}"
|
16
16
|
@download_path = @target_path + @filename
|
17
17
|
download_file(@download_path)
|
18
18
|
end
|
@@ -32,8 +32,8 @@ module Pod
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def user_agent_argument
|
35
|
-
"-A
|
35
|
+
"-A cocoapods-nexus"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'cocoapods-core'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Specification
|
5
|
+
class << Specification
|
6
|
+
def _eval_nexus_podspec(nexus_podspec, parent_podspec)
|
7
|
+
podspec_string = nexus_podspec.gsub('Pod::Spec.new', 'Pod::Spec.nexus(parent_podspec)')
|
8
|
+
.gsub('Pod::Specification.new', 'Pod::Spec.nexus(parent_podspec)')
|
9
|
+
# rubocop:disable Eval
|
10
|
+
eval(podspec_string, binding)
|
11
|
+
# rubocop:enable Eval
|
12
|
+
end
|
13
|
+
|
14
|
+
def nexus(parent_podspec)
|
15
|
+
yield parent_podspec if block_given?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'cocoapods-nexus/api'
|
2
2
|
require 'cocoapods-nexus/downloader'
|
3
|
+
require 'versionomy'
|
4
|
+
require 'cocoapods-nexus/hook/specification'
|
3
5
|
|
4
6
|
module Pod
|
5
7
|
class NexusSource < Source
|
@@ -65,7 +67,24 @@ module Pod
|
|
65
67
|
specification.attributes_hash['source'] = {
|
66
68
|
'http' => download_url
|
67
69
|
}
|
68
|
-
|
70
|
+
|
71
|
+
# 执行自定义脚本
|
72
|
+
podspec_rb_url = parse_artifacte_asset_url(artifacte, 'podspec_hook.rb')
|
73
|
+
if podspec_rb_url
|
74
|
+
tmpdir = Dir.tmpdir
|
75
|
+
downloader = Pod::Downloader::NexusHttp.new(tmpdir, podspec_rb_url, {:type => 'rb', :name => name})
|
76
|
+
downloader.download
|
77
|
+
|
78
|
+
path = File.join(tmpdir, "#{name}.rb")
|
79
|
+
if File.exist?(path)
|
80
|
+
string = File.open(path, 'r:utf-8', &:read)
|
81
|
+
if string
|
82
|
+
Pod::Specification._eval_nexus_podspec(string, specification)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
else
|
86
|
+
specification.attributes_hash['vendored_frameworks'] = "#{name}.framework"
|
87
|
+
end
|
69
88
|
end
|
70
89
|
specification
|
71
90
|
end
|
@@ -86,12 +105,14 @@ module Pod
|
|
86
105
|
# 解析附件downloadUrl
|
87
106
|
def parse_artifacte_asset_url(artifacte, asset_type)
|
88
107
|
asset = artifacte['assets'].select { |asset| asset['path'].end_with?(asset_type) }.first
|
89
|
-
asset['downloadUrl']
|
108
|
+
asset['downloadUrl'] if asset && asset['downloadUrl']
|
90
109
|
end
|
91
110
|
|
92
111
|
def nexus_find_artifacte(spec_name:, spec_version:)
|
93
112
|
artifactes = nexus_api.search_maven_component(artifact_id: spec_name)
|
94
|
-
artifacte = artifactes.select { |artifacte| artifacte['version'].start_with?(spec_version) }.sort_by { |artifacte| artifacte['version']
|
113
|
+
# artifacte = artifactes.select { |artifacte| artifacte['version'].start_with?(spec_version) }.sort_by { |artifacte| Versionomy.parse(artifacte['version'])}.last
|
114
|
+
# 暂时只支持查询指定版本
|
115
|
+
artifacte = artifactes.select { |artifacte| artifacte['version'] == spec_version }.last
|
95
116
|
artifacte
|
96
117
|
end
|
97
118
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-nexus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mrdaios
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: versionomy
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.5.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.5.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,7 @@ files:
|
|
94
108
|
- lib/cocoapods-nexus/hook/analyzer.rb
|
95
109
|
- lib/cocoapods-nexus/hook/installer.rb
|
96
110
|
- lib/cocoapods-nexus/hook/manager.rb
|
111
|
+
- lib/cocoapods-nexus/hook/specification.rb
|
97
112
|
- lib/cocoapods-nexus/nexus_source.rb
|
98
113
|
- lib/cocoapods_plugin.rb
|
99
114
|
- spec/command/nexus_spec.rb
|
@@ -102,7 +117,7 @@ homepage: https://github.com/mrdaios/cocoapods-nexus
|
|
102
117
|
licenses:
|
103
118
|
- MIT
|
104
119
|
metadata: {}
|
105
|
-
post_install_message:
|
120
|
+
post_install_message:
|
106
121
|
rdoc_options: []
|
107
122
|
require_paths:
|
108
123
|
- lib
|
@@ -117,8 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
132
|
- !ruby/object:Gem::Version
|
118
133
|
version: '0'
|
119
134
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
121
|
-
signing_key:
|
135
|
+
rubygems_version: 3.1.4
|
136
|
+
signing_key:
|
122
137
|
specification_version: 4
|
123
138
|
summary: 运行时修改spec的source为nexus中的预编译的zip.
|
124
139
|
test_files:
|