lg_pod_plugin 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lg_pod_plugin/cache.rb +50 -14
- data/lib/lg_pod_plugin/database.rb +1 -1
- data/lib/lg_pod_plugin/download.rb +38 -30
- data/lib/lg_pod_plugin/git_util.rb +36 -19
- data/lib/lg_pod_plugin/install.rb +87 -40
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +56 -7
- metadata +3 -5
- data/bin/lg +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61fa41fbaf71702b19bf2ef604d2283f68d472e5c47428890398463556a985f7
|
4
|
+
data.tar.gz: 9c45761ced23924ce2e70557245d70eb883b4f7158c63acfeb3f0547af2e1fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 549679243cd9e06a3d4626c06c79733bd779817e018bc5c46eb75f1731f7c5806f98bc02956ffd2e696b34e8ca1fb29f3fffb33feb231b9cb07180c3189ad586
|
7
|
+
data.tar.gz: 00d3b2bf9cf9d22c87141e63872b2dd466658d14972b1e8b4a4ae2a5f23d3fbb96195971cddc8063bc38cc97b4d7468422c9ccbe330e70aac6af80ce1126dcc0
|
data/lib/lg_pod_plugin/cache.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
require 'git'
|
2
|
-
require 'cocoapods/downloader
|
3
|
-
require 'cocoapods/downloader/cache
|
4
|
-
require 'cocoapods/downloader/response
|
5
|
-
require 'cocoapods/downloader/request
|
2
|
+
require 'cocoapods/downloader'
|
3
|
+
require 'cocoapods/downloader/cache'
|
4
|
+
require 'cocoapods/downloader/response'
|
5
|
+
require 'cocoapods/downloader/request'
|
6
6
|
|
7
7
|
module LgPodPlugin
|
8
8
|
|
9
9
|
class CachePodInfo
|
10
|
-
attr_accessor :sha
|
11
|
-
attr_accessor :tag
|
12
|
-
attr_accessor :name
|
13
|
-
attr_accessor :path
|
14
|
-
attr_accessor :branch
|
15
|
-
attr_accessor :timestamp
|
10
|
+
# attr_accessor :sha
|
11
|
+
# attr_accessor :tag
|
12
|
+
# attr_accessor :name
|
13
|
+
# attr_accessor :path
|
14
|
+
# attr_accessor :branch
|
15
|
+
# attr_accessor :timestamp
|
16
|
+
REQUIRED_ATTRS ||= %i[sha tag name path branch timestamp].freeze
|
17
|
+
attr_accessor(*REQUIRED_ATTRS)
|
16
18
|
def initialize
|
17
19
|
super
|
18
20
|
end
|
@@ -46,9 +48,9 @@ class Cache
|
|
46
48
|
destination = Cache.path_for_pod(request, {})
|
47
49
|
cache_pod_spec = Cache.path_for_spec(request, {})
|
48
50
|
if File.exist?(destination) && File.exist?(cache_pod_spec)
|
49
|
-
|
51
|
+
[false , last_commit]
|
50
52
|
else
|
51
|
-
|
53
|
+
[true , last_commit]
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -127,7 +129,7 @@ class Cache
|
|
127
129
|
def self.copy_and_clean(source, destination, spec)
|
128
130
|
specs_by_platform = group_sub_specs_by_platform(spec)
|
129
131
|
destination.parent.mkpath
|
130
|
-
|
132
|
+
self.write_lock(destination) do
|
131
133
|
FileUtils.rm_rf(destination)
|
132
134
|
FileUtils.cp_r(source, destination)
|
133
135
|
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
@@ -135,12 +137,46 @@ class Cache
|
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
140
|
+
def self.write_lock(location, &block)
|
141
|
+
self.lock(location, File::LOCK_EX, &block)
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.lock(location, lock_type)
|
145
|
+
raise ArgumentError, 'no block given' unless block_given?
|
146
|
+
lockfile = "#{location}.lock"
|
147
|
+
f = nil
|
148
|
+
loop do
|
149
|
+
f.close if f
|
150
|
+
f = File.open(lockfile, File::CREAT, 0o644)
|
151
|
+
f.flock(lock_type)
|
152
|
+
break if self.valid_lock?(f, lockfile)
|
153
|
+
end
|
154
|
+
begin
|
155
|
+
yield location
|
156
|
+
ensure
|
157
|
+
if lock_type == File::LOCK_SH
|
158
|
+
f.flock(File::LOCK_EX)
|
159
|
+
File.delete(lockfile) if self.valid_lock?(f, lockfile)
|
160
|
+
else
|
161
|
+
File.delete(lockfile)
|
162
|
+
end
|
163
|
+
f.close
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.valid_lock?(file, filename)
|
168
|
+
file.stat.ino == File.stat(filename).ino
|
169
|
+
rescue Errno::ENOENT
|
170
|
+
false
|
171
|
+
end
|
172
|
+
|
138
173
|
def self.write_spec(spec, path)
|
139
174
|
path.dirname.mkpath
|
140
175
|
Pod::Downloader::Cache.write_lock(path) do
|
141
176
|
path.open('w') { |f| f.write spec.to_pretty_json }
|
142
177
|
end
|
143
178
|
end
|
179
|
+
|
144
180
|
# 拷贝 pod 缓存文件到 sandbox
|
145
181
|
def self.cache_pod(name, target, is_update, options = {})
|
146
182
|
request = Cache.download_request(name, options)
|
@@ -149,7 +185,7 @@ class Cache
|
|
149
185
|
pods_pecs.each do |s_name, s_spec|
|
150
186
|
destination = path_for_pod(request, {})
|
151
187
|
if !File.exist?(destination) || is_update
|
152
|
-
|
188
|
+
LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
|
153
189
|
copy_and_clean(target, destination, s_spec)
|
154
190
|
end
|
155
191
|
cache_pod_spec = path_for_spec(request, {})
|
@@ -1,28 +1,42 @@
|
|
1
1
|
require 'git'
|
2
|
-
require_relative 'cache
|
3
|
-
require_relative 'database
|
4
|
-
require_relative 'file_path
|
2
|
+
require_relative 'cache'
|
3
|
+
require_relative 'database'
|
4
|
+
require_relative 'file_path'
|
5
5
|
|
6
|
-
module
|
6
|
+
module LgPodPlugin
|
7
7
|
|
8
8
|
class Downloader
|
9
|
-
|
10
|
-
|
11
|
-
attr_accessor :cache
|
12
|
-
REQUIRED_ATTRS ||= %i[git name commit branch tag options].freeze
|
9
|
+
|
10
|
+
REQUIRED_ATTRS ||= %i[git name commit branch tag options git_util db cache is_cache].freeze
|
13
11
|
attr_accessor(*REQUIRED_ATTRS)
|
12
|
+
|
14
13
|
def initialize
|
15
14
|
self.cache = Cache.new
|
16
15
|
self.db = SqliteDb.instance
|
17
16
|
super
|
18
17
|
end
|
18
|
+
|
19
19
|
def download_init(name, options = {})
|
20
|
+
hash_map = options
|
20
21
|
self.name = name
|
21
|
-
self.
|
22
|
-
self.
|
23
|
-
self.
|
24
|
-
self.
|
25
|
-
self.
|
22
|
+
self.git = hash_map[:git]
|
23
|
+
self.tag = hash_map[:tag]
|
24
|
+
self.branch = hash_map[:branch]
|
25
|
+
self.commit = hash_map[:commit]
|
26
|
+
self.is_cache = hash_map[:depth]
|
27
|
+
# 通过ls-remote获取 head 指向 branch
|
28
|
+
if !self.branch && self.git
|
29
|
+
ls = Git.ls_remote(self.git, :head => true)
|
30
|
+
head_ref = ls["head"][:sha]
|
31
|
+
ls["branches"].each do |key, value|
|
32
|
+
sha = value[:sha]
|
33
|
+
next if sha != head_ref
|
34
|
+
self.branch = key
|
35
|
+
hash_map[:branch] = key
|
36
|
+
break
|
37
|
+
end
|
38
|
+
end
|
39
|
+
self.options = hash_map
|
26
40
|
end
|
27
41
|
|
28
42
|
def is_update_pod
|
@@ -50,19 +64,14 @@ module LgPodPlugin
|
|
50
64
|
self.git_util = git
|
51
65
|
is_update = self.is_update_pod
|
52
66
|
self.git_util.git_init(self.name, self.options)
|
53
|
-
# if name == "LBase" || name == "LLogger" || name == "LUnityFramework" || name == "LUser"
|
54
|
-
# pp name
|
55
|
-
# end
|
56
|
-
# tag = options[:tag]
|
57
67
|
git_url = options[:git]
|
58
68
|
# commit = options[:commit]
|
59
69
|
branch = options[:branch]
|
60
|
-
|
61
|
-
|
70
|
+
LgPodPlugin.log_green "Using `#{name}` (#{branch})"
|
62
71
|
# 发现本地有缓存, 不需要更新缓存
|
63
72
|
need_download, new_commit = self.cache.find_pod_cache(name, git_url, branch, is_update)
|
64
73
|
unless need_download
|
65
|
-
|
74
|
+
LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
|
66
75
|
return
|
67
76
|
end
|
68
77
|
|
@@ -91,40 +100,39 @@ module LgPodPlugin
|
|
91
100
|
if new_commit != current_commit && is_update
|
92
101
|
#删除旧的pod 缓存
|
93
102
|
self.cache.clean_old_cache(name, git_url, current_commit)
|
94
|
-
|
103
|
+
LgPodPlugin.log_green "git pull #{name} origin/#{current_branch}"
|
95
104
|
self.git_util.should_pull(git, current_branch, new_commit)
|
96
105
|
current_commit = new_commit
|
97
106
|
end
|
98
|
-
hash_map = {:git => git_url}
|
107
|
+
hash_map = { :git => git_url }
|
99
108
|
if current_commit
|
100
109
|
hash_map[:commit] = current_commit
|
101
110
|
end
|
102
111
|
SqliteDb.instance.insert_table(name, branch, current_commit, nil, real_pod_path)
|
103
|
-
LgPodPlugin::Cache.cache_pod(name,real_pod_path,is_update,hash_map)
|
112
|
+
LgPodPlugin::Cache.cache_pod(name, real_pod_path, is_update, hash_map)
|
104
113
|
else
|
105
|
-
branch_exist = git.branches.local.find {|e| e.to_s == branch}
|
114
|
+
branch_exist = git.branches.local.find { |e| e.to_s == branch }
|
106
115
|
if branch_exist
|
107
|
-
|
116
|
+
LgPodPlugin.log_green "git switch #{name} #{git_url} -b #{branch}"
|
108
117
|
self.git_util.git_switch(branch)
|
109
118
|
else
|
110
|
-
|
119
|
+
LgPodPlugin.log_green "git checkout #{name} #{git_url} -b #{branch}"
|
111
120
|
self.git_util.git_checkout(branch)
|
112
121
|
end
|
113
122
|
current_commit = git.log(1).to_s
|
114
123
|
if current_commit != new_commit
|
115
|
-
|
124
|
+
LgPodPlugin.log_green "git pull #{name} #{git_url} -b #{branch}"
|
116
125
|
self.git_util.should_pull(git, current_branch, new_commit)
|
117
126
|
current_commit = new_commit
|
118
127
|
end
|
119
|
-
hash_map = {:git => git_url}
|
128
|
+
hash_map = { :git => git_url }
|
120
129
|
if current_commit
|
121
130
|
hash_map[:commit] = current_commit
|
122
131
|
end
|
123
132
|
SqliteDb.instance.insert_table(name, branch, current_commit, nil, real_pod_path)
|
124
|
-
LgPodPlugin::Cache.cache_pod(name,real_pod_path,is_update,hash_map)
|
133
|
+
LgPodPlugin::Cache.cache_pod(name, real_pod_path, is_update, hash_map)
|
125
134
|
end
|
126
135
|
|
127
|
-
|
128
136
|
end
|
129
137
|
|
130
138
|
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'pp'
|
2
2
|
require 'git'
|
3
|
+
require_relative 'cache'
|
3
4
|
|
4
5
|
module LgPodPlugin
|
5
6
|
|
6
7
|
class GitUtil
|
7
|
-
attr_accessor :git
|
8
|
-
attr_accessor :tag
|
9
|
-
attr_accessor :path
|
10
|
-
attr_accessor :name
|
11
|
-
attr_accessor :commit
|
12
|
-
attr_accessor :branch
|
13
|
-
attr_accessor :temp_git_path
|
8
|
+
# attr_accessor :git
|
9
|
+
# attr_accessor :tag
|
10
|
+
# attr_accessor :path
|
11
|
+
# attr_accessor :name
|
12
|
+
# attr_accessor :commit
|
13
|
+
# attr_accessor :branch
|
14
|
+
# attr_accessor :temp_git_path
|
15
|
+
REQUIRED_ATTRS ||= %i[git tag path name commit branch temp_git_path is_cache].freeze
|
16
|
+
attr_accessor(*REQUIRED_ATTRS)
|
17
|
+
|
14
18
|
def initialize
|
15
19
|
super
|
16
20
|
end
|
@@ -22,14 +26,14 @@ module LgPodPlugin
|
|
22
26
|
self.path = options[:path]
|
23
27
|
self.branch = options[:branch]
|
24
28
|
self.commit = options[:commit]
|
29
|
+
self.is_cache = options[:depth]
|
25
30
|
end
|
26
31
|
|
27
32
|
def git_clone(path)
|
28
33
|
if self.branch
|
29
34
|
temp_git_path = path.join("l-temp-pod")
|
30
|
-
|
35
|
+
LgPodPlugin.log_yellow "git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git}"
|
31
36
|
system("git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git} #{temp_git_path}")
|
32
|
-
puts "\n"
|
33
37
|
temp_git_path
|
34
38
|
else
|
35
39
|
nil
|
@@ -54,7 +58,7 @@ module LgPodPlugin
|
|
54
58
|
end
|
55
59
|
|
56
60
|
FileUtils.chdir(root_path)
|
57
|
-
temp_path = root_path.join("
|
61
|
+
temp_path = root_path.join("temp")
|
58
62
|
if temp_path.exist?
|
59
63
|
FileUtils.rm_r(temp_path)
|
60
64
|
end
|
@@ -66,18 +70,28 @@ module LgPodPlugin
|
|
66
70
|
unless get_temp_folder.exist?
|
67
71
|
return nil
|
68
72
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
73
|
+
|
74
|
+
if self.is_cache
|
75
|
+
pod_root_director = FileManager.download_pod_path(name)
|
76
|
+
unless pod_root_director.exist?
|
77
|
+
FileUtils.mkdir(pod_root_director)
|
78
|
+
end
|
79
|
+
FileUtils.mv(get_temp_folder, lg_pod_path)
|
80
|
+
temp_path.rmdir
|
81
|
+
lg_pod_path
|
82
|
+
else
|
83
|
+
commit = GitUtil.git_ls_remote_refs(self.git, self.branch)
|
84
|
+
LgPodPlugin::Cache.cache_pod(self.name, get_temp_folder, true, {:git => self.git, :commit => commit})
|
85
|
+
system("cd ..")
|
86
|
+
system("rm -rf #{get_temp_folder.to_path}")
|
87
|
+
return lg_pod_path
|
72
88
|
end
|
73
|
-
|
74
|
-
temp_path.rmdir
|
75
|
-
lg_pod_path
|
89
|
+
|
76
90
|
end
|
77
91
|
|
78
92
|
# 本地pod库git操作
|
79
|
-
def git_local_pod_check
|
80
|
-
FileUtils.chdir(
|
93
|
+
def git_local_pod_check(path)
|
94
|
+
FileUtils.chdir(path)
|
81
95
|
git = Git.open(Pathname("./"))
|
82
96
|
current_branch = git.current_branch
|
83
97
|
last_stash_message = "#{current_branch}_pod_install_cache"
|
@@ -107,16 +121,19 @@ module LgPodPlugin
|
|
107
121
|
# 获取最新的一条 commit 信息
|
108
122
|
def self.git_ls_remote_refs(git, branch)
|
109
123
|
last_commit = nil
|
110
|
-
|
124
|
+
LgPodPlugin.log_yellow "git ls-remote #{git} #{branch}"
|
111
125
|
sha = %x(git ls-remote #{git} #{branch}).split(" ").first
|
112
126
|
if sha
|
113
127
|
last_commit = sha
|
128
|
+
return last_commit
|
114
129
|
else
|
115
130
|
ls = Git.ls_remote(git, :refs => true )
|
116
131
|
find_branch = ls["branches"][branch]
|
117
132
|
if find_branch
|
118
133
|
last_commit = find_branch[:sha]
|
134
|
+
return last_commit
|
119
135
|
end
|
136
|
+
return nil
|
120
137
|
end
|
121
138
|
end
|
122
139
|
|
@@ -6,81 +6,126 @@ require 'cocoapods'
|
|
6
6
|
require_relative 'database'
|
7
7
|
require_relative 'download'
|
8
8
|
require_relative 'git_util'
|
9
|
-
require_relative 'pod_spec
|
9
|
+
require_relative 'pod_spec'
|
10
10
|
|
11
11
|
module LgPodPlugin
|
12
|
+
|
12
13
|
class Installer
|
13
|
-
|
14
|
-
|
15
|
-
attr_accessor
|
16
|
-
|
17
|
-
def initialize(
|
18
|
-
|
14
|
+
|
15
|
+
REQUIRED_ATTRS ||= %i[name version options profile target real_name downloader git_util].freeze
|
16
|
+
attr_accessor(*REQUIRED_ATTRS)
|
17
|
+
|
18
|
+
def initialize(profile, name, *requirements)
|
19
|
+
if name.include?("/")
|
20
|
+
self.name = name.split("/").first
|
21
|
+
else
|
22
|
+
self.name = name
|
23
|
+
end
|
24
|
+
self.real_name = name
|
19
25
|
self.profile = profile
|
20
26
|
self.git_util = GitUtil.new
|
21
27
|
self.downloader = Downloader.new
|
22
28
|
self.target = profile.send(:current_target_definition)
|
23
|
-
|
24
|
-
|
29
|
+
|
30
|
+
unless requirements && !requirements.empty?
|
31
|
+
self.lg_pod(self.real_name, requirements)
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
first = requirements[0].first
|
36
|
+
if "#{first.class}" == "String"
|
37
|
+
self.version = first
|
38
|
+
elsif "#{first.class}" == "Hash"
|
39
|
+
self.options = first
|
25
40
|
end
|
41
|
+
|
42
|
+
hash_map = requirements[0].last
|
43
|
+
if "#{hash_map.class}" == "Hash"
|
44
|
+
self.options = hash_map
|
45
|
+
end
|
46
|
+
|
47
|
+
self.lg_pod(name, requirements)
|
48
|
+
|
26
49
|
end
|
27
50
|
|
51
|
+
public
|
28
52
|
# @param [Object] name
|
29
53
|
# @param [Hash] options
|
30
54
|
# @return [Object] nil
|
31
|
-
def
|
55
|
+
def lg_pod(name, *requirements)
|
32
56
|
unless name
|
33
57
|
raise StandardError, 'A dependency requires a name.'
|
34
58
|
end
|
35
|
-
|
36
|
-
|
37
|
-
self.target.store_pod(
|
59
|
+
|
60
|
+
if !requirements
|
61
|
+
self.target.store_pod(self.real_name)
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
65
|
+
if self.version && !self.options
|
66
|
+
self.target.store_pod(self.real_name, self.version)
|
67
|
+
return
|
68
|
+
end
|
69
|
+
|
70
|
+
if self.version && self.options
|
71
|
+
hash_map = self.options
|
72
|
+
hash_map.delete(:depth)
|
73
|
+
self.target.store_pod(self.real_name, self.version, hash_map)
|
74
|
+
return
|
75
|
+
end
|
76
|
+
|
77
|
+
hash_map = self.options
|
78
|
+
unless hash_map.is_a?(Hash)
|
79
|
+
self.target.store_pod(self.real_name)
|
38
80
|
return
|
39
81
|
end
|
40
82
|
|
41
|
-
path = options[:path]
|
42
|
-
tag = options[:tag]
|
43
|
-
commit = options[:commit]
|
44
|
-
url = options[:git]
|
45
|
-
branch = options[:branch]
|
46
|
-
depth = options[:depth] ||= true
|
47
83
|
real_path = nil
|
48
|
-
|
84
|
+
tag = hash_map[:tag]
|
85
|
+
url = hash_map[:git]
|
86
|
+
path = hash_map[:path]
|
87
|
+
commit = hash_map[:commit]
|
88
|
+
branch = hash_map[:branch]
|
89
|
+
is_cache = options[:depth]
|
90
|
+
if path
|
49
91
|
profile_path = self.profile.send(:defined_in_file).dirname
|
50
92
|
real_path = Pathname.new(path).expand_path(profile_path)
|
51
93
|
end
|
52
94
|
# 找到本地组件库 执行 git pull
|
53
95
|
if real_path && File.directory?(real_path)
|
54
|
-
|
96
|
+
hash_map[:path] = real_path
|
97
|
+
hash_map.delete(:depth)
|
98
|
+
self.install_local_pod(self.name, hash_map)
|
55
99
|
return
|
56
100
|
end
|
57
101
|
|
58
102
|
# 根据tag, commit下载文件
|
59
|
-
hash_map = options
|
60
103
|
hash_map.delete(:path)
|
61
|
-
if tag || commit
|
62
|
-
hash_map.delete(:branch)
|
104
|
+
if (tag && url) || (commit && url)
|
63
105
|
hash_map.delete(:depth)
|
64
|
-
|
106
|
+
hash_map.delete(:branch)
|
107
|
+
self.target.store_pod(self.real_name, hash_map)
|
65
108
|
return
|
66
109
|
end
|
67
110
|
|
68
111
|
# 根据 branch 下载代码
|
69
|
-
if url
|
112
|
+
if url
|
70
113
|
hash_map.delete(:tag)
|
71
114
|
hash_map.delete(:commit)
|
72
|
-
|
73
|
-
self.downloader.download_init(name, options)
|
115
|
+
self.downloader.download_init(self.name, hash_map)
|
74
116
|
self.downloader.pre_download_pod(self.git_util)
|
75
|
-
|
117
|
+
hash_map.delete(:depth)
|
118
|
+
self.target.store_pod(self.real_name, hash_map)
|
76
119
|
end
|
77
120
|
|
121
|
+
|
78
122
|
end
|
79
123
|
|
124
|
+
public
|
80
125
|
def install_form_specs(spec_path = nil)
|
81
126
|
spec_path ||= './Specs'
|
82
127
|
path = File.expand_path(spec_path, Dir.pwd)
|
83
|
-
file_objects = Dir.glob(File.expand_path("*.rb",path)).map do |file_path|
|
128
|
+
file_objects = Dir.glob(File.expand_path("*.rb", path)).map do |file_path|
|
84
129
|
#读取 xxx.rb文件
|
85
130
|
Spec.form_file(file_path)
|
86
131
|
end
|
@@ -88,34 +133,36 @@ module LgPodPlugin
|
|
88
133
|
file_objects.each do |file|
|
89
134
|
if file.install
|
90
135
|
options = file.pod_requirements
|
91
|
-
self.
|
136
|
+
self.lg_pod(file.name, options)
|
92
137
|
end
|
93
138
|
end
|
94
139
|
|
95
140
|
end
|
96
141
|
|
97
|
-
|
142
|
+
public
|
98
143
|
def install_local_pod(name, options = {})
|
99
144
|
hash_map = options
|
100
|
-
|
145
|
+
local_path = options[:path]
|
101
146
|
branch = options[:branch]
|
102
|
-
unless Dir.
|
103
|
-
|
147
|
+
unless Dir.glob(File.expand_path(".git", local_path)).count > 0
|
148
|
+
LgPodPlugin.log_red("pod `#{name}` at path => #{local_path} 找不到.git目录")
|
104
149
|
return
|
105
150
|
end
|
106
|
-
local_path
|
107
|
-
|
108
|
-
|
151
|
+
unless Dir.glob(File.expand_path("#{name}.podspec", local_path)).count > 0
|
152
|
+
LgPodPlugin.log_red("pod `#{name}` at path => #{local_path} 找不到#{name}.podspec文件")
|
153
|
+
return
|
109
154
|
end
|
155
|
+
|
110
156
|
self.git_util.git_init(name, :branch => branch, :path => local_path)
|
111
|
-
self.git_util.git_local_pod_check
|
157
|
+
self.git_util.git_local_pod_check(local_path)
|
158
|
+
hash_map[:path] = local_path.to_path
|
112
159
|
hash_map.delete(:tag)
|
113
160
|
hash_map.delete(:git)
|
114
161
|
hash_map.delete(:depth)
|
115
162
|
hash_map.delete(:commit)
|
116
163
|
hash_map.delete(:branch)
|
117
164
|
# 安装本地私有组件库
|
118
|
-
self.target.store_pod(
|
165
|
+
self.target.store_pod(self.real_name, hash_map)
|
119
166
|
end
|
120
167
|
|
121
168
|
end
|
data/lib/lg_pod_plugin.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'git'
|
2
2
|
require 'sqlite3'
|
3
3
|
require "lg_pod_plugin/version"
|
4
|
+
require 'cocoapods/user_interface'
|
4
5
|
require_relative 'lg_pod_plugin/database'
|
5
6
|
require_relative 'lg_pod_plugin/download'
|
6
7
|
require_relative 'lg_pod_plugin/git_util'
|
@@ -10,17 +11,65 @@ require 'cocoapods-core/podfile/target_definition'
|
|
10
11
|
|
11
12
|
module LgPodPlugin
|
12
13
|
|
14
|
+
class String
|
15
|
+
# colorization
|
16
|
+
def colorize(color_code)
|
17
|
+
"\e[#{color_code}m#{self}\e[0m"
|
18
|
+
end
|
19
|
+
|
20
|
+
def red
|
21
|
+
colorize(31)
|
22
|
+
end
|
23
|
+
|
24
|
+
def green
|
25
|
+
colorize(32)
|
26
|
+
end
|
27
|
+
|
28
|
+
def yellow
|
29
|
+
colorize(33)
|
30
|
+
end
|
31
|
+
|
32
|
+
def blue
|
33
|
+
colorize(34)
|
34
|
+
end
|
35
|
+
|
36
|
+
def pink
|
37
|
+
colorize(35)
|
38
|
+
end
|
39
|
+
|
40
|
+
def light_blue
|
41
|
+
colorize(36)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
13
45
|
class Error < StandardError; end
|
14
|
-
|
15
|
-
def self.
|
16
|
-
|
46
|
+
|
47
|
+
def self.log_red(msg)
|
48
|
+
Pod::CoreUI.puts msg.red
|
17
49
|
end
|
18
50
|
|
19
|
-
|
20
|
-
|
21
|
-
return Installer.new(profile).install_form_specs(spec_path)
|
51
|
+
def self.log_blue(msg)
|
52
|
+
Pod::CoreUI.puts msg.blue
|
22
53
|
end
|
23
54
|
|
24
|
-
|
55
|
+
def self.log_green(msg)
|
56
|
+
Pod::CoreUI.puts msg.green
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.log_yellow(msg)
|
60
|
+
Pod::CoreUI.puts msg.yellow
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.log(msg)
|
64
|
+
Pod::CoreUI.puts msg
|
65
|
+
end
|
66
|
+
|
67
|
+
public
|
68
|
+
# 对 Profile 方法进行拓展
|
69
|
+
def pod(name, *requirements)
|
70
|
+
Installer.new(self, name, requirements)
|
71
|
+
end
|
72
|
+
|
73
|
+
|
25
74
|
end
|
26
75
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lg_pod_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dongzb01
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -111,14 +111,12 @@ dependencies:
|
|
111
111
|
description: 拦截pod_install 方法, 并设置 pod 方法参数列表
|
112
112
|
email:
|
113
113
|
- 1060545231@qq.com
|
114
|
-
executables:
|
115
|
-
- lg
|
114
|
+
executables: []
|
116
115
|
extensions: []
|
117
116
|
extra_rdoc_files: []
|
118
117
|
files:
|
119
118
|
- LICENSE
|
120
119
|
- README.md
|
121
|
-
- bin/lg
|
122
120
|
- lib/command/cache.rb
|
123
121
|
- lib/command/command.rb
|
124
122
|
- lib/lg_pod_plugin.rb
|