cocoapods-nexus 0.0.5 → 0.0.6

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: 8330342a1bfb924159fd14f64c815a82244bb3d127ea04fca63c221cbc48c06b
4
- data.tar.gz: 83dadc37dd09a79bcc5fa428dec201b5626949eba412dbbf4c62fefc18c53d8c
3
+ metadata.gz: f26e201f54fc7fa7527ced7f39be79211ea312640a2080b1cf9dad3f27d32b8e
4
+ data.tar.gz: eea1a06b6eb1eb14f80b63961c37d2ed1abfcdc1e83e126a8659cf0e19b76095
5
5
  SHA512:
6
- metadata.gz: c9ebc809664b18f2a02d5d05df55933e5e5e0d8056ef4efd5bc442549a1b3cc981de187df08c6a7654feaea3b15527249c9c959b27c6e9dd32e088743201fec6
7
- data.tar.gz: ac82c558f92e9faf3797f0b70c156113816061423936f90d47004b9d77ef761d5adb9ddd2828e77d18aa69867768a8b21d8b7209660f5362ac27adfbb2337c31
6
+ metadata.gz: 472e4c8da17a58c0f3dc9067a968308727b24f97da71f31da0bd276a1bdc86574bf5a6dcc659cc5122e5125ccd0d0efc2ee665f85f3a1f4f9d691b752964d159
7
+ data.tar.gz: 525daa7f70e4fe069c0d83ffa6ac68bf20ebaa8bea43c7dd9762d0245a59f0e79d2fff83b29bf950eb07cfdc0e3670520050a7ce97c19751485883e3efe5c0d5
data/README.md CHANGED
@@ -26,7 +26,7 @@ $ gem install cocoapods-nexus
26
26
  ```shell
27
27
  $ pod nexus add RepoName NexusHostUrl
28
28
  # 例如:
29
- # pod nexus add ios_release http://ip:host
29
+ # pod nexus add ios_release http://ip:port
30
30
  ```
31
31
 
32
32
  #### List
@@ -45,7 +45,7 @@ $ pod nexus list
45
45
  $ pod nexus push path/to/podspec --url=NexusHostUrl --repo=RepoName --artifact=path/to/预编译文件
46
46
 
47
47
  # 例如:
48
- # pod nexus push ~/demo.podspec --url=http://ip:host --repo=ios_release --artifact=~/demo.zip
48
+ # pod nexus push ~/demo.podspec --url=http://ip:port --repo=ios_release --artifact=~/demo.zip
49
49
  ```
50
50
 
51
51
  ### Podfile配置
@@ -55,7 +55,7 @@ $ pod nexus push path/to/podspec --url=NexusHostUrl --repo=RepoName --artifact=p
55
55
  plugin 'cocoapods-nexus', :sources => [
56
56
  {
57
57
  :name => "ios",
58
- :url => "http://ip:host",
58
+ :url => "http://ip:port",
59
59
  }
60
60
  ]
61
61
 
@@ -77,7 +77,7 @@ password nexus_password
77
77
 
78
78
  ### 2.服务器地址
79
79
 
80
- 插件关于nexus的相关操作只需要配置ip和host,后续的mount地址默认为nexus,暂时不支持修改。
80
+ 插件关于nexus的相关操作只需要配置ip和port,后续的mount地址默认为nexus,暂时不支持修改。
81
81
 
82
82
  ## 致谢
83
83
 
@@ -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.5"
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.'
@@ -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
- upload_files << podspec unless podspec.nil?
19
- upload_files << artifact unless artifact.nil?
20
- upload_files | files unless files.nil?
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"] = File.extname(upload_files[index]).delete(".")
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
- ['--url=url', 'a nexus hostname'],
20
- ['--repo=repo', 'a nexus repo'],
21
- ['--artifact=artifact', 'a nexus artifact']
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
- UI.section("开始发布 #{File.basename(@podspec)} -> #{@url}/nexus/#browse/browse:#{@repo}") do
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
- files: [])
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]}.#{'podspec'.to_sym}"
15
+ @filename = "#{options[:name]}.#{options[:type]}"
16
16
  @download_path = @target_path + @filename
17
17
  download_file(@download_path)
18
18
  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,6 +1,7 @@
1
1
  require 'cocoapods-nexus/api'
2
2
  require 'cocoapods-nexus/downloader'
3
3
  require 'versionomy'
4
+ require 'cocoapods-nexus/hook/specification'
4
5
 
5
6
  module Pod
6
7
  class NexusSource < Source
@@ -39,7 +40,7 @@ module Pod
39
40
  # 暂时这样处理
40
41
  spec_version = query.requirement.requirements.last.last.to_s
41
42
  artifacte = nexus_find_artifacte(spec_name: query.root_name, spec_version: spec_version)
42
- unless artifacte.empty?
43
+ if artifacte
43
44
  download_url = parse_artifacte_asset_url(artifacte, 'podspec')
44
45
  if download_url
45
46
  target_path = "#{@repo}/#{query.root_name}/#{spec_version}"
@@ -66,7 +67,24 @@ module Pod
66
67
  specification.attributes_hash['source'] = {
67
68
  'http' => download_url
68
69
  }
69
- specification.attributes_hash['vendored_frameworks'] = "#{name}.framework"
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
70
88
  end
71
89
  specification
72
90
  end
@@ -88,7 +106,7 @@ module Pod
88
106
  def parse_artifacte_asset_url(artifacte, asset_type)
89
107
  asset = artifacte['assets'].select { |asset| asset['path'].end_with?(asset_type) }.first
90
108
  asset['downloadUrl'] if asset && asset['downloadUrl']
91
- end
109
+ end
92
110
 
93
111
  def nexus_find_artifacte(spec_name:, spec_version:)
94
112
  artifactes = nexus_api.search_maven_component(artifact_id: spec_name)
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - mrdaios
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2020-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -108,6 +108,7 @@ files:
108
108
  - lib/cocoapods-nexus/hook/analyzer.rb
109
109
  - lib/cocoapods-nexus/hook/installer.rb
110
110
  - lib/cocoapods-nexus/hook/manager.rb
111
+ - lib/cocoapods-nexus/hook/specification.rb
111
112
  - lib/cocoapods-nexus/nexus_source.rb
112
113
  - lib/cocoapods_plugin.rb
113
114
  - spec/command/nexus_spec.rb