bigkeeper 0.7.6 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/big_keeper.gemspec +3 -3
  4. data/docs/en-US/README.md +2 -2
  5. data/docs/zh-CN/BIGKEEPER_FILE.md +2 -2
  6. data/docs/zh-CN/FEATURE&HOTFIX.md +18 -11
  7. data/lib/big_keeper.rb +9 -289
  8. data/lib/big_keeper/command/feature&hotfix.rb +140 -0
  9. data/lib/big_keeper/command/feature&hotfix/finish.rb +7 -4
  10. data/lib/big_keeper/command/feature&hotfix/publish.rb +7 -6
  11. data/lib/big_keeper/command/feature&hotfix/pull.rb +2 -2
  12. data/lib/big_keeper/command/feature&hotfix/push.rb +2 -2
  13. data/lib/big_keeper/command/feature&hotfix/rebase.rb +2 -2
  14. data/lib/big_keeper/command/feature&hotfix/start.rb +16 -6
  15. data/lib/big_keeper/command/feature&hotfix/switch.rb +4 -6
  16. data/lib/big_keeper/command/feature&hotfix/update.rb +6 -4
  17. data/lib/big_keeper/command/pod.rb +36 -0
  18. data/lib/big_keeper/command/release.rb +68 -0
  19. data/lib/big_keeper/command/release/home.rb +2 -1
  20. data/lib/big_keeper/dependency/dep_gradle_operator.rb +26 -130
  21. data/lib/big_keeper/dependency/dep_operator.rb +4 -10
  22. data/lib/big_keeper/dependency/dep_pod_operator.rb +9 -53
  23. data/lib/big_keeper/dependency/dep_service.rb +2 -2
  24. data/lib/big_keeper/dependency/dep_type.rb +4 -4
  25. data/lib/big_keeper/model/gitflow_type.rb +12 -0
  26. data/lib/big_keeper/service/git_service.rb +2 -2
  27. data/lib/big_keeper/service/module_service.rb +15 -6
  28. data/lib/big_keeper/util/cache_operator.rb +69 -0
  29. data/lib/big_keeper/util/gradle_operator.rb +151 -0
  30. data/lib/big_keeper/util/podfile_operator.rb +4 -4
  31. data/lib/big_keeper/version.rb +1 -1
  32. data/resources/keynote/big-keeper-readme-feature.key +0 -0
  33. metadata +10 -6
@@ -22,4 +22,73 @@ module BigKeeper
22
22
  FileUtils.rm_r(@cache_path)
23
23
  end
24
24
  end
25
+
26
+ class ModuleCacheOperator
27
+ def initialize(path)
28
+ @cache_path = File.expand_path("#{path}/.bigkeeper")
29
+ @modules = {"git" => {"all" => [], "current" => []}, "path" => {"all" => [], "current" => []}}
30
+
31
+ FileUtils.mkdir_p(@cache_path) unless File.exist?(@cache_path)
32
+
33
+ if File.exist?("#{@cache_path}/module.cache")
34
+ file = File.open("#{@cache_path}/module.cache", 'r')
35
+ @modules = JSON.load(file.read())
36
+ file.close
37
+ end
38
+ end
39
+
40
+ def all_path_modules
41
+ @modules["path"]["all"]
42
+ end
43
+
44
+ def current_path_modules
45
+ @modules["path"]["current"]
46
+ end
47
+
48
+ def all_git_modules
49
+ @modules["git"]["all"]
50
+ end
51
+
52
+ def current_git_modules
53
+ @modules["git"]["current"]
54
+ end
55
+
56
+ def cache_path_modules(modules)
57
+ @modules["path"]["all"] = modules
58
+ cache_modules
59
+ end
60
+
61
+ def cache_git_modules(modules)
62
+ @modules["git"]["all"] = modules
63
+ cache_modules
64
+ end
65
+
66
+ def add_branch_module(module_name)
67
+ @modules["path"]["current"].delete(module_name)
68
+ @modules["git"]["current"] << module_name
69
+ cache_modules
70
+ end
71
+
72
+ def del_branch_module(module_name)
73
+ @modules["git"]["current"].delete(module_name)
74
+ cache_modules
75
+ end
76
+
77
+ def add_path_module(module_name)
78
+ @modules["git"]["current"].delete(module_name)
79
+ @modules["path"]["current"] << module_name
80
+ cache_modules
81
+ end
82
+
83
+ def del_path_module(module_name)
84
+ @modules["path"]["current"].delete(module_name)
85
+ cache_modules
86
+ end
87
+
88
+ def cache_modules
89
+ file = File.new("#{@cache_path}/module.cache", 'w')
90
+ file << @modules.to_json
91
+ file.close
92
+ end
93
+ end
25
94
  end
@@ -0,0 +1,151 @@
1
+ require 'big_keeper/util/cache_operator'
2
+
3
+ module BigKeeper
4
+ # Operator for podfile
5
+ class GradleOperator
6
+ def initialize(path)
7
+ @path = File.expand_path(path)
8
+ end
9
+
10
+ def backup
11
+ cache_operator = CacheOperator.new(@path)
12
+ cache_operator.save('settings.gradle')
13
+ Dir.glob("#{@path}/*/build.gradle").each do |build_gradle_file_path|
14
+ build_gradle_file = build_gradle_file_path.gsub!(/#{@path}/, '')
15
+ cache_operator.save(build_gradle_file)
16
+ end
17
+ end
18
+
19
+ def recover
20
+ cache_operator = CacheOperator.new(@path)
21
+ cache_operator.load('settings.gradle')
22
+ cache_operator.clean
23
+ end
24
+
25
+ def update_setting_config(current_module_name, user, modules)
26
+ CacheOperator.new(@path).load('settings.gradle')
27
+ begin
28
+ File.open("#{@path}/settings.gradle", 'a') do |file|
29
+ modules.each do |module_name|
30
+ next if current_module_name == module_name
31
+ file.puts "\r\ninclude ':module:#{module_name.downcase}'\r\n"
32
+ file.puts "project(':module:#{module_name.downcase}')." \
33
+ "projectDir = new File(rootProject.projectDir," \
34
+ "'#{BigkeeperParser.module_path(user, module_name)}/#{module_name.downcase}-lib')\r\n"
35
+ end
36
+ end
37
+ ensure
38
+ end
39
+ end
40
+
41
+ def update_module_config(module_name, module_type, source)
42
+ Dir.glob("#{@path}/*/build.gradle").each do |file|
43
+ temp_file = Tempfile.new('.build.gradle.tmp')
44
+ begin
45
+ version_flag = false
46
+ version_index = 0
47
+
48
+ File.open(file, 'r') do |file|
49
+ file.each_line do |line|
50
+ version_flag = true if line.include? 'modifyPom'
51
+ if version_flag
52
+ version_index += 1 if line.include? '{'
53
+ version_index -= 1 if line.include? '}'
54
+
55
+ version_flag = false if 0 == version_flag
56
+
57
+ temp_file.puts generate_version_config(line, module_name, module_type, source)
58
+ else
59
+ temp_file.puts generate_compile_config(line, module_name, module_type, source)
60
+ end
61
+ end
62
+ end
63
+ temp_file.close
64
+ FileUtils.mv(temp_file.path, file)
65
+ ensure
66
+ temp_file.close
67
+ temp_file.unlink
68
+ end
69
+ end
70
+ end
71
+
72
+ def generate_version_config(line, module_name, module_type, source)
73
+ if ModuleType::GIT == module_type
74
+ branch_name = GitOperator.new.current_branch(@path)
75
+ full_name = ''
76
+
77
+ # Get version part of source.addition
78
+ if 'develop' == source.addition || 'master' == source.addition
79
+ full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
80
+ else
81
+ full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
82
+ end
83
+ line.sub(/(\s*)version ('|")(\S*)('|")([\s\S]*)/){
84
+ "#{$1}version '#{full_name}'#{$5}"
85
+ }
86
+ elsif ModuleType::SPEC == module_type
87
+ line.sub(/(\s*)version ('|")(\S*)('|")([\s\S]*)/){
88
+ "#{$1}version '#{source}'#{$5}"
89
+ }
90
+ else
91
+ line
92
+ end
93
+ end
94
+
95
+ def prefix_of_module(module_name)
96
+ prefix = ''
97
+ Dir.glob("#{@path}/.bigkeeper/*/build.gradle").each do |file|
98
+ File.open(file, 'r') do |file|
99
+ file.each_line do |line|
100
+ if line =~ /(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/
101
+ prefix = line.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
102
+ $4
103
+ }
104
+ break
105
+ end
106
+ end
107
+ end
108
+ break unless prefix.empty?
109
+ end
110
+
111
+ prefix.chop
112
+ end
113
+
114
+ def generate_compile_config(line, module_name, module_type, source)
115
+ if ModuleType::PATH == module_type
116
+ line.sub(/(\s*)compile(\s*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
117
+ "#{$1}compile project(':module:#{module_name.downcase}')"
118
+ }
119
+ elsif ModuleType::GIT == module_type
120
+ branch_name = GitOperator.new.current_branch(@path)
121
+ full_name = ''
122
+
123
+ # Get version part of source.addition
124
+ if 'develop' == source.addition || 'master' == source.addition
125
+ full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
126
+ else
127
+ full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
128
+ end
129
+ line.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
130
+ if $2.include? 'moduleCompile'
131
+ "#{$1}moduleCompile '#{prefix_of_module(module_name)}#{module_name.downcase}:#{full_name}-SNAPSHOT'"
132
+ else
133
+ "#{$1}compile '#{prefix_of_module(module_name)}#{module_name.downcase}:#{full_name}-SNAPSHOT'"
134
+ end
135
+ }
136
+ elsif ModuleType::SPEC == module_type
137
+ line.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
138
+ if $2.include? 'moduleCompile'
139
+ "#{$1}moduleCompile '#{prefix_of_module(module_name)}#{module_name.downcase}:#{source}'"
140
+ else
141
+ "#{$1}compile '#{prefix_of_module(module_name)}#{module_name.downcase}:#{source}'"
142
+ end
143
+ }
144
+ else
145
+ line
146
+ end
147
+ end
148
+
149
+ private :generate_compile_config, :generate_version_config, :prefix_of_module
150
+ end
151
+ end
@@ -26,16 +26,16 @@ module BigKeeper
26
26
  end
27
27
  end
28
28
 
29
- def replace_all_module_release(path, module_names, version)
29
+ def replace_all_module_release(path, user, module_names, version)
30
30
  module_names.each do |module_name|
31
- DepService.dep_operator(path).update_module_config(
31
+ DepService.dep_operator(path, user).update_module_config(
32
32
  module_name,
33
33
  ModuleType::GIT,
34
34
  GitInfo.new(BigkeeperParser.module_git(module_name), GitType::TAG, version))
35
35
  end
36
36
  end
37
37
 
38
- def find_and_lock(podfile,dictionary)
38
+ def find_and_lock(podfile, dictionary)
39
39
  temp_file = Tempfile.new('.Podfile.tmp')
40
40
  begin
41
41
  File.open(podfile, 'r') do |file|
@@ -57,7 +57,7 @@ module BigKeeper
57
57
  end
58
58
  end
59
59
 
60
- def find_and_upgrade(podfile,dictionary)
60
+ def find_and_upgrade(podfile, dictionary)
61
61
  temp_file = Tempfile.new('.Podfile.tmp')
62
62
  begin
63
63
  File.open(podfile, 'r') do |file|
@@ -1,3 +1,3 @@
1
1
  module BigKeeper
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmoaay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -192,8 +192,8 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 0.50.0
195
- description: Efficiency improvement for iOS modular development, iOSer using this
196
- tool can make modular development easier.
195
+ description: Efficiency improvement for iOS&Android modular development, iOSer&Androider
196
+ using this tool can make modular development easier.
197
197
  email:
198
198
  - mmoaay@sina.com
199
199
  executables:
@@ -224,6 +224,7 @@ files:
224
224
  - docs/zh-CN/RECOMMEND.md
225
225
  - docs/zh-CN/RELEASE.md
226
226
  - lib/big_keeper.rb
227
+ - lib/big_keeper/command/feature&hotfix.rb
227
228
  - lib/big_keeper/command/feature&hotfix/delete.rb
228
229
  - lib/big_keeper/command/feature&hotfix/finish.rb
229
230
  - lib/big_keeper/command/feature&hotfix/publish.rb
@@ -233,7 +234,9 @@ files:
233
234
  - lib/big_keeper/command/feature&hotfix/start.rb
234
235
  - lib/big_keeper/command/feature&hotfix/switch.rb
235
236
  - lib/big_keeper/command/feature&hotfix/update.rb
237
+ - lib/big_keeper/command/pod.rb
236
238
  - lib/big_keeper/command/pod/podfile.rb
239
+ - lib/big_keeper/command/release.rb
237
240
  - lib/big_keeper/command/release/home.rb
238
241
  - lib/big_keeper/command/release/module.rb
239
242
  - lib/big_keeper/dependency/dep_gradle_operator.rb
@@ -252,6 +255,7 @@ files:
252
255
  - lib/big_keeper/util/file_operator.rb
253
256
  - lib/big_keeper/util/git_operator.rb
254
257
  - lib/big_keeper/util/gitflow_operator.rb
258
+ - lib/big_keeper/util/gradle_operator.rb
255
259
  - lib/big_keeper/util/info_plist_operator.rb
256
260
  - lib/big_keeper/util/logger.rb
257
261
  - lib/big_keeper/util/pod_operator.rb
@@ -290,7 +294,7 @@ files:
290
294
  - resources/readme/big-keeper-readme.010.png
291
295
  - resources/readme/big-keeper-readme.011.png
292
296
  - resources/readme/big-keeper-readme.012.png
293
- homepage: https://github.com/BigKeeper/big-keeper
297
+ homepage: https://github.com/BigKeeper/bigkeeper
294
298
  licenses:
295
299
  - MIT
296
300
  metadata:
@@ -314,5 +318,5 @@ rubyforge_project:
314
318
  rubygems_version: 2.5.1
315
319
  signing_key:
316
320
  specification_version: 4
317
- summary: Efficiency improvement for iOS modular development.
321
+ summary: Efficiency improvement for iOS&Android modular development.
318
322
  test_files: []