bigkeeper 0.8.9 → 0.9.0

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: accc51fc75fc6d9d662aee5a2f6201682d3eaf1f
4
- data.tar.gz: 1de9680bcb63b9bd8c0062945d96bd173e57adfe
3
+ metadata.gz: 1ad21818615753657a7b1d3132495d7906703993
4
+ data.tar.gz: ba755aa80b7eaed3ef46e8160425d2bd2833538f
5
5
  SHA512:
6
- metadata.gz: 00df2a04ec69be4a786849b4f7138ec4e282eba92f3364696ae393e35598a693f132ba0ad352beef2f9bab3ce178bc815d7e14d8c0a70ed32b7dffd3167f2518
7
- data.tar.gz: bb9473f395ff7729223cd50ad0f855c3f3db0e031c8e9706913907665ddb9432e802f30784e0415f73e8f713462f09cd0e30caf3e157d3084c48206146d6b095
6
+ metadata.gz: a59d3b3a12ac0b58693a3b616dfdf3b7d53b3f01fb2dd495112088014ebcb37bacf9a8624073eb0682e7d5d3a0b7b540372ce99075ff159c008e6f260b54ec56
7
+ data.tar.gz: a189a9bec318f410cb675ff29905078f32d2d70668412748b9a2cfa781a3737030d83823858be4857d95cae1f28496ce2c83866582053e0088dceaa79aa987c5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bigkeeper (0.8.8)
4
+ bigkeeper (0.9.0)
5
5
  big_resources
6
6
  big_stash (~> 0.1)
7
7
  cocoapods
@@ -12,14 +12,14 @@ PATH
12
12
  GEM
13
13
  remote: https://gems.ruby-china.com/
14
14
  specs:
15
- CFPropertyList (2.3.3)
16
- activesupport (4.2.7.1)
15
+ CFPropertyList (3.0.0)
16
+ activesupport (4.2.11)
17
17
  i18n (~> 0.7)
18
- json (~> 1.7, >= 1.7.7)
19
18
  minitest (~> 5.1)
20
19
  thread_safe (~> 0.3, >= 0.3.4)
21
20
  tzinfo (~> 1.1)
22
21
  ast (2.3.0)
22
+ atomos (0.1.3)
23
23
  big_resources (0.1.1)
24
24
  chunky_png
25
25
  cocoapods
@@ -28,59 +28,60 @@ GEM
28
28
  plist
29
29
  big_stash (0.6.0)
30
30
  gli (~> 2.16)
31
- chunky_png (1.3.10)
32
- claide (1.0.1)
33
- cocoapods (1.2.1)
31
+ chunky_png (1.3.11)
32
+ claide (1.0.2)
33
+ cocoapods (1.5.3)
34
34
  activesupport (>= 4.0.2, < 5)
35
- claide (>= 1.0.1, < 2.0)
36
- cocoapods-core (= 1.2.1)
37
- cocoapods-deintegrate (>= 1.0.1, < 2.0)
38
- cocoapods-downloader (>= 1.1.3, < 2.0)
35
+ claide (>= 1.0.2, < 2.0)
36
+ cocoapods-core (= 1.5.3)
37
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
38
+ cocoapods-downloader (>= 1.2.0, < 2.0)
39
39
  cocoapods-plugins (>= 1.0.0, < 2.0)
40
40
  cocoapods-search (>= 1.0.0, < 2.0)
41
41
  cocoapods-stats (>= 1.0.0, < 2.0)
42
- cocoapods-trunk (>= 1.2.0, < 2.0)
42
+ cocoapods-trunk (>= 1.3.0, < 2.0)
43
43
  cocoapods-try (>= 1.1.0, < 2.0)
44
44
  colored2 (~> 3.1)
45
45
  escape (~> 0.0.4)
46
46
  fourflusher (~> 2.0.1)
47
47
  gh_inspector (~> 1.0)
48
- molinillo (~> 0.5.7)
48
+ molinillo (~> 0.6.5)
49
49
  nap (~> 1.0)
50
50
  ruby-macho (~> 1.1)
51
- xcodeproj (>= 1.4.4, < 2.0)
52
- cocoapods-core (1.2.1)
53
- activesupport (>= 4.0.2, < 5)
51
+ xcodeproj (>= 1.5.7, < 2.0)
52
+ cocoapods-core (1.5.3)
53
+ activesupport (>= 4.0.2, < 6)
54
54
  fuzzy_match (~> 2.0.4)
55
55
  nap (~> 1.0)
56
- cocoapods-deintegrate (1.0.1)
57
- cocoapods-downloader (1.1.3)
56
+ cocoapods-deintegrate (1.0.2)
57
+ cocoapods-downloader (1.2.2)
58
58
  cocoapods-plugins (1.0.0)
59
59
  nap
60
60
  cocoapods-search (1.0.0)
61
61
  cocoapods-stats (1.0.0)
62
- cocoapods-trunk (1.2.0)
62
+ cocoapods-trunk (1.3.1)
63
63
  nap (>= 0.8, < 2.0)
64
- netrc (= 0.7.8)
64
+ netrc (~> 0.11)
65
65
  cocoapods-try (1.1.0)
66
66
  colored2 (3.1.2)
67
67
  colorize (0.8.1)
68
+ concurrent-ruby (1.1.4)
68
69
  escape (0.0.4)
69
70
  fourflusher (2.0.1)
70
71
  fuzzy_match (2.0.4)
71
- gh_inspector (1.0.2)
72
- gli (2.17.1)
73
- i18n (0.7.0)
74
- json (1.8.6)
75
- minitest (5.8.3)
76
- molinillo (0.5.7)
77
- nanaimo (0.2.3)
72
+ gh_inspector (1.1.3)
73
+ gli (2.18.0)
74
+ i18n (0.9.5)
75
+ concurrent-ruby (~> 1.0)
76
+ minitest (5.8.5)
77
+ molinillo (0.6.6)
78
+ nanaimo (0.2.6)
78
79
  nap (1.1.0)
79
- netrc (0.7.8)
80
+ netrc (0.11.0)
80
81
  parallel (1.12.0)
81
82
  parser (2.4.0.0)
82
83
  ast (~> 2.2)
83
- plist (3.3.0)
84
+ plist (3.5.0)
84
85
  powerpack (0.1.1)
85
86
  rainbow (2.2.2)
86
87
  rake
@@ -92,17 +93,18 @@ GEM
92
93
  rainbow (>= 2.2.2, < 3.0)
93
94
  ruby-progressbar (~> 1.7)
94
95
  unicode-display_width (~> 1.0, >= 1.0.1)
95
- ruby-macho (1.1.0)
96
+ ruby-macho (1.3.1)
96
97
  ruby-progressbar (1.9.0)
97
- thread_safe (0.3.5)
98
- tzinfo (1.2.2)
98
+ thread_safe (0.3.6)
99
+ tzinfo (1.2.5)
99
100
  thread_safe (~> 0.1)
100
101
  unicode-display_width (1.3.0)
101
- xcodeproj (1.4.4)
102
- CFPropertyList (~> 2.3.3)
103
- claide (>= 1.0.1, < 2.0)
102
+ xcodeproj (1.7.0)
103
+ CFPropertyList (>= 2.3.3, < 4.0)
104
+ atomos (~> 0.1.3)
105
+ claide (>= 1.0.2, < 2.0)
104
106
  colored2 (~> 3.1)
105
- nanaimo (~> 0.2.3)
107
+ nanaimo (~> 0.2.6)
106
108
 
107
109
  PLATFORMS
108
110
  ruby
@@ -120,4 +122,4 @@ DEPENDENCIES
120
122
  rubocop (~> 0.50.0)
121
123
 
122
124
  BUNDLED WITH
123
- 1.16.4
125
+ 1.17.2
data/bin/big CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # require "bundler/setup"
3
+ require "bundler/setup"
4
4
  require "big_keeper"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
@@ -20,12 +20,25 @@ module BigKeeper
20
20
 
21
21
  podfile.desc 'Lock podname should be locked.'
22
22
  podfile.command :lock do |lock|
23
- lock.action do |global_options, options, args|
24
- LeanCloudLogger.instance.set_command("podfile/lock")
25
-
26
- path = File.expand_path(global_options[:path])
27
- podfile_lock(path)
23
+ lock.desc 'Lock pods accouding to Podfile.'
24
+ lock.command :module do |m|
25
+ m.action do |global_options, options, args|
26
+ LeanCloudLogger.instance.set_command("podfile/lock/module")
27
+
28
+ path = File.expand_path(global_options[:path])
29
+ podfile_lock(path, false)
30
+ end
28
31
  end
32
+ lock.desc 'Lock pods accouding to Podfile.lock.'
33
+ lock.command :submodule do |s|
34
+ s.action do |global_options, options, args|
35
+ LeanCloudLogger.instance.set_command("podfile/lock/submodule")
36
+
37
+ path = File.expand_path(global_options[:path])
38
+ podfile_lock(path, true)
39
+ end
40
+ end
41
+
29
42
  end
30
43
 
31
44
  podfile.desc 'Update modules should be upgrade.'
@@ -5,6 +5,7 @@ require 'big_keeper/util/gitflow_operator'
5
5
  require 'big_keeper/util/bigkeeper_parser'
6
6
  require 'big_keeper/dependency/dep_type'
7
7
  require 'big_keeper/util/logger'
8
+ require 'big_keeper/util/lockfile_parser'
8
9
 
9
10
  module BigKeeper
10
11
 
@@ -12,9 +13,10 @@ module BigKeeper
12
13
  # Parse Bigkeeper file
13
14
  BigkeeperParser.parse("#{path}/Bigkeeper")
14
15
  # Get modules' name
15
- module_list = BigkeeperParser.module_names
16
+ # module_list = BigkeeperParser.module_names
16
17
  # initialize PodfileDetector
17
- detector = PodfileDetector.new(path, module_list)
18
+ detector = PodfileParser.instance
19
+ detactor.parse
18
20
  # Get unlocked third party pods list
19
21
  unlock_pod_list = detector.get_unlock_pod_list
20
22
  # Print out unlock pod list
@@ -25,27 +27,28 @@ module BigKeeper
25
27
 
26
28
  end
27
29
 
28
- def self.podfile_lock(path)
30
+ def self.podfile_lock(path, is_all)
29
31
  # Parse Bigkeeper file
30
32
  BigkeeperParser.parse("#{path}/Bigkeeper")
31
- # Get modules' name
32
- module_list = BigkeeperParser.module_names
33
33
  # initialize PodfileDetector
34
- detector = PodfileDetector.new(path, module_list)
34
+ pod_parser = PodfileParser.instance
35
+ #Parser Podfile.lock
36
+ pod_parser.parse(path)
37
+ #initialize LockfileParser
38
+ lock_parser = LockfileParser.instance
39
+ #Parser Podfile.lock
40
+ lock_parser.parse(path)
35
41
  # Get unlocked third party pods list
36
- unlock_pod_list = detector.get_unlock_pod_list
37
- # Get Version
38
- dictionary = detector.deal_lock_file(path, unlock_pod_list)
39
- if dictionary.empty?
42
+ unlock_pod_info = lock_parser.get_unlock_pod_list(is_all)
43
+ # Lock modules in podfile
44
+ if unlock_pod_info.empty?
40
45
  Logger.warning("There is nothing to be locked.")
41
46
  else
42
- PodfileOperator.new.find_and_lock("#{path}/Podfile", dictionary)
47
+ PodfileOperator.new.find_and_lock("#{path}/Podfile", unlock_pod_info)
43
48
  Logger.highlight("The Podfile has been changed.")
44
49
  Logger.separator
45
50
  end
46
51
 
47
-
48
-
49
52
  end
50
53
 
51
54
  def self.podfile_modules_update(path)
@@ -10,6 +10,8 @@ require 'big_keeper/util/pod_operator'
10
10
  module BigKeeper
11
11
  def self.release_module_start(path, version, user, module_name, ignore)
12
12
  BigkeeperParser.parse("#{path}/Bigkeeper")
13
+
14
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
13
15
  module_path = BigkeeperParser.module_full_path(path, user, module_name)
14
16
 
15
17
  # stash
@@ -32,6 +34,8 @@ module BigKeeper
32
34
  ## release finish
33
35
  def self.release_module_finish(path, version, user, module_name, spec)
34
36
  BigkeeperParser.parse("#{path}/Bigkeeper")
37
+
38
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
35
39
  module_path = BigkeeperParser.module_full_path(path, user, module_name)
36
40
 
37
41
  # check commit
@@ -1,50 +1,73 @@
1
1
  require 'big_keeper/dependency/dep_operator'
2
- require 'big_keeper/util/gradle_operator'
2
+
3
3
 
4
4
  module BigKeeper
5
5
  # Operator for podfile
6
6
  class DepGradleOperator < DepOperator
7
7
 
8
+ PATH_VERSION_CONFIG = "doc/config/version-config.gradle"
9
+
8
10
  def backup
9
- GradleOperator.new(@path).backup
10
- modules = ModuleCacheOperator.new(@path).all_path_modules
11
- modules.each do |module_name|
12
- module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
13
- GradleOperator.new(module_full_path).backup
14
- end
11
+ cache_operator = CacheOperator.new(@path)
12
+ cache_operator.save(PATH_VERSION_CONFIG)
15
13
  end
16
14
 
17
15
  def recover
18
- GradleOperator.new(@path).recover(true, false)
16
+ cache_operator = CacheOperator.new(@path)
17
+ cache_operator.load(PATH_VERSION_CONFIG)
18
+ cache_operator.clean
19
19
  end
20
20
 
21
21
  def update_module_config(module_name, module_operate_type)
22
- module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
23
-
24
- # get modules
25
- if ModuleOperateType::ADD == module_operate_type
26
- GradleOperator.new(module_full_path).backup
27
-
28
- add_modules = ModuleCacheOperator.new(@path).add_path_modules
29
- GradleOperator.new(module_full_path).update_build_config(module_name, add_modules, ModuleOperateType::ADD)
30
- GradleOperator.new(module_full_path).update_settings_config(module_name, add_modules, ModuleOperateType::ADD, @user)
31
-
32
- del_modules = ModuleCacheOperator.new(@path).del_path_modules
33
- GradleOperator.new(module_full_path).update_build_config(module_name, del_modules, ModuleOperateType::DELETE)
34
- GradleOperator.new(module_full_path).update_settings_config(module_name, del_modules, ModuleOperateType::DELETE, @user)
35
- elsif ModuleOperateType::DELETE == module_operate_type
36
- GradleOperator.new(module_full_path).recover(true, true)
37
- elsif ModuleOperateType::FINISH == module_operate_type
38
- modules = ModuleCacheOperator.new(@path).all_path_modules
39
- GradleOperator.new(module_full_path).update_build_config(module_name, modules, ModuleOperateType::FINISH)
40
- elsif ModuleOperateType::PUBLISH == module_operate_type
41
- modules = ModuleCacheOperator.new(@path).all_git_modules
42
- GradleOperator.new(module_full_path).update_build_config(module_name, modules, ModuleOperateType::PUBLISH)
43
- GradleOperator.new(module_full_path).recover(true, false)
22
+ temp_file = Tempfile.new('.version-config.gradle.tmp')
23
+ begin
24
+ File.open("#{@path}/#{PATH_VERSION_CONFIG}", 'r') do |file|
25
+ file.each_line do |line|
26
+ new_line = generate_version_config_of_line(
27
+ line,
28
+ module_name,
29
+ module_operate_type)
30
+ temp_file.puts(new_line)
31
+ end
32
+ end
33
+ temp_file.close
34
+ FileUtils.mv(temp_file.path, "#{@path}/#{PATH_VERSION_CONFIG}")
35
+ ensure
36
+ temp_file.close
37
+ temp_file.unlink
44
38
  end
39
+ end
40
+
41
+ def generate_version_config_of_line(line, module_name, module_operate_type)
42
+ if line.downcase.match(/([\s\S]*)#{module_name.downcase}version(\s*)=(\s*)('|")(\S*)('|")([\s\S]*)/)
43
+ branch_name = GitOperator.new.current_branch(@path)
44
+ version_name = ''
45
+ # Get version part of source.addition
45
46
 
46
- GradleOperator.new(@path).update_build_config('', [module_name], module_operate_type)
47
- GradleOperator.new(@path).update_settings_config('', [module_name], module_operate_type, @user)
47
+ if ModuleOperateType::ADD == module_operate_type
48
+ version_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
49
+ elsif ModuleOperateType::DELETE == module_operate_type
50
+ return origin_config_of_module(module_name)
51
+ else
52
+ version_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
53
+ end
54
+ return line.sub(/([\s\S]*)Version(\s*)=(\s*)('|")(\S*)('|")([\s\S]*)/){
55
+ "#{$1}Version = '#{version_name}'"}
56
+ end
57
+ line
58
+ end
59
+
60
+ def origin_config_of_module(module_name)
61
+ origin_config = ''
62
+ File.open("#{@path}/.bigkeeper/#{PATH_VERSION_CONFIG}", 'r') do |file|
63
+ file.each_line do |line|
64
+ if line.downcase.match(/([\s\S]*)#{module_name.downcase}version(\s*)=(\s*)('|")(\S*)('|")([\s\S]*)/)
65
+ origin_config = line
66
+ break
67
+ end
68
+ end
69
+ end
70
+ origin_config.chop
48
71
  end
49
72
 
50
73
  def install(should_update)
@@ -3,207 +3,5 @@ require 'big_keeper/util/cache_operator'
3
3
  module BigKeeper
4
4
  # Operator for podfile
5
5
  class GradleOperator
6
- def initialize(path)
7
- @path = path
8
- end
9
-
10
- def backup
11
- cache_operator = CacheOperator.new(@path)
12
-
13
- cache_operator.save('settings.gradle')
14
-
15
- Dir.glob("#{@path}/*/build.gradle").each do |build_gradle_file_path|
16
- build_gradle_file = build_gradle_file_path.gsub!(/#{@path}/, '')
17
- cache_operator.save(build_gradle_file)
18
- end
19
- end
20
-
21
- def recover(settings_config, build_config)
22
- cache_operator = CacheOperator.new(@path)
23
-
24
- cache_operator.load('settings.gradle') if settings_config
25
-
26
- if build_config
27
- Dir.glob("#{@path}/*/build.gradle").each do |build_gradle_file_path|
28
- build_gradle_file = build_gradle_file_path.gsub!(/#{@path}/, '')
29
- cache_operator.load(build_gradle_file)
30
- end
31
- end
32
-
33
- cache_operator.clean
34
- end
35
-
36
- def update_settings_config(current_module_name, modules, module_operate_type, user)
37
- return if modules.empty?
38
-
39
- if ModuleOperateType::ADD == module_operate_type
40
- modules.each do |module_name|
41
- next if current_module_name == module_name
42
-
43
- File.open("#{@path}/settings.gradle", 'a') do |file|
44
- file.puts "\r\ninclude ':module:#{module_name.downcase}'\r\n"
45
- file.puts "project(':module:#{module_name.downcase}')." \
46
- "projectDir = new File(rootProject.projectDir," \
47
- "'#{BigkeeperParser.module_path(user, module_name)}/#{module_name.downcase}-lib')\r\n"
48
- end
49
- end
50
- else
51
- modules.each do |module_name|
52
- next if current_module_name == module_name
53
- temp_file = Tempfile.new('.settings.gradle.tmp')
54
- begin
55
- File.open("#{@path}/settings.gradle", 'r') do |file|
56
- file.each_line do |line|
57
- unless line =~ /(\s*)include(\s*)('|")(\S*):#{module_name.downcase}('|")(\S*)/ ||
58
- line =~ /(\s*)project\(('|")(\S*):#{module_name.downcase}('|")\).(\S*)/
59
- temp_file.puts(line)
60
- end
61
- end
62
- end
63
- temp_file.close
64
- FileUtils.mv(temp_file.path, "#{@path}/settings.gradle")
65
- ensure
66
- temp_file.close
67
- temp_file.unlink
68
- end
69
- end
70
- end
71
- end
72
-
73
- def update_build_config(current_module_name, modules, module_operate_type)
74
- return if modules.empty?
75
-
76
- Dir.glob("#{@path}/*/build.gradle").each do |file_path|
77
- modules.each do |module_name|
78
- next if current_module_name == module_name
79
-
80
- temp_file = Tempfile.new('.build.gradle.tmp')
81
- begin
82
- version_flag = false
83
- version_index = 0
84
-
85
- File.open(file_path, 'r') do |file|
86
- file.each_line do |line|
87
- new_line, version_index, version_flag = generate_build_config(
88
- line,
89
- module_name,
90
- module_operate_type,
91
- version_index,
92
- version_flag)
93
-
94
- temp_file.puts(new_line)
95
- end
96
- end
97
- temp_file.close
98
- FileUtils.mv(temp_file.path, file_path)
99
- ensure
100
- temp_file.close
101
- temp_file.unlink
102
- end
103
- end
104
- end
105
- end
106
-
107
- def generate_build_config(line, module_name, module_operate_type, version_index, version_flag)
108
- new_line = line
109
-
110
- version_flag = true if line.downcase.include? 'modifypom'
111
- if version_flag
112
- version_index += 1 if line.include? '{'
113
- version_index -= 1 if line.include? '}'
114
-
115
- version_flag = false if 0 == version_flag
116
-
117
- new_line = generate_version_config(line, module_name, module_operate_type)
118
- else
119
- new_line = generate_compile_config(line, module_name, module_operate_type)
120
- end
121
-
122
- [new_line, version_index, version_flag]
123
- end
124
-
125
- def generate_version_config(line, module_name, module_operate_type)
126
- if ModuleOperateType::FINISH == module_operate_type || ModuleOperateType::PUBLISH == module_operate_type
127
- branch_name = GitOperator.new.current_branch(@path)
128
- full_name = ''
129
-
130
- # Get version part of source.addition
131
- if ModuleOperateType::PUBLISH == module_operate_type
132
- full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
133
- else
134
- full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
135
- end
136
-
137
- line.sub(/(\s*)version ('|")(\S*)('|")([\s\S]*)/){
138
- "#{$1}version '#{full_name}'#{$5}"
139
- }
140
- else
141
- line
142
- end
143
- end
144
-
145
- def generate_compile_config(line, module_name, module_operate_type)
146
- if ModuleOperateType::ADD == module_operate_type
147
- line.sub(/(\s*)compile(\s*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/){
148
- "#{$1}compile project(':module:#{module_name.downcase}')"
149
- }
150
- elsif ModuleOperateType::DELETE == module_operate_type
151
- line.sub(/(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/){
152
- origin_config_of_module = origin_config_of_module(module_name)
153
- if origin_config_of_module.empty?
154
- line
155
- else
156
- origin_config_of_module
157
- end
158
- }
159
- elsif ModuleOperateType::FINISH == module_operate_type || ModuleOperateType::PUBLISH == module_operate_type
160
- branch_name = GitOperator.new.current_branch(@path)
161
- full_name = ''
162
-
163
- # Get version part of source.addition
164
- if ModuleOperateType::PUBLISH == module_operate_type
165
- full_name = branch_name.sub(/([\s\S]*)\/(\d+.\d+.\d+)_([\s\S]*)/){ $2 }
166
- else
167
- full_name = branch_name.sub(/([\s\S]*)\/([\s\S]*)/){ $2 }
168
- end
169
- line.sub(/(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}(:\S*)*('|")(\S*)/){
170
- if $2.downcase.include? 'modulecompile'
171
- "#{$1}moduleCompile '#{prefix_of_module(module_name)}:#{module_name.downcase}:#{full_name}-SNAPSHOT'"
172
- else
173
- "#{$1}compile '#{prefix_of_module(module_name)}:#{module_name.downcase}:#{full_name}-SNAPSHOT'"
174
- end
175
- }
176
- else
177
- line
178
- end
179
- end
180
-
181
- def origin_config_of_module(module_name)
182
- origin_config = ''
183
-
184
- Dir.glob("#{@path}/.bigkeeper/*/build.gradle").each do |file|
185
- File.open(file, 'r') do |file|
186
- file.each_line do |line|
187
- if line =~ /(\s*)([\s\S]*)('|")(\S*):#{module_name.downcase}:(\S*)('|")(\S*)/
188
- origin_config = line
189
- break
190
- end
191
- end
192
- end
193
- break unless origin_config.empty?
194
- end
195
-
196
- origin_config.chop
197
- end
198
-
199
- def prefix_of_module(module_name)
200
- origin_config = origin_config_of_module(module_name)
201
- prefix = origin_config.sub(/(\s*)([\s\S]*)('|")(\S*)#{module_name.downcase}(\S*)('|")(\S*)/){
202
- $4
203
- }
204
- prefix.chop
205
- end
206
-
207
- private :generate_build_config, :generate_compile_config, :generate_version_config, :origin_config_of_module, :prefix_of_module
208
6
  end
209
7
  end
@@ -0,0 +1,143 @@
1
+ require 'big_keeper/util/bigkeeper_parser'
2
+ require 'big_keeper/util/logger'
3
+ require 'big_keeper/util/podfile_detector'
4
+ require 'Singleton'
5
+
6
+ module BigKeeper
7
+ class LockfileParser
8
+ include Singleton
9
+ attr_accessor :main_path, :dependencies, :pods, :podfile_hash
10
+ $mode = 'PODS'
11
+
12
+ def initialize
13
+ self.pods = {}
14
+ self.dependencies = []
15
+ end
16
+
17
+ def parse(main_path)
18
+ self.main_path = main_path
19
+ $mode = 'PODS'
20
+ podfile_lock_lines = File.readlines("#{main_path}/Podfile.lock")
21
+ Logger.highlight("Analyzing Podfile.lock...")
22
+ podfile_lock_lines.each do |sentence|
23
+ if sentence.include?('PODS')
24
+ $mode = 'PODS'
25
+ elsif sentence.include?('DEPENDENCIES')
26
+ $mode = 'DEPENDENCIES'
27
+ elsif sentence.include?('SPEC REPOS')
28
+ $mode = 'SPEC REPOS'
29
+ elsif sentence.include?('SPEC CHECKSUMS')
30
+ $mode = 'SPEC CHECKSUMS'
31
+ elsif sentence.include?('CHECKOUT OPTIONS')
32
+ $mode = 'CHECKOUT OPTIONS'
33
+ elsif sentence.include?('EXTERNAL SOURCES')
34
+ $mode = 'EXTERNAL SOURCES'
35
+ elsif sentence.include?('PODFILE CHECKSUM')
36
+ $mode = 'PODFILE CHECKSUM'
37
+ else
38
+ if $mode == 'PODS'
39
+ deal_pod(sentence.strip.delete('\n'))
40
+ end
41
+ if $mode == 'SPEC CHECKSUMS'
42
+ deal_spec(sentence.strip.delete('\n'))
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def get_unlock_pod_list(is_all)
49
+ result = {}
50
+ pod_parser = PodfileParser.instance
51
+ #podfile 中 unlock pods
52
+ unlock_pods = pod_parser.get_unlock_pod_list
53
+ # @unlock_pod_list << pod_name unless @module_list.include pod_name
54
+ if is_all
55
+ self.dependencies.each do |pod_name|
56
+ if pod_parser.pod_list.include?(pod_name)
57
+ next
58
+ end
59
+ if self.pods[pod_name] != nil
60
+ result[pod_name] = self.pods[pod_name]
61
+ end
62
+ end
63
+
64
+ unlock_pods.each do |pod_name|
65
+ if self.pods[pod_name] != nil
66
+ result[pod_name] = self.pods[pod_name]
67
+ end
68
+ end
69
+ return result
70
+ else
71
+ unlock_pods.each do |pod_name|
72
+ if self.pods[pod_name] != nil
73
+ result[pod_name] = self.pods[pod_name]
74
+ end
75
+ end
76
+ return result
77
+ end
78
+ end
79
+
80
+ #处理PODS
81
+ # TODO 去除重复
82
+ def deal_pod(s)
83
+ pod_name = get_lock_podname(s)
84
+ return if pod_name == nil
85
+ pod_version = get_lock_version(s)
86
+ if self.pods.keys.include?(pod_name)
87
+ current_version = self.pods[pod_name]
88
+ if pod_version != nil && current_version != nil
89
+ self.pods[pod_name] = chose_version(current_version, pod_version)
90
+ else
91
+ self.pods[pod_name] = pod_version unless pod_version == nil
92
+ end
93
+ end
94
+ self.pods[pod_name] = pod_version unless pod_version == nil
95
+ end
96
+ #
97
+ # #处理EXTERNAL SOURCES
98
+ # def deal_sources(s)
99
+ #
100
+ # end
101
+ # #处理CHECKOUT OPTIONS
102
+ # def deal_checkout(s)
103
+ #
104
+ # end
105
+
106
+ #处理SPEC CHECKSUMS
107
+ def deal_spec(s)
108
+ if /: +/ =~ s
109
+ dependency = $~.pre_match.strip
110
+ self.dependencies << dependency unless self.dependencies.include?(dependency)
111
+ end
112
+ end
113
+
114
+ def get_lock_podname(sentence) #获得lock pod名称
115
+ match_result = /(\d+.){1,2}\d+/.match(sentence.delete('- :~>='))
116
+ pod_name = match_result.pre_match unless match_result == nil
117
+ return pod_name.delete('()') unless pod_name == nil
118
+ end
119
+
120
+ def get_lock_version(sentence)#获得lock pod版本号
121
+ match_result = /(\d+.){1,2}\d+/.match(sentence)
122
+ return match_result[0].strip unless match_result == nil
123
+ end
124
+
125
+ def chose_version(cur_version,temp_version)
126
+ # p "cur:#{cur_version},temp:#{temp_version}"
127
+ cur_list = cur_version.split('.')
128
+ temp_list = temp_version.split('.')
129
+ cur_list << 0.to_s if cur_list.size == 2
130
+ temp_list << 0.to_s if temp_list.size == 2
131
+ if cur_list[0] >= temp_list[0]
132
+ if cur_list[1] >= temp_list[1]
133
+ if cur_list[2] > temp_list[2]
134
+ return cur_version
135
+ end
136
+ return temp_version
137
+ end
138
+ return temp_version
139
+ end
140
+ return temp_version
141
+ end
142
+ end
143
+ end
@@ -1,27 +1,39 @@
1
1
  require 'big_keeper/util/bigkeeper_parser'
2
2
  require 'big_keeper/model/podfile_model'
3
3
  require 'big_keeper/util/logger'
4
-
4
+ require 'Singleton'
5
5
  module BigKeeper
6
6
 
7
- class PodfileDetector
8
-
9
- attr_accessor :module_list, :main_path
7
+ class PodfileParser
8
+ include Singleton
9
+ attr_accessor :module_list, :main_path, :pod_list
10
10
  $unlock_pod_list = []
11
11
  $modify_pod_list = {}
12
12
 
13
- def initialize(main_path, module_list)
14
- @module_list = module_list
15
- @main_path = main_path
13
+ def initialize
14
+ @module_list = BigkeeperParser.module_names
15
+ @pod_list = []
16
16
  end
17
17
 
18
- def get_unlock_pod_list
18
+ def parse(path)
19
+ @main_path = path
19
20
  podfile_lines = File.readlines("#{@main_path}/Podfile")
20
21
  Logger.highlight("Analyzing Podfile...") unless podfile_lines.size.zero?
21
- podfile_lines.collect do |sentence|
22
- deal_podfile_line(sentence) unless sentence =~(/(\d+.){1,2}\d+/)
22
+ podfile_lines.collect do |sentence|
23
+ if /pod / =~ sentence
24
+ pod_name = get_pod_name(sentence)
25
+ @pod_list << pod_name
23
26
  end
24
- $unlock_pod_list
27
+ end
28
+ end
29
+
30
+ def get_unlock_pod_list
31
+ podfile_lines = File.readlines("#{@main_path}/Podfile")
32
+ #Logger.highlight("Analyzing Podfile...") unless podfile_lines.size.zero?
33
+ podfile_lines.collect do |sentence|
34
+ deal_podfile_line(sentence) unless sentence =~(/'(\d+.){1,2}\d+'/)
35
+ end
36
+ $unlock_pod_list
25
37
  end
26
38
 
27
39
  def deal_podfile_line(sentence)
@@ -32,37 +44,24 @@ class PodfileDetector
32
44
  pod_model.configurations != '[\'Debug\']' &&
33
45
  pod_model.path == nil &&
34
46
  pod_model.tag == nil
35
- $unlock_pod_list << pod_model.name unless @module_list.include?(pod_model.name)
47
+ pod_names = pod_model.name.split('/')
48
+ if pod_names.size > 1
49
+ pod_name = pod_names[0]
50
+ else
51
+ pod_name = pod_model.name
52
+ end
53
+ $unlock_pod_list << pod_name unless @module_list.include?(pod_name)
36
54
  end
37
55
  pod_model
38
56
  end
39
57
  end
40
58
 
59
+ def get_pod_name(sentence)
41
60
 
42
- def deal_lock_file(main_path, deal_list)
43
- $result = {}
44
- podfile_lock_lines = File.readlines("#{main_path}/Podfile.lock")
45
- Logger.highlight("Analyzing Podfile.lock...") unless podfile_lock_lines.size.zero?
46
- podfile_lock_lines.select do |sentence|
47
- if sentence.include?('DEPENDENCIES') #指定范围解析 Dependencies 之前
48
- break
49
- end
50
-
51
- temp_sentence = sentence.strip
52
- pod_name = get_lock_podname(temp_sentence)
53
- if deal_list.include?(pod_name)
54
- current_version = $result[pod_name]
55
- temp_version = get_lock_version(temp_sentence)
56
- if temp_version != nil
57
- if current_version != nil
58
- $result[pod_name] = chose_version(current_version, temp_version)
59
- else
60
- $result[pod_name] = temp_version
61
- end
62
- end
63
- end
61
+ pod_model = deal_podfile_line(sentence)
62
+ if pod_model != nil
63
+ return pod_model.name
64
64
  end
65
- return $result
66
65
  end
67
66
 
68
67
  def self.get_pod_model(sentence)
@@ -72,14 +71,6 @@ class PodfileDetector
72
71
  end
73
72
  end
74
73
 
75
- def get_pod_name(sentence)
76
- pod_model = deal_podfile_line(sentence)
77
- pod_name = pod_model.name if pod_model != nil && pod_model.configurations.nil
78
- @unlock_pod_list << pod_name unless @module_list.include pod_name
79
- end
80
-
81
-
82
-
83
74
  def get_lock_podname(sentence) #获得pod名称
84
75
  match_result = /(\d+.){1,2}\d+/.match(sentence.delete('- :~>='))
85
76
  pod_name = match_result.pre_match unless match_result == nil
@@ -40,15 +40,22 @@ module BigKeeper
40
40
  begin
41
41
  File.open(podfile, 'r') do |file|
42
42
  file.each_line do |line|
43
- pod_model = PodfileDetector.get_pod_model(line)
43
+ pod_model = PodfileParser.get_pod_model(line)
44
44
  if pod_model != nil && pod_model.name != nil && dictionary[pod_model.name] != nil
45
- # p "#{pod_name},#{dictionary[pod_name]}"
46
45
  temp_file.puts generate_pod_config(pod_model.name, dictionary[pod_model.name], pod_model.comment)
46
+ dictionary.delete(pod_model.name)
47
47
  else
48
48
  temp_file.puts line
49
49
  end
50
50
  end
51
51
  end
52
+ if !dictionary.empty?
53
+ temp_file.puts 'def sub_dependency'
54
+ dictionary.keys.each do |sub_pod|
55
+ temp_file.puts generate_pod_config(sub_pod, dictionary[sub_pod], 'bigkeeper')
56
+ end
57
+ temp_file.puts 'end'
58
+ end
52
59
  temp_file.close
53
60
  FileUtils.mv(temp_file.path, podfile)
54
61
  ensure
@@ -62,8 +69,9 @@ module BigKeeper
62
69
  begin
63
70
  File.open(podfile, 'r') do |file|
64
71
  file.each_line do |line|
65
- pod_model = PodfileDetector.get_pod_model(line)
72
+ pod_model = PodfileParser.get_pod_model(line)
66
73
  if pod_model != nil && pod_model.name != nil && dictionary[pod_model.name] != nil
74
+ #替换
67
75
  temp_file.puts generate_pod_config(pod_model.name, dictionary[pod_model.name], pod_model.comment)
68
76
  else
69
77
  temp_file.puts line
@@ -1,3 +1,3 @@
1
1
  module BigKeeper
2
- VERSION = "0.8.9"
2
+ VERSION = "0.9.0"
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.8.9
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmoaay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-23 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -301,6 +301,7 @@ files:
301
301
  - lib/big_keeper/util/info_plist_operator.rb
302
302
  - lib/big_keeper/util/leancloud_logger.rb
303
303
  - lib/big_keeper/util/list_generator.rb
304
+ - lib/big_keeper/util/lockfile_parser.rb
304
305
  - lib/big_keeper/util/logger.rb
305
306
  - lib/big_keeper/util/pod_operator.rb
306
307
  - lib/big_keeper/util/podfile_detector.rb
@@ -337,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
337
338
  version: '0'
338
339
  requirements: []
339
340
  rubyforge_project:
340
- rubygems_version: 2.6.13
341
+ rubygems_version: 2.5.2.3
341
342
  signing_key:
342
343
  specification_version: 4
343
344
  summary: Efficiency improvement for iOS&Android modular development.