stool 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9087dc7a077981a605928ca0ddf072cdf0f89da5
4
- data.tar.gz: 43801ab73b2147d3c025909c5558ddc9a1cf05a0
3
+ metadata.gz: ca7802d81948fa28cf6f1e5f6b58af037f4486f0
4
+ data.tar.gz: e96efdffc43381497d9daa490ec34c4953c7389b
5
5
  SHA512:
6
- metadata.gz: 8e08b78b68d280ab6cc36f6a3f7746d3c946a3c5bdff0e8a417e69402082332322c8b59a32281e1360ffc27529aa7abaaf1014ca17a981b9722513ed8d14eb1c
7
- data.tar.gz: 49f84777e00d90b37140dced8194c6d7d19e64297494e3bc2155806fd1dcba6af7843b7e1b423e717734ec5d1cc3b886d359d623dd00ead72d0afc64312e62a7
6
+ metadata.gz: 96b36aeb50ae71d9e0a2e838255e3ba7c8f52554d70773d742a27b2a247e42c965d75209296a5a58809760581f564e6b17fa023bd98d004aca12e0f173dea552
7
+ data.tar.gz: 3b56660f045840b496fa14a45fb569863eba8644b108e28be1953ddfb7d44d6aebb53fff0ddb42d73c9fe39353d0fbc2e498f1b067b690722bb5e899406d773c
@@ -77,8 +77,7 @@ module Stool
77
77
  # }
78
78
  #
79
79
  # arr
80
- # end
81
-
80
+ # end
82
81
  end
83
82
  end
84
83
  end
@@ -1,7 +1,4 @@
1
1
  #添加一个池
2
-
3
- require 'yaml'
4
-
5
2
  module Stool
6
3
  class Command
7
4
  class LibPool < Command
@@ -93,4 +90,4 @@ module Stool
93
90
  end
94
91
  end
95
92
  end
96
- end
93
+ end
@@ -0,0 +1,32 @@
1
+ #查看当前pool列表
2
+ module Stool
3
+ class Command
4
+ class Repo < Command
5
+ class CacheClean < Repo
6
+
7
+ self.command = 'cc'
8
+ self.summary = '清除相关缓存'
9
+
10
+ self.arguments = [
11
+ CLAide::Argument.new('NAME', false),
12
+ ]
13
+
14
+ def initialize(argv)
15
+ super
16
+ end
17
+
18
+ #查看当前的pool list
19
+ def run
20
+ pp('')
21
+ pp('**Pool list')
22
+ List::pools_from_config.map do |pInfo|
23
+ pInfo.info_tos
24
+ end
25
+ end
26
+
27
+ @public
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ #私有库的池,池中有多个lib
2
+ require 'Core/RepoInfo'
3
+
4
+ module Stool
5
+ class Command
6
+ class Repo < Command
7
+
8
+ require 'Command/Repo/CacheClean'
9
+
10
+ self.abstract_command = true
11
+ self.command = 'rp'
12
+ self.summary = 'cocoapods的repos信息,及相关操作'
13
+ # self.default_subcommand = 'list'
14
+
15
+ def initialize(argv)
16
+ super
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -1,7 +1,5 @@
1
1
  #查看当前workspace列表
2
2
 
3
- require 'yaml'
4
-
5
3
  module Stool
6
4
  class Command
7
5
  class WorkSpace < Command
@@ -1,4 +1,5 @@
1
1
  #对执行pod update的整合
2
+ require 'Utils/ArrayUtile'
2
3
 
3
4
  module Stool
4
5
  class Command
@@ -21,36 +22,27 @@ module Stool
21
22
  unless @tag
22
23
  help! 'need the tag of workspace you configed.'
23
24
  end
24
-
25
25
  unless existAtConfig?
26
26
  help! "To run, please ensure the tag(#{@tag}) exist."
27
27
  end
28
-
29
28
  unless hasPodfile?(@info.path)
30
29
  help! 'To run, please ensure the workspace contain a podfile in zhe folder.' + "#{@info.path}"
31
30
  end
32
-
33
31
  super
34
32
  end
35
33
 
36
34
  @public
37
35
 
38
36
  def run
39
- repos_up
40
-
37
+ # repos_up
41
38
  localLibs_git_up
42
-
43
- @info.task_git_up
44
-
45
- @info.edit_podfile_use_loaclLibs
46
-
47
- del_folers
48
-
49
- pod_update
50
-
51
- @info.resetPofile
52
-
53
- @info.open_task
39
+ # @info.task_git_up
40
+ # @info.edit_podfile_use_loaclLibs
41
+ # del_folers
42
+ # check_lastUpdate
43
+ # pod_update
44
+ # @info.resetPofile
45
+ # @info.open_task
54
46
  end
55
47
 
56
48
  #更新相关repo(除了master)
@@ -86,26 +78,48 @@ module Stool
86
78
  end
87
79
  end
88
80
 
81
+ include ArrayUtile
82
+ #检测上一次更新用到的lib,源码是否与本次有冲突
83
+ def check_lastUpdate
84
+ lastTaskInfo = TaskInfo::fromYAML(pathForTaskInfo_last_pod_update)
85
+ unless lastTaskInfo
86
+ cleanAllCache
87
+ return
88
+ end
89
+
90
+ if lastTaskInfo.allUseCode != @info.allUseCode
91
+ cleanAllCache
92
+ return
93
+ end
94
+
95
+ diff = diffOf(lastTaskInfo.otherCode,@info.otherCode)
96
+ diff.each do |x|
97
+ puts "--- 清除lib缓存:#{x} ..."
98
+ `pod cache clean #{x} --all`
99
+ end
100
+ end
101
+
89
102
  #执行pod update
90
103
  def pod_update
91
104
  useCode = @info.localLibs + @info.otherCode
92
-
93
105
  useCode.collect! {|item|
94
-
95
106
  item + "_use_code=1 "
96
107
  }
108
+ libs_useCode = useCode.join
109
+ if @info.allUseCode
110
+ libs_useCode = 'use_code=1' + libs_useCode
111
+ end
97
112
 
98
- puts "---源码库有" + useCode.join
113
+ @info.doCacheByYAML(pathForTaskInfo_last_pod_update)
99
114
 
115
+ puts "---源码库有" + libs_useCode
100
116
  Dir.chdir(@info.path)
101
-
102
117
  puts '---当前目录' + Dir.getwd
103
-
104
118
  puts "---update中...."
105
- puts `#{useCode.join} pod update --no-repo-update`
119
+ # puts `#{libs_useCode} pod update --no-repo-update`
106
120
  end
107
121
 
108
122
  end
109
123
  end
110
124
  end
111
- end
125
+ end
@@ -48,6 +48,7 @@ module Stool
48
48
  @info
49
49
  end
50
50
 
51
+ #获取task用的所有repos
51
52
  def getAllRepos
52
53
  arr = []
53
54
  if @info.repos.count == 0
@@ -63,6 +64,34 @@ module Stool
63
64
  arr
64
65
  end
65
66
 
67
+ def pathForTaskInfo_last_pod_update
68
+ unless Dir.exist?(Config::logsDirPath)
69
+ Dir.mkdir(Config::logsDirPath)
70
+ end
71
+ File.join(Config::logsDirPath, 'TaskInfo_lastUpdate.yaml')
72
+ end
73
+
74
+ #清理所有pod缓存(除master repo的pod)
75
+ def cleanAllCache
76
+ puts "clean all cache"
77
+ hasClean = []
78
+ path = @@config.repoCachePath
79
+ Dir.entries(path).each{|file|
80
+ if file['.'] || file.eql?('master')
81
+ #do nothing
82
+ else
83
+ podCache = File.join(path,file)
84
+ Dir.entries(podCache).sort.each{|podName|
85
+ unless hasClean.include?(podName) || podName['.']
86
+ puts "清理缓存#{podName} "
87
+ puts `pod cache clean #{podName}`
88
+ hasClean.push(podName)
89
+ end
90
+ }
91
+ end
92
+ }
93
+ end
94
+
66
95
  end
67
96
  end
68
97
  end
@@ -1,9 +1,14 @@
1
+
2
+ # require 'Object'
3
+ require 'yaml'
4
+
1
5
  module Stool
2
- class BaseObj
6
+ class BaseObj < Object
3
7
 
4
8
  @public
5
9
 
6
10
  def initialize
11
+ super
7
12
  yield self if block_given?
8
13
  end
9
14
 
@@ -14,5 +19,20 @@ module Stool
14
19
  end
15
20
  end
16
21
 
22
+ #加载从yaml
23
+ def self.fromYAML(path)
24
+ if File.exist?(path)
25
+ content = File.open(path)
26
+ YAML.load(content)
27
+ end
28
+ end
29
+
30
+ #以yaml缓存
31
+ def doCacheByYAML(path)
32
+ if path
33
+ File.open(path, "w") { |file| YAML.dump(self, file) }
34
+ end
35
+ end
36
+
17
37
  end
18
38
  end
@@ -0,0 +1,6 @@
1
+
2
+ module Stool
3
+ class Cache
4
+ @@pathForSysCache = File.join('stool','slCache')
5
+ end
6
+ end
@@ -6,18 +6,19 @@ require 'Core/TaskInfo'
6
6
  module Stool
7
7
  class Config < BaseObj
8
8
 
9
- #cache路径
9
+ @public
10
+ #cache相关的路径
10
11
  @@cachePath = File.join(Dir.home(),'stool')
11
12
  @@configFilePath = File.join(@@cachePath, 'ConfigFile.rb')
13
+ @@logsDirPath = File.join(@@cachePath, 'log')
14
+
12
15
  #本地lib池子
13
16
  attr_accessor :pools
14
17
  #主工程
15
18
  attr_accessor :tasks
16
-
19
+ #cocoapods的repo缓存路径
17
20
  attr_accessor :repoCachePath
18
21
 
19
- @public
20
-
21
22
  def initialize
22
23
  @repoCachePath = File.join(Dir.home,'.cocoapods/repos')
23
24
  @pools = []
@@ -25,6 +26,10 @@ module Stool
25
26
  super
26
27
  end
27
28
 
29
+ def self.logsDirPath
30
+ @@logsDirPath
31
+ end
32
+
28
33
  #从配置中心读取
29
34
  def self.loadConfig
30
35
  checkConfigFile?
@@ -76,7 +81,6 @@ module Stool
76
81
  demo = <<-EOF
77
82
  #stool 配置
78
83
  Config.new do |c|
79
-
80
84
  #添加一个本地lib pool
81
85
  c.addPool do |p|
82
86
  p.name = '本地lib池 - 凤凰'
@@ -95,11 +99,15 @@ module Stool
95
99
  t.tag = '1'
96
100
  t.path = '/Users/syswin/Documents/Siyuan/Libs/phenix/tlauncher/TLauncher'
97
101
  #项目使用的本地lib,默认都是源码
98
- t.localLibs = ['tcardReader',
102
+ addLocalLib(['tcardReader',
99
103
  'tcardLibrary',
100
104
  'tcardKit',
101
105
  'tcontentGroup',
102
- 'tcontentCommon']
106
+ 'tcontentCommon'])
107
+ #非本地lib,配置使用源码
108
+ addOtherLibUseCode(['tcard'])
109
+ #是否所有lib都使用源码,默认false
110
+ #allLibsUseCode
103
111
  end
104
112
 
105
113
  end
@@ -88,9 +88,13 @@ module Stool
88
88
  Dir.chdir(@path)
89
89
  puts "*** git处理<#{@name}>"
90
90
  git_st
91
- git_stash
91
+ result = git_stash
92
92
  git_up
93
- git_stash_pop
93
+ if result['Saved working']
94
+ git_stash_pop
95
+ else
96
+ puts "no stash to pop"
97
+ end
94
98
  end
95
99
  end
96
100
 
@@ -16,6 +16,7 @@ module Stool
16
16
  attr_accessor :localLibs
17
17
  #其他源码指定
18
18
  attr_accessor :otherCode
19
+ attr_accessor :allUseCode
19
20
 
20
21
  #指定的repo
21
22
  attr_accessor :repos
@@ -24,6 +25,7 @@ module Stool
24
25
  @localLibs = []
25
26
  @otherCode = []
26
27
  @repos = []
28
+ @allUseCode = false
27
29
  super
28
30
  end
29
31
 
@@ -35,9 +37,32 @@ module Stool
35
37
  self.localLibs.sort.map do |lib|
36
38
  puts(' ' + lib.to_s)
37
39
  end
40
+ puts('--' + 'otherCode:')
41
+ self.otherCode.sort.map do |lib|
42
+ puts(' ' + lib.to_s)
43
+ end
44
+ puts('--' + 'allUseCode:'+ self.allUseCode.to_s)
38
45
  puts('')
39
46
  end
40
47
 
48
+ def addLocalLib(libs)
49
+ libs.each do |lib|
50
+ @localLibs.push(lib)
51
+ end
52
+ end
53
+
54
+ def addOtherLibUseCode(libs)
55
+ libs.each do |lib|
56
+ @otherCode.push(lib)
57
+ end
58
+ end
59
+
60
+ def allLibsUseCode
61
+ @allUseCode = true
62
+ end
63
+
64
+ ########################
65
+
41
66
  def open_task
42
67
  `open *.xcworkspace`
43
68
  end
@@ -123,9 +148,8 @@ module Stool
123
148
  file.write(newStr)
124
149
  end
125
150
  end
126
-
127
151
  end
128
-
129
152
  end
153
+
130
154
  end
131
155
  end
@@ -0,0 +1,39 @@
1
+ #本地lib池
2
+ require 'Core/BaseObj'
3
+
4
+ module Stool
5
+ class RepoInfo < BaseObj
6
+ attr_accessor :name
7
+ attr_accessor :path
8
+
9
+ def info_tos
10
+ puts('--' + 'name:'+ self.name)
11
+ puts('--' + 'path:'+ self.path)
12
+ puts('--' + 'Repos:')
13
+ subDirs.sort.each do |f|
14
+ unless f['.']
15
+ puts ' ' + f.to_s
16
+ end
17
+ end
18
+ puts('')
19
+ end
20
+
21
+ #本地搜索一个lib
22
+ def searchLib(name)
23
+ libInfo = nil
24
+ if subDirs.include?(name)
25
+ libInfo = LibInfo::loadFromPath(File.join(@path,name))
26
+ end
27
+ libInfo
28
+ end
29
+
30
+ def subDirs
31
+ arr = []
32
+ if @path
33
+ arr = Dir.entries(@path)
34
+ end
35
+ arr
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,9 @@
1
+ module ArrayUtile
2
+
3
+ #找到两个数组中,不同的元素
4
+ def diffOf(a,b)
5
+ sum = a + b
6
+ sum.uniq
7
+ end
8
+
9
+ end
data/lib/stool/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stool
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fiend
@@ -138,7 +138,6 @@ extra_rdoc_files: []
138
138
  files:
139
139
  - README.md
140
140
  - bin/sl
141
- - lib/VERSION.rb
142
141
  - lib/stool.rb
143
142
  - lib/stool/Command.rb
144
143
  - lib/stool/Command/Lib.rb
@@ -146,15 +145,20 @@ files:
146
145
  - lib/stool/Command/LibPool.rb
147
146
  - lib/stool/Command/LibPool/Add.rb
148
147
  - lib/stool/Command/LibPool/List.rb
148
+ - lib/stool/Command/Repo.rb
149
+ - lib/stool/Command/Repo/CacheClean.rb
149
150
  - lib/stool/Command/WorkSpace.rb
150
151
  - lib/stool/Command/WorkSpace/list.rb
151
152
  - lib/stool/Command/WorkSpace/update.rb
152
153
  - lib/stool/Core/BaseObj.rb
154
+ - lib/stool/Core/Cache.rb
153
155
  - lib/stool/Core/Config.rb
154
156
  - lib/stool/Core/Git.rb
155
157
  - lib/stool/Core/LibInfo.rb
156
158
  - lib/stool/Core/PoolInfo.rb
157
159
  - lib/stool/Core/TaskInfo.rb
160
+ - lib/stool/Core/repoInfo.rb
161
+ - lib/stool/Utils/ArrayUtile.rb
158
162
  - lib/stool/Utils/StringUtil.rb
159
163
  - lib/stool/version.rb
160
164
  homepage: https://rubygems.org/gems/Stool
data/lib/VERSION.rb DELETED
@@ -1,3 +0,0 @@
1
- module Stool
2
- VERSION = '0.1.0'
3
- end