cocoapods-dongjia 1.0.7 → 1.1.2
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 +4 -4
- data/lib/cocoapods-dongjia/command.rb +5 -1
- data/lib/cocoapods-dongjia/command/demo.rb +47 -0
- data/lib/cocoapods-dongjia/command/install.rb +26 -0
- data/lib/cocoapods-dongjia/command/open.rb +32 -0
- data/lib/cocoapods-dongjia/command/{dongjia.rb → reinstall.rb} +0 -0
- data/lib/cocoapods-dongjia/command/strip.rb +182 -0
- data/lib/cocoapods-dongjia/gem_version.rb +3 -2
- data/lib/cocoapods_plugin.rb +7 -6
- data/lib/dongjia_branch_inspector.rb +27 -22
- data/lib/dongjia_config.rb +56 -0
- data/lib/dongjia_pods_iterator.rb +77 -0
- data/lib/dongjia_router.rb +58 -26
- data/lib/dongjia_scheme_manager.rb +58 -0
- data/lib/dongjia_source.rb +0 -2
- data/lib/helper/dongjia_version_checker.rb +22 -12
- data/lib/helper/pod.rb +13 -2
- data/lib/helper/podfile_local_importer.rb +6 -2
- data/lib/helper/project.rb +27 -0
- metadata +29 -6
- data/lib/dongjia_warning_manager.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa6197291c8d0327124cdfe9a152f5a4cddc91a15fb42571ca10c175f96fa730
|
4
|
+
data.tar.gz: 4e68535d83b1c174b1e01314cf00f4fecd45c0131de4fbb4b37e64ffb4504c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d3a68721994c607cace3a8bca9bd89832887ef55646f5d9950c71c23099881f7299449cfd37940201a703116819d9173f18f99aaffa4a5dc0272ff7256ef598
|
7
|
+
data.tar.gz: dc481b20dc7a3505f0a089ef465a513e4e026086df1a89fe7d97563c30accab74cd6492897a8debf79645aae1ffa0ac1241bd4356584cd7b6a5567e115cda484
|
@@ -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
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
|
5
|
+
class Command
|
6
|
+
|
7
|
+
class Open < Command
|
8
|
+
|
9
|
+
self.summary = '快速打开项目的 .xcworkspace'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
快速打开项目的 .xcworkspace
|
13
|
+
DESC
|
14
|
+
|
15
|
+
def validate!
|
16
|
+
super
|
17
|
+
|
18
|
+
workspace_list = Pathname.glob('*.xcworkspace')
|
19
|
+
@workspace_path = workspace_list.first if workspace_list.size == 1
|
20
|
+
|
21
|
+
help! '没有找到 xcworkspace' unless @workspace_path.exist?
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
`open #{@workspace_path}`
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
File without changes
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
|
6
|
+
class Image
|
7
|
+
attr_accessor :dir
|
8
|
+
attr_accessor :name
|
9
|
+
attr_accessor :fuzzy_name
|
10
|
+
def initialize(dir, name)
|
11
|
+
@dir = dir
|
12
|
+
if name.end_with?('@2x') || name.end_with?('@3x')
|
13
|
+
name = name[0, name.length-3]
|
14
|
+
end
|
15
|
+
@name = name
|
16
|
+
|
17
|
+
# 只处理最后一段为数字,或分了三段及以上的命名形式
|
18
|
+
comps = name.split('_')
|
19
|
+
last = comps.last
|
20
|
+
if last.to_i > 0 || last.start_with?('0') || comps.count >= 3
|
21
|
+
@fuzzy_name = name[0, name.length - last.length]
|
22
|
+
else
|
23
|
+
@fuzzy_name = ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def eql?(other)
|
28
|
+
@dir == other.dir && @name == other.name
|
29
|
+
end
|
30
|
+
|
31
|
+
def hash
|
32
|
+
[@dir, @name].hash
|
33
|
+
end
|
34
|
+
|
35
|
+
def fullpath
|
36
|
+
File.join(@dir, @name)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Command
|
41
|
+
|
42
|
+
class Strip < Command
|
43
|
+
|
44
|
+
self.summary = '查找工程内所有无效资源'
|
45
|
+
|
46
|
+
self.description = <<-DESC
|
47
|
+
查找工程内所有无效资源
|
48
|
+
DESC
|
49
|
+
|
50
|
+
def validate!
|
51
|
+
super
|
52
|
+
|
53
|
+
@img_exts = ['.png', '.jpg', '.jpeg', '.webp', '.gif']
|
54
|
+
|
55
|
+
@proj_paths = []
|
56
|
+
@proj_paths |= Pathname.glob('*.xcodeproj')
|
57
|
+
@proj_paths |= Pathname.glob('Pods/*.xcodeproj')
|
58
|
+
|
59
|
+
help! '未发现任何工程' unless @proj_paths.count > 0
|
60
|
+
end
|
61
|
+
|
62
|
+
# 遍历目录找出所有图片
|
63
|
+
def traverse(path, except_dirs, bk = nil)
|
64
|
+
dir = File.dirname(path)
|
65
|
+
ext = File.extname(path)
|
66
|
+
name = File.basename(path, ext)
|
67
|
+
basename = File.basename(path)
|
68
|
+
if except_dirs.include?(basename)
|
69
|
+
return
|
70
|
+
end
|
71
|
+
if File.directory?(path)
|
72
|
+
if ext == '.imageset'
|
73
|
+
# imageset 直接返回
|
74
|
+
bk.call(dir, name, ext)
|
75
|
+
else
|
76
|
+
Dir.foreach(path) do |name|
|
77
|
+
unless name.start_with?('.') || name.end_with?('.launchimage')
|
78
|
+
traverse(File.join(path, name), except_dirs, bk)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
else
|
83
|
+
bk.call(dir, name, ext) if @img_exts.include?(ext)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# 获取源文件
|
88
|
+
def get_source_files
|
89
|
+
source_files = []
|
90
|
+
@proj_paths.each do |path|
|
91
|
+
proj = Xcodeproj::Project.open(path)
|
92
|
+
proj.targets.each do |target|
|
93
|
+
target.build_phases.each do |phase|
|
94
|
+
if phase.is_a?(Xcodeproj::Project::PBXSourcesBuildPhase)
|
95
|
+
source_files |= phase.files
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
source_files
|
101
|
+
end
|
102
|
+
|
103
|
+
# 获取所有图片资源
|
104
|
+
def get_images
|
105
|
+
images = Set[]
|
106
|
+
except_dirs = [
|
107
|
+
'QYResource.bundle',
|
108
|
+
'DJMate',
|
109
|
+
'IQKeyboardManager',
|
110
|
+
'MJRefresh.bundle',
|
111
|
+
'AlipaySDK.bundle',
|
112
|
+
'AppIcon.appiconset',
|
113
|
+
'KPCameraImages.xcassets',
|
114
|
+
'Umeng',
|
115
|
+
'LaunchResource'
|
116
|
+
]
|
117
|
+
except_files = [
|
118
|
+
'image_placeholder',
|
119
|
+
'register_add_avatar'
|
120
|
+
]
|
121
|
+
bk = Proc.new do |dir, name, ext|
|
122
|
+
next if except_files.include?(name)
|
123
|
+
images << Image.new(dir, name)
|
124
|
+
end
|
125
|
+
traverse(Dir.pwd, except_dirs, bk)
|
126
|
+
images
|
127
|
+
end
|
128
|
+
|
129
|
+
# 分析
|
130
|
+
def analyze(source_files, images)
|
131
|
+
source_file_paths = source_files.map { |x|
|
132
|
+
x.file_ref.real_path
|
133
|
+
}
|
134
|
+
.select { |x|
|
135
|
+
File.exist?(x)
|
136
|
+
}
|
137
|
+
count = source_file_paths.count
|
138
|
+
source_file_paths.each_index do | index |
|
139
|
+
percent = index.to_f / count.to_f * 100
|
140
|
+
print "\r" if index != 0
|
141
|
+
print "#{format("%.2f", percent)}%"
|
142
|
+
path = source_file_paths[index]
|
143
|
+
File.open(path, 'r') do |f|
|
144
|
+
image_using = []
|
145
|
+
f.each_line do |line|
|
146
|
+
next unless line.include?('"')
|
147
|
+
['"', '/'].each do |prefix|
|
148
|
+
images.each do |img|
|
149
|
+
if line.include?(prefix + img.name)
|
150
|
+
image_using << img
|
151
|
+
else
|
152
|
+
# 根据下划线分割剔除最后一项,再尝试匹配
|
153
|
+
if !img.fuzzy_name.empty?
|
154
|
+
['%', '"'].each do |suffix|
|
155
|
+
image_using << img if line.include?(prefix + img.fuzzy_name + suffix)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
images = images - image_using
|
163
|
+
end
|
164
|
+
end
|
165
|
+
print "\r"
|
166
|
+
images
|
167
|
+
end
|
168
|
+
|
169
|
+
def run
|
170
|
+
images = analyze(get_source_files, get_images)
|
171
|
+
puts "无效资源文件:"
|
172
|
+
images.each do |img|
|
173
|
+
path = Pathname.new(img.fullpath).relative_path_from(Dir.pwd).to_s
|
174
|
+
puts " #{path}"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -2,8 +2,9 @@ require 'cocoapods-dongjia/command'
|
|
2
2
|
require_relative 'dongjia_source'
|
3
3
|
require_relative 'dongjia_branch_inspector'
|
4
4
|
require_relative 'dongjia_enterprise_inspector'
|
5
|
-
require_relative '
|
5
|
+
require_relative 'dongjia_pods_iterator'
|
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'
|
@@ -28,11 +29,11 @@ module Dongjia
|
|
28
29
|
|
29
30
|
Pod::HooksManager.register('cocoapods-dongjia', :post_install) do |ctx, params|
|
30
31
|
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
)
|
32
|
+
# 关闭警告 / 检查 LTO
|
33
|
+
PodsIterator.iterate(params, ctx.sandbox_root)
|
34
|
+
|
35
|
+
# 处理 appspec 配置
|
36
|
+
SchemeManager.setup(ctx, params)
|
36
37
|
|
37
38
|
# 企业版文件引用校验
|
38
39
|
files = EnterpriseInspector.inspect()
|
@@ -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
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
|
3
|
+
module Dongjia
|
4
|
+
|
5
|
+
class PodsIterator
|
6
|
+
|
7
|
+
# 关闭警告
|
8
|
+
def self.disable_warnings(config, target_name)
|
9
|
+
# 禁用非 DJ 开头 Pod 的警告
|
10
|
+
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES" unless target_name.start_with?('DJ')
|
11
|
+
|
12
|
+
# 不检测 block 中的隐式 self 调用
|
13
|
+
config.build_settings['CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF'] = "NO"
|
14
|
+
|
15
|
+
# 不检测已废弃的方法
|
16
|
+
config.build_settings['GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS'] = "NO"
|
17
|
+
|
18
|
+
# 允许 objc_msgSend
|
19
|
+
config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
|
20
|
+
|
21
|
+
# 不检测注释
|
22
|
+
config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = "NO"
|
23
|
+
|
24
|
+
# 不严格的原型校验
|
25
|
+
config.build_settings['CLANG_WARN_STRICT_PROTOTYPES'] = "NO"
|
26
|
+
|
27
|
+
# 强制设置 deployment 版本为 8.0
|
28
|
+
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
|
29
|
+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
|
30
|
+
end
|
31
|
+
|
32
|
+
# 关闭 bitcode
|
33
|
+
config.build_settings['ENABLE_BITCODE'] = "NO"
|
34
|
+
end
|
35
|
+
|
36
|
+
# 打开 LTO
|
37
|
+
def self.enable_lto(config)
|
38
|
+
config.build_settings['LLVM_LTO'] = 'YES_THIN' if config.name == 'Release'
|
39
|
+
end
|
40
|
+
|
41
|
+
# 遍历所有 Pod 工程配置
|
42
|
+
def self.iterate(params, sandbox_root)
|
43
|
+
turn_off_warnings = params[:turn_off_warnings]
|
44
|
+
lto_enabled = params[:lto_enabled]
|
45
|
+
return if (turn_off_warnings != true) && (lto_enabled != true)
|
46
|
+
|
47
|
+
Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
|
48
|
+
|
49
|
+
proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
|
50
|
+
|
51
|
+
if name != 'Pods.xcodeproj'
|
52
|
+
proj.build_configurations.each do | config |
|
53
|
+
# 强制设置 deployment 版本为 8.0
|
54
|
+
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
|
55
|
+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# project 的每个 target 配置
|
61
|
+
proj.targets.select {|t| !t.name.start_with?('Pods')}.each do | target |
|
62
|
+
next if target.name.start_with?('Pods')
|
63
|
+
target.build_configurations.each do | config |
|
64
|
+
disable_warnings(config, target.name) if turn_off_warnings
|
65
|
+
enable_lto(config) if lto_enabled
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
proj.save
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
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
|
|
@@ -28,16 +30,19 @@ EOS
|
|
28
30
|
@body = ''
|
29
31
|
@prefix = nil
|
30
32
|
prefix_len = 0
|
31
|
-
if @defining_line.start_with?('@redirectObj(')
|
32
|
-
@prefix = '
|
33
|
+
if @defining_line.start_with?('@RedirectObj(') || @defining_line.start_with?('@redirectObj(')
|
34
|
+
@prefix = 'RedirectObj'
|
33
35
|
prefix_len = @prefix.length + 2
|
34
|
-
elsif @defining_line.start_with?('@redirect(')
|
35
|
-
@prefix = '
|
36
|
+
elsif @defining_line.start_with?('@Redirect(') || @defining_line.start_with?('@redirect(')
|
37
|
+
@prefix = 'Redirect'
|
36
38
|
prefix_len = @prefix.length + 2
|
37
39
|
end
|
38
40
|
|
39
41
|
if @prefix != nil
|
40
|
-
|
42
|
+
end_index = @defining_line.index(',') || @defining_line.index(')')
|
43
|
+
if !end_index.nil?
|
44
|
+
@redirect_type = @defining_line[prefix_len, end_index - prefix_len]
|
45
|
+
end
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
@@ -67,11 +72,13 @@ EOS
|
|
67
72
|
pre_line = nil
|
68
73
|
file.each_line do |line|
|
69
74
|
is_start = false
|
70
|
-
if line.start_with?('@redirect')
|
75
|
+
if line.start_with?('@Redirect') || line.start_with?('@redirect')
|
76
|
+
# 路由定义开始
|
71
77
|
item = RouterItem.new(line)
|
72
78
|
item.pre_line = pre_line
|
73
79
|
is_start = true
|
74
80
|
elsif item != nil && line.start_with?('}')
|
81
|
+
# 路由定义结束
|
75
82
|
item.body << line
|
76
83
|
route_items << item
|
77
84
|
item = nil
|
@@ -88,24 +95,13 @@ EOS
|
|
88
95
|
route_items
|
89
96
|
end
|
90
97
|
|
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
|
-
|
98
|
+
# 开始抓取
|
99
|
+
def start_scrapy(sandbox_root, result_file_path)
|
100
|
+
|
107
101
|
route_items = []
|
108
102
|
|
103
|
+
Pod::UI.puts("Scraping routers")
|
104
|
+
|
109
105
|
Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
|
110
106
|
proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
|
111
107
|
if name != 'Pods.xcodeproj'
|
@@ -113,10 +109,6 @@ EOS
|
|
113
109
|
next unless target.name.start_with?('DJ')
|
114
110
|
next unless target.is_a?(Xcodeproj::Project::Object::PBXNativeTarget)
|
115
111
|
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
112
|
route_items += route_items_from_file(file.real_path)
|
121
113
|
end
|
122
114
|
end
|
@@ -142,6 +134,46 @@ EOS
|
|
142
134
|
|
143
135
|
# 将文件只读
|
144
136
|
FileUtils.chmod('ugo-w', result_file_path)
|
137
|
+
end
|
138
|
+
|
139
|
+
# 外部入口
|
140
|
+
def scrape_routers(sandbox_root, config)
|
141
|
+
|
142
|
+
if config == nil
|
143
|
+
return
|
144
|
+
end
|
145
|
+
|
146
|
+
begin
|
147
|
+
|
148
|
+
result_file_path = ''
|
149
|
+
path = config[:path]
|
150
|
+
if path && path.length > 0
|
151
|
+
result_file_path = File.expand_path(File.join(sandbox_root, '..', path))
|
152
|
+
end
|
153
|
+
|
154
|
+
if !File.exist?(result_file_path)
|
155
|
+
Pod::UI.warn("Router scrapy: path not found.")
|
156
|
+
return
|
157
|
+
end
|
158
|
+
|
159
|
+
key = 'latest_scrapy_router_tm'
|
160
|
+
content = File.read(result_file_path)
|
161
|
+
if content.length < 10
|
162
|
+
Config.check do |cfg, save|
|
163
|
+
start_scrapy(sandbox_root, result_file_path)
|
164
|
+
cfg[key] = Time.now.to_i
|
165
|
+
save.call
|
166
|
+
end
|
167
|
+
else
|
168
|
+
Config.is_expired?(key, 24 * 60 * 60) do |_, update|
|
169
|
+
start_scrapy(sandbox_root, result_file_path)
|
170
|
+
update.call
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
rescue => e
|
175
|
+
puts "Error: #{e}"
|
176
|
+
end
|
145
177
|
|
146
178
|
end
|
147
179
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'helper/project'
|
2
|
+
|
3
|
+
module Dongjia
|
4
|
+
|
5
|
+
class SchemeManager
|
6
|
+
|
7
|
+
# 获取主工程的 development team
|
8
|
+
def self.development_team(ctx)
|
9
|
+
team = nil
|
10
|
+
project = ctx.umbrella_targets.first.user_project
|
11
|
+
return team unless project.is_a?(Xcodeproj::Project)
|
12
|
+
|
13
|
+
target = project.targets.find { |t|
|
14
|
+
!t.name.include?('企业版') && !t.name.end_with?('Extension')
|
15
|
+
}
|
16
|
+
return team unless target.is_a?(Xcodeproj::Project::PBXNativeTarget)
|
17
|
+
|
18
|
+
build_cfg = target.build_configurations.find { |c| c.name == 'Debug' }
|
19
|
+
return team unless build_cfg.is_a?(Xcodeproj::Project::XCBuildConfiguration)
|
20
|
+
|
21
|
+
team = build_cfg.build_settings['DEVELOPMENT_TEAM']
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.setup(ctx, params)
|
25
|
+
visibled_appspecs = params[:visibled_appspecs]
|
26
|
+
# return if !visibled_appspecs || visibled_appspecs.empty?
|
27
|
+
sandbox_root = ctx.sandbox_root
|
28
|
+
|
29
|
+
team = development_team(ctx)
|
30
|
+
|
31
|
+
Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
|
32
|
+
proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
|
33
|
+
proj.targets.each do | target |
|
34
|
+
# 确保是 appspec
|
35
|
+
next unless target.name.include?('-')
|
36
|
+
# 确保是可执行程序
|
37
|
+
next unless target.product_type == 'com.apple.product-type.application'
|
38
|
+
|
39
|
+
# 设置签名信息
|
40
|
+
if team.is_a?(String)
|
41
|
+
target.build_configurations.first.build_settings['DEVELOPMENT_TEAM'] = team
|
42
|
+
target.build_configurations.each { |cfg|
|
43
|
+
cfg.build_settings['DEVELOPMENT_TEAM'] = team
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
if visibled_appspecs.include?(target.name.split('-').first)
|
48
|
+
# 将 visibled_appspecs 中指定的 target 设为可见状态
|
49
|
+
proj.set_target_scheme_visible(target, true)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
proj.save if team.is_a?(String)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
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 Gem::Version.new(v) < Gem::Version.new(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,22 @@ 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
|
+
if cfg.is_a?(Hash)
|
26
|
+
cfg.reject! { |key, value|
|
27
|
+
[:git, :branch, :tag, :commit, :podspec].include?(key)
|
28
|
+
}
|
29
|
+
else
|
30
|
+
cfg = {:path => local_path}
|
31
|
+
end
|
32
|
+
cfg.merge!({:path => local_path})
|
33
|
+
requirements.push(cfg)
|
24
34
|
end
|
25
35
|
end
|
26
36
|
|
27
37
|
# 注入远程仓库地址
|
28
38
|
def self.inject_remote_git(name, requirements)
|
39
|
+
name = name.split('/').first
|
29
40
|
options = requirements.pop
|
30
41
|
options[:git] = "git@code.kaipao.cc:ios-team/components/#{name}.git"
|
31
42
|
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.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiangzhuoyi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.13.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.13.0
|
55
69
|
description: A short description of cocoapods-dongjia.
|
56
70
|
email:
|
57
71
|
- jiangzhuoyi@idongjia.cn
|
@@ -61,24 +75,33 @@ extra_rdoc_files: []
|
|
61
75
|
files:
|
62
76
|
- lib/cocoapods-dongjia.rb
|
63
77
|
- lib/cocoapods-dongjia/command.rb
|
64
|
-
- lib/cocoapods-dongjia/command/
|
78
|
+
- lib/cocoapods-dongjia/command/demo.rb
|
79
|
+
- lib/cocoapods-dongjia/command/install.rb
|
80
|
+
- lib/cocoapods-dongjia/command/open.rb
|
81
|
+
- lib/cocoapods-dongjia/command/reinstall.rb
|
82
|
+
- lib/cocoapods-dongjia/command/strip.rb
|
65
83
|
- lib/cocoapods-dongjia/gem_version.rb
|
66
84
|
- lib/cocoapods_plugin.rb
|
67
85
|
- lib/dongjia_branch_inspector.rb
|
86
|
+
- lib/dongjia_config.rb
|
68
87
|
- lib/dongjia_enterprise_inspector.rb
|
88
|
+
- lib/dongjia_pods_iterator.rb
|
69
89
|
- lib/dongjia_router.rb
|
90
|
+
- lib/dongjia_scheme_manager.rb
|
70
91
|
- lib/dongjia_source.rb
|
71
|
-
- lib/dongjia_warning_manager.rb
|
72
92
|
- lib/helper/dongjia_version_checker.rb
|
73
93
|
- lib/helper/pod.rb
|
74
94
|
- lib/helper/podfile_local_importer.rb
|
75
95
|
- lib/helper/podfile_options.rb
|
76
96
|
- lib/helper/podfile_warnings.rb
|
97
|
+
- lib/helper/project.rb
|
77
98
|
homepage: https://github.com/EXAMPLE/cocoapods-dongjia
|
78
99
|
licenses:
|
79
100
|
- MIT
|
80
101
|
metadata:
|
81
|
-
update_desc:
|
102
|
+
update_desc: |2
|
103
|
+
- 修复路由抓取错误
|
104
|
+
- 修复 pod strip
|
82
105
|
post_install_message:
|
83
106
|
rdoc_options: []
|
84
107
|
require_paths:
|
@@ -94,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
117
|
- !ruby/object:Gem::Version
|
95
118
|
version: '0'
|
96
119
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.1.4
|
98
121
|
signing_key:
|
99
122
|
specification_version: 4
|
100
123
|
summary: A longer description of cocoapods-dongjia.
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'xcodeproj'
|
2
|
-
|
3
|
-
module Dongjia
|
4
|
-
|
5
|
-
class WarningManager
|
6
|
-
|
7
|
-
def self.turn_off_warnings(turn_off, sandbox_root)
|
8
|
-
|
9
|
-
return if (turn_off != true)
|
10
|
-
|
11
|
-
Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
|
12
|
-
|
13
|
-
proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
|
14
|
-
|
15
|
-
if name != 'Pods.xcodeproj'
|
16
|
-
proj.build_configurations.each do | config |
|
17
|
-
# 强制设置 deployment 版本为 8.0
|
18
|
-
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
|
19
|
-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# project 的每个 target 配置
|
25
|
-
proj.targets.each do | target |
|
26
|
-
|
27
|
-
next if target.name.start_with?('Pods')
|
28
|
-
|
29
|
-
target.build_configurations.each do | config |
|
30
|
-
|
31
|
-
# 禁用非 DJ 开头 Pod 的警告
|
32
|
-
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES" unless target.name.start_with?('DJ')
|
33
|
-
|
34
|
-
# 不检测 block 中的隐式 self 调用
|
35
|
-
config.build_settings['CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF'] = "NO"
|
36
|
-
|
37
|
-
# 不检测已废弃的方法
|
38
|
-
config.build_settings['GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS'] = "NO"
|
39
|
-
|
40
|
-
# 允许 objc_msgSend
|
41
|
-
config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
|
42
|
-
|
43
|
-
# 不检测注释
|
44
|
-
config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = "NO"
|
45
|
-
|
46
|
-
# 不严格的原型校验
|
47
|
-
config.build_settings['CLANG_WARN_STRICT_PROTOTYPES'] = "NO"
|
48
|
-
|
49
|
-
# 强制设置 deployment 版本为 8.0
|
50
|
-
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
|
51
|
-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
|
52
|
-
end
|
53
|
-
|
54
|
-
# 关闭 bitcode
|
55
|
-
config.build_settings['ENABLE_BITCODE'] = "NO"
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
proj.save
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|