cocoapods-TSPodfileTimeWatch 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89729e0d0c653130cfbb13c2d89e6b0d7d622dc407509c7e7a05cecaa66ee482
4
- data.tar.gz: ffe84060ada4a3cf0885dc06f15d0c2ee9130438f76600cc84a3e7d3c7fd7d68
3
+ metadata.gz: 1c1c799547f6b0af443869a0c5f264e27e8887a976718576e33da494f2bab4ab
4
+ data.tar.gz: 8d6c7a5e9f35f833122def3143184c15ebf88b14c8b628c82ff1e2ae262c7d81
5
5
  SHA512:
6
- metadata.gz: 1d3bf5efc5d150e3a4a8a1a8fa02d744190a503187be64d6716fb89c82e845998d32925cba5c59d0c75c01ef622526dec926cff88a78109e4aac308123bccfc8
7
- data.tar.gz: 19ff0979aff5e38ec424bcd5b26f423b2eac5d827e90caeebf62dd75b638897fd8390a60c55d491a8fb8a2ad069592f28c7865a527f49005c92ed206f3cd01d7
6
+ metadata.gz: 273fe76b9b43e5a3a0072072b8c3d5fff6518294f5376712667f15de26ce09cdd216fdf8ddcea3626e5d851871d57201df519ca259aaa69750e93164c1f467da
7
+ data.tar.gz: 17bddcc381c6f3dd3c4072ad9a9ccb4f85189b47be789e3604ac815833bf7b42635186b3b241bf8accddff0f0c7e729ca53d63c1817c6dfc3c85720bab5e78b5
data/README.md CHANGED
@@ -2,8 +2,29 @@
2
2
 
3
3
 
4
4
 
5
+ ## 统计每个pod库下载耗时插件
6
+ [![Bb8zIx.png](https://s1.ax1x.com/2020/11/09/Bb8zIx.png)](https://imgchr.com/i/Bb8zIx)
7
+
5
8
  ## 安装:
6
9
 
10
+ 使用cocoapods plugin的方式实现
11
+
7
12
  $ gem install cocoapods-TSPodfileTimeWatch
8
13
 
9
- 可以通过pod install/update --verbose获取每个pod的下载耗时(S),git clone文件大小(M),cache文件大小(M),大小差值(M)。如果大小差值过大则存在优化空间。具体的统计数据请在#{Dir.home}/.AllPodsTimeAndSize.csv中查看。
14
+ ## 使用方法
15
+
16
+ 1.gem install cocoapods-TSPodfileTimeWatch(安装cocoapods-TSPodfileTimeWatch)
17
+
18
+ 2.删除pods文件夹
19
+
20
+ 3.删除podfile.lock文件
21
+
22
+ 4.删除pod缓存(pod cache clean --all)
23
+
24
+ 5.在podfile中加入plugin "cocoapods-TSPodfileTimeWatch"
25
+
26
+ 6.pod结束后会在pods文件夹下生成AllPodsTimeAndSize.csv文件,用来记录所有pod下载耗时情况
27
+
28
+ 7.如果git clone文件大小和cache文件大的差值越大,说明下载的多余文件越多,则存在可优化空间。
29
+
30
+ 8.可以通过尝试把podfile中使用git commit集成的,修改为使用git tag集成的方式,减少git clone下载内容
@@ -1,3 +1,3 @@
1
1
  module CocoapodsTspodfiletimewatch
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -10,7 +10,7 @@ class Dir
10
10
  path = File.join(dir, entry)
11
11
  FileTest.directory?(path) ? sum += Dir.size(path) : sum += File.size(path)
12
12
  rescue => exception
13
- puts "\e[31mCocoapodsTSPodfileTimeWatch Dir.size error: #{exception}\e[0m"
13
+ puts "\e[31mCocoapodsTSPodfileTimeWatch Dir.size error(已捕获): #{exception}\e[0m"
14
14
  next
15
15
  retry
16
16
  end
@@ -29,11 +29,35 @@ end
29
29
 
30
30
  module CocoapodsTSPodfileTimeWatch
31
31
 
32
+ Pod::HooksManager.register("cocoapods-TSPodfileTimeWatch", :pre_install) do |context|
33
+ begin
34
+ if $pluginIsVerbose == true
35
+ # home路径下是否存在.AllPodsTimeAndSize.csv的隐藏文件
36
+ if File.exist?("#{Dir.home}/.AllPodsTimeAndSize.csv")
37
+ # 如果存在则先删除,每次都生成新的csv文件
38
+ File.delete("#{Dir.home}/.AllPodsTimeAndSize.csv")
39
+ end
40
+ # 统计到csv中
41
+ CSV.open("#{Dir.home}/.AllPodsTimeAndSize.csv", "ab") do |csv|
42
+ csv << ["名称", "下载耗时(S)", "git clone文件大小(M)", "cache文件大小(M)", "大小差值"]
43
+ end
44
+ end
45
+ rescue => exception
46
+
47
+ end
48
+ end
32
49
  Pod::HooksManager.register("cocoapods-TSPodfileTimeWatch", :post_install) do |context|
33
- puts "\e[31mCocoapodsTSPodfileTimeWatch gitAllSize: #{$gitAllSize}M\e[0m"
34
- puts "\e[31mCocoapodsTSPodfileTimeWatch cloneAllTime: #{$cloneAllTime}S\e[0m"
35
- if $pluginIsVerbose == true
36
- puts "\e[31m具体的统计数据请在#{Dir.home}/.AllPodsTimeAndSize.csv中查看\e[0m"
50
+ begin
51
+ puts "\e[31mCocoapodsTSPodfileTimeWatch gitAllSize: #{$gitAllSize}M\e[0m"
52
+ puts "\e[31mCocoapodsTSPodfileTimeWatch cloneAllTime: #{$cloneAllTime}S\e[0m"
53
+ # 如果是--verbose模式且$gitAllSize与$cloneAllTime(不为0表示有下载pod)
54
+ if $pluginIsVerbose == true && $gitAllSize != 0 && $cloneAllTime != 0
55
+ File.rename "#{Dir.home}/.AllPodsTimeAndSize.csv", "#{context.sandbox_root}/AllPodsTimeAndSize.csv"
56
+ puts "\e[31m具体的统计数据请在#{context.sandbox_root}/AllPodsTimeAndSize.csv中查看\e[0m"
57
+ end
58
+ rescue => exception
59
+ # 如果没有下载则#{Dir.home}/.AllPodsTimeAndSize.csv文件不会生成,产生异常
60
+ puts "\e[31mCocoapodsTSPodfileTimeWatch post_install error(已捕获): #{exception}\e[0m"
37
61
  end
38
62
  end
39
63
 
@@ -49,7 +73,7 @@ module CocoapodsTSPodfileTimeWatch
49
73
  end
50
74
  end
51
75
 
52
- # --verbose输出详细信息,生成在home路劲下AllPodsTimeAndSize.csv的隐藏文件
76
+ # --verbose输出详细信息,生成在home路径下.AllPodsTimeAndSize.csv的隐藏文件
53
77
  def verboseCopy_and_clean(source, destination, spec)
54
78
  begin
55
79
  # 计算拷贝到的目录下所有文件总大小,单位为M
@@ -61,14 +85,14 @@ module CocoapodsTSPodfileTimeWatch
61
85
  # 标红输出差值
62
86
  puts "\e[31mCocoapodsTSPodfileTimeWatch diffSize = #{diffSize}\e[0m"
63
87
  # 统计到csv中
64
- CSV.open("#{Dir.home}/.AllPodsTimeAndSize.csv", "ab") do |csv|
88
+ CSV.open("#{Dir.home}/.AllPodsTimeAndSize.csv", "a+") do |csv|
65
89
  csv << [spec.name, $cloneTime, $gitSize, dirSum, diffSize]
66
90
  end
67
91
  # 换行
68
92
  puts
69
93
  rescue => exception
70
94
  # 输出拷贝清除方法异常
71
- puts "\e[31mCocoapodsTSPodfileTimeWatch verboseCopy_and_clean error: #{exception}\e[0m"
95
+ puts "\e[31mCocoapodsTSPodfileTimeWatch verboseCopy_and_clean error(已捕获): #{exception}\e[0m"
72
96
  end
73
97
  $gitSize = 0
74
98
  end
@@ -106,7 +130,7 @@ module CocoapodsTSPodfileTimeWatch
106
130
  end
107
131
  rescue => exception
108
132
  # 标红输出git clone hook异常
109
- puts "\e[31mCocoapodsTSPodfileTimeWatch clone error: #{exception}\e[0m"
133
+ puts "\e[31mCocoapodsTSPodfileTimeWatch clone error(已捕获): #{exception}\e[0m"
110
134
  end
111
135
 
112
136
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-TSPodfileTimeWatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - keai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-02 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler