big_keeper 0.4.0 → 0.5.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: 18a0e9bf18ad96844aa32421e09b56aa48681fd9
4
- data.tar.gz: 63ea947213a94d6b8707acf5232d2dc7e475f9ed
3
+ metadata.gz: 4a3c399d6961d86ef419b46541eed58b809c484d
4
+ data.tar.gz: 699643b23a3b95ef5d843918d0c4f1f8999be335
5
5
  SHA512:
6
- metadata.gz: af8e302003e39f9b0b5c020eb45429166843420fa0ec01fcff02e8eff2be215b33d6f5195e645e0e44f292e7994abb36db532af24aa8175251d4ea6864a3e3c8
7
- data.tar.gz: 30fcdf96aeecee91a1518944c029b92d2e6f6b04aa0d43d967e060dc6bf5fd2a02dfbe4e75664345a3afde80bf7f18e8d566e5835ea85197921e5b126747c4ba
6
+ metadata.gz: 878010d015f1fab7c07d1392152badae3ef259e5c63b0b916ba0169be9fc616e25a7a6d59f2d35d76619a4567b06a20297e298b091bb599824ce39ce1c41d2fc
7
+ data.tar.gz: 0b5cbce481f7330aaef652251c01e3ceab73b93bb4f6261ff414426cdce77bed903213e51d69e75e09606b2d023756efb84ad35e34ecf4ec0f4fcc3422cd2e1f
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- big_keeper (0.3.0)
4
+ big_keeper (0.4.0)
5
5
  big_stash (~> 0.1)
6
6
  cocoapods
7
+ colorize
7
8
  gli (~> 2.16)
8
9
  plist
9
10
 
@@ -54,6 +55,7 @@ GEM
54
55
  netrc (= 0.7.8)
55
56
  cocoapods-try (1.1.0)
56
57
  colored2 (3.1.2)
58
+ colorize (0.8.1)
57
59
  escape (0.0.4)
58
60
  fourflusher (2.0.1)
59
61
  fuzzy_match (2.0.4)
@@ -101,6 +103,7 @@ DEPENDENCIES
101
103
  big_stash (~> 0.1)
102
104
  bundler (~> 1.15)
103
105
  cocoapods
106
+ colorize
104
107
  gli (~> 2.16)
105
108
  plist
106
109
  rake (~> 10.0)
data/big_keeper.gemspec CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency "big_stash", "~> 0.1"
35
35
  spec.add_runtime_dependency "cocoapods"
36
36
  spec.add_runtime_dependency "plist"
37
+ spec.add_runtime_dependency "colorize"
37
38
 
38
39
  spec.add_development_dependency "bundler", "~> 1.15"
39
40
  spec.add_development_dependency "rake", "~> 10.0"
@@ -41,5 +42,6 @@ Gem::Specification.new do |spec|
41
42
  spec.add_development_dependency "big_stash", "~> 0.1"
42
43
  spec.add_development_dependency "cocoapods"
43
44
  spec.add_development_dependency "plist"
45
+ spec.add_development_dependency "colorize"
44
46
  spec.add_development_dependency "rubocop", "~> 0.50.0"
45
47
  end
@@ -0,0 +1,20 @@
1
+ # release - 功能开发流程
2
+
3
+ 直接在命令行执行 `big-keeper release --help` 可以查看其提供的所有功能:
4
+ ```
5
+ // todo
6
+ ```
7
+ 全局参数如下:
8
+
9
+ - -u, --user:用户名,默认是 git global config 的 user.name,会显示在命令提示信息中,比如上述提示信息中的默认用户名是 mmoaay
10
+
11
+ - -p, --path:项目路径名,默认是当前所在的路径
12
+
13
+ - -v, --version:项目版本号,默认是当前所在的路径
14
+
15
+ 功能列表如下:
16
+
17
+ - home: 发布主工程命令
18
+ - start: 开始发布主工程的某个版本
19
+ - finish:
20
+ - module: 发布模块命令
data/lib/big_keeper.rb CHANGED
@@ -15,6 +15,7 @@ require 'big_keeper/command/feature_pull'
15
15
  require 'big_keeper/command/feature_push'
16
16
  require 'big_keeper/command/release_home'
17
17
  require 'big_keeper/command/release_module'
18
+ require 'big_keeper/command/podfile_lock'
18
19
 
19
20
  require 'big_keeper/service/git_service'
20
21
 
@@ -28,7 +29,7 @@ module BigKeeper
28
29
 
29
30
  flag %i[p path], default_value: './'
30
31
  flag %i[v ver], default_value: 'Version in Bigkeeper file'
31
- flag %i[u user], default_value: GitOperator.new.user
32
+ flag %i[u user], default_value: GitOperator.new.user.gsub(/[^0-9A-Za-z]/, '').downcase
32
33
 
33
34
  path = ''
34
35
  version = ''
@@ -37,7 +38,12 @@ module BigKeeper
37
38
  pre do |global_options, _command, options, args|
38
39
  path = File.expand_path(global_options[:path])
39
40
  version = global_options[:ver]
40
- user = global_options[:user]
41
+ user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
42
+ end
43
+
44
+ if !GitflowOperator.new.verify_git_flow_command
45
+ p %Q('git-flow' not found, use 'brew install git-flow' to install it)
46
+ exit
41
47
  end
42
48
 
43
49
  desc 'Feature operations'
@@ -46,7 +52,6 @@ module BigKeeper
46
52
  c.desc 'Start a new feature with name for given modules and main project'
47
53
  c.command :start do |start|
48
54
  start.action do |global_options, options, args|
49
- user = user.gsub(/[^0-9A-Za-z]/, '').downcase
50
55
  help_now!('user name is required') if user and user.empty?
51
56
  help_now!('feature name is required') if args.length < 1
52
57
  name = args[0]
@@ -58,7 +63,6 @@ module BigKeeper
58
63
  c.desc 'Update moduels for the feature with name'
59
64
  c.command :update do |update|
60
65
  update.action do |global_options, options, args|
61
- user = user.gsub(/[^0-9A-Za-z]/, '').downcase
62
66
  help_now!('user name is required') if user and user.empty?
63
67
  modules = args[(0...args.length)] if args.length > 0
64
68
  feature_update(path, user, modules)
@@ -68,7 +72,6 @@ module BigKeeper
68
72
  c.desc 'Switch to the feature with name'
69
73
  c.command :switch do |switch|
70
74
  switch.action do |global_options, options, args|
71
- user = user.gsub(/[^0-9A-Za-z]/, '').downcase
72
75
  help_now!('user name is required') if user and user.empty?
73
76
  help_now!('feature name is required') if args.length < 1
74
77
  name = args[0]
@@ -79,7 +82,6 @@ module BigKeeper
79
82
  c.desc 'Pull remote changes for current feature'
80
83
  c.command :pull do |pull|
81
84
  pull.action do |global_options, options, args|
82
- user = user.gsub(/[^0-9A-Za-z]/, '').downcase
83
85
  help_now!('user name is required') if user and user.empty?
84
86
  feature_pull(path, user)
85
87
  end
@@ -88,7 +90,6 @@ module BigKeeper
88
90
  c.desc 'Push local changes to remote for current feature'
89
91
  c.command :push do |push|
90
92
  push.action do |global_options, options, args|
91
- user = user.gsub(/[^0-9A-Za-z]/, '').downcase
92
93
  help_now!('user name is required') if user and user.empty?
93
94
  help_now!('comment message is required') if args.length < 1
94
95
  comment = args[0]
@@ -99,7 +100,6 @@ module BigKeeper
99
100
  c.desc 'Finish current feature'
100
101
  c.command :finish do |finish|
101
102
  finish.action do |global_options, options, args|
102
- user = user.gsub(/[^0-9A-Za-z]/, '').downcase
103
103
  help_now!('user name is required') if user and user.empty?
104
104
  feature_finish(path, user)
105
105
  end
@@ -124,11 +124,6 @@ module BigKeeper
124
124
  home.desc 'Start release home project'
125
125
  home.command :start do |start|
126
126
  start.action do |global_options, options, args|
127
- # path(optional): path of the Bigkeeper file in project
128
- # version(optional): if null, will read verson in Bigkeeper file
129
- # e.g: ruby big_keeper.rb -p /Users/SFM/Downloads/BigKeeperMain-master
130
- # /Bigkeeper -v 3.0.0 release home start
131
- user = user.gsub(/[^0-9A-Za-z]/, '').downcase
132
127
  help_now!('user name is required') if user and user.empty?
133
128
  release_home_start(path, version, user)
134
129
  end
@@ -140,17 +135,44 @@ module BigKeeper
140
135
  release_home_finish(path, version)
141
136
  end
142
137
  end
138
+ end
143
139
 
144
- home.desc 'Start release module'
145
- home.command :module do |finish|
146
- finish.action do |global_options, options, args|
147
- help_now!('module name is required') if args.length != 1
148
- module_name = args[0]
149
- start_module_release(path, module_name)
150
- end
140
+ c.desc 'Start release module'
141
+ c.command :module do |finish|
142
+ finish.action do |global_options, options, args|
143
+ help_now!('module name is required') if args.length != 1
144
+ module_name = args[0]
145
+ start_module_release(path, version, user, module_name)
146
+ end
147
+ end
148
+ end
149
+
150
+ desc 'Podfile operation'
151
+ command :podfile do |podfile|
152
+ podfile.flag %i[pod podfile]
153
+ podfile.desc 'Podfile'
154
+ path = ''
155
+
156
+ podfile.desc 'Detect podname should be locked.'
157
+ podfile.command :detect do |detect|
158
+ detect.action do |global_options,options,args|
159
+ podfile_detect(path)
160
+ end
161
+ end
162
+
163
+ podfile.desc 'Lock podname should be locked.'
164
+ podfile.command :lock do |lock|
165
+ lock.action do |global_options, options, args|
166
+ podfile_lock(path)
151
167
  end
152
168
  end
153
169
  end
154
170
 
171
+ desc 'Version'
172
+ command :version do |version|
173
+ version.action do |global_options, options, args|
174
+ p "big-keeper (#{VERSION})"
175
+ end
176
+ end
155
177
  exit run(ARGV)
156
178
  end
@@ -15,7 +15,7 @@ module BigKeeper
15
15
  end
16
16
 
17
17
  p "Pull branch #{branch_name} for home..."
18
- GitOperator.new.pull(path, branch_name)
18
+ GitOperator.new.pull(path)
19
19
  ensure
20
20
  end
21
21
  end
@@ -20,7 +20,7 @@ module BigKeeper
20
20
 
21
21
  # Switch to new feature
22
22
  GitOperator.new.git_checkout(path, branch_name)
23
- GitOperator.new.pull(path, branch_name)
23
+ GitOperator.new.pull(path)
24
24
 
25
25
  modules = PodfileOperator.new.modules_with_type("#{path}/Podfile",
26
26
  BigkeeperParser.module_names, ModuleType::PATH)
@@ -1,16 +1,51 @@
1
1
 
2
- require './big_keeper/util/podfile_detector'
3
- require './big_keeper/util/gitflow_operator'
4
- require './big_keeper/util/bigkeeper_parser'
5
- require './big_keeper/model/podfile_type'
2
+ require 'big_keeper/util/podfile_detector'
3
+ require 'big_keeper/util/podfile_operator'
4
+ require 'big_keeper/util/gitflow_operator'
5
+ require 'big_keeper/util/bigkeeper_parser'
6
+ require 'big_keeper/model/podfile_type'
7
+ require 'big_keeper/util/log_util'
6
8
 
7
9
  module BigKeeper
10
+
11
+ def self.podfile_detect(path)
12
+ # Parse Bigkeeper file
13
+ BigkeeperParser.parse("#{path}/Bigkeeper")
14
+ # Get modulars' name
15
+ modular_list = BigkeeperParser.module_names
16
+ # initialize PodfileDetector
17
+ detector = PodfileDetector.new(path,modular_list)
18
+ # Get unlocked third party pods list
19
+ unlock_pod_list = detector.get_unlock_pod_list
20
+ # Print out unlock pod list
21
+ unlock_pod_list.each do |pod_name|
22
+ BigKeeperLog.default("#{pod_name} should be locked.")
23
+ end
24
+ BigKeeperLog.separator
25
+
26
+ end
27
+
8
28
  def self.podfile_lock(path)
9
- begin
10
29
  # Parse Bigkeeper file
11
30
  BigkeeperParser.parse("#{path}/Bigkeeper")
12
- unlock_pod_list = PodfileDetector.new.get_unlock_pod_list
13
- p unlock_pod_list
14
- end
31
+ # Get modulars' name
32
+ modular_list = BigkeeperParser.module_names
33
+ # initialize PodfileDetector
34
+ detector = PodfileDetector.new(path,modular_list)
35
+ # 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?
40
+ BigKeeperLog.warning("There is nothing to be locked.")
41
+ else
42
+ PodfileOperator.new.find_and_lock("#{path}/Podfile",dictionary)
43
+ BigKeeperLog.highlight("The Podfile has been changed.")
44
+ BigKeeperLog.separator
45
+ end
46
+
47
+
48
+
15
49
  end
50
+
16
51
  end
@@ -4,10 +4,6 @@ require 'big_keeper/util/gitflow_operator'
4
4
  require 'big_keeper/model/podfile_type'
5
5
  require 'big_keeper/util/info_plist_operator'
6
6
 
7
- # 1.切换主工程的分支到 release分支
8
- # 2.替换当前 podfile 中每个 module 为 pod #{module_name}, :git => '#{source.base}', :tag => '#{source.addition}'
9
- # 3.替换 info.plist 中的 build version
10
-
11
7
  module BigKeeper
12
8
  def self.release_home_start(path, version, user)
13
9
  BigkeeperParser.parse("#{path}/Bigkeeper")
@@ -15,37 +11,54 @@ module BigKeeper
15
11
  end
16
12
 
17
13
  def self.release_home_finish(path, version)
18
- GitOperator.new.commit(path, "release: V #{version}")
19
- GitOperator.new.push(path, "release/#{version}")
20
- GitflowOperator.new.finish_release(path, version)
21
- GitOperator.new.tag(path, version)
14
+ Dir.chdir(path) do
15
+ if GitOperator.new.has_branch(project_path, "release/#{version}")
16
+ if GitOperator.new.current_branch(project_path) != "release/#{version}"
17
+ GitOperator.new.commit(path, "release: V #{version}")
18
+ GitOperator.new.push(path, "release/#{version}")
19
+ GitflowOperator.new.finish_release(path, version)
20
+ if GitOperator.new.current_branch(project_path) == "master"
21
+ GitOperator.new.tag(path, version)
22
+ else
23
+ GitOperator.new.git_checkout(project_path, "master")
24
+ GitOperator.new.tag(path, version)
25
+ end
26
+ else
27
+ raise "Not in release branch, please check your branches."
28
+ end
29
+ else
30
+ raise "Not has release branch, use release start first."
31
+ end
32
+ end
22
33
  end
23
34
 
24
35
  private
25
36
  def self.start_release(project_path, version, modules, source, user)
26
- # step 0 Stash current branch
27
- StashService.new.stash(project_path, GitOperator.new.current_branch(project_path), user, modules)
37
+ Dir.chdir(project_path) do
38
+ # step 0 Stash current branch
39
+ StashService.new.stash(project_path, GitOperator.new.current_branch(project_path), user, modules)
28
40
 
29
- # step 1 checkout release
30
- if GitOperator.new.current_branch(project_path) != "release/#{version}"
31
- if GitOperator.new.has_branch(project_path, "release/#{version}")
32
- GitOperator.new.git_checkout(project_path, "release/#{version}")
33
- else
34
- GitflowOperator.new.start(project_path, version, GitflowType::RELEASE)
35
- GitOperator.new.push(project_path, "release/#{version}")
41
+ # step 1 checkout release
42
+ if GitOperator.new.current_branch(project_path) != "release/#{version}"
43
+ if GitOperator.new.has_branch(project_path, "release/#{version}")
44
+ GitOperator.new.git_checkout(project_path, "release/#{version}")
45
+ else
46
+ GitflowOperator.new.start(project_path, version, GitflowType::RELEASE)
47
+ GitOperator.new.push(project_path, "release/#{version}")
48
+ end
36
49
  end
37
- end
38
50
 
39
- # step 2 replace_modules
40
- PodfileOperator.new.replace_all_module_release(%Q(#{project_path}/Podfile),
41
- modules,
42
- version,
43
- source)
51
+ # step 2 replace_modules
52
+ PodfileOperator.new.replace_all_module_release(%Q(#{project_path}/Podfile),
53
+ modules,
54
+ version,
55
+ source)
44
56
 
45
- # step 3 change Info.plist value
46
- InfoPlistOperator.new.change_version_build(project_path, version)
57
+ # step 3 change Info.plist value
58
+ InfoPlistOperator.new.change_version_build(project_path, version)
47
59
 
48
- p `pod install --project-directory=#{project_path}`
49
- p `open #{project_path}/*.xcworkspace`
60
+ p `pod install --project-directory=#{project_path}`
61
+ p `open #{project_path}/*.xcworkspace`
62
+ end
50
63
  end
51
64
  end
@@ -4,24 +4,24 @@ require 'big_keeper/util/gitflow_operator'
4
4
  require 'big_keeper/model/podfile_type'
5
5
  require 'big_keeper/util/info_plist_operator'
6
6
 
7
- # 替换当前 podfile 中某个 module 为 pod #{module_name}, :git => '#{source.base}', :tag => '#{source.addition}'
8
-
9
7
  module BigKeeper
10
- def self.start_module_release(path, module_name)
11
- BigkeeperParser.parse("#{path}/Bigkeeper")
12
-
13
- module_release(path,
14
- module_name,
15
- GitInfo.new(BigkeeperParser.home_git, GitType::BRANCH, 'develop'))
8
+ def self.start_module_release(path, version, user, module_name)
9
+ main_path = File.expand_path("#{path}/Example")
10
+ module_release(main_path,
11
+ version,
12
+ BigkeeperParser::module_names,
13
+ GitInfo.new(BigkeeperParser::home_git, GitType::TAG, version), user)
16
14
  end
17
15
 
18
16
  private
19
- def self.module_release(project_path, module_name, source)
20
- PodfileOperator.new.find_and_replace(%Q(#{project_path}/Podfile),
21
- module_name,
22
- ModuleType::GIT,
23
- source)
24
- p `pod install --project-directory=#{project_path}`
25
- p `open #{project_path}/*.xcworkspace`
17
+ def self.module_release(project_path, version, module_name, source)
18
+ Dir.chdir(project_path) do
19
+ PodfileOperator.new.find_and_replace(%Q(#{project_path}/Podfile),
20
+ module_name,
21
+ ModuleType::GIT,
22
+ source)
23
+ p `pod install --project-directory=#{project_path}`
24
+ p `open #{project_path}/*.xcworkspace`
25
+ end
26
26
  end
27
27
  end
@@ -0,0 +1,33 @@
1
+
2
+ module BigKeeper
3
+
4
+ class Podfile_Modle
5
+ attr_accessor :name,:git,:path,:configurations,:branch,:tag,:comment
6
+ def initialize(sentence)
7
+ if sentence.include?('#')
8
+ list = sentence.split('#')
9
+ @comment = list[1]
10
+ sentence = list[0]
11
+ end
12
+
13
+ sentence_slip_list = sentence.split(',')
14
+ return if sentence_slip_list.size.zero?
15
+ for piece in sentence_slip_list do
16
+ if /:git =>/ =~ piece
17
+ @git = $~.post_match.strip
18
+ elsif /:path =>/ =~ piece
19
+ @path = $~.post_match.strip
20
+ elsif /:configurations =>/ =~ piece
21
+ @configurations = $~.post_match.strip
22
+ elsif /:branch =>/ =~ piece
23
+ @branch = $~.post_match.strip
24
+ elsif /:tag =>/ =~ piece
25
+ @tag = $~.post_match.strip
26
+ elsif /pod /=~ piece
27
+ @name = $~.post_match.delete("'\n ")
28
+ end
29
+ # p %Q{model name:#{@name},git:#{@git},path:#{@path},config:#{@configurations},branch:#{@branch},tag:#{@tag},comment:#{@comment}}
30
+ end
31
+ end
32
+ end
33
+ end
@@ -12,7 +12,7 @@ module BigKeeper
12
12
  raise %Q('master' has unpushed commits, you should fix it)
13
13
  else
14
14
  GitOperator.new.git_checkout(path, 'master')
15
- GitOperator.new.pull(path, 'master')
15
+ GitOperator.new.pull(path)
16
16
  end
17
17
  else
18
18
  GitOperator.new.git_checkout(path, 'master')
@@ -25,7 +25,7 @@ module BigKeeper
25
25
  raise %Q('develop' has unpushed commits, you should fix it)
26
26
  else
27
27
  GitOperator.new.git_checkout(path, 'develop')
28
- GitOperator.new.pull(path, 'develop')
28
+ GitOperator.new.pull(path)
29
29
  end
30
30
  else
31
31
  GitOperator.new.git_checkout(path, 'develop')
@@ -40,7 +40,7 @@ module BigKeeper
40
40
  branch_name = "#{GitflowType.name(type)}/#{name}"
41
41
  if GitOperator.new.has_branch(path, branch_name)
42
42
  GitOperator.new.git_checkout(path, branch_name)
43
- GitOperator.new.pull(path, branch_name)
43
+ GitOperator.new.pull(path)
44
44
  else
45
45
  GitflowOperator.new.start(path, name, type)
46
46
  GitOperator.new.push(path, branch_name)
@@ -19,7 +19,7 @@ module BigKeeper
19
19
  GitOperator.new.git_checkout(module_full_path, branch_name)
20
20
  end
21
21
  p "Pull branch #{branch_name} for module #{module_name}..."
22
- GitOperator.new.pull(module_full_path, branch_name)
22
+ GitOperator.new.pull(module_full_path)
23
23
  end
24
24
  end
25
25
 
@@ -34,7 +34,7 @@ module BigKeeper
34
34
  GitOperator.new.git_checkout(module_full_path, branch_name)
35
35
  else
36
36
  GitOperator.new.git_checkout(module_full_path, branch_name)
37
- GitOperator.new.pull(module_full_path, branch_name)
37
+ GitOperator.new.pull(module_full_path)
38
38
  end
39
39
  end
40
40
 
@@ -39,7 +39,11 @@ module BigKeeper
39
39
 
40
40
  def git_checkout(path, branch_name)
41
41
  Dir.chdir(path) do
42
- `git checkout #{branch_name}`
42
+ IO.popen("git checkout #{branch_name}") do |io|
43
+ io.each do |line|
44
+ raise "Checkout #{branch_name} failed." if line.include? 'error'
45
+ end
46
+ end
43
47
  end
44
48
  end
45
49
 
@@ -70,13 +74,13 @@ module BigKeeper
70
74
 
71
75
  def push(path, branch_name)
72
76
  Dir.chdir(path) do
73
- p `git push origin #{branch_name}`
77
+ p `git push -u origin #{branch_name}`
74
78
  end
75
79
  end
76
80
 
77
- def pull(path, branch_name)
81
+ def pull(path)
78
82
  Dir.chdir(path) do
79
- p `git pull origin #{branch_name}`
83
+ p `git pull`
80
84
  end
81
85
  end
82
86
 
@@ -10,6 +10,16 @@ module BigKeeper
10
10
  end
11
11
  end
12
12
 
13
+ def verify_git_flow_command
14
+ has_git_flow_command = false
15
+ IO.popen('command -v git-flow') do |io|
16
+ io.each do |line|
17
+ has_git_flow_command = true
18
+ end
19
+ end
20
+ has_git_flow_command
21
+ end
22
+
13
23
  def verify_git_flow(path)
14
24
  has_git_flow = false
15
25
  Dir.chdir(path) do
@@ -0,0 +1,40 @@
1
+ require 'colorize'
2
+
3
+ module BigKeeper
4
+ DEFAULT_LOG = 1
5
+ HIGHLIGHT_LOG = 2
6
+ ERROR_LOG = 3
7
+ WARNING_LOG = 4
8
+
9
+ class BigKeeperLog
10
+
11
+ def self.log_with_type(sentence,type)
12
+ case type
13
+ when DEFAULT_LOG then puts sentence.to_s.colorize(:default)
14
+ when HIGHLIGHT_LOG then puts sentence.to_s.colorize(:green)
15
+ when ERROR_LOG then raise sentence.to_s.colorize(:red)
16
+ when WARNING_LOG then puts sentence.to_s.colorize(:yellow)
17
+ end
18
+ end
19
+
20
+ def self.default(sentence)
21
+ puts sentence.to_s.colorize(:default)
22
+ end
23
+
24
+ def self.highlight(sentence)
25
+ puts sentence.to_s.colorize(:green)
26
+ end
27
+
28
+ def self.error(sentence)
29
+ raise sentence.to_s.colorize(:red)
30
+ end
31
+
32
+ def self.warning(sentence)
33
+ puts sentence.to_s.colorize(:yellow)
34
+ end
35
+
36
+ def self.separator
37
+ puts "- - - - - - - - - - - - - - - - - - - - - - - - - - -".colorize(:light_blue)
38
+ end
39
+ end
40
+ end
@@ -1,68 +1,57 @@
1
- require '../util/param_parser'
1
+ require 'big_keeper/util/bigkeeper_parser'
2
+ require 'big_keeper/model/podfile_model'
3
+ require 'big_keeper/util/log_util'
2
4
 
3
- params = BigKeeper::ParamParser.new.detect_podfile_unlock_items
4
- main_path = File.expand_path(params[:main_path])
5
-
6
- $modular_name_list = ["ELMKnightCollegeModule","LPDFoundationKit",
7
- "LPDIntelligentDispatchModular","LPDUserRelevanceModular",
8
- "LPDFeedbackModular","LPDQualityControlKit","LPDWalletModular",
9
- "LPDRiderClassificationModular","LPDTransferOrderModular",
10
- "LPDActivityModular","LPDPOIAddressService"]
5
+ module BigKeeper
11
6
 
12
7
  class PodfileDetector
13
8
 
9
+ attr_accessor :modular_list, :main_path
14
10
  $unlock_pod_list = []
15
11
  $modify_pod_list = {}
16
- def get_unlock_pod_list(main_path)
17
- podfile_lines = File.readlines("#{main_path}/Podfile")
18
- p 'Analyzing Podfile...' unless podfile_lines.size.zero?
12
+
13
+ def initialize(main_path,modular_list)
14
+ @modular_list = modular_list
15
+ @main_path = main_path
16
+ end
17
+
18
+ def get_unlock_pod_list
19
+ podfile_lines = File.readlines("#{@main_path}/Podfile")
20
+ BigKeeperLog.highlight("Analyzing Podfile...") unless podfile_lines.size.zero?
19
21
  podfile_lines.collect do |sentence|
20
- deal_podfile_line(sentence) unless sentence =~(/\'\d+.\d+.\d+'/)
22
+ deal_podfile_line(sentence) unless sentence =~(/(\d+.){1,2}\d+/)
21
23
  end
22
- p $unlock_pod_list
23
- $modify_pod_list = deal_lock_file(main_path,$unlock_pod_list)
24
- p $modify_pod_list
24
+ return $unlock_pod_list
25
+ # p $unlock_pod_list
25
26
  end
26
27
 
27
28
  def deal_podfile_line(sentence)
28
29
  if sentence.include?('pod ')
29
30
  pod_model = Podfile_Modle.new(sentence)
30
- # p pod_model
31
31
  if !pod_model.name.empty? && pod_model.configurations != '[\'Debug\']' && pod_model.path == nil && pod_model.tag == nil
32
- $unlock_pod_list << pod_model.name unless $modular_name_list.include?(pod_model.name)
32
+ $unlock_pod_list << pod_model.name unless @modular_list.include?(pod_model.name)
33
33
  end
34
34
  return pod_model
35
35
  end
36
36
  end
37
37
 
38
- def get_pod_name(sentence)
39
- # match_data = /\'\w*\'/.match(sentence)
40
- # pod_name = match_data.to_a[0].delete('\'')
41
- pod_model = deal_podfile_line(sentence)
42
- pod_name = pod_model.name if pod_model != nil && pod_model.configurations.nil
43
- # puts pod_name
44
- $unlock_pod_list << pod_name unless modular_name_list.include pod_name
45
- end
46
38
 
47
39
  def deal_lock_file(main_path,deal_list)
48
40
  $result = {}
49
41
  podfile_lock_lines = File.readlines("#{main_path}/Podfile.lock")
50
- p 'Analyzing Podfile.lock...' unless podfile_lock_lines.size.zero?
42
+ BigKeeperLog.highlight("Analyzing Podfile.lock...") unless podfile_lock_lines.size.zero?
51
43
  podfile_lock_lines.select do |sentence|
52
-
53
44
  if sentence.include?('DEPENDENCIES') #指定范围解析 Dependencies 之前
54
45
  break
55
46
  end
56
47
 
57
48
  temp_sentence = sentence.strip
58
49
  pod_name = get_lock_podname(temp_sentence)
59
- # p pod_name
60
50
  if deal_list.include?(pod_name)
61
51
  current_version = $result[pod_name]
62
52
  temp_version = get_lock_version(temp_sentence)
63
53
  if temp_version != nil
64
54
  if current_version != nil
65
- # p "cur_version #{current_version} temp_version #{temp_version}"
66
55
  $result[pod_name] = chose_version(current_version,temp_version)
67
56
  else
68
57
  $result[pod_name] = temp_version
@@ -70,24 +59,37 @@ class PodfileDetector
70
59
  end
71
60
  end
72
61
  end
73
- return $result
62
+ return $result
63
+ end
64
+
65
+ def self.get_pod_model(sentence)
66
+ if sentence.include?('pod ')
67
+ pod_model = Podfile_Modle.new(sentence)
68
+ return pod_model
69
+ end
74
70
  end
75
71
 
72
+ def get_pod_name(sentence)
73
+ pod_model = deal_podfile_line(sentence)
74
+ pod_name = pod_model.name if pod_model != nil && pod_model.configurations.nil
75
+ @unlock_pod_list << pod_name unless @modular_list.include pod_name
76
+ end
77
+
78
+
79
+
76
80
  def get_lock_podname(sentence) #获得pod名称
77
- # p sentence.delete('- :~>=')
78
- match_result = /(\d+.\d+.\d+)|(\d+.\d+)/.match(sentence.delete('- :~>='))
81
+ match_result = /(\d+.){1,2}\d+/.match(sentence.delete('- :~>='))
79
82
  pod_name = match_result.pre_match unless match_result == nil
80
- return pod_name.delete('(') unless pod_name == nil
83
+ return pod_name.delete('()') unless pod_name == nil
81
84
  end
82
85
 
83
86
  def get_lock_version(sentence)#获得pod版本号
84
- sentence.scan(/\d+.\d+.\d+/) do |version|
85
- return version
86
- end
87
- return nil
87
+ match_result = /(\d+.){1,2}\d+/.match(sentence)
88
+ return match_result[0] unless match_result == nil
88
89
  end
89
90
 
90
91
  def chose_version(cur_version,temp_version)
92
+ # p "cur:#{cur_version},temp:#{temp_version}"
91
93
  cur_list = cur_version.split('.')
92
94
  temp_list = temp_version.split('.')
93
95
  temp_list << 0.to_s if temp_list.size == 2
@@ -102,39 +104,5 @@ class PodfileDetector
102
104
  end
103
105
  return temp_version
104
106
  end
105
-
106
107
  end
107
-
108
- class Podfile_Modle
109
- attr_accessor :name,:git,:path,:configurations,:branch,:tag,:comment
110
- def initialize(sentence)
111
- if sentence.include?('#')
112
- list = sentence.split('#')
113
- @comment = list[1]
114
- sentence = list[0]
115
- end
116
-
117
- sentence_slip_list = sentence.split(',')
118
- return if sentence_slip_list.size.zero?
119
- for piece in sentence_slip_list do
120
- if /:git =>/ =~ piece
121
- @git = $~.post_match.strip
122
- elsif /:path =>/ =~ piece
123
- @path = $~.post_match.strip
124
- elsif /:configurations =>/ =~ piece
125
- @configurations = $~.post_match.strip
126
- elsif /:branch =>/ =~ piece
127
- @branch = $~.post_match.strip
128
- elsif /:tag =>/ =~ piece
129
- @tag = $~.post_match.strip
130
- elsif /pod /=~ piece
131
- @name = $~.post_match.delete("'\n ")
132
- end
133
- # p %Q{model name:#{@name},git:#{@git},path:#{@path},config:#{@configurations},branch:#{@branch},tag:#{@tag},comment:#{@comment}}
134
- end
135
- end
136
108
  end
137
-
138
- # p params
139
- # p main_path
140
- PodfileDetector.new.get_unlock_pod_list(main_path)
@@ -1,6 +1,7 @@
1
1
  require 'tempfile'
2
2
  require 'fileutils'
3
3
  require 'big_keeper/model/podfile_type'
4
+ require 'big_keeper/util/podfile_detector'
4
5
 
5
6
  module BigKeeper
6
7
  # Operator for podfile
@@ -74,6 +75,15 @@ module BigKeeper
74
75
  module_config
75
76
  end
76
77
 
78
+ def generate_pod_config(pod_name, version,comment)
79
+ module_config = ''
80
+ if comment != nil
81
+ module_config = " pod '#{pod_name}' , '#{version}' # #{comment}"
82
+ else
83
+ module_config = " pod '#{pod_name}' , '#{version}'"
84
+ end
85
+ end
86
+
77
87
  def replace_all_module_release(podfile, module_names, version, source)
78
88
 
79
89
  module_names.each do |module_name|
@@ -106,6 +116,27 @@ module BigKeeper
106
116
  # end
107
117
  end
108
118
 
109
- private :generate_module_config
119
+ def find_and_lock(podfile,dictionary)
120
+ temp_file = Tempfile.new('.Podfile.tmp')
121
+ begin
122
+ File.open(podfile, 'r') do |file|
123
+ file.each_line do |line|
124
+ pod_model = PodfileDetector.get_pod_model(line)
125
+ if pod_model != nil && pod_model.name != nil && dictionary[pod_model.name] != nil
126
+ # p "#{pod_name},#{dictionary[pod_name]}"
127
+ temp_file.puts generate_pod_config(pod_model.name,dictionary[pod_model.name],pod_model.comment)
128
+ else
129
+ temp_file.puts line
130
+ end
131
+ end
132
+ end
133
+ temp_file.close
134
+ FileUtils.mv(temp_file.path, podfile)
135
+ ensure
136
+ temp_file.close
137
+ temp_file.unlink
138
+ end
139
+ end
140
+ private :generate_module_config,:generate_pod_config
110
141
  end
111
142
  end
@@ -1,3 +1,3 @@
1
1
  module BigKeeper
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: big_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmoaay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +164,20 @@ dependencies:
150
164
  - - ">="
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: colorize
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  - !ruby/object:Gem::Dependency
154
182
  name: rubocop
155
183
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +215,7 @@ files:
187
215
  - docs/zh-CN/BIGKEEPER_FILE.md
188
216
  - docs/zh-CN/FEATURE.md
189
217
  - docs/zh-CN/README.md
218
+ - docs/zh-CN/RELEASE.md
190
219
  - lib/big_keeper.rb
191
220
  - lib/big_keeper/command/feature_finish.rb
192
221
  - lib/big_keeper/command/feature_pull.rb
@@ -201,6 +230,7 @@ files:
201
230
  - lib/big_keeper/command/start_module_release.sh
202
231
  - lib/big_keeper/model/gitflow_type.rb
203
232
  - lib/big_keeper/model/operate_type.rb
233
+ - lib/big_keeper/model/podfile_model.rb
204
234
  - lib/big_keeper/model/podfile_type.rb
205
235
  - lib/big_keeper/service/git_service.rb
206
236
  - lib/big_keeper/service/module_service.rb
@@ -209,6 +239,7 @@ files:
209
239
  - lib/big_keeper/util/git_operator.rb
210
240
  - lib/big_keeper/util/gitflow_operator.rb
211
241
  - lib/big_keeper/util/info_plist_operator.rb
242
+ - lib/big_keeper/util/log_util.rb
212
243
  - lib/big_keeper/util/podfile_detector.rb
213
244
  - lib/big_keeper/util/podfile_operator.rb
214
245
  - lib/big_keeper/version.rb