lg_pod_plugin 1.1.6.6 → 1.1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/lib/command/command.rb +1 -0
  3. data/lib/command/doctor.rb +31 -0
  4. data/lib/command/init.rb +36 -8
  5. data/lib/command/install.rb +1 -1
  6. data/lib/command/update.rb +1 -1
  7. data/lib/lg_pod_plugin/config/l_config.rb +6 -19
  8. data/lib/lg_pod_plugin/db/database.rb +116 -110
  9. data/lib/lg_pod_plugin/downloader/downloader.rb +7 -6
  10. data/lib/lg_pod_plugin/downloader/l_cache.rb +11 -2
  11. data/lib/lg_pod_plugin/downloader/overload_cache.rb +329 -0
  12. data/lib/lg_pod_plugin/downloader/request.rb +32 -32
  13. data/lib/lg_pod_plugin/git/gitlab_api.rb +102 -5
  14. data/lib/lg_pod_plugin/installer/PodDownload +0 -0
  15. data/lib/lg_pod_plugin/installer/install.rb +1 -4
  16. data/lib/lg_pod_plugin/installer/main.rb +0 -1
  17. data/lib/lg_pod_plugin/installer/project.rb +2 -7
  18. data/lib/lg_pod_plugin/net/l_uri.rb +0 -7
  19. data/lib/lg_pod_plugin/pod/release-pod.rb +11 -42
  20. data/lib/lg_pod_plugin/utils/l_util.rb +9 -9
  21. data/lib/lg_pod_plugin/version.rb +1 -1
  22. data/lib/lg_pod_plugin.rb +1 -0
  23. metadata +29 -119
  24. data/lib/sqlite3-1.5.3-arm64-darwin/API_CHANGES.md +0 -49
  25. data/lib/sqlite3-1.5.3-arm64-darwin/CHANGELOG.md +0 -462
  26. data/lib/sqlite3-1.5.3-arm64-darwin/CONTRIBUTING.md +0 -24
  27. data/lib/sqlite3-1.5.3-arm64-darwin/ChangeLog.cvs +0 -88
  28. data/lib/sqlite3-1.5.3-arm64-darwin/README.md +0 -235
  29. data/lib/sqlite3-1.5.3-arm64-darwin/dependencies.yml +0 -14
  30. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.c +0 -274
  31. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.h +0 -12
  32. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.c +0 -168
  33. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.h +0 -15
  34. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.c +0 -853
  35. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.h +0 -17
  36. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.c +0 -98
  37. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.h +0 -8
  38. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/extconf.rb +0 -251
  39. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3.c +0 -163
  40. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3_ruby.h +0 -48
  41. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.c +0 -442
  42. data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.h +0 -16
  43. data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.md +0 -431
  44. data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.rb +0 -145
  45. data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.yml +0 -426
  46. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
  47. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
  48. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
  49. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
  50. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.2/sqlite3_native.bundle +0 -0
  51. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/constants.rb +0 -50
  52. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/database.rb +0 -741
  53. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/errors.rb +0 -35
  54. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/pragmas.rb +0 -595
  55. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/resultset.rb +0 -187
  56. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/statement.rb +0 -145
  57. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/translator.rb +0 -118
  58. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb +0 -57
  59. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/version.rb +0 -23
  60. data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3.rb +0 -15
  61. data/lib/sqlite3-1.5.3-arm64-darwin/test/helper.rb +0 -27
  62. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_backup.rb +0 -33
  63. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_collation.rb +0 -82
  64. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database.rb +0 -545
  65. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb +0 -95
  66. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb +0 -36
  67. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb +0 -41
  68. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_deprecated.rb +0 -44
  69. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_encoding.rb +0 -155
  70. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration.rb +0 -507
  71. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_aggregate.rb +0 -336
  72. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_open_close.rb +0 -30
  73. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_pending.rb +0 -115
  74. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_resultset.rb +0 -142
  75. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_statement.rb +0 -194
  76. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb +0 -37
  77. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_sqlite3.rb +0 -30
  78. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement.rb +0 -263
  79. data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb +0 -35
  80. data/lib/sqlite3-1.5.3-x86_64-darwin/API_CHANGES.md +0 -49
  81. data/lib/sqlite3-1.5.3-x86_64-darwin/CHANGELOG.md +0 -462
  82. data/lib/sqlite3-1.5.3-x86_64-darwin/CONTRIBUTING.md +0 -24
  83. data/lib/sqlite3-1.5.3-x86_64-darwin/ChangeLog.cvs +0 -88
  84. data/lib/sqlite3-1.5.3-x86_64-darwin/README.md +0 -235
  85. data/lib/sqlite3-1.5.3-x86_64-darwin/dependencies.yml +0 -14
  86. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.c +0 -274
  87. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.h +0 -12
  88. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.c +0 -168
  89. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.h +0 -15
  90. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.c +0 -853
  91. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.h +0 -17
  92. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.c +0 -98
  93. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.h +0 -8
  94. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/extconf.rb +0 -251
  95. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3.c +0 -163
  96. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3_ruby.h +0 -48
  97. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.c +0 -442
  98. data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.h +0 -16
  99. data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.md +0 -431
  100. data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.rb +0 -145
  101. data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.yml +0 -426
  102. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
  103. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
  104. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
  105. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
  106. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.2/sqlite3_native.bundle +0 -0
  107. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/constants.rb +0 -50
  108. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/database.rb +0 -741
  109. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/errors.rb +0 -35
  110. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/pragmas.rb +0 -595
  111. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/resultset.rb +0 -187
  112. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/statement.rb +0 -145
  113. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/translator.rb +0 -118
  114. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/value.rb +0 -57
  115. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/version.rb +0 -23
  116. data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3.rb +0 -15
  117. data/lib/sqlite3-1.5.3-x86_64-darwin/test/helper.rb +0 -27
  118. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_backup.rb +0 -33
  119. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_collation.rb +0 -82
  120. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database.rb +0 -545
  121. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_flags.rb +0 -95
  122. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readonly.rb +0 -36
  123. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readwrite.rb +0 -41
  124. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_deprecated.rb +0 -44
  125. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_encoding.rb +0 -155
  126. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration.rb +0 -507
  127. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_aggregate.rb +0 -336
  128. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_open_close.rb +0 -30
  129. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_pending.rb +0 -115
  130. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_resultset.rb +0 -142
  131. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_statement.rb +0 -194
  132. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_result_set.rb +0 -37
  133. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_sqlite3.rb +0 -30
  134. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement.rb +0 -263
  135. data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement_execute.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49669409fc52a28372c3033cd25e908b939267d30147689f982b84c9cea0d748
4
- data.tar.gz: ddd14338375b62677fd81ee52e0a3f15170b58a852870c203b3a27f2121a7151
3
+ metadata.gz: 44d4ceb34301dcc5a0312f8591cdbde166e1a4b7e2cb8a885738fa6997192de8
4
+ data.tar.gz: 0f770eba1a322ed7294d68d7ed81f9aef997f546a0d9c3c61f315cb563824e8d
5
5
  SHA512:
6
- metadata.gz: 2a9bb5866675919b09e0ebcad919085431ec96eb103caa56477356a833e9369365e9fed62506c8919866d4c6ae8ecb2bfb918a5dd22dc956cf16adc28cc674c7
7
- data.tar.gz: 85604ebf38280f2c65d929dcf60c0af3a29434b244290a4f67682b337090f81e8fc93e51bd165ee10529d0ee1bd826c9ac794894e344732fc93ebbf3531c1a37
6
+ metadata.gz: 06506e9cd1131a5932ea3e550cc641832f13f194cd9427edfafcff2bcdd93758da909a8f0542c282869be565b23f42b80fee02c2e0ae52515eabefee433bcbb3
7
+ data.tar.gz: 72be08ac45145844d3c7082bdf1fe53e68b8892ac3bef7b9c58d6bfabe35448c2033290e66aace828a3397490e641926c8a7297c5480eb4b6cb61770da2ebc41
@@ -6,6 +6,7 @@ module LgPodPlugin
6
6
  require_relative 'update'
7
7
  require_relative 'init'
8
8
  require_relative 'install'
9
+ require_relative 'doctor'
9
10
  self.command = 'lg'
10
11
  self.version = VERSION
11
12
  self.abstract_command = true
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require 'claide'
3
+ require_relative 'command'
4
+
5
+ module LgPodPlugin
6
+ class Command
7
+ class Doctor < Command
8
+ self.abstract_command = false
9
+ self.summary = 'Manipulate the CocoaPods cache'
10
+
11
+ self.description = <<-DESC
12
+ Manipulate the download cache for pods, like printing the cache content
13
+ or cleaning the pods cache.
14
+ DESC
15
+
16
+ def initialize(argv)
17
+ # pp argv
18
+ super
19
+ end
20
+
21
+ def run
22
+ pwd = Pathname.new(File.dirname(__FILE__)).realpath
23
+ exexPath = pwd.parent.join("lg_pod_plugin/installer")
24
+ FileUtils.chdir exexPath
25
+ pp "sudo xattr -rd com.apple.quarantine ./PodDownload"
26
+ result = %x(sudo xattr -rd com.apple.quarantine ./PodDownload)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
data/lib/command/init.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'claide'
2
+ require 'json'
2
3
  require_relative 'command'
3
4
 
4
5
  module LgPodPlugin
@@ -7,8 +8,7 @@ module LgPodPlugin
7
8
  self.command = "init"
8
9
  self.abstract_command = false
9
10
  self.summary = '初始化gitlab projects 信息'
10
- attr_accessor :username
11
- attr_accessor :password
11
+ attr_accessor :token
12
12
  attr_accessor :host
13
13
  self.description = <<-DESC
14
14
  Manipulate the download cache for pods, like printing the cache content
@@ -17,16 +17,44 @@ module LgPodPlugin
17
17
 
18
18
  def initialize(argv)
19
19
  self.host = argv.option('host')
20
- self.username = argv.option('username')
21
- self.password = argv.option('password')
20
+ self.token = argv.option('token')
22
21
  super
23
22
  end
24
23
 
25
24
  def run
26
- raise unless self.host
27
- raise unless self.username
28
- raise unless self.password
29
- GitLabAPI.request_gitlab_access_token(self.host, self.username, self.password)
25
+ if self.host.nil? || self.host == ""
26
+ LgPodPlugin.log_red "传入host不能为空"
27
+ return
28
+ end
29
+ if self.token.nil? || self.token == ""
30
+ LgPodPlugin.log_red "传入token不能为空"
31
+ return
32
+ end
33
+ token_vaild = GitLabAPI.request_user_emails(self.host, self.token)
34
+ if token_vaild == "invalid token"
35
+ LgPodPlugin.log_red "无效的access_token, 请检查私人令牌是否在有限期内"
36
+ return
37
+ end
38
+ refresh_token = ""
39
+ expires_in = 7879680
40
+ created_at = Time.now.to_i
41
+ encrypt_access_token = LUtils.encrypt(self.token, "AZMpxzVxzbo3sFDLRZMpxzVxzbo3sFDZ")
42
+ hash = {"access_token": encrypt_access_token}
43
+ hash["token_type"] = "Bearer"
44
+ hash["expires_in"] = expires_in
45
+ hash["scope"] = "api"
46
+ hash["created_at"] = created_at
47
+ hash["refresh_token"] = refresh_token
48
+ db_path = LFileManager.download_director.join("database")
49
+ db_path.mkdir unless db_path.exist?
50
+ token_file = db_path.join("access_token.json")
51
+ str = JSON.generate(hash)
52
+ File.open(token_file.to_path, 'w+') { |f| f.write(str) }
53
+ LSqliteDb.shared.init_database
54
+ user_id = LUserAuthInfo.get_user_id(self.host)
55
+ user_model = LUserAuthInfo.new(user_id, "", "", self.host, self.token, "", (created_at + expires_in))
56
+ LSqliteDb.shared.insert_user_info(user_model)
57
+ LgPodPlugin.log_green "设置私人访问令牌成功"
30
58
  end
31
59
 
32
60
  end
@@ -42,7 +42,7 @@ module LgPodPlugin
42
42
  self.log = argv.flag?('verbose')
43
43
  repo_flag = argv.flag?('repo-update')
44
44
  if repo_flag.nil?
45
- self.repo_update = true
45
+ self.repo_update = false
46
46
  else
47
47
  self.repo_update = repo_flag
48
48
  end
@@ -29,7 +29,7 @@ module LgPodPlugin
29
29
  self.log = argv.flag?('verbose')
30
30
  repo_flag = argv.flag?('repo-update')
31
31
  if repo_flag.nil?
32
- self.repo_update = true
32
+ self.repo_update = false
33
33
  else
34
34
  self.repo_update = repo_flag
35
35
  end
@@ -17,29 +17,16 @@ module LgPodPlugin
17
17
 
18
18
  public
19
19
  def self.get_config(git, uri)
20
- return nil unless uri&.host
20
+ return nil unless uri&.hostname
21
21
  return nil unless LUtils.is_gitlab_uri(git, uri.hostname)
22
22
  user_id = LUserAuthInfo.get_user_id(uri.hostname)
23
23
  user_info = LSqliteDb.shared.query_user_info(user_id)
24
- # 用户授权 token 不存在, 提示用户输入用户名密码
25
- unless user_info
26
- user_info = GitLabAPI.get_gitlab_access_token_input(uri, user_id,nil ,nil )
27
- return nil unless user_info
28
- end
29
- time_now = Time.now.to_i
30
- # 判断 token 是否失效
31
- if user_info.expires_in <= time_now
32
- # 刷新 token 失败时, 通过已经保存的用户名密码来刷新 token
33
- new_user_info = GitLabAPI.refresh_gitlab_access_token uri.hostname, user_info.refresh_token
34
- if new_user_info.nil?
35
- username = user_info.username
36
- password = user_info.password
37
- user_info = GitLabAPI.get_gitlab_access_token_input(uri, user_id, username, password)
38
- return nil unless user_info
39
- else
40
- user_info = new_user_info
41
- end
24
+ if user_info != nil
25
+ user_info = GitLabAPI.check_gitlab_access_token_valid(uri, user_info)
26
+ else
27
+ user_info = GitLabAPI.get_gitlab_access_token(uri, user_id)
42
28
  end
29
+ return nil unless user_info
43
30
  config = LConfig.new
44
31
  config.host = uri.hostname
45
32
  config.access_token = user_info.access_token
@@ -1,10 +1,6 @@
1
1
  require 'singleton'
2
- arch = %x(ruby -v)
3
- if arch.include?("arm64")
4
- require_relative '../../sqlite3-1.5.3-arm64-darwin/lib/sqlite3'
5
- else
6
- require_relative '../../sqlite3-1.5.3-x86_64-darwin/lib/sqlite3'
7
- end
2
+ # arch = %x(ruby -v)
3
+ require 'sqlite3'
8
4
  module LgPodPlugin
9
5
 
10
6
  class ProjectModel
@@ -25,41 +21,42 @@ module LgPodPlugin
25
21
 
26
22
  end
27
23
 
28
- class LPodLatestRefs
29
- attr_accessor :id
30
- attr_accessor :name
31
- attr_accessor :tag
32
- attr_accessor :git
33
- attr_accessor :branch
34
- attr_accessor :commit
35
-
36
- def initialize(id, name, git, branch, tag, commit)
37
- self.id = id
38
- self.git = git
39
- self.tag = tag
40
- self.name = name
41
- self.branch = branch
42
- self.commit = commit
43
- end
44
-
45
- def self.get_pod_id(name, git, branch)
46
- key = name + git + branch
47
- return Digest::MD5.hexdigest(key)
48
- end
49
-
50
- end
24
+ # class LPodLatestRefs
25
+ # attr_accessor :id
26
+ # attr_accessor :name
27
+ # attr_accessor :tag
28
+ # attr_accessor :git
29
+ # attr_accessor :branch
30
+ # attr_accessor :commit
31
+ #
32
+ # def initialize(id, name, git, branch, tag, commit)
33
+ # self.id = id
34
+ # self.git = git
35
+ # self.tag = tag
36
+ # self.name = name
37
+ # self.branch = branch
38
+ # self.commit = commit
39
+ # end
40
+ #
41
+ # def self.get_pod_id(name, git, branch)
42
+ # key = name + git + branch
43
+ # return Digest::MD5.hexdigest(key)
44
+ # end
45
+ #
46
+ # end
51
47
 
52
48
  class LUserAuthInfo
53
- REQUIRED_ATTRS ||= %i[id username password host access_token refresh_token expires_in].freeze
49
+ REQUIRED_ATTRS ||= %i[id username password host access_token refresh_token expires_in update_time].freeze
54
50
  attr_accessor(*REQUIRED_ATTRS)
55
51
 
56
- def initialize(id = nil, name = nil, pwd = nil, host = nil, token = nil, refresh_token = nil, time = nil)
52
+ def initialize(id = nil, name = nil, pwd = nil, host = nil, token = nil, refresh_token = nil, time = nil, update_time = nil)
57
53
  self.id = id
58
54
  self.host = host
59
55
  self.password = pwd
60
56
  self.username = name
61
57
  self.expires_in = time
62
58
  self.access_token = token
59
+ self.update_time = update_time
63
60
  self.refresh_token = refresh_token
64
61
  end
65
62
 
@@ -110,6 +107,13 @@ module LgPodPlugin
110
107
  expires_in TimeStamp NOT NULL DEFAULT CURRENT_TIMESTAMP);"
111
108
  self.db.execute(sql1)
112
109
 
110
+ sel_sql = "select * from sqlite_master where name = '#{K_USER_TABLE}' and sql like '%update_time%'; "
111
+ resultSetPrincipal = self.db.execute(sel_sql)
112
+ if resultSetPrincipal.count == 0
113
+ alter = "ALTER TABLE #{K_USER_TABLE} ADD 'update_time' TimeStamp;"
114
+ self.db.execute(alter)
115
+ end
116
+
113
117
  #添加项目表
114
118
  sql2 = "create table if not exists #{K_USER_PROJECTS}(
115
119
  id varchar(100) primary key not null,
@@ -124,26 +128,27 @@ module LgPodPlugin
124
128
  );"
125
129
  self.db.execute(sql2)
126
130
 
127
- #添加项目表
128
- sql3 = "create table if not exists #{K_POD_LATEST_REFS}(
129
- id varchar(100) primary key not null,
130
- name varchar(100),
131
- git varchar(100),
132
- branch varchar(100),
133
- tag varchar(100),
134
- sha varchar(100)
135
- );"
136
- self.db.execute(sql3)
131
+ # #添加项目表
132
+ # sql3 = "create table if not exists #{K_POD_LATEST_REFS}(
133
+ # id varchar(100) primary key not null,
134
+ # name varchar(100),
135
+ # git varchar(100),
136
+ # branch varchar(100),
137
+ # tag varchar(100),
138
+ # sha varchar(100)
139
+ # );"
140
+ # self.db.execute(sql3)
141
+ #
142
+ # #添加项目表
143
+ # sql4 = "create table if not exists #{K_POD_SHA_BRANCH}(
144
+ # id varchar(100) primary key not null,
145
+ # name varchar(100),
146
+ # git varchar(100),
147
+ # branch varchar(100),
148
+ # sha varchar(100)
149
+ # );"
150
+ # self.db.execute(sql4)
137
151
 
138
- #添加项目表
139
- sql4 = "create table if not exists #{K_POD_SHA_BRANCH}(
140
- id varchar(100) primary key not null,
141
- name varchar(100),
142
- git varchar(100),
143
- branch varchar(100),
144
- sha varchar(100)
145
- );"
146
- self.db.execute(sql4)
147
152
  end
148
153
 
149
154
  public
@@ -151,11 +156,11 @@ module LgPodPlugin
151
156
  # pp "user.id => #{user.id}"
152
157
  if self.query_user_info(user.id) != nil
153
158
  self.db.execute_batch(
154
- "UPDATE #{K_USER_TABLE} SET username = (:username), password = (:password), host = (:host), access_token = (:access_token), expires_in = (:expires_in), refresh_token = (:refresh_token) where (id = :id)", { "username" => user.username, "password" => user.password, "host" => user.host, "access_token" => user.access_token, :expires_in => user.expires_in, :id => user.id, :refresh_token => user.refresh_token }
159
+ "UPDATE #{K_USER_TABLE} SET username = (:username), password = (:password), host = (:host), access_token = (:access_token), expires_in = (:expires_in), refresh_token = (:refresh_token), update_time = (:update_time) where (id = :id)", { "username" => user.username, "password" => user.password, "host" => user.host, "access_token" => user.access_token, :expires_in => user.expires_in, :id => user.id, :refresh_token => user.refresh_token , :update_time => user.update_time}
155
160
  )
156
161
  else
157
- self.db.execute("INSERT INTO #{K_USER_TABLE} (id, username, password, host, access_token,refresh_token, expires_in)
158
- VALUES (?, ?, ?, ?,?,?,?)", [user.id, user.username, user.password, user.host, user.access_token, user.refresh_token, user.expires_in])
162
+ self.db.execute("INSERT INTO #{K_USER_TABLE} (id, username, password, host, access_token,refresh_token, expires_in, update_time)
163
+ VALUES (?, ?, ?, ?,?,?,?, ?)", [user.id, user.username, user.password, user.host, user.access_token, user.refresh_token, user.expires_in, user.update_time])
159
164
  end
160
165
 
161
166
  end
@@ -173,6 +178,7 @@ module LgPodPlugin
173
178
  user_info.access_token = row[4]
174
179
  user_info.refresh_token = row[5]
175
180
  user_info.expires_in = row[6]
181
+ user_info.update_time = row[7]
176
182
  end
177
183
  user_info
178
184
  end
@@ -220,67 +226,67 @@ module LgPodPlugin
220
226
  ps.execute('n' => project_id)
221
227
  end
222
228
 
223
- def insert_pod_refs(name, git, branch, tag, commit)
224
- id = LPodLatestRefs.get_pod_id(name, git, branch)
225
- pod = LPodLatestRefs.new(id, name, git, branch, tag, commit)
226
- if self.query_pod_refs(id) != nil
227
- self.db.execute_batch(
228
- "UPDATE #{K_POD_LATEST_REFS} SET name = (:name), git = (:git), branch = (:branch), tag = (:tag), sha = (:sha) where (id = :id)", { "name" => pod.name, "git" => pod.git, "sha" => pod.commit, "branch" => pod.branch, :tag => pod.tag, :id => pod.id }
229
- )
230
- else
231
- self.db.execute("INSERT INTO #{K_POD_LATEST_REFS} (id, name, git, branch, tag, sha)
232
- VALUES (?, ?, ?, ?, ?, ?)", [pod.id, pod.name, pod.git, pod.branch, pod.tag, pod.commit])
233
- end
234
- self.insert_pod_sha_with_branch(name, git, commit, branch)
235
- end
236
-
237
- def query_pod_refs(id)
238
- pod_info = nil
239
- self.db.execute("select * from #{K_POD_LATEST_REFS} where id = '#{id}';") do |row|
240
- id = row[0]
241
- name = row[1]
242
- git = row[2]
243
- branch = row[3]
244
- tag = row[4]
245
- commit = row[5]
246
- pod_info = LPodLatestRefs.new(id, name, git, branch, tag, commit)
247
- end
248
- pod_info
249
- end
229
+ # def insert_pod_refs(name, git, branch, tag, commit)
230
+ # id = LPodLatestRefs.get_pod_id(name, git, branch)
231
+ # pod = LPodLatestRefs.new(id, name, git, branch, tag, commit)
232
+ # if self.query_pod_refs(id) != nil
233
+ # self.db.execute_batch(
234
+ # "UPDATE #{K_POD_LATEST_REFS} SET name = (:name), git = (:git), branch = (:branch), tag = (:tag), sha = (:sha) where (id = :id)", { "name" => pod.name, "git" => pod.git, "sha" => pod.commit, "branch" => pod.branch, :tag => pod.tag, :id => pod.id }
235
+ # )
236
+ # else
237
+ # self.db.execute("INSERT INTO #{K_POD_LATEST_REFS} (id, name, git, branch, tag, sha)
238
+ # VALUES (?, ?, ?, ?, ?, ?)", [pod.id, pod.name, pod.git, pod.branch, pod.tag, pod.commit])
239
+ # end
240
+ # self.insert_pod_sha_with_branch(name, git, commit, branch)
241
+ # end
242
+ #
243
+ # def query_pod_refs(id)
244
+ # pod_info = nil
245
+ # self.db.execute("select * from #{K_POD_LATEST_REFS} where id = '#{id}';") do |row|
246
+ # id = row[0]
247
+ # name = row[1]
248
+ # git = row[2]
249
+ # branch = row[3]
250
+ # tag = row[4]
251
+ # commit = row[5]
252
+ # pod_info = LPodLatestRefs.new(id, name, git, branch, tag, commit)
253
+ # end
254
+ # pod_info
255
+ # end
250
256
 
251
257
  # 保存 sha, branch 到数据库
252
- def insert_pod_sha_with_branch(name, git, sha, branch)
253
- return unless name && git && sha
254
- id = Digest::MD5.hexdigest(name + git + sha)
255
- if self.query_branch_with_sha(name, git, sha)[:sha] != nil
256
- self.db.execute_batch(
257
- "UPDATE #{K_POD_SHA_BRANCH} SET name = (:name), git = (:git), branch = (:branch), sha = (:sha) where (id = :id)", { "name" => name, "git" => git, "branch" => branch, :id => id, :sha => sha }
258
- )
259
- else
260
- self.db.execute("INSERT INTO #{K_POD_SHA_BRANCH} (id, name, git, branch, sha)
261
- VALUES (?, ?, ?, ?, ?)", [id, name, git, branch, sha])
262
- end
263
- end
258
+ # def insert_pod_sha_with_branch(name, git, sha, branch)
259
+ # return unless name && git && sha
260
+ # id = Digest::MD5.hexdigest(name + git + sha)
261
+ # if self.query_branch_with_sha(name, git, sha)[:sha] != nil
262
+ # self.db.execute_batch(
263
+ # "UPDATE #{K_POD_SHA_BRANCH} SET name = (:name), git = (:git), branch = (:branch), sha = (:sha) where (id = :id)", { "name" => name, "git" => git, "branch" => branch, :id => id, :sha => sha }
264
+ # )
265
+ # else
266
+ # self.db.execute("INSERT INTO #{K_POD_SHA_BRANCH} (id, name, git, branch, sha)
267
+ # VALUES (?, ?, ?, ?, ?)", [id, name, git, branch, sha])
268
+ # end
269
+ # end
264
270
 
265
271
  # 通过 sha 查询对应 branch
266
- def query_branch_with_sha(id = nil, name, git, sha)
267
- hash_map = Hash.new
268
- id = Digest::MD5.hexdigest(name + git + sha) unless id
269
- self.db.execute("select * from #{K_POD_SHA_BRANCH} where id = '#{id}' and name = '#{name}' and git = '#{git}' ;") do |row|
270
- new_id = row[0]
271
- new_sha = row[4]
272
- new_git = row[2]
273
- new_name = row[1]
274
- new_branch = row[3]
275
- hash_map[:id] = new_id
276
- hash_map[:git] = new_git
277
- hash_map[:sha] = new_sha
278
- hash_map[:name] = new_name
279
- hash_map[:branch] = new_branch
280
- end
281
- hash_map
282
- end
283
-
272
+ # def query_branch_with_sha(id = nil, name, git, sha)
273
+ # hash_map = Hash.new
274
+ # id = Digest::MD5.hexdigest(name + git + sha) unless id
275
+ # self.db.execute("select * from #{K_POD_SHA_BRANCH} where id = '#{id}' and name = '#{name}' and git = '#{git}' ;") do |row|
276
+ # new_id = row[0]
277
+ # new_sha = row[4]
278
+ # new_git = row[2]
279
+ # new_name = row[1]
280
+ # new_branch = row[3]
281
+ # hash_map[:id] = new_id
282
+ # hash_map[:git] = new_git
283
+ # hash_map[:sha] = new_sha
284
+ # hash_map[:name] = new_name
285
+ # hash_map[:branch] = new_branch
286
+ # end
287
+ # hash_map
288
+ # end
289
+ #
284
290
  end
285
291
 
286
292
  end
@@ -32,10 +32,10 @@ module LgPodPlugin
32
32
  checkout_options[:branch] = branch if branch
33
33
  end
34
34
  commit = checkout_options[:commit]
35
- unless commit
36
- commit = self.request.params[:commit] if self.request.params[:commit]
37
- checkout_options[:commit] = commit if commit
38
- end
35
+ # unless commit
36
+ # commit = self.request.params[:commit] if self.request.params[:commit]
37
+ # checkout_options[:commit] = commit if commit
38
+ # end
39
39
  if branch
40
40
  LgPodPlugin.log_green "Using `#{name}` (#{branch})"
41
41
  elsif tag
@@ -49,8 +49,8 @@ module LgPodPlugin
49
49
  LgPodPlugin.log_green "Using `#{name}`"
50
50
  end
51
51
  hash_map = self.request.get_cache_key_params
52
- self.request.checkout_options.delete(:branch) if commit
53
- self.request.checkout_options[:commit] = commit if commit
52
+ # self.request.checkout_options.delete(:branch) if commit
53
+ # self.request.checkout_options[:commit] = commit if commit
54
54
  # 发现本地有缓存, 不需要更新缓存
55
55
  pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
56
56
  if pod_is_exist
@@ -58,6 +58,7 @@ module LgPodPlugin
58
58
  return nil
59
59
  else
60
60
  LgPodPlugin.log_green "find the new commit of `#{name}`, Git downloading now."
61
+
61
62
  # 本地 git 下载 pod 目录
62
63
  download_params = self.pre_download_git_repository(checkout_options)
63
64
  if download_params && download_params.is_a?(Hash)
@@ -13,7 +13,16 @@ module LgPodPlugin
13
13
 
14
14
  public
15
15
  def pod_cache_exist(name, options, spec = nil, released_pod = false)
16
+ # 参数为空不执行下载任务, 交给 cocoapods 处理下载
17
+ if options.nil?
18
+ return [true, nil, nil]
19
+ end
20
+
16
21
  destination, cache_pod_spec = self.find_pod_cache name, options, spec, released_pod
22
+ lock_temp_file = destination.to_path+ ".lock"
23
+ if File.exist?(lock_temp_file)
24
+ FileUtils.rm_rf lock_temp_file
25
+ end
17
26
  if (File.exist?(destination) && !destination.children.empty?) && cache_pod_spec.exist?
18
27
  return [true, destination, cache_pod_spec]
19
28
  else
@@ -29,8 +38,8 @@ module LgPodPlugin
29
38
  hash_map.delete(:version)
30
39
  end
31
40
  request = LCache.download_request(name, hash_map, spec, released_pod)
32
- destination = LCache.path_for_pod(request, {})
33
- cache_pod_spec = LCache.path_for_spec(request, {})
41
+ destination = LCache.path_for_pod(request)
42
+ cache_pod_spec = LCache.path_for_spec(request)
34
43
  [destination, cache_pod_spec]
35
44
  end
36
45