lg_pod_plugin 1.1.3 → 1.1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lg +2 -2
- data/lib/command/command.rb +1 -2
- data/lib/command/install.rb +7 -2
- data/lib/command/update.rb +4 -1
- data/lib/lg_pod_plugin/config/l_config.rb +59 -0
- data/lib/lg_pod_plugin/config/lockfile_model.rb +59 -0
- data/lib/lg_pod_plugin/config/podspec.rb +266 -0
- data/lib/lg_pod_plugin/config/target.rb +33 -0
- data/lib/lg_pod_plugin/{database.rb → db/database.rb} +76 -16
- data/lib/lg_pod_plugin/downloader/downloader.rb +156 -0
- data/lib/lg_pod_plugin/{l_cache.rb → downloader/l_cache.rb} +42 -23
- data/lib/lg_pod_plugin/downloader/request.rb +239 -0
- data/lib/lg_pod_plugin/git/git_clone.rb +85 -0
- data/lib/lg_pod_plugin/git/git_download.rb +53 -0
- data/lib/lg_pod_plugin/git/github_api.rb +137 -0
- data/lib/lg_pod_plugin/git/github_archive.rb +165 -0
- data/lib/lg_pod_plugin/git/gitlab_api.rb +266 -0
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +180 -0
- data/lib/lg_pod_plugin/git/http_download.rb +39 -0
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/concurrency.rb +21 -0
- data/lib/lg_pod_plugin/installer/install.rb +111 -0
- data/lib/lg_pod_plugin/installer/main.rb +63 -0
- data/lib/lg_pod_plugin/installer/project.rb +47 -0
- data/lib/lg_pod_plugin/net/l_uri.rb +87 -0
- data/lib/lg_pod_plugin/net/net-ping.rb +27 -0
- data/lib/lg_pod_plugin/pod/external_pod.rb +21 -0
- data/lib/lg_pod_plugin/pod/release-pod.rb +158 -0
- data/lib/lg_pod_plugin/utils/aes-crypt.rb +82 -0
- data/lib/lg_pod_plugin/{file_path.rb → utils/file_path.rb} +3 -5
- data/lib/lg_pod_plugin/utils/l_util.rb +133 -0
- data/lib/lg_pod_plugin/{log.rb → utils/log.rb} +1 -1
- data/lib/lg_pod_plugin/{string.rb → utils/string.rb} +0 -0
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +24 -9
- data/lib/sqlite3-1.5.3-arm64-darwin/API_CHANGES.md +49 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/CHANGELOG.md +462 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/CONTRIBUTING.md +24 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ChangeLog.cvs +88 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/README.md +235 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/dependencies.yml +14 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.c +274 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.h +12 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.c +168 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.h +15 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.c +853 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.h +17 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.c +98 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.h +8 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/extconf.rb +251 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3.c +163 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.c +442 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.h +16 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.md +431 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.rb +145 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.yml +426 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/constants.rb +50 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/database.rb +741 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/errors.rb +35 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/pragmas.rb +595 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/resultset.rb +187 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/statement.rb +145 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/translator.rb +118 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb +57 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/version.rb +23 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3.rb +15 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/helper.rb +27 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_backup.rb +33 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_collation.rb +82 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database.rb +545 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb +95 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb +36 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb +41 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_deprecated.rb +44 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_encoding.rb +155 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration.rb +507 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_aggregate.rb +336 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_open_close.rb +30 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_pending.rb +115 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_resultset.rb +142 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_statement.rb +194 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb +37 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_sqlite3.rb +30 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement.rb +263 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb +35 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/API_CHANGES.md +49 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/CHANGELOG.md +462 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/CONTRIBUTING.md +24 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ChangeLog.cvs +88 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/README.md +235 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/dependencies.yml +14 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.c +274 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.h +12 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.c +168 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.h +15 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.c +853 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.h +17 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.c +98 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.h +8 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/extconf.rb +251 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3.c +163 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.c +442 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.h +16 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.md +431 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.rb +145 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.yml +426 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/constants.rb +50 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/database.rb +741 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/errors.rb +35 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/pragmas.rb +595 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/resultset.rb +187 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/statement.rb +145 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/translator.rb +118 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/value.rb +57 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/version.rb +23 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3.rb +15 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/helper.rb +27 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_backup.rb +33 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_collation.rb +82 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database.rb +545 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_flags.rb +95 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readonly.rb +36 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readwrite.rb +41 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_deprecated.rb +44 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_encoding.rb +155 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration.rb +507 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_aggregate.rb +336 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_open_close.rb +30 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_pending.rb +115 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_resultset.rb +142 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_statement.rb +194 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_result_set.rb +37 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_sqlite3.rb +30 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement.rb +263 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement_execute.rb +35 -0
- metadata +146 -53
- data/lib/lg_pod_plugin/downloader.rb +0 -57
- data/lib/lg_pod_plugin/gitlab_api.rb +0 -147
- data/lib/lg_pod_plugin/gitlab_archive.rb +0 -352
- data/lib/lg_pod_plugin/gitlab_download.rb +0 -159
- data/lib/lg_pod_plugin/install.rb +0 -81
- data/lib/lg_pod_plugin/l_config.rb +0 -83
- data/lib/lg_pod_plugin/l_util.rb +0 -145
- data/lib/lg_pod_plugin/net-ping.rb +0 -41
- data/lib/lg_pod_plugin/podspec.rb +0 -156
- data/lib/lg_pod_plugin/release-pod.rb +0 -90
- data/lib/lg_pod_plugin/request.rb +0 -221
- data/lib/lg_pod_plugin/runner.rb +0 -114
- data/lib/lg_pod_plugin/specification.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87687aa81b8335f7b51b978287803b7e85dae0edd6eecfed4faafdf4c4de0550
|
4
|
+
data.tar.gz: b53597d6581b1a54b0aafc0e12f53a3d4450fb66d816dc8426e8b1c30a6e6a54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5457155ee61aa98b3f2d46f2eac75995f5389eede33f52a634dfb0553a0620ca73be8ef48ff4b4b11b513e46793f0a101b5ca580e8755ece71807b0d8c1bf4c1
|
7
|
+
data.tar.gz: 813f73b37ae4b359705794860bbeb00132da55429ab95dc31f8a65dd5dea7119c630278604905cd19cb134eae57e3751c0419e23e3d68b0dc0e740e92e2f9e56
|
data/bin/lg
CHANGED
data/lib/command/command.rb
CHANGED
@@ -6,7 +6,6 @@ module LgPodPlugin
|
|
6
6
|
require_relative 'update'
|
7
7
|
require_relative 'init'
|
8
8
|
require_relative 'install'
|
9
|
-
require_relative '../lg_pod_plugin/gitlab_api.rb'
|
10
9
|
self.command = 'lg'
|
11
10
|
self.version = VERSION
|
12
11
|
self.abstract_command = true
|
@@ -26,4 +25,4 @@ module LgPodPlugin
|
|
26
25
|
end
|
27
26
|
|
28
27
|
end
|
29
|
-
end
|
28
|
+
end
|
data/lib/command/install.rb
CHANGED
@@ -45,8 +45,13 @@ module LgPodPlugin
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def run
|
48
|
-
|
48
|
+
|
49
|
+
begin_time = Time.now.to_i
|
50
|
+
LgPodPlugin::Main.run("install", { :verbose => self.log, :repo_update => self.repo_update })
|
51
|
+
end_time = Time.now.to_i
|
52
|
+
LgPodPlugin.log_blue "`lg install`安装所需时间: #{end_time - begin_time}"
|
49
53
|
end
|
54
|
+
|
50
55
|
end
|
51
56
|
end
|
52
|
-
end
|
57
|
+
end
|
data/lib/command/update.rb
CHANGED
@@ -32,7 +32,10 @@ module LgPodPlugin
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def run
|
35
|
-
|
35
|
+
begin_time = Time.now.to_i
|
36
|
+
LgPodPlugin::Main.run("update", { :verbose => self.log, :repo_update => self.repo_update})
|
37
|
+
end_time = Time.now.to_i
|
38
|
+
LgPodPlugin.log_blue "`lg update`安装所需时间: #{end_time - begin_time}"
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'uri'
|
3
|
+
require 'io/console'
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
class LConfig
|
8
|
+
attr_accessor :host
|
9
|
+
attr_accessor :base_url
|
10
|
+
attr_accessor :project_name
|
11
|
+
attr_accessor :access_token
|
12
|
+
attr_accessor :refresh_token
|
13
|
+
attr_accessor :project
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
end
|
17
|
+
|
18
|
+
public
|
19
|
+
def self.get_config(git, uri)
|
20
|
+
return nil unless uri&.host
|
21
|
+
return nil unless LUtils.is_gitlab_uri(git, uri.hostname)
|
22
|
+
user_id = LUserAuthInfo.get_user_id(uri.hostname)
|
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
|
42
|
+
end
|
43
|
+
|
44
|
+
config = LConfig.new
|
45
|
+
config.host = uri.hostname
|
46
|
+
config.access_token = user_info.access_token
|
47
|
+
config.refresh_token = user_info.refresh_token
|
48
|
+
config.base_url = LUtils.get_gitlab_base_url(git)
|
49
|
+
config.project_name = LUtils.get_git_project_name(git)
|
50
|
+
config.project = LSqliteDb.shared.query_project_info(config.project_name, git)
|
51
|
+
unless config.project
|
52
|
+
config.project = GitLabAPI.request_project_info(config.host, config.project_name, config.access_token, git)
|
53
|
+
end
|
54
|
+
return config
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'cocoapods-core'
|
2
|
+
|
3
|
+
module LgPodPlugin
|
4
|
+
|
5
|
+
class LockfileModel
|
6
|
+
attr_accessor :lockfile
|
7
|
+
attr_accessor :release_pods
|
8
|
+
attr_accessor :external_sources_data
|
9
|
+
attr_accessor :checkout_options_data
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.from_file
|
15
|
+
lockfile = LProject.shared.lockfile
|
16
|
+
unless lockfile
|
17
|
+
lockfile_model = LockfileModel.new
|
18
|
+
lockfile_model.lockfile = nil
|
19
|
+
lockfile_model.release_pods = {}
|
20
|
+
lockfile_model.checkout_options_data = {}
|
21
|
+
lockfile_model.external_sources_data = {}
|
22
|
+
return lockfile_model
|
23
|
+
end
|
24
|
+
release_pods = Hash.new
|
25
|
+
pods = lockfile.send(:generate_pod_names_and_versions)
|
26
|
+
pods.each do |element|
|
27
|
+
if LUtils.is_a_string?(element) || element.is_a?(Hash)
|
28
|
+
key = element.is_a?(Hash) ? element.keys.first : element
|
29
|
+
next unless key
|
30
|
+
if key.include?(" ")
|
31
|
+
pod_name = LUtils.pod_real_name(key.split(" ").first)
|
32
|
+
else
|
33
|
+
pod_name = key
|
34
|
+
end
|
35
|
+
tag = key[/(?<=\().*?(?=\))/]
|
36
|
+
release_pods[pod_name] = tag
|
37
|
+
else
|
38
|
+
next
|
39
|
+
end
|
40
|
+
end
|
41
|
+
lockfile_model = LockfileModel.new
|
42
|
+
lockfile_model.lockfile = lockfile
|
43
|
+
lockfile_model.release_pods = release_pods
|
44
|
+
lockfile_model.checkout_options_data = lockfile.send(:checkout_options_data)
|
45
|
+
lockfile_model.checkout_options_data = {} unless lockfile_model.checkout_options_data
|
46
|
+
lockfile_model.external_sources_data = lockfile.send(:external_sources_data)
|
47
|
+
lockfile_model.external_sources_data = {} unless lockfile_model.external_sources_data
|
48
|
+
lockfile_model
|
49
|
+
end
|
50
|
+
|
51
|
+
def checkout_options_for_pod_named(name)
|
52
|
+
return {} unless @lockfile
|
53
|
+
hash = @lockfile.checkout_options_for_pod_named(name)
|
54
|
+
hash ? hash : {}
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,266 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-core'
|
3
|
+
|
4
|
+
module LgPodPlugin
|
5
|
+
|
6
|
+
class PodSpec
|
7
|
+
attr_reader :spec
|
8
|
+
attr_accessor :json_files
|
9
|
+
attr_accessor :source_files
|
10
|
+
|
11
|
+
public
|
12
|
+
def self.form_file(path)
|
13
|
+
begin
|
14
|
+
spec = Pod::Specification.from_file(path)
|
15
|
+
return PodSpec.new(spec)
|
16
|
+
rescue
|
17
|
+
return nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
public
|
22
|
+
def prepare_command
|
23
|
+
json = self.to_pretty_json
|
24
|
+
return nil unless json
|
25
|
+
hash = JSON.parse json
|
26
|
+
hash["prepare_command"]
|
27
|
+
end
|
28
|
+
|
29
|
+
public
|
30
|
+
def to_pretty_json(*a)
|
31
|
+
require 'json'
|
32
|
+
JSON.pretty_generate(self.spec.to_hash, *a) << "\n"
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
public
|
37
|
+
def self.form_string(string, path)
|
38
|
+
begin
|
39
|
+
#Work around for Rubinius incomplete encoding in 1.9 mode
|
40
|
+
if string.respond_to?(:encoding) && string.encoding.name != 'UTF-8'
|
41
|
+
string = string.force_encoding("gb2312").force_encoding("utf-8")
|
42
|
+
end
|
43
|
+
spec = Pod::Specification.from_string string, path
|
44
|
+
return PodSpec.new(spec)
|
45
|
+
rescue
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.form_pod_spec(spec)
|
51
|
+
return PodSpec.new(spec)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.form_json(object)
|
55
|
+
begin
|
56
|
+
spec = Pod::Specification.from_json(object)
|
57
|
+
return PodSpec.new(spec)
|
58
|
+
rescue
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize(spec)
|
64
|
+
if spec == nil
|
65
|
+
@spec = nil
|
66
|
+
@json_files = Hash.new
|
67
|
+
@source_files = Hash.new
|
68
|
+
return
|
69
|
+
end
|
70
|
+
set = Set[]
|
71
|
+
@spec = spec
|
72
|
+
attributes_hash = spec.send(:attributes_hash)
|
73
|
+
return unless attributes_hash.is_a?(Hash)
|
74
|
+
license = attributes_hash["license"]
|
75
|
+
if license.is_a?(Hash)
|
76
|
+
license_file = license["file"]
|
77
|
+
set.add(license_file) if license_file
|
78
|
+
else
|
79
|
+
set.add("LICENSE")
|
80
|
+
end
|
81
|
+
# 解析主模块依赖信息
|
82
|
+
set.merge(parse_subspec_with(attributes_hash))
|
83
|
+
subspecs = spec.subspecs
|
84
|
+
unless subspecs.is_a?(Array)
|
85
|
+
self.source_files = parse_with_set set
|
86
|
+
if self.source_files.has_key?("*")
|
87
|
+
self.source_files.delete("*")
|
88
|
+
self.source_files["All"] = "All"
|
89
|
+
end
|
90
|
+
self.json_files = spec.to_pretty_json
|
91
|
+
return
|
92
|
+
end
|
93
|
+
subspecs.each do |sub_spec|
|
94
|
+
sub_attributes_hash = sub_spec.send(:attributes_hash)
|
95
|
+
next unless sub_attributes_hash && sub_attributes_hash.is_a?(Hash)
|
96
|
+
sub_set = self.parse_subspec_with(sub_attributes_hash)
|
97
|
+
next if sub_set.empty?
|
98
|
+
set.merge(sub_set)
|
99
|
+
end
|
100
|
+
self.source_files = parse_with_set set
|
101
|
+
if self.source_files.has_key?("*")
|
102
|
+
self.source_files.delete("*")
|
103
|
+
self.source_files["All"] = "All"
|
104
|
+
end
|
105
|
+
self.json_files = spec.to_pretty_json
|
106
|
+
end
|
107
|
+
|
108
|
+
public
|
109
|
+
def write_to_file(path)
|
110
|
+
LCache.write_spec(@spec, path)
|
111
|
+
end
|
112
|
+
|
113
|
+
def parse_with_set(set)
|
114
|
+
new_hash = Hash.new
|
115
|
+
set.each do |element|
|
116
|
+
if element.start_with?("**/")
|
117
|
+
new_hash["All"] = "All"
|
118
|
+
elsif element.include?("/")
|
119
|
+
str = element.split("/", 0).first
|
120
|
+
new_hash[str] = str unless str.empty?
|
121
|
+
elsif element.start_with?("**.") || element.start_with?("*.")
|
122
|
+
new_hash["All"] = "All"
|
123
|
+
elsif element.start_with?("*.framework") || element.include?("*.a")
|
124
|
+
new_hash["All"] = "All"
|
125
|
+
else
|
126
|
+
new_hash[element] = element unless element.empty?
|
127
|
+
end
|
128
|
+
end
|
129
|
+
new_hash
|
130
|
+
end
|
131
|
+
|
132
|
+
# 公共解析解析subspec
|
133
|
+
def parse_subspec_with(hash)
|
134
|
+
set = Set[]
|
135
|
+
source_files = self.parse_source_files(hash["source_files"])
|
136
|
+
set.merge(source_files) unless source_files.empty?
|
137
|
+
resources = self.parse_resource_files(hash["resource"] ||= hash["resources"])
|
138
|
+
set.merge(resources) unless resources.empty?
|
139
|
+
resource_bundles = self.parse_resource_bundles(hash["resource_bundle"] ||= hash["resource_bundles"])
|
140
|
+
set.merge(resource_bundles) unless resource_bundles.empty?
|
141
|
+
project_header_files = self.parse_project_header_files(hash["project_header_files"])
|
142
|
+
set.merge(resource_bundles) unless project_header_files.empty?
|
143
|
+
private_header_files = self.parse_private_header_files(hash["private_header_files"])
|
144
|
+
set.merge(private_header_files) unless private_header_files.empty?
|
145
|
+
vendored_frameworks = self.parse_vendored_frameworks(hash["vendored_frameworks"])
|
146
|
+
set.merge(vendored_frameworks) unless vendored_frameworks.empty?
|
147
|
+
vendored_library = self.parse_vendored_library(hash["vendored_library"] ||= hash["vendored_libraries"])
|
148
|
+
set.merge(vendored_library) unless vendored_library.empty?
|
149
|
+
#parse_preserve_path
|
150
|
+
preserve_paths = self.parse_preserve_path(hash["preserve_path"] ||= hash["preserve_paths"])
|
151
|
+
set.merge(preserve_paths) unless preserve_paths.empty?
|
152
|
+
module_map = self.parse_module_map(hash["module_map"])
|
153
|
+
set.merge(module_map) unless module_map.empty?
|
154
|
+
ios_hash = hash["ios"]
|
155
|
+
if ios_hash && ios_hash.is_a?(Hash)
|
156
|
+
|
157
|
+
ios_source_files = self.parse_source_files(ios_hash["source_files"])
|
158
|
+
set.merge(ios_source_files) unless ios_source_files.empty?
|
159
|
+
|
160
|
+
ios_resources = self.parse_resource_files(ios_hash["resource"] ||= ios_hash["resources"])
|
161
|
+
set.merge(ios_resources) unless ios_resources.empty?
|
162
|
+
|
163
|
+
ios_resource_bundles = self.parse_resource_bundles(ios_hash["resource_bundle"] ||= ios_hash["resource_bundles"])
|
164
|
+
set.merge(ios_resource_bundles) unless ios_resource_bundles.empty?
|
165
|
+
|
166
|
+
ios_project_header_files = self.parse_project_header_files(ios_hash["project_header_files"])
|
167
|
+
set.merge(ios_project_header_files) unless ios_project_header_files.empty?
|
168
|
+
|
169
|
+
ios_private_header_files = self.parse_private_header_files(ios_hash["private_header_files"])
|
170
|
+
set.merge(ios_private_header_files) unless ios_private_header_files.empty?
|
171
|
+
|
172
|
+
ios_vendored_frameworks = self.parse_vendored_frameworks(ios_hash["vendored_frameworks"])
|
173
|
+
set.merge(ios_vendored_frameworks) unless ios_vendored_frameworks.empty?
|
174
|
+
|
175
|
+
ios_vendored_library = self.parse_vendored_library(ios_hash["vendored_library"] ||= ios_hash["vendored_libraries"])
|
176
|
+
set.merge(ios_vendored_library) unless ios_vendored_library.empty?
|
177
|
+
|
178
|
+
ios_preserve_paths = self.parse_preserve_path(ios_hash["preserve_path"] ||= ios_hash["preserve_paths"])
|
179
|
+
set.merge(ios_preserve_paths) unless ios_preserve_paths.empty?
|
180
|
+
|
181
|
+
ios_module_map = self.parse_module_map(ios_hash["module_map"])
|
182
|
+
set.merge(ios_module_map) unless ios_module_map.empty?
|
183
|
+
|
184
|
+
end
|
185
|
+
set
|
186
|
+
end
|
187
|
+
|
188
|
+
# 公共解析文件路径的方法
|
189
|
+
def parse_public_source_files(source_files)
|
190
|
+
return Array.new unless source_files
|
191
|
+
array = Array.new
|
192
|
+
if LUtils.is_a_string?(source_files)
|
193
|
+
array.append(source_files) unless source_files.empty?
|
194
|
+
elsif source_files.is_a?(Array)
|
195
|
+
source_files.each do |element|
|
196
|
+
next unless LUtils.is_a_string?(element)
|
197
|
+
array.append(element) unless element.empty?
|
198
|
+
end
|
199
|
+
elsif source_files.is_a?(Hash)
|
200
|
+
source_files.each do |_, val|
|
201
|
+
if LUtils.is_a_string?(val)
|
202
|
+
array.append(val) unless val.empty?
|
203
|
+
elsif val.is_a?(Array)
|
204
|
+
val.each do |element|
|
205
|
+
next unless LUtils.is_a_string?(element)
|
206
|
+
array.append(element) unless element.empty?
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
array
|
212
|
+
end
|
213
|
+
|
214
|
+
# 解析source_files路径
|
215
|
+
def parse_source_files(source_files)
|
216
|
+
self.parse_public_source_files(source_files)
|
217
|
+
end
|
218
|
+
|
219
|
+
# 解析 resource所在路径
|
220
|
+
def parse_resource_files(source_files)
|
221
|
+
self.parse_public_source_files(source_files)
|
222
|
+
end
|
223
|
+
|
224
|
+
# 解析public_header_files字段的值
|
225
|
+
def parse_public_header_files(source_files)
|
226
|
+
self.parse_public_source_files(source_files)
|
227
|
+
end
|
228
|
+
|
229
|
+
# 解析 parse_resource_bundles
|
230
|
+
def parse_resource_bundles(source_files)
|
231
|
+
self.parse_public_source_files(source_files)
|
232
|
+
end
|
233
|
+
|
234
|
+
# 解析 project_header_files
|
235
|
+
def parse_project_header_files(source_files)
|
236
|
+
self.parse_public_source_files(source_files)
|
237
|
+
end
|
238
|
+
|
239
|
+
# 解析 private_header_files
|
240
|
+
def parse_private_header_files(source_files)
|
241
|
+
self.parse_public_source_files(source_files)
|
242
|
+
end
|
243
|
+
|
244
|
+
# 解析 vendored_frameworks
|
245
|
+
def parse_vendored_frameworks(source_files)
|
246
|
+
self.parse_public_source_files(source_files)
|
247
|
+
end
|
248
|
+
|
249
|
+
# 解析 parse_vendored_library
|
250
|
+
def parse_vendored_library(source_files)
|
251
|
+
self.parse_public_source_files(source_files)
|
252
|
+
end
|
253
|
+
|
254
|
+
# 解析 parse_preserve_path
|
255
|
+
def parse_preserve_path(source_files)
|
256
|
+
self.parse_public_source_files(source_files)
|
257
|
+
end
|
258
|
+
|
259
|
+
# 解析 module_map
|
260
|
+
def parse_module_map(source_files)
|
261
|
+
self.parse_public_source_files(source_files)
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
|
3
|
+
module LgPodPlugin
|
4
|
+
class LPodTarget
|
5
|
+
attr_reader :name
|
6
|
+
attr_reader :dependencies
|
7
|
+
def initialize(target)
|
8
|
+
internal_hash = target.send(:internal_hash)
|
9
|
+
@name = internal_hash["name"]
|
10
|
+
array = Array.new(internal_hash['dependencies'] ||= [])
|
11
|
+
dependencies = array.reject do |e|
|
12
|
+
if LUtils.is_a_string?(e)
|
13
|
+
true
|
14
|
+
elsif e.is_a?(Hash)
|
15
|
+
key = e.keys.last ||= ""
|
16
|
+
val = e[key].last ||= ""
|
17
|
+
!val.is_a?(Hash)
|
18
|
+
else
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
external_pods = Hash.new
|
23
|
+
dependencies.each do |e|
|
24
|
+
key = e.keys.last ||= ""
|
25
|
+
val = e[key].last ||= {}
|
26
|
+
next unless val.is_a?(Hash)
|
27
|
+
pod = ExternalPod.new(self, key, val)
|
28
|
+
external_pods[pod.name] = pod
|
29
|
+
end
|
30
|
+
@dependencies = external_pods
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
|
-
require "sqlite3"
|
2
1
|
require 'singleton'
|
3
|
-
|
4
|
-
|
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
|
5
8
|
module LgPodPlugin
|
6
9
|
|
7
10
|
class ProjectModel
|
@@ -70,11 +73,12 @@ module LgPodPlugin
|
|
70
73
|
|
71
74
|
class LSqliteDb
|
72
75
|
include Singleton
|
73
|
-
REQUIRED_ATTRS ||= %i[db
|
76
|
+
REQUIRED_ATTRS ||= %i[db].freeze
|
74
77
|
attr_accessor(*REQUIRED_ATTRS)
|
75
78
|
K_USER_TABLE = "user_tab"
|
76
79
|
K_USER_PROJECTS = "user_projects"
|
77
80
|
K_POD_LATEST_REFS = "user_pod_latest_refs"
|
81
|
+
K_POD_SHA_BRANCH = "user_pod_sha_with_branch"
|
78
82
|
|
79
83
|
def self.shared
|
80
84
|
return LSqliteDb.instance
|
@@ -82,9 +86,13 @@ module LgPodPlugin
|
|
82
86
|
|
83
87
|
# 初始化 db
|
84
88
|
def initialize
|
89
|
+
end
|
90
|
+
|
91
|
+
#初始化database
|
92
|
+
def init_database
|
85
93
|
root_path = LFileManager.download_director.join("database")
|
86
94
|
db_file_path = root_path.join("my.db")
|
87
|
-
|
95
|
+
unless root_path.exist? && db_file_path.exist?
|
88
96
|
FileUtils.mkdir(root_path)
|
89
97
|
FileUtils.chdir(root_path)
|
90
98
|
FileUtils.touch("my.db")
|
@@ -127,11 +135,18 @@ module LgPodPlugin
|
|
127
135
|
);"
|
128
136
|
self.db.execute(sql3)
|
129
137
|
|
130
|
-
|
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)
|
131
147
|
end
|
132
148
|
|
133
149
|
public
|
134
|
-
|
135
150
|
def insert_user_info(user)
|
136
151
|
# pp "user.id => #{user.id}"
|
137
152
|
if self.query_user_info(user.id) != nil
|
@@ -146,6 +161,7 @@ module LgPodPlugin
|
|
146
161
|
end
|
147
162
|
|
148
163
|
public
|
164
|
+
|
149
165
|
def query_user_info(user_id)
|
150
166
|
user_info = nil
|
151
167
|
self.db.execute("select * from #{K_USER_TABLE} where id = '#{user_id}';") do |row|
|
@@ -161,11 +177,17 @@ module LgPodPlugin
|
|
161
177
|
user_info
|
162
178
|
end
|
163
179
|
|
180
|
+
#删除用户信息
|
181
|
+
def delete_user_info(id)
|
182
|
+
ps = @db.prepare("DELETE FROM #{K_USER_TABLE} WHERE id = :n")
|
183
|
+
ps.execute('n' => id)
|
184
|
+
end
|
185
|
+
|
164
186
|
# 保存项目信息到数据库
|
165
187
|
def insert_project(project)
|
166
188
|
if self.query_project_info(project.name, project.http_url_to_repo) != nil
|
167
189
|
self.db.execute_batch(
|
168
|
-
"UPDATE #{K_USER_PROJECTS} SET name = (:name), desc = (:desc), path = (:path), ssh_url_to_repo = (:ssh_url_to_repo), http_url_to_repo = (:http_url_to_repo), web_url = (:web_url), name_with_namespace = (:name_with_namespace), path_with_namespace = (:path_with_namespace) where (id = :id)", { "name" => project.name, "desc" => project.description, "path" => project.path, "ssh_url_to_repo" => project.ssh_url_to_repo, :http_url_to_repo => project.http_url_to_repo, :web_url => project.web_url, :id => project.id
|
190
|
+
"UPDATE #{K_USER_PROJECTS} SET name = (:name), desc = (:desc), path = (:path), ssh_url_to_repo = (:ssh_url_to_repo), http_url_to_repo = (:http_url_to_repo), web_url = (:web_url), name_with_namespace = (:name_with_namespace), path_with_namespace = (:path_with_namespace) where (id = :id)", { "name" => project.name, "desc" => project.description, "path" => project.path, "ssh_url_to_repo" => project.ssh_url_to_repo, :http_url_to_repo => project.http_url_to_repo, :web_url => project.web_url, :id => project.id, :path_with_namespace => project.path_with_namespace, :name_with_namespace => project.name_with_namespace }
|
169
191
|
)
|
170
192
|
else
|
171
193
|
self.db.execute("INSERT INTO #{K_USER_PROJECTS} (id, name, desc, path, ssh_url_to_repo, http_url_to_repo, web_url,name_with_namespace, path_with_namespace)
|
@@ -174,7 +196,7 @@ module LgPodPlugin
|
|
174
196
|
end
|
175
197
|
|
176
198
|
# 通过名称查询项目信息
|
177
|
-
def query_project_info(name, git
|
199
|
+
def query_project_info(name, git)
|
178
200
|
project_info = nil
|
179
201
|
self.db.execute("select * from #{K_USER_PROJECTS} where name = '#{name}' or path = '#{name}' ;") do |row|
|
180
202
|
name_with_namespace = row[7]
|
@@ -186,25 +208,30 @@ module LgPodPlugin
|
|
186
208
|
web_url = row[6]
|
187
209
|
description = row[2]
|
188
210
|
ssh_url_to_repo = row[4]
|
189
|
-
http_url_to_repo =
|
211
|
+
http_url_to_repo = row[5]
|
190
212
|
project_info = ProjectModel.new(id, name, description, path, ssh_url_to_repo, http_url_to_repo, web_url, name_with_namespace, path_with_namespace)
|
191
213
|
return project_info
|
192
214
|
end
|
193
|
-
|
215
|
+
project_info
|
194
216
|
end
|
195
217
|
|
196
|
-
def
|
218
|
+
def delete_project_by_id(project_id)
|
219
|
+
ps = @db.prepare("DELETE FROM #{K_USER_PROJECTS} WHERE id = :n")
|
220
|
+
ps.execute('n' => project_id)
|
221
|
+
end
|
222
|
+
|
223
|
+
def insert_pod_refs(name, git, branch, tag, commit)
|
197
224
|
id = LPodLatestRefs.get_pod_id(name, git)
|
198
225
|
pod = LPodLatestRefs.new(id, name, git, branch, tag, commit)
|
199
226
|
if self.query_pod_refs(id) != nil
|
200
227
|
self.db.execute_batch(
|
201
|
-
"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}
|
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 }
|
202
229
|
)
|
203
230
|
else
|
204
231
|
self.db.execute("INSERT INTO #{K_POD_LATEST_REFS} (id, name, git, branch, tag, sha)
|
205
232
|
VALUES (?, ?, ?, ?, ?, ?)", [pod.id, pod.name, pod.git, pod.branch, pod.tag, pod.commit])
|
206
233
|
end
|
207
|
-
|
234
|
+
self.insert_pod_sha_with_branch(name, git, commit, branch)
|
208
235
|
end
|
209
236
|
|
210
237
|
def query_pod_refs(id)
|
@@ -218,9 +245,42 @@ module LgPodPlugin
|
|
218
245
|
commit = row[5]
|
219
246
|
pod_info = LPodLatestRefs.new(id, name, git, branch, tag, commit)
|
220
247
|
end
|
221
|
-
|
248
|
+
pod_info
|
249
|
+
end
|
250
|
+
|
251
|
+
# 保存 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
|
264
|
+
|
265
|
+
# 通过 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
|
222
282
|
end
|
223
283
|
|
224
284
|
end
|
225
285
|
|
226
|
-
end
|
286
|
+
end
|