cocoapods-dongjia 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-dongjia/command.rb +3 -1
- data/lib/cocoapods-dongjia/command/demo.rb +47 -0
- data/lib/cocoapods-dongjia/command/install.rb +26 -0
- data/lib/cocoapods-dongjia/command/{dongjia.rb → reinstall.rb} +0 -0
- data/lib/cocoapods-dongjia/gem_version.rb +5 -2
- data/lib/cocoapods_plugin.rb +4 -0
- data/lib/dongjia_branch_inspector.rb +27 -22
- data/lib/dongjia_config.rb +56 -0
- data/lib/dongjia_router.rb +49 -20
- data/lib/dongjia_scheme_manager.rb +28 -0
- data/lib/dongjia_source.rb +0 -2
- data/lib/helper/dongjia_version_checker.rb +22 -12
- data/lib/helper/pod.rb +9 -2
- data/lib/helper/podfile_local_importer.rb +6 -2
- data/lib/helper/project.rb +27 -0
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09ee5f3903da98865392df97577a07edeb689c257ff99366254ae5a4372a32b8'
|
4
|
+
data.tar.gz: ca00ddd8cca267b055156c7b201dc4a96358eb7b2e214ae65ccab3992e94f133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e295e3c6c8d7f309ed6329268b8876fd8ee576fcb90af7b01e868a73776608d363b422b221c6b6ea094ebade9824718d4dac67ae8956cc99e9d7776dc570e4
|
7
|
+
data.tar.gz: aa1d10dda525fb3d28c1e2f8fd27a36666d6111f22b6c411b55a9411dcc4efe4b60ff672787e8a1db44a7a74c6a4ca05e5d70c21bb4856a46ae26dded88bfbda
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
|
5
|
+
class Command
|
6
|
+
|
7
|
+
class Demo < Command
|
8
|
+
|
9
|
+
self.summary = '创建 Demo 工程在当前目录'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
创建 Demo 工程在当前目录
|
13
|
+
DESC
|
14
|
+
|
15
|
+
def run
|
16
|
+
|
17
|
+
dir = Dir.new('.')
|
18
|
+
|
19
|
+
is_pod_root = false
|
20
|
+
has_demo = false
|
21
|
+
dir.each do |name|
|
22
|
+
if name.end_with?('podspec') || name.end_with?('podspec.json')
|
23
|
+
is_pod_root = true
|
24
|
+
end
|
25
|
+
if name == 'Demo'
|
26
|
+
has_demo = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if is_pod_root
|
31
|
+
if has_demo
|
32
|
+
Pod::UI.warn('已存在 Demo')
|
33
|
+
else
|
34
|
+
`git clone git@code.kaipao.cc:ios-team/AppSpecDemo.git Demo`
|
35
|
+
`rm -fr ./Demo/.git` if File.exist?('./Demo/.git')
|
36
|
+
end
|
37
|
+
else
|
38
|
+
Pod::UI.warn('当前不在一个 Pod 的根目录')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
|
5
|
+
class Command
|
6
|
+
|
7
|
+
class Install < Command
|
8
|
+
|
9
|
+
alias_method :run_retryable, :run
|
10
|
+
def run
|
11
|
+
begin
|
12
|
+
run_retryable()
|
13
|
+
rescue => exception
|
14
|
+
# 有异常,打开 --repo-update 重试
|
15
|
+
unless @repo_update
|
16
|
+
@repo_update = true
|
17
|
+
run_retryable()
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
File without changes
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'dongjia_branch_inspector'
|
|
4
4
|
require_relative 'dongjia_enterprise_inspector'
|
5
5
|
require_relative 'dongjia_warning_manager'
|
6
6
|
require_relative 'dongjia_router'
|
7
|
+
require_relative 'dongjia_scheme_manager'
|
7
8
|
|
8
9
|
require_relative 'helper/podfile_local_importer'
|
9
10
|
require_relative 'helper/podfile_options'
|
@@ -34,6 +35,9 @@ module Dongjia
|
|
34
35
|
ctx.sandbox_root
|
35
36
|
)
|
36
37
|
|
38
|
+
# 处理 appspec 配置
|
39
|
+
SchemeManager.setup(ctx, params)
|
40
|
+
|
37
41
|
# 企业版文件引用校验
|
38
42
|
files = EnterpriseInspector.inspect()
|
39
43
|
Pod::UI.warn "文件未加入企业版:#{files}" if files.count > 0
|
@@ -3,33 +3,38 @@ require 'cocoapods'
|
|
3
3
|
module Pod
|
4
4
|
|
5
5
|
class Podfile
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
|
7
|
+
gitdir = File.join(Dir.pwd, '.git')
|
8
|
+
if File.exist?(gitdir)
|
9
|
+
|
10
|
+
# 获取当前分支,仅对 dev 和 master 进行校验
|
11
|
+
branch = `git symbolic-ref --short -q HEAD`.strip
|
12
|
+
if branch == 'dev' or branch == 'master'
|
13
|
+
|
14
|
+
# Hook pod 方法
|
15
|
+
alias_method :pod_alias_by_inspector, :pod
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
if
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
def pod(name = nil, *requirements, &block)
|
18
|
+
|
19
|
+
if name.start_with?('DJ') && requirements.count > 0
|
20
|
+
req = requirements.first
|
21
|
+
if req[:branch] && req[:branch] != 'master'
|
22
|
+
UI.warn "检测到 #{name} 指向了分支 #{req[:branch]}\n"
|
23
|
+
exit -1
|
24
|
+
elsif req[:tag]
|
25
|
+
UI.warn "检测到 #{name} 指向了标签 #{req[:tag]}\n"
|
26
|
+
exit -1
|
27
|
+
elsif req[:commit]
|
28
|
+
UI.warn "检测到 #{name} 指向了节点 #{req[:commit]}\n"
|
29
|
+
exit -1
|
30
|
+
end
|
27
31
|
end
|
32
|
+
|
33
|
+
pod_alias_by_inspector(name, *requirements, &block)
|
28
34
|
end
|
29
35
|
|
30
|
-
pod_alias_by_inspector(name, *requirements, &block)
|
31
36
|
end
|
32
|
-
|
37
|
+
|
33
38
|
end
|
34
39
|
|
35
40
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'json'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
module Dongjia
|
6
|
+
|
7
|
+
class Config
|
8
|
+
|
9
|
+
# 获取当前保存的配置
|
10
|
+
# 提供的 block 中会包含当前配置,以及一个用于保存的 Proc
|
11
|
+
def self.check
|
12
|
+
|
13
|
+
config_root = File.expand_path('~/.cocoapods-dongjia')
|
14
|
+
FileUtils.mkdir_p(config_root) unless File.exists?(config_root)
|
15
|
+
config_file = File.join(config_root, 'config.json')
|
16
|
+
|
17
|
+
config = {}
|
18
|
+
if File.exists?(config_file)
|
19
|
+
config = JSON.parse(File.read(config_file))
|
20
|
+
end
|
21
|
+
|
22
|
+
save_block = Proc.new do
|
23
|
+
File.open(config_file, 'w') do |f|
|
24
|
+
f.write(JSON.pretty_generate(config))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
yield config, save_block if block_given?
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
# 将 key 字段记录的时间,与当前时间对比,是否超过了 interval(秒)
|
33
|
+
def self.is_expired?(key, interval)
|
34
|
+
|
35
|
+
check do |config, save|
|
36
|
+
|
37
|
+
tm = config[key]
|
38
|
+
now = Time.now.to_i
|
39
|
+
if tm && (now > tm) && (now - tm < interval)
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
update_block = Proc.new do
|
44
|
+
config[key] = now
|
45
|
+
save.call
|
46
|
+
end
|
47
|
+
|
48
|
+
yield config, update_block if block_given?
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/lib/dongjia_router.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'xcodeproj'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'dongjia_config'
|
4
|
+
require 'time'
|
3
5
|
|
4
6
|
module Dongjia
|
5
7
|
|
@@ -68,10 +70,12 @@ EOS
|
|
68
70
|
file.each_line do |line|
|
69
71
|
is_start = false
|
70
72
|
if line.start_with?('@redirect')
|
73
|
+
# 路由定义开始
|
71
74
|
item = RouterItem.new(line)
|
72
75
|
item.pre_line = pre_line
|
73
76
|
is_start = true
|
74
77
|
elsif item != nil && line.start_with?('}')
|
78
|
+
# 路由定义结束
|
75
79
|
item.body << line
|
76
80
|
route_items << item
|
77
81
|
item = nil
|
@@ -88,24 +92,13 @@ EOS
|
|
88
92
|
route_items
|
89
93
|
end
|
90
94
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
return
|
95
|
-
end
|
96
|
-
|
97
|
-
result_file_path = ''
|
98
|
-
path = config[:path]
|
99
|
-
if path && path.length > 0
|
100
|
-
result_file_path = File.expand_path(File.join(sandbox_root, '..', path))
|
101
|
-
end
|
102
|
-
if !File.exist?(result_file_path)
|
103
|
-
Pod::UI.warn("Router scrapy: path not found.")
|
104
|
-
return
|
105
|
-
end
|
106
|
-
|
95
|
+
# 开始抓取
|
96
|
+
def start_scrapy(sandbox_root, result_file_path)
|
97
|
+
|
107
98
|
route_items = []
|
108
99
|
|
100
|
+
Pod::UI.puts("Scraping routers")
|
101
|
+
|
109
102
|
Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
|
110
103
|
proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
|
111
104
|
if name != 'Pods.xcodeproj'
|
@@ -113,10 +106,6 @@ EOS
|
|
113
106
|
next unless target.name.start_with?('DJ')
|
114
107
|
next unless target.is_a?(Xcodeproj::Project::Object::PBXNativeTarget)
|
115
108
|
target.source_build_phase.files_references.each do |file|
|
116
|
-
next if file.path.end_with?('Api.m')
|
117
|
-
next if file.path.end_with?('Model.m')
|
118
|
-
next if file.path.end_with?('-dummy.m')
|
119
|
-
next if file.path.end_with?('Log.m')
|
120
109
|
route_items += route_items_from_file(file.real_path)
|
121
110
|
end
|
122
111
|
end
|
@@ -142,6 +131,46 @@ EOS
|
|
142
131
|
|
143
132
|
# 将文件只读
|
144
133
|
FileUtils.chmod('ugo-w', result_file_path)
|
134
|
+
end
|
135
|
+
|
136
|
+
# 外部入口
|
137
|
+
def scrape_routers(sandbox_root, config)
|
138
|
+
|
139
|
+
if config == nil
|
140
|
+
return
|
141
|
+
end
|
142
|
+
|
143
|
+
begin
|
144
|
+
|
145
|
+
result_file_path = ''
|
146
|
+
path = config[:path]
|
147
|
+
if path && path.length > 0
|
148
|
+
result_file_path = File.expand_path(File.join(sandbox_root, '..', path))
|
149
|
+
end
|
150
|
+
|
151
|
+
if !File.exist?(result_file_path)
|
152
|
+
Pod::UI.warn("Router scrapy: path not found.")
|
153
|
+
return
|
154
|
+
end
|
155
|
+
|
156
|
+
key = 'latest_scrapy_router_tm'
|
157
|
+
content = File.read(result_file_path)
|
158
|
+
if content.length < 10
|
159
|
+
Config.check do |cfg, save|
|
160
|
+
start_scrapy(sandbox_root, result_file_path)
|
161
|
+
cfg[key] = Time.now.to_i
|
162
|
+
save.call
|
163
|
+
end
|
164
|
+
else
|
165
|
+
Config.is_expired?(key, 24 * 60 * 60) do |_, update|
|
166
|
+
start_scrapy(sandbox_root, result_file_path)
|
167
|
+
update.call
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
rescue => e
|
172
|
+
puts "Error: #{e}"
|
173
|
+
end
|
145
174
|
|
146
175
|
end
|
147
176
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper/project'
|
2
|
+
|
3
|
+
module Dongjia
|
4
|
+
|
5
|
+
class SchemeManager
|
6
|
+
|
7
|
+
def self.setup(ctx, params)
|
8
|
+
visibled_appspecs = params[:visibled_appspecs]
|
9
|
+
return if !visibled_appspecs || visibled_appspecs.empty?
|
10
|
+
sandbox_root = ctx.sandbox_root
|
11
|
+
Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
|
12
|
+
proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
|
13
|
+
proj.targets.each do | target |
|
14
|
+
# 确保是 appspec
|
15
|
+
next unless target.name.include?('-')
|
16
|
+
# 确保是可执行程序
|
17
|
+
next unless target.product_type == 'com.apple.product-type.application'
|
18
|
+
pod_name = target.name.split('-').first
|
19
|
+
if visibled_appspecs.include?(pod_name)
|
20
|
+
proj.set_target_scheme_visible(target, true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/dongjia_source.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cocoapods-dongjia/gem_version'
|
2
|
+
require 'dongjia_config'
|
2
3
|
require 'gems'
|
3
4
|
|
4
5
|
module Dongjia
|
@@ -10,21 +11,30 @@ module Dongjia
|
|
10
11
|
Pod::UI.puts 'Done.'
|
11
12
|
|
12
13
|
begin
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
|
15
|
+
Config.is_expired?('latest_check_tm', 24 * 60 * 60) do |config, update|
|
16
|
+
|
17
|
+
info = Gems.info 'cocoapods-dongjia'
|
18
|
+
latest_version = info['version']
|
19
|
+
v = CocoapodsDongjia::VERSION
|
20
|
+
|
21
|
+
if v < latest_version
|
22
|
+
update_desc = info['metadata']['update_desc']
|
23
|
+
warnings = "cocoapods-dongjia #{latest_version} is available.\n\n"
|
24
|
+
warnings << update_desc.rstrip << "\n\n"
|
25
|
+
warnings << "To upgrade: [sudo] gem install cocoapods-dongjia\n"
|
26
|
+
Pod::UI.warn warnings
|
27
|
+
end
|
28
|
+
|
29
|
+
update.call
|
30
|
+
|
23
31
|
end
|
24
|
-
|
32
|
+
|
33
|
+
rescue => e
|
34
|
+
puts "Error: #{e}"
|
25
35
|
end
|
26
36
|
end
|
27
37
|
|
28
38
|
end
|
29
39
|
|
30
|
-
end
|
40
|
+
end
|
data/lib/helper/pod.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
|
1
3
|
module Pod
|
2
4
|
|
3
5
|
def self.repo_name(name)
|
@@ -19,13 +21,18 @@ module Pod
|
|
19
21
|
local_path = File.join(local_root, repo_name(name))
|
20
22
|
end
|
21
23
|
if local_path
|
22
|
-
requirements.pop
|
23
|
-
|
24
|
+
cfg = requirements.pop
|
25
|
+
cfg.reject! { |key, value|
|
26
|
+
[:git, :branch, :tag, :commit, :podspec].include?(key)
|
27
|
+
}
|
28
|
+
cfg.merge!({:path => local_path})
|
29
|
+
requirements.push(cfg)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
27
33
|
# 注入远程仓库地址
|
28
34
|
def self.inject_remote_git(name, requirements)
|
35
|
+
name = name.split('/').first
|
29
36
|
options = requirements.pop
|
30
37
|
options[:git] = "git@code.kaipao.cc:ios-team/components/#{name}.git"
|
31
38
|
requirements.push(options)
|
@@ -18,8 +18,12 @@ module Pod
|
|
18
18
|
original_pod = instance_method(:pod)
|
19
19
|
define_method(:pod) do |name = nil, *requirements|
|
20
20
|
if @local_spec_importing
|
21
|
+
path_cfg = { :path => "#{@local_spec_path}/#{Pod::repo_name(name)}" }
|
21
22
|
if requirements.length == 0
|
22
|
-
requirements = [
|
23
|
+
requirements = [path_cfg]
|
24
|
+
else
|
25
|
+
cfg = requirements.first
|
26
|
+
cfg.merge!(path_cfg) unless cfg.has_key?(:path)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
original_pod.bind(self).(name, *requirements)
|
@@ -27,4 +31,4 @@ module Pod
|
|
27
31
|
|
28
32
|
end
|
29
33
|
|
30
|
-
end
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
|
3
|
+
module Xcodeproj
|
4
|
+
|
5
|
+
class Project
|
6
|
+
|
7
|
+
# 设置对应 target 为可见
|
8
|
+
# 逻辑参考 Xcodeproj::Project.recreate_user_schemes 方法
|
9
|
+
def set_target_scheme_visible(target, visible = true)
|
10
|
+
schemes_dir = XCScheme.user_data_dir(target.project.path)
|
11
|
+
|
12
|
+
xcschememanagement_path = schemes_dir + 'xcschememanagement.plist'
|
13
|
+
|
14
|
+
xcschememanagement = Plist.read_from_path(xcschememanagement_path)
|
15
|
+
|
16
|
+
user_state = xcschememanagement['SchemeUserState']
|
17
|
+
|
18
|
+
key = target.name + '.xcscheme'
|
19
|
+
|
20
|
+
user_state[key]['isShown'] = visible
|
21
|
+
|
22
|
+
Plist.write_to_path(xcschememanagement, xcschememanagement_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-dongjia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiangzhuoyi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,12 +61,16 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- lib/cocoapods-dongjia.rb
|
63
63
|
- lib/cocoapods-dongjia/command.rb
|
64
|
-
- lib/cocoapods-dongjia/command/
|
64
|
+
- lib/cocoapods-dongjia/command/demo.rb
|
65
|
+
- lib/cocoapods-dongjia/command/install.rb
|
66
|
+
- lib/cocoapods-dongjia/command/reinstall.rb
|
65
67
|
- lib/cocoapods-dongjia/gem_version.rb
|
66
68
|
- lib/cocoapods_plugin.rb
|
67
69
|
- lib/dongjia_branch_inspector.rb
|
70
|
+
- lib/dongjia_config.rb
|
68
71
|
- lib/dongjia_enterprise_inspector.rb
|
69
72
|
- lib/dongjia_router.rb
|
73
|
+
- lib/dongjia_scheme_manager.rb
|
70
74
|
- lib/dongjia_source.rb
|
71
75
|
- lib/dongjia_warning_manager.rb
|
72
76
|
- lib/helper/dongjia_version_checker.rb
|
@@ -74,11 +78,16 @@ files:
|
|
74
78
|
- lib/helper/podfile_local_importer.rb
|
75
79
|
- lib/helper/podfile_options.rb
|
76
80
|
- lib/helper/podfile_warnings.rb
|
81
|
+
- lib/helper/project.rb
|
77
82
|
homepage: https://github.com/EXAMPLE/cocoapods-dongjia
|
78
83
|
licenses:
|
79
84
|
- MIT
|
80
85
|
metadata:
|
81
|
-
update_desc:
|
86
|
+
update_desc: |2
|
87
|
+
- 修复本地 pod 添加属性出错
|
88
|
+
- 添加 demo 指令
|
89
|
+
- 更为高效的 repo 更新机制
|
90
|
+
- 优化版本检测和路由抓取触发逻辑
|
82
91
|
post_install_message:
|
83
92
|
rdoc_options: []
|
84
93
|
require_paths:
|