cocoapods-pahealth-bin 0.0.4 → 0.0.5

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: 94a1fea35fcbe57752bef46c23661a3068639783bbb6fa0ecd567c6eb84eb694
4
- data.tar.gz: 2c9472f051b88873423a2ca004d5a350c997b0e4aa469a1a1669361a322d7730
3
+ metadata.gz: 548ec031b506a3415e358a531b7164c58ffa5f98bd60a6bdd39b2a7bb1fbc5da
4
+ data.tar.gz: 26a9775ac5184aaee5543bb7e732f1c9781039ca42b7e942ba9f0e2a45b6ef78
5
5
  SHA512:
6
- metadata.gz: f5d8836a8bc3f9e38a0fbc906d65f259932c16a8d39e93d02c01e30bb73b34bf466917affa0c92cc38b12a2d206222cc7d687c2a03043ee71ccc9076609e661e
7
- data.tar.gz: 20e867d0745fdcf6a0a096c4d3f87a2fd9181a0a86841af28e7e5676db493b4ad9936ea0d9e993b7f3f582769ec065237d53fc50e923bef498f351b6b9153690
6
+ metadata.gz: 782b67edcf136c3f51523eb15a30ece5f293b17ca5f3c013384d93911a376787111231456c5f10165104b1d27ceffeb9310ac607605892d7640656f8d4c62ec6
7
+ data.tar.gz: 5f106a5efb491af72858e877b084f5a6fb225d4c3f2cc5b3cc6b1edba1cf35ded83421f2ca0ab299e17dc9d2c23e1eb5c65ff8cebc80abd200527e5d23fe6c9e
@@ -1,6 +1,7 @@
1
1
  require 'cocoapods-pahealth-bin/command/bin/init'
2
2
  require 'cocoapods-pahealth-bin/command/bin/spec'
3
3
  require 'cocoapods-pahealth-bin/command/bin/update'
4
+ require 'cocoapods-pahealth-bin/command/bin/repo/push'
4
5
  require 'cocoapods-pahealth-bin/helpers'
5
6
 
6
7
  module Pod
@@ -6,8 +6,8 @@ module Pod
6
6
  class Init < Bin
7
7
  self.summary = '初始化插件.'
8
8
  self.description = <<-DESC
9
- 创建 #{CBin.config.config_file} 文件,在其中保存插件需要的配置信息,
10
- 如二进制私有源地址、源码私有源地址等。
9
+ 创建.yml文件,在其中保存组件需要的配置信息,
10
+ 如私有源地址、依赖环境等。
11
11
  DESC
12
12
 
13
13
  def self.options
@@ -0,0 +1,79 @@
1
+ require 'cocoapods-pahealth-bin/config/config'
2
+ require 'cocoapods-pahealth-bin/native/podfile'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Repo < Bin
8
+ class Push < Repo
9
+ self.summary = '发布组件.'
10
+ self.description = <<-DESC
11
+ 发布组件
12
+ DESC
13
+
14
+ self.arguments = [
15
+ CLAide::Argument.new('NAME.podspec', false)
16
+ ]
17
+
18
+ def self.options
19
+ [
20
+ ['--trunk-dependencies', 'push 到官方源'],
21
+ ].concat(Pod::Command::Repo::Push.options).concat(super).uniq
22
+ end
23
+
24
+ def initialize(argv)
25
+ @podspec = argv.shift_argument
26
+ @trunk_dependencies = argv.flag?('trunk-dependencies')
27
+ @sources = argv.option('sources') || []
28
+ super
29
+
30
+ @additional_args = argv.remainder!
31
+ end
32
+
33
+ def run
34
+ Podfile.execute_with_bin_plugin do
35
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
36
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
37
+ argvs = [
38
+ repo,
39
+ "--sources=#{sources_option(!@trunk_dependencies, @sources)}",
40
+ *@additional_args
41
+ ]
42
+
43
+ argvs << spec_file if spec_file
44
+
45
+ push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
46
+ push.validate!
47
+ push.run
48
+ end
49
+ end
50
+ end
51
+ ensure
52
+ clear_binary_spec_file_if_needed unless @reserve_created_spec
53
+ end
54
+
55
+ private
56
+
57
+ def spec_file
58
+ @spec_file ||= begin
59
+ if @podspec
60
+ find_spec_file(@podspec)
61
+ else
62
+ if code_spec_files.empty?
63
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
64
+ end
65
+
66
+ spec_file = code_spec_files.first
67
+ spec_file
68
+ end
69
+ end
70
+ end
71
+
72
+ def repo
73
+ code_source.name
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -13,19 +13,18 @@ module Pod
13
13
 
14
14
  def self.options
15
15
  [
16
- ['--trunk-repo-update', '更新官方源']
17
16
  ].concat(super)
18
17
  end
19
18
 
20
19
  def initialize(argv)
21
- @trunk = argv.flag?('trunk-repo-update',false )
22
20
  super
23
21
  end
24
22
 
25
23
  def run
26
24
  show_output = !config.silent?
27
- Parallel.each(valid_sources(!@trunk), in_threads: 4) do |source|
25
+ Parallel.each(valid_sources, in_threads: 4) do |source|
28
26
  source.update(show_output)
27
+ # update_git_repo
29
28
  end
30
29
  end
31
30
  end
@@ -17,23 +17,14 @@ module Pod
17
17
 
18
18
  def self.options
19
19
  [
20
- ['--binary', 'lint 组件的二进制版本'],
21
- ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
22
- ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
23
- ['--code-dependencies', '使用源码依赖进行 lint'],
24
- ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
25
- ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
20
+ ['--release', '在 release 环境下进行 lint']
26
21
  ].concat(Pod::Command::Spec::Lint.options).concat(super).uniq
27
22
  end
28
23
 
29
24
  def initialize(argv)
30
25
  @podspec = argv.shift_argument
31
- @loose_options = argv.flag?('loose-options')
32
- @code_dependencies = argv.flag?('code-dependencies')
33
- @sources = argv.option('sources') || []
34
- @binary = argv.flag?('binary')
35
- @reserve_created_spec = argv.flag?('reserve-created-spec')
36
- @template_podspec = argv.option('template-podspec')
26
+ @release = argv.flag?('release',false )
27
+ @sources = argv.option('sources')
37
28
  @allow_prerelease = argv.flag?('allow-prerelease')
38
29
  super
39
30
 
@@ -43,43 +34,20 @@ module Pod
43
34
  def run
44
35
  Podfile.execute_with_bin_plugin do
45
36
  Podfile.execute_with_allow_prerelease(@allow_prerelease) do
46
- Podfile.execute_with_use_binaries(!@code_dependencies) do
47
- argvs = [
48
- "--sources=#{sources_option(@code_dependencies, @sources)}",
49
- *@additional_args
50
- ]
51
-
52
- argvs << spec_file if spec_file
53
-
54
- if @loose_options
55
- argvs += ['--allow-warnings']
56
- if code_spec&.all_dependencies&.any?
57
- argvs << '--use-libraries'
58
- end
59
- end
60
-
61
- lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
62
- lint.validate!
63
- lint.run
64
- end
37
+ argvs = [
38
+ "--sources=#{sources_option(@release, @sources)+','+Pod::TrunkSource::TRUNK_REPO_URL}",
39
+ *@additional_args
40
+ ]
41
+ argvs << spec_file if spec_file
42
+ lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
43
+ lint.validate!
44
+ lint.run
65
45
  end
66
46
  end
67
- ensure
68
- clear_binary_spec_file_if_needed unless @reserve_created_spec
69
47
  end
70
48
 
71
49
  private
72
50
 
73
- def template_spec_file
74
- @template_spec_file ||= begin
75
- if @template_podspec
76
- find_spec_file(@template_podspec)
77
- else
78
- binary_template_spec_file
79
- end
80
- end
81
- end
82
-
83
51
  def spec_file
84
52
  @spec_file ||= begin
85
53
  if @podspec
@@ -89,15 +57,7 @@ module Pod
89
57
  raise Informative, '当前目录下没有找到可用源码 podspec.'
90
58
  end
91
59
 
92
- spec_file = if @binary
93
- code_spec = Pod::Specification.from_file(code_spec_files.first)
94
- if template_spec_file
95
- template_spec = Pod::Specification.from_file(template_spec_file)
96
- end
97
- create_binary_spec_file(code_spec, template_spec)
98
- else
99
- code_spec_files.first
100
- end
60
+ spec_file = code_spec_files.first
101
61
  spec_file
102
62
  end
103
63
  end
@@ -1,4 +1,5 @@
1
1
  require 'cocoapods-pahealth-bin/command/bin/repo/update'
2
+ require 'cocoapods-pahealth-bin/native/podfile'
2
3
  require 'cocoapods'
3
4
 
4
5
  module Pod
@@ -10,6 +11,11 @@ module Pod
10
11
  CLAide::Argument.new('NAME.podspec', false)
11
12
  ]
12
13
 
14
+ def self.options
15
+ [
16
+ ].concat(Pod::Command::Spec::Lint.options).concat(super).uniq
17
+ end
18
+
13
19
  def initialize(argv)
14
20
  super
15
21
  end
@@ -30,8 +36,7 @@ module Pod
30
36
 
31
37
  def pod_update_no_repo_update
32
38
  argvs = [
33
- "--no-repo-update",
34
- "--sources=#{sources_option(true, @sources)}"
39
+ "--no-repo-update"
35
40
  ]
36
41
  update = Pod::Command::Update.new(CLAide::ARGV.new(argvs))
37
42
  update.validate!
@@ -1,23 +1,61 @@
1
1
  require 'yaml'
2
+ require 'cocoapods-pahealth-bin/native/podfile'
3
+ require 'cocoapods-pahealth-bin/native/podfile_env'
4
+ require 'cocoapods/generate'
2
5
 
3
6
  module CBin
4
7
  class Config
5
8
  def config_file
6
- File.expand_path("#{Pod::Config.instance.home_dir}/bin.yml")
9
+ config_file_with_configuration_dependence(configuration_dependence)
7
10
  end
8
11
 
9
12
  def template_hash
10
13
  {
11
- 'code_repo_url' => { description: '私有源 Git 地址', default: 'http://domain/git/pahealth_private_repo.git' },
12
- #'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'git@git.2dfire.net:ios/cocoapods-spec-binary.git' },
13
- #'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip' },
14
- # 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
15
- #'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] }
14
+ 'configuration_dependence' => { description: '依赖环境', default: 'uat', selection: %w[uat test] },
15
+ 'code_repo_url' => { description: '私有源 Git 地址', default: 'uat环境:https://github.com/GitWangKai/ReleasePrivateRepo.git test环境:https://github.com/GitWangKai/TestPrivateRepo.git' },
16
16
  }
17
17
  end
18
18
 
19
+ def config_file_with_configuration_dependence(configuration_dependence)
20
+ file = config_uat_dependence_file
21
+ if configuration_dependence == "test"
22
+ file = config_test_dependence_file
23
+ puts "\n====== #{configuration_dependence} 环境 ========"
24
+ elsif configuration_dependence == "uat"
25
+ puts "\n====== #{configuration_dependence} 环境 ========"
26
+ else
27
+ raise "\n===== #{configuration_dependence} 参数有误,请检查%w[uat test]===="
28
+ end
29
+
30
+ File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
31
+ end
32
+
33
+ def configuration_dependence
34
+ #如果是dev 再去 podfile的配置文件中获取,确保是正确的, pod update时会用到
35
+ if @configuration_dependence == "uat" || @configuration_dependence == nil
36
+ if Pod::Config.instance.podfile
37
+ configuration_dependence ||= Pod::Config.instance.podfile.configuration_dependence
38
+ end
39
+ configuration_dependence ||= "uat"
40
+ @configuration_dependence = configuration_dependence
41
+ end
42
+ @configuration_dependence
43
+ end
44
+
45
+ def set_configuration_dependence(dependence)
46
+ @configuration_dependence = dependence
47
+ end
48
+
49
+ def config_test_dependence_file
50
+ "pahealth_test.yml"
51
+ end
52
+
53
+ def config_uat_dependence_file
54
+ "pahealth_uat.yml"
55
+ end
56
+
19
57
  def sync_config(config)
20
- File.open(config_file, 'w+') do |f|
58
+ File.open(config_file_with_configuration_dependence(config['configuration_dependence']), 'w+') do |f|
21
59
  f.write(config.to_yaml)
22
60
  end
23
61
  end
@@ -38,6 +76,7 @@ module CBin
38
76
 
39
77
  def config
40
78
  @config ||= begin
79
+ puts "====== cocoapods-pahealth-bin #{CocoapodsPahealthBin::VERSION} 版本 ======== \n"
41
80
  @config = OpenStruct.new load_config
42
81
  validate!
43
82
  @config
@@ -75,5 +114,6 @@ module CBin
75
114
  def self.config
76
115
  @config ||= Config.new
77
116
  end
78
- end
79
117
 
118
+
119
+ end
@@ -40,8 +40,9 @@ module CBin
40
40
  def wellcome_message
41
41
  print <<~EOF
42
42
 
43
- 开始设置二进制化初始信息.
43
+ 开始设置组件私有化初始信息.
44
44
  所有的信息都会保存在 #{CBin.config.config_file} 文件中.
45
+ %w[pahealth_test.yml pahealth_uat.yml]
45
46
  你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
46
47
 
47
48
  #{CBin.config.default_config.to_yaml}
@@ -52,10 +53,5 @@ module CBin
52
53
  print "\n设置完成.\n".green
53
54
  end
54
55
  end
55
-
56
- def binary_repo_url
57
- # code here
58
- end
59
56
  end
60
57
  end
61
-
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPahealthBin
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -6,32 +6,17 @@ module CBin
6
6
  Pod::Config.instance.sources_manager
7
7
  end
8
8
 
9
- def binary_source
10
- sources_manager.binary_source
11
- end
12
-
13
9
  def code_source
14
10
  sources_manager.code_source
15
11
  end
16
12
 
17
- def trunk_source
18
- sources_manager.trunk_source
19
- end
20
-
21
- # 优先采用对应依赖的 source
22
- # cocoapods 内部会先匹配前面符合的 specification
23
- # 只允许二进制的 specification subspec 比源码的 specification subspec 多
24
- #
25
- def valid_sources(code_dependencies = false)
13
+ def valid_sources
26
14
  sources = [code_source]
27
- unless code_dependencies
28
- sources << trunk_source
29
- end
30
15
  sources
31
16
  end
32
17
 
33
- def sources_option(code_dependencies, additional_sources)
34
- (valid_sources(code_dependencies).map(&:url) + Array(additional_sources)).join(',')
18
+ def sources_option(additional_sources)
19
+ (valid_sources.map(&:url) + Array(additional_sources)).join(',')
35
20
  end
36
21
  end
37
22
  end
@@ -25,6 +25,11 @@ module Pod
25
25
  hash_pods_use_source += Array(pods)
26
26
  set_internal_hash_value(USE_SOURCE_PODS, hash_pods_use_source)
27
27
  end
28
+
29
+ def set_configuration_dependence(dependence = "uat")
30
+ set_internal_hash_value(CONFIGURATION_DEPENDENCE, dependence)
31
+ end
32
+
28
33
  end
29
34
 
30
35
  alias old_plugins plugins
@@ -55,11 +60,15 @@ module Pod
55
60
  get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
56
61
  end
57
62
 
63
+ def configuration_dependence
64
+ get_internal_hash_value(CONFIGURATION_DEPENDENCE, "uat") || ENV[CONFIGURATION_DEPENDENCE] == "uat"
65
+ end
66
+
58
67
  private
59
68
 
60
69
  def valid_bin_plugin
61
- unless plugins.keys.include?('cocoapods-bin')
62
- raise Pod::Informative, 'You should add `plugin \'cocoapods-bin\'` before using its DSL'
70
+ unless plugins.keys.include?('cocoapods-pahealth-bin')
71
+ raise Pod::Informative, 'You should add `plugin \'cocoapods-pahealth-bin\'` before using its DSL'
63
72
  end
64
73
  end
65
74
 
@@ -5,8 +5,10 @@ module Pod
5
5
  USE_BINARIES_SELECTOR = 'use_binaries_selector'
6
6
  ALLOW_PRERELEASE = 'allow_prerelease'
7
7
  USE_PLUGINS = 'use_plugins'
8
+ CONFIGURATION_DEPENDENCE = 'configuration_dependence'
8
9
 
9
10
  module ENVExecutor
11
+
10
12
  def execute_with_bin_plugin(&block)
11
13
  execute_with_key(USE_PLUGINS, -> { 'cocoapods-pahealth-bin' }, &block)
12
14
  end
@@ -4,19 +4,16 @@ require 'cocoapods-pahealth-bin/config/config'
4
4
  module Pod
5
5
  class Source
6
6
  class Manager
7
- # 源码 source
7
+ # 私有源
8
8
  def code_source
9
9
  source_with_name_or_url(CBin.config.code_repo_url)
10
10
  end
11
11
 
12
- # 二进制 source
13
- def binary_source
14
- source_with_name_or_url(CBin.config.binary_repo_url)
15
- end
16
-
12
+ # 公有源 source
17
13
  def trunk_source
18
14
  source_with_name_or_url('https://github.com/CocoaPods/Specs.git')
19
15
  end
16
+
20
17
  end
21
18
  end
22
19
  end
@@ -0,0 +1,17 @@
1
+ require 'cocoapods-pahealth-bin/native/sources_manager'
2
+ require 'cocoapods-pahealth-bin/native/podfile'
3
+ require 'cocoapods'
4
+
5
+ Pod::HooksManager.register('cocoapods-pahealth-bin', :source_provider) do |context, _|
6
+ sources_manager = Pod::Config.instance.sources_manager
7
+ podfile = Pod::Config.instance.podfile
8
+
9
+ if podfile
10
+ # 添加源
11
+ added_sources = [sources_manager.trunk_source]
12
+ added_sources << sources_manager.code_source
13
+ added_sources.reverse!
14
+
15
+ added_sources.each { |source| context.add_source(source) }
16
+ end
17
+ end
@@ -1 +1,3 @@
1
1
  require 'cocoapods-pahealth-bin/command'
2
+ require 'cocoapods-pahealth-bin/source_provider_hook'
3
+ require 'cocoapods-pahealth-bin/gem_version.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-pahealth-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitWangKai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-17 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -91,6 +91,7 @@ files:
91
91
  - lib/cocoapods-pahealth-bin/command.rb
92
92
  - lib/cocoapods-pahealth-bin/command/bin.rb
93
93
  - lib/cocoapods-pahealth-bin/command/bin/init.rb
94
+ - lib/cocoapods-pahealth-bin/command/bin/repo/push.rb
94
95
  - lib/cocoapods-pahealth-bin/command/bin/repo/update.rb
95
96
  - lib/cocoapods-pahealth-bin/command/bin/spec.rb
96
97
  - lib/cocoapods-pahealth-bin/command/bin/spec/lint.rb
@@ -106,6 +107,7 @@ files:
106
107
  - lib/cocoapods-pahealth-bin/native/podfile.rb
107
108
  - lib/cocoapods-pahealth-bin/native/podfile_env.rb
108
109
  - lib/cocoapods-pahealth-bin/native/sources_manager.rb
110
+ - lib/cocoapods-pahealth-bin/source_provider_hook.rb
109
111
  - lib/cocoapods_plugin.rb
110
112
  homepage: https://github.com/EXAMPLE/cocoapods-pahealth-bin
111
113
  licenses: