lg_pod_plugin 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b53208ed4fa32c2ca693aaa0b1d960ba2699e0a1b5e89c521123f489c35dc9b
4
- data.tar.gz: da8650d3f68524a9b25667094edc57386509ef86c7ca90c1dacd350365efe8ea
3
+ metadata.gz: 872508947b930ee5b91b49de9ccba4fe2bd74aedc1dfcb829ccb470d140c1165
4
+ data.tar.gz: 1882ba4f26ae21d1d2f821911339adb0e8fc3d39fa6c12537cf7800c7d57d4eb
5
5
  SHA512:
6
- metadata.gz: 42d727f09c1e37babdde7cc562af7c5301e11813b37768d138b57bb76f3fe28e40ad1e1fc3d81db341fa5c901275e2c894778814a285768240fbbff872368b84
7
- data.tar.gz: 3ce6ae923d9c7c8af2a5a514d137935efeb111607b1bc52c49e4bd7c130c48153857816efd67c07b8b77e80110e5710c25da861316d70339993377fc866f3027
6
+ metadata.gz: d43f347f17d5fce098ff285abbf4b843f982c6d6e108dbe72a5c6e1da809859558092830a241b97955c0adecdaafc601eb9ec971a316e39cf906797a547be184
7
+ data.tar.gz: d0de1ffeb0bf00948b7ab8953c2d04792b401ef681095b65029f4b7af966592c1a5e1dc2c8987c0f20097ae54b6d42316b4564e55e3b6d1811419363c15917ae
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ 安装和使用教程: https://juejin.cn/post/7142388587852464135
1
2
  # LgPodPlugin
2
3
 
3
4
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lg_pod_plugin`. To experiment with that code, run `bin/console` for an interactive prompt.
data/bin/lg ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ puts "这是我的第一个ruby项目"
3
+ puts ENV["NAME"]
4
+ puts ARGV
5
+
6
+ # require 'command/command'
7
+ #
8
+ # LgPodPlugin::Command.run(ARGV)
@@ -0,0 +1,18 @@
1
+ # require 'claide'
2
+ #
3
+ # module LgPodPlugin
4
+ # class Cache < Command
5
+ # self.abstract_command = true
6
+ # self.summary = 'Inter-process communication'
7
+ # def initialize(argv)
8
+ #
9
+ # end
10
+ # def output_pipe
11
+ # pp "hello world"
12
+ # end
13
+ #
14
+ # def run
15
+ # pp "run"
16
+ # end
17
+ # end
18
+ # end
@@ -0,0 +1,35 @@
1
+ # require 'claide'
2
+ #
3
+ # module LgPodPlugin
4
+ # class Command < CLAide::Command
5
+ # require_relative './cache'
6
+ #
7
+ # self.abstract_command = true
8
+ # self.command = 'pod'
9
+ # self.version = VERSION
10
+ # self.description = 'this is my command lint tool!'
11
+ # self.plugin_prefixes = %w(claide cocoapods)
12
+ #
13
+ # def self.options
14
+ # [
15
+ # ['--allow-root', 'Allows CocoaPods to run as root'],
16
+ # ['--silent', 'Show nothing'],
17
+ # ].concat(super)
18
+ # end
19
+ #
20
+ # def self.run(argv)
21
+ # super(argv)
22
+ # end
23
+ #
24
+ # def initialize(argv)
25
+ # super
26
+ # # config.silent = argv.flag?('silent', config.silent)
27
+ # # config.allow_root = argv.flag?('allow-root', config.allow_root)
28
+ # # config.verbose = self.verbose? unless verbose.nil?
29
+ # unless self.ansi_output?
30
+ # Colored2.disable!
31
+ # String.send(:define_method, :colorize) { |string, _| string }
32
+ # end
33
+ # end
34
+ # end
35
+ # end
@@ -28,24 +28,15 @@ class Cache
28
28
  #判断缓存是否存在且有效命中缓存
29
29
  def find_pod_cache(name ,git, branch, is_update)
30
30
  last_commit = nil
31
-
32
31
  if is_update
33
- puts "git ls-remote #{git} #{branch}"
34
- sha = %x(git ls-remote #{git} #{branch}).split(" ").first
35
- if sha
36
- last_commit = sha
37
- else
38
- ls = Git.ls_remote(git, :refs => true )
39
- find_branch = ls["branches"][branch]
40
- if find_branch
41
- last_commit = find_branch[:sha]
42
- end
43
- end
32
+ last_commit = GitUtil.git_ls_remote_refs(git, branch)
44
33
  else
45
34
  local_pod_path = self.get_download_path(name, git, branch)
46
35
  if Dir.exist?(local_pod_path)
47
36
  local_git = Git.open(Pathname("#{local_pod_path}"))
48
37
  last_commit = local_git.log(1).to_s
38
+ else
39
+ last_commit = GitUtil.git_ls_remote_refs(git, branch)
49
40
  end
50
41
  end
51
42
  unless last_commit
@@ -50,14 +50,14 @@ module LgPodPlugin
50
50
  self.git_util = git
51
51
  is_update = self.is_update_pod
52
52
  self.git_util.git_init(self.name, self.options)
53
- # if name == "LAddressComponents" || name == "LLogger" || name == "LUnityFramework" || name == "LUser"
53
+ # if name == "LBase" || name == "LLogger" || name == "LUnityFramework" || name == "LUser"
54
54
  # pp name
55
55
  # end
56
56
  # tag = options[:tag]
57
57
  git_url = options[:git]
58
58
  # commit = options[:commit]
59
59
  branch = options[:branch]
60
- puts "Pre-downloading: `#{name}` \n"
60
+ puts "Using `#{name}` (#{branch})\n"
61
61
 
62
62
  # 发现本地有缓存, 不需要更新缓存
63
63
  need_download, new_commit = self.cache.find_pod_cache(name, git_url, branch, is_update)
@@ -81,7 +81,7 @@ module LgPodPlugin
81
81
  git = Git.open(Pathname("./"))
82
82
  current_branch = git.current_branch
83
83
  last_stash_message = "#{current_branch}_pod_install_cache"
84
- if self.branch == current_branch
84
+ if self.branch == current_branch || !self.branch
85
85
  # 是否恢复储藏内容到暂存区
86
86
  self.should_pull(git ,current_branch)
87
87
  else
@@ -104,12 +104,27 @@ module LgPodPlugin
104
104
  end
105
105
  end
106
106
 
107
+ # 获取最新的一条 commit 信息
108
+ def self.git_ls_remote_refs(git, branch)
109
+ last_commit = nil
110
+ puts "git ls-remote #{git} #{branch}"
111
+ sha = %x(git ls-remote #{git} #{branch}).split(" ").first
112
+ if sha
113
+ last_commit = sha
114
+ else
115
+ ls = Git.ls_remote(git, :refs => true )
116
+ find_branch = ls["branches"][branch]
117
+ if find_branch
118
+ last_commit = find_branch[:sha]
119
+ end
120
+ end
121
+ end
122
+
107
123
  # 是否pull 代码
108
124
  def should_pull(git, branch, new_commit = nil)
109
125
  git_url = git.remote.url
110
126
  if new_commit == nil
111
- puts "git ls-remote #{git_url} #{branch}"
112
- new_commit = %x(git ls-remote #{git_url} #{branch}).split(" ").first
127
+ new_commit = GitUtil.git_ls_remote_refs(git_url, branch)
113
128
  end
114
129
  local_commit = git.log(1).to_s #本地最后一条 commit hash 值
115
130
  if local_commit != new_commit
@@ -10,13 +10,16 @@ require_relative 'pod_spec.rb'
10
10
 
11
11
  module LgPodPlugin
12
12
  class Installer
13
+ attr_accessor :profile
14
+ attr_accessor :target
13
15
  attr_accessor :downloader
14
16
  attr_accessor :git_util
15
17
  def initialize(defined_in_file = nil, profile, &block)
16
18
  @defined_in_file = defined_in_file
17
- @target = profile.send(:current_target_definition)
19
+ self.profile = profile
18
20
  self.git_util = GitUtil.new
19
21
  self.downloader = Downloader.new
22
+ self.target = profile.send(:current_target_definition)
20
23
  if block
21
24
  instance_eval(&block)
22
25
  end
@@ -31,7 +34,7 @@ module LgPodPlugin
31
34
  end
32
35
  if options[0].is_a?(String)
33
36
  version = options[0].to_s
34
- @target.store_pod(name, version)
37
+ self.target.store_pod(name, version)
35
38
  return
36
39
  end
37
40
 
@@ -41,9 +44,13 @@ module LgPodPlugin
41
44
  url = options[:git]
42
45
  branch = options[:branch]
43
46
  depth = options[:depth] ||= true
44
-
47
+ real_path = nil
48
+ if path
49
+ profile_path = self.profile.send(:defined_in_file).dirname
50
+ real_path = Pathname.new(path).expand_path(profile_path)
51
+ end
45
52
  # 找到本地组件库 执行 git pull
46
- if path && File.directory?(path)
53
+ if real_path && File.directory?(real_path)
47
54
  self.install_local_pod(name, options)
48
55
  return
49
56
  end
@@ -54,7 +61,7 @@ module LgPodPlugin
54
61
  if tag || commit
55
62
  hash_map.delete(:branch)
56
63
  hash_map.delete(:depth)
57
- @target.store_pod(name, hash_map)
64
+ self.target.store_pod(name, hash_map)
58
65
  return
59
66
  end
60
67
 
@@ -65,7 +72,7 @@ module LgPodPlugin
65
72
  hash_map.delete(:depth)
66
73
  self.downloader.download_init(name, options)
67
74
  self.downloader.pre_download_pod(self.git_util)
68
- @target.store_pod(name, hash_map)
75
+ self.target.store_pod(name, hash_map)
69
76
  end
70
77
 
71
78
  end
@@ -108,7 +115,7 @@ module LgPodPlugin
108
115
  hash_map.delete(:commit)
109
116
  hash_map.delete(:branch)
110
117
  # 安装本地私有组件库
111
- @target.store_pod(name, hash_map)
118
+ self.target.store_pod(name, hash_map)
112
119
  end
113
120
 
114
121
  end
@@ -1,3 +1,3 @@
1
1
  module LgPodPlugin
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/lg_pod_plugin.rb CHANGED
@@ -6,18 +6,21 @@ require_relative 'lg_pod_plugin/download'
6
6
  require_relative 'lg_pod_plugin/git_util'
7
7
  require_relative 'lg_pod_plugin/pod_spec'
8
8
  require_relative 'lg_pod_plugin/install'
9
+ require 'cocoapods-core/podfile/target_definition'
9
10
 
10
11
  module LgPodPlugin
11
12
 
12
13
  class Error < StandardError; end
13
-
14
+ # 在已经存在target下边安装pod
14
15
  def self.install(defined_in_file = nil, profile, &block)
15
16
  Installer.new(defined_in_file, profile, &block)
16
17
  end
17
18
 
19
+ # 通过spec文件安装
18
20
  def self.install_form_spec(profile, spec_path = nil)
19
21
  return Installer.new(profile).install_form_specs(spec_path)
20
22
  end
21
23
 
24
+ # autoload :Command, '../lib/command/command'
22
25
  end
23
26
 
metadata CHANGED
@@ -1,27 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lg_pod_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-10 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: claide
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: sqlite3
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - '='
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
33
  version: 1.4.4
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - '='
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: 1.4.4
27
41
  - !ruby/object:Gem::Dependency
@@ -56,67 +70,57 @@ dependencies:
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '='
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
75
  version: 13.0.6
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '='
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: 13.0.6
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: git
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '='
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
89
  version: 1.12.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '='
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: 1.12.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: cocoapods
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 1.11.3
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 1.11.3
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.0'
103
+ version: 1.11.3
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.0'
110
+ version: 1.11.3
111
111
  description: 拦截pod_install 方法, 并设置 pod 方法参数列表
112
112
  email:
113
113
  - 1060545231@qq.com
114
- executables: []
114
+ executables:
115
+ - lg
115
116
  extensions: []
116
117
  extra_rdoc_files: []
117
118
  files:
118
119
  - LICENSE
119
120
  - README.md
121
+ - bin/lg
122
+ - lib/command/cache.rb
123
+ - lib/command/command.rb
120
124
  - lib/lg_pod_plugin.rb
121
125
  - lib/lg_pod_plugin/cache.rb
122
126
  - lib/lg_pod_plugin/database.rb
@@ -145,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
149
  - !ruby/object:Gem::Version
146
150
  version: '0'
147
151
  requirements: []
148
- rubygems_version: 3.1.6
152
+ rubygems_version: 3.3.22
149
153
  signing_key:
150
154
  specification_version: 4
151
155
  summary: 封装了自定义podfile 中pod 方法