cocoapods-hbh 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-hbh/command/common/podfile.rb +11 -4
- data/lib/cocoapods-hbh/command/custom/sync_githooks.rb +123 -0
- data/lib/cocoapods-hbh/command/{sub_module/add_submodule.rb → module/add_module.rb} +25 -17
- data/lib/cocoapods-hbh/gem_version.rb +1 -1
- data/lib/cocoapods-hbh/source_provider_hook.rb +11 -0
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 416d296eacf21ea795f369ce67716788f512101da11b1975f95fcb31d0201d92
|
4
|
+
data.tar.gz: 5dde5bfb57c073b6db07c2b7094a97f7830ba466e3c82d1c4e0a9cc998917d2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8054f00ec0d7b35bfd1dd00263f89e9ae79987c3a33a3d3130653bc8cf9ef53e8357f63a8a73dd98de6af4c4e97f0753b2790bf29f4cd3404a2d64328add7be
|
7
|
+
data.tar.gz: 327c35772d4bdb96a701f9aa2fe2328ab0b2bf106abc28da4e48a84d038d794ad6d88e9624ca7646edf81539add3cc111a79b0948e13990b1e175c936f6135b6
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'cocoapods'
|
2
|
-
require 'cocoapods-hbh/command/
|
2
|
+
require 'cocoapods-hbh/command/module/add_module'
|
3
3
|
|
4
4
|
|
5
5
|
module Pod
|
@@ -11,11 +11,18 @@ module Pod
|
|
11
11
|
unless name
|
12
12
|
raise StandardError, 'A dependency requires a name.'
|
13
13
|
end
|
14
|
-
add_sub_module =
|
15
|
-
add_sub_module.
|
16
|
-
# current_target_definition.store_pod(name, *requirements)
|
14
|
+
add_sub_module = AddModule.new(@current_target_definition)
|
15
|
+
add_sub_module.pod_submoudle(name, *requirements)
|
17
16
|
end
|
18
17
|
|
18
|
+
def pod_private(name = nil, *requirements)
|
19
|
+
unless name
|
20
|
+
raise StandardError, 'A dependency requires a name.'
|
21
|
+
end
|
22
|
+
add_sub_module = AddModule.new(@current_target_definition)
|
23
|
+
add_sub_module.pod_private(name, *requirements)
|
24
|
+
end
|
25
|
+
|
19
26
|
end
|
20
27
|
|
21
28
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module CocoapodsGitHooks
|
5
|
+
class GitHooksManager
|
6
|
+
class << self
|
7
|
+
# @return [Array<String>]
|
8
|
+
def hook_types
|
9
|
+
%w(applypatch-msg commit-msg fsmonitor-watchman post-update pre-applypatch pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg push-to-checkout)
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [TargetDefinition]
|
13
|
+
def abstract_target_of_githooks
|
14
|
+
abstract_target = nil
|
15
|
+
podfile = Pod::Config.instance.podfile
|
16
|
+
podfile.target_definition_list.each do |target|
|
17
|
+
if target.name == 'Githooks'
|
18
|
+
abstract_target = target
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end unless podfile.target_definition_list.nil?
|
22
|
+
|
23
|
+
if abstract_target.nil?
|
24
|
+
Pod::UI.puts 'The abstract_target of SyncGithooks is not defined.'
|
25
|
+
return nil
|
26
|
+
end
|
27
|
+
|
28
|
+
abstract_target
|
29
|
+
end
|
30
|
+
|
31
|
+
# @param [TargetDefinition]
|
32
|
+
# @return [Array<Dependency>]
|
33
|
+
def dependencies_in_target(abstract_target)
|
34
|
+
abstract_target.dependencies
|
35
|
+
end
|
36
|
+
|
37
|
+
def validate_git_directory?
|
38
|
+
unless File.directory?(".git")
|
39
|
+
Pod::UI.puts 'Can not find .git directory.'
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
# @param [Array<Dependency>] dependencies
|
47
|
+
def sync_githooks_in_dependencies(dependencies)
|
48
|
+
pods_directory = "#{Dir.pwd}/Pods"
|
49
|
+
hook_dependencies = Hash.new([])
|
50
|
+
dependencies.each do |dependency|
|
51
|
+
dependency_directory = if dependency.local?
|
52
|
+
File.expand_path(dependency.external_source[:path])
|
53
|
+
else
|
54
|
+
"#{pods_directory}/#{dependency.name}"
|
55
|
+
end
|
56
|
+
hook_types.each { |hook_type|
|
57
|
+
file_path = "#{dependency_directory}/githooks/#{hook_type}"
|
58
|
+
if File.exist?(file_path)
|
59
|
+
hook_dependencies[hook_type] += [dependency]
|
60
|
+
end
|
61
|
+
}
|
62
|
+
end
|
63
|
+
git_hook_directory = '.git/hooks'
|
64
|
+
hook_dependencies.each_pair { |key, dependencies|
|
65
|
+
file_path = "#{git_hook_directory}/#{key}"
|
66
|
+
|
67
|
+
File.delete(file_path) if File.exist?(file_path)
|
68
|
+
|
69
|
+
File.new(file_path, 'w')
|
70
|
+
File.open(file_path, File::RDWR) do |file|
|
71
|
+
file.write("#!/bin/sh\n")
|
72
|
+
file.write("#!/usr/bin/env ruby\n")
|
73
|
+
file.write("#!/usr/bin/env python\n")
|
74
|
+
|
75
|
+
dependencies.each do |dependency|
|
76
|
+
dependency_directory = if dependency.local?
|
77
|
+
File.expand_path(dependency.external_source[:path])
|
78
|
+
else
|
79
|
+
"#{pods_directory}/#{dependency.name}"
|
80
|
+
end
|
81
|
+
|
82
|
+
hook_file_path = "#{dependency_directory}/githooks/#{key}"
|
83
|
+
|
84
|
+
file.write("# #{dependency.name} githook\n")
|
85
|
+
file.write("if [ -f \"#{hook_file_path}\" ]; then\n")
|
86
|
+
file.write(" function #{dependency.name}(){\n")
|
87
|
+
file.write(" local script_directory=#{dependency_directory}/scripts\n")
|
88
|
+
File.readlines(hook_file_path).each { |line|
|
89
|
+
file.write(" #{line}")
|
90
|
+
}
|
91
|
+
file.write("\n }\n")
|
92
|
+
file.write(" #{dependency.name}\n")
|
93
|
+
file.write("fi\n")
|
94
|
+
end
|
95
|
+
|
96
|
+
FileUtils.chmod('+x', file_path)
|
97
|
+
end
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
def sync
|
102
|
+
Pod::UI.message 'Start syncing Git Hook' do
|
103
|
+
return unless validate_git_directory?
|
104
|
+
|
105
|
+
FileUtils.mkdir '.git/hooks' unless File.directory?('.git/hooks')
|
106
|
+
|
107
|
+
abstract_target = abstract_target_of_githooks
|
108
|
+
return if abstract_target.nil?
|
109
|
+
dependencies = dependencies_in_target(abstract_target)
|
110
|
+
if dependencies.nil? || dependencies.empty?
|
111
|
+
Pod::UI.warn 'The dependencies of SyncGithooks is nil or empty.'
|
112
|
+
return
|
113
|
+
end
|
114
|
+
dependencies.each { |dependency|
|
115
|
+
Pod::UI.message "- #{dependency.name}"
|
116
|
+
}
|
117
|
+
sync_githooks_in_dependencies(dependencies)
|
118
|
+
end
|
119
|
+
Pod::UI.message 'Githooks are synced'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -4,7 +4,7 @@ require 'cocoapods/user_interface'
|
|
4
4
|
|
5
5
|
module Pod
|
6
6
|
class Podfile
|
7
|
-
class
|
7
|
+
class AddModule
|
8
8
|
UI = Pod::UserInterface unless defined? UI
|
9
9
|
# @return [TargetDefinition] The current target definition to which the DSL
|
10
10
|
# commands apply.
|
@@ -23,33 +23,41 @@ module Pod
|
|
23
23
|
return default
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
def pod_private (moduleName, *requirements)
|
28
|
+
info = requirements.last
|
29
|
+
git = get_info(info, :git, nil)
|
30
|
+
sub_config = HBHConfig.config.submodule_env
|
31
|
+
remoteUrl = sub_config['sub_url']
|
32
|
+
if git.blank?
|
33
|
+
if moduleName.include?('/')
|
34
|
+
name = moduleName.split('/').first
|
35
|
+
requirements.last[:git] = "#{remoteUrl}/#{name}.git"
|
36
|
+
else
|
37
|
+
requirements.last[:git] = "#{remoteUrl}/#{moduleName}.git"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
Pod::UI.puts "#{moduleName}使用私有库".yellow
|
41
|
+
current_target_definition.store_pod moduleName, *requirements
|
42
|
+
end
|
26
43
|
|
27
44
|
|
28
45
|
# 添加模块 模块名称为podspec的名称,路径默认为Module/下的模块,tag或者branch 优先使用tag,默认develop分支
|
29
46
|
# (moduleName, submodule: true, moduleTag: nil, moduleBranch: 'develop', appspecs: nil)
|
30
|
-
def
|
47
|
+
def pod_submoudle (moduleName, *requirements)
|
31
48
|
info = requirements.last
|
32
|
-
# git = get_info(info, :git, nil)
|
33
|
-
|
34
|
-
|
35
|
-
# if git.blank?
|
36
|
-
# hbh_git = get_info(info, :hbh_git, nil)
|
37
|
-
# if moduleName.include?('/')
|
38
|
-
# name = moduleName.split('/').first
|
39
|
-
# requirements.last[:git] = "#{remoteUrl}/#{name}.git"
|
40
|
-
# else
|
41
|
-
# requirements.last[:git] = "#{remoteUrl}/#{moduleName}.git"
|
42
|
-
# end
|
43
|
-
# requirements.last.delete(:hbh_git)
|
44
|
-
# end
|
45
|
-
|
46
49
|
is_submodule = get_info(info, :submodule, true)
|
47
50
|
if is_submodule
|
48
51
|
if info.nil? then raise "请输入正确的参数" end
|
49
52
|
return requirements unless info.is_a?(Hash)
|
50
53
|
|
51
54
|
moduleTag = get_info(info, :tag, nil)
|
52
|
-
moduleBranch = get_info(info, :branch,
|
55
|
+
moduleBranch = get_info(info, :branch, nil)
|
56
|
+
if moduleTag.nil? && moduleBranch.nil?
|
57
|
+
Pod::UI.puts "请配置依赖tag或者branch".red
|
58
|
+
raise "注意: 请配置依赖tag或者branch"
|
59
|
+
end
|
60
|
+
|
53
61
|
appspecs = get_info(info, :appspecs, nil)
|
54
62
|
sub_config = HBHConfig.config.submodule_env
|
55
63
|
remoteUrl = sub_config['sub_url']
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-hbh/command/custom/sync_githooks'
|
3
|
+
|
4
|
+
module CocoapodsGitHooks
|
5
|
+
Pod::HooksManager.register('cocoapods-hbh', :post_install) do |context|
|
6
|
+
CocoapodsGitHooks::GitHooksManager.sync
|
7
|
+
end
|
8
|
+
Pod::HooksManager.register('cocoapods-hbh', :post_update) do |context|
|
9
|
+
CocoapodsGitHooks::GitHooksManager.sync
|
10
|
+
end
|
11
|
+
end
|
data/lib/cocoapods_plugin.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-hbh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zanju
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -79,11 +79,13 @@ files:
|
|
79
79
|
- lib/cocoapods-hbh/command/common/podfile.rb
|
80
80
|
- lib/cocoapods-hbh/command/common/push.rb
|
81
81
|
- lib/cocoapods-hbh/command/custom/pod_push.rb
|
82
|
+
- lib/cocoapods-hbh/command/custom/sync_githooks.rb
|
82
83
|
- lib/cocoapods-hbh/command/hbh.rb
|
83
|
-
- lib/cocoapods-hbh/command/
|
84
|
+
- lib/cocoapods-hbh/command/module/add_module.rb
|
84
85
|
- lib/cocoapods-hbh/config/config.rb
|
85
86
|
- lib/cocoapods-hbh/gem_version.rb
|
86
87
|
- lib/cocoapods-hbh/helpers/git_depend.rb
|
88
|
+
- lib/cocoapods-hbh/source_provider_hook.rb
|
87
89
|
- lib/cocoapods_plugin.rb
|
88
90
|
homepage: https://github.com/EXAMPLE/cocoapods-hbh
|
89
91
|
licenses:
|