release-gem 0.1.3 → 0.1.5

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
  SHA256:
3
- metadata.gz: 0ae1c83005e05a5eeb8c5342aa98ae270205dbeb02c3090f585ba5eb68e26f09
4
- data.tar.gz: 6a50159b2e2acba162ea32cf9e5294805f4358ae57b3717d14ac2b825f1e66bc
3
+ metadata.gz: 4a3f43d3c0b887a2346a0ee9b126a6f7a2edd0715f77b910762caeec3056bd76
4
+ data.tar.gz: 937d525b33b1695c16ddd1ff3edd77a554ea8be086832cc1052d27e468d4b7a0
5
5
  SHA512:
6
- metadata.gz: 96081961c0db069c1affa0f83ba4cc7ff8db5d0ca5f7ecfa50fff124bbc93244da78ba1ec0d386059fef313021896e62c25595335bdd9713bc024258a4bc1a4c
7
- data.tar.gz: e779b2b0e95fc57744a6164e157ecaf7121dbc61cee878fc735808a859fb8d103a73f5d2bfef3c4eb8630e1a36365ff17a39a5361fb87f272f95a36aab1b5fe6
6
+ metadata.gz: ca0da466583bf5191772d82a08507acaca1db045a6e93c6dc9573ed5a445f58a31570328f73a0f1840fcc328bfadf92fc40b03696a46086628ebfe1a99d828ea
7
+ data.tar.gz: b2a5f5d9ec4d3bda1fb86bed8b001b85ca7b1e12fefe585dba8297dcda51cd76f7b9acccddd63192c6119bb0237ba671dd0cb7662847c9d7cf9960f0e0b74b91
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- release-gem (0.1.3)
4
+ release-gem (0.1.5)
5
5
  colorize
6
6
  git_cli
7
7
  gvcs
@@ -15,7 +15,7 @@ GEM
15
15
  specs:
16
16
  colorize (0.8.1)
17
17
  diff-lcs (1.5.0)
18
- git_cli (0.11.2)
18
+ git_cli (0.11.3)
19
19
  gvcs
20
20
  ptools (~> 1.4.0)
21
21
  teLogger
@@ -39,7 +39,7 @@ GEM
39
39
  rspec-support (~> 3.12.0)
40
40
  rspec-support (3.12.0)
41
41
  teLogger (0.2.2)
42
- toolrack (0.21.0)
42
+ toolrack (0.22.0)
43
43
  tty-color (0.6.0)
44
44
  tty-command (0.10.1)
45
45
  pastel (~> 0.8)
@@ -1,7 +1,7 @@
1
1
 
2
2
  #require 'rake'
3
3
  require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
4
+ #require "rspec/core/rake_task"
5
5
  require 'yaml'
6
6
  require_relative 'gemdep'
7
7
 
@@ -30,32 +30,48 @@ module Release
30
30
  end
31
31
 
32
32
  def release_dependencies(*args, &block)
33
- if block
34
33
 
35
- block.call(:action_start, :relase_dependencies)
36
- puts "gem release dependencies"
37
- puts "Project has development gem? : #{gemdepInst.has_development_gem?}"
38
- keys = gemdepInst.development_gem.keys
39
- loop do
40
- begin
41
- conf = block.call(:define_gem_prod_config, { gems: keys })
42
- if conf.is_a?(Hash)
43
- conf.each do |k,v|
44
- gemdepInst.configure_gem(k,v)
34
+ if gemdepInst.has_development_gem?
35
+
36
+ if block
37
+
38
+ block.call(:action_start, :relase_dependencies)
39
+
40
+ gemdepInst.development_gem.each do |k,v|
41
+ gemdepInst.infect_gem(v, k, &block)
42
+ block.call(:block_until_dev_gem_done, { name: k, path: v })
43
+ end
44
+
45
+
46
+ keys = gemdepInst.development_gem.keys
47
+ loop do
48
+ begin
49
+ conf = block.call(:define_gem_prod_config, { gems: keys })
50
+ if conf.is_a?(Hash)
51
+ conf.each do |k,v|
52
+ gemdepInst.configure_gem(k,v)
53
+ end
54
+ break if gemdepInst.all_dev_gems_has_config?
55
+ keys = gemdepInst.not_configured_gem
56
+ else
57
+ block.call(:invalid_gem_prod_config, "Expected return from :define_gem_prod_config is a hash of \"gem name\" => { type: [:runtime | :dev], version: \">= 1.2.0\" }. Note version can be empty")
45
58
  end
46
- break if gemdepInst.all_dev_gems_has_config?
47
- keys = gemdepInst.not_configured_gem
48
- else
49
- block.call(:invalid_gem_prod_config, "Expected return from :define_gem_prod_config is a hash of \"gem name\" => { type: [:runtime | :dev], version: \">= 1.2.0\" }. Note version can be empty")
59
+ rescue GemDepError => ex
60
+ block.call(:invlid_gem_prod_config, ex.message)
50
61
  end
51
- rescue GemDepError => ex
52
- block.call(:invlid_gem_prod_config, ex.message)
53
62
  end
63
+
64
+ gemdepInst.transfer_gem
65
+
66
+ block.call(:development_gem_temporary_promoted)
54
67
  end
55
68
 
56
- gemdepInst.transfer_gem
57
- end
69
+ else
70
+ if block
71
+ block.call(:no_development_gems_found)
72
+ end
58
73
 
74
+ end
59
75
 
60
76
  end
61
77
 
@@ -12,6 +12,8 @@ module Release
12
12
  opts[:ui] = TTY::Prompt.new
13
13
  @inst = Action::GemAction.new(root, opts)
14
14
  @pmt = opts[:tty] || opts[:ui]
15
+ @msgColor = opts[:msgColor] || :yellow
16
+ @discardColor = opts[:discardColor] || false
15
17
  end
16
18
 
17
19
  def exec(&block)
@@ -22,7 +24,58 @@ module Release
22
24
  @inst.release_dependencies do |ops, *args|
23
25
  case ops
24
26
  when :action_start
25
- @pmt.say "\n Release dependencies starting...\n".yellow
27
+ @pmt.say pmsg("\n Release dependencies starting...\n")
28
+
29
+ ## from release_infector
30
+ when :multiple_gemspec
31
+ v = args.first
32
+ @pmt.select(pmsg("\n There are multiple gemspecs found. Please select one to proceed : ")) do |m|
33
+ v.each do |vv|
34
+ m.choice vv, vv
35
+ end
36
+ end
37
+
38
+ when :adding_to_gemspec
39
+ v = args.first
40
+ @pmt.say pmsg("\n Adding release-gem to gemspec '#{v[:gemspec]}'")
41
+
42
+ when :gemspec_updated
43
+ v = args.first
44
+ @pmt.say pmsg("\n Gemspec file of GEM '#{v[:name]}' updated with release-gem gem")
45
+
46
+ when :adding_to_rackfile
47
+ v = args.first
48
+ @pmt.say pmsg("\n Adding require to Rakefile at #{v[:rakefile]}")
49
+
50
+ when :creating_new_rakefile
51
+ v = args.first
52
+ @pmt.say pmsg("\n Creating new Rakefile at #{v[:rakefile]}")
53
+
54
+ when :rakefile_updated
55
+ v = args.first
56
+ @pmt.say pmsg("\n Rakefile '#{v[:rakefile]}' updated!")
57
+
58
+ when :select_terminal
59
+ v = args.first
60
+ @pmt.select(pmsg("\n Please select a terminal for development GEM '#{v[:name]}' release : ")) do |m|
61
+ v[:options].each do |t|
62
+ m.choice t, t
63
+ end
64
+ end
65
+
66
+ when :new_terminal_launching
67
+ v = args.first
68
+ @pmt.say pmsg("\n New terminal lanching for GEM '#{v[:name]}' using terminal '#{v[:terminal]}'")
69
+
70
+ when :new_terminal_launched
71
+ v = args.first
72
+ @pmt.say pmsg("\n New terminal launched for GEM '#{v[:name]}' using terminal '#{v[:terminal]}'")
73
+
74
+ when :block_until_dev_gem_done
75
+ v = args.first
76
+ @pmt.yes? pmsg("\n Development GEM '#{v[:name]}' has separate windows for release. Is it done? ")
77
+
78
+ ### End release_infector
26
79
 
27
80
  when :define_gem_prod_config
28
81
 
@@ -31,7 +84,7 @@ module Release
31
84
 
32
85
  loop do
33
86
 
34
- sel = @pmt.select("\n The following development gems requires configuration. Please select one to configure") do |m|
87
+ sel = @pmt.select(pmsg("\n The following development gems requires configuration. Please select one to configure ")) do |m|
35
88
  selections.each do |g|
36
89
  m.choice g, g
37
90
  end
@@ -39,17 +92,17 @@ module Release
39
92
 
40
93
  config[sel] = {} if config[sel].nil?
41
94
 
42
- type = @pmt.select("\n The gem in production will be runtime or development ? ") do |m|
95
+ type = @pmt.select(pmsg("\n The gem in production will be runtime or development ? ")) do |m|
43
96
  m.choice "Runtime", :runtime
44
97
  m.choice "Development only", :dev
45
98
  end
46
99
 
47
100
  config[sel][:type] = type
48
101
 
49
- ver = @pmt.ask("\n Is there specific version pattern (including the ~>/>/>=/= of gemspec) for the gem in production? (Not mandatory) : ")
102
+ ver = @pmt.ask(pmsg("\n Is there specific version pattern (including the ~>/>/>=/= of gemspec) for the gem in production? (Not mandatory) : "))
50
103
  config[sel][:version] = ver if not_empty?(ver)
51
104
 
52
- @pmt.puts " ** Done configure for gem #{sel}"
105
+ @pmt.puts pmsg(" ** Done configure for gem #{sel}")
53
106
  selections.delete_if { |v| v == sel }
54
107
  break if selections.length == 0
55
108
 
@@ -57,6 +110,12 @@ module Release
57
110
 
58
111
  config
59
112
 
113
+ when :development_gem_temporary_promoted
114
+ @pmt.puts pmsg("\n Development gem(s) temporary promoted to production status")
115
+
116
+ when :no_development_gems_found
117
+ @pmt.puts pmsg("\n No development gem(s) in used found")
118
+
60
119
  end
61
120
  end
62
121
 
@@ -67,7 +126,7 @@ module Release
67
126
  @inst.build do |ops, *args|
68
127
  case ops
69
128
  when :action_start
70
- @pmt.say " Gem building starting...\n".yellow
129
+ @pmt.say pmsg(" Gem building starting...\n")
71
130
  when :select_version
72
131
  preset = false
73
132
  if block
@@ -84,7 +143,7 @@ module Release
84
143
  if preset
85
144
 
86
145
  opts = args.first
87
- res = @pmt.select("\n Please select new gem version : \n".yellow) do |m|
146
+ res = @pmt.select(pmsg("\n Please select new gem version : \n")) do |m|
88
147
  opts[:proposed_next].reverse.each do |v|
89
148
  m.choice v,v
90
149
  end
@@ -97,8 +156,8 @@ module Release
97
156
 
98
157
  if res == :custom
99
158
  loop do
100
- res = @pmt.ask("\n Please provide custom version number for the release : ".yellow,required: true)
101
- confirmed = @pmt.yes?("\n Use version '#{res}'? No to try again")
159
+ res = @pmt.ask(pmsg("\n Please provide custom version number for the release : "),required: true)
160
+ confirmed = @pmt.yes?(pmsg("\n Use version '#{res}'? No to try again"))
102
161
  break if confirmed
103
162
  end
104
163
  end
@@ -122,7 +181,7 @@ module Release
122
181
 
123
182
  if preset
124
183
 
125
- res = @pmt.select("\n There are multiple version file found. Please select which one to update : ".yellow) do |m|
184
+ res = @pmt.select(pmsg("\n There are multiple version file found. Please select which one to update : ")) do |m|
126
185
  opts = args.first
127
186
  opts.each do |f|
128
187
  m.choice f,f
@@ -138,7 +197,7 @@ module Release
138
197
  @selVersion = args.first
139
198
 
140
199
  when :gem_build_successfully
141
- @pmt.puts "\n Gem version '#{args.first}' built successfully".green
200
+ @pmt.puts pmsg("\n Gem version '#{args.first}' built successfully", :green)
142
201
  @inst.register(:selected_version, args.first)
143
202
  [true, args.first]
144
203
  end
@@ -152,7 +211,7 @@ module Release
152
211
  case ops
153
212
  when :multiple_rubygems_account
154
213
  creds = args.first
155
- res = @pmt.select("\n Multiple rubygems account detected. Please select one : ".yellow) do |m|
214
+ res = @pmt.select(pmsg("\n Multiple rubygems account detected. Please select one : ")) do |m|
156
215
  creds.each do |k,v|
157
216
  m.choice k,k
158
217
  end
@@ -167,9 +226,9 @@ module Release
167
226
  st = pargs.first
168
227
  res = pargs[1]
169
228
  if st
170
- @pmt.puts "\n Gem push successful.".green
229
+ @pmt.puts pmsg("\n Gem push successful.", :green)
171
230
  else
172
- @pmt.puts "\n Gem push failed. Error was :\n #{res}".red
231
+ @pmt.puts pmsg("\n Gem push failed. Error was :\n #{res}", :red)
173
232
  end
174
233
  end
175
234
  end
@@ -178,7 +237,7 @@ module Release
178
237
 
179
238
  def install(*args, &block)
180
239
 
181
- sysInst = @pmt.yes?("\n Install release into system? ".yellow)
240
+ sysInst = @pmt.yes?(pmsg("\n Install release into system? "))
182
241
  if sysInst
183
242
  @inst.install(*args)
184
243
  end
@@ -189,6 +248,22 @@ module Release
189
248
  @inst.send(mtd,*args, &block)
190
249
  end
191
250
 
251
+ def pmsg(msg, color = nil)
252
+ if not msg.nil?
253
+ if @discardColor == true
254
+ msg
255
+ else
256
+ if not_empty?(color)
257
+ msg.send(color)
258
+ elsif not_empty?(@msgColor)
259
+ msg.send(@msgColor)
260
+ else
261
+ msg
262
+ end
263
+ end
264
+ end
265
+ end
266
+
192
267
  end
193
268
  end
194
269
  end
@@ -0,0 +1,178 @@
1
+
2
+ require 'bundler'
3
+
4
+ module Release
5
+ module Gem
6
+
7
+ class GemDepError < StandardError; end
8
+
9
+ class GemDep
10
+ include TR::CondUtils
11
+
12
+ def initialize(root, opts = { })
13
+ @root = root
14
+ @discardColor = opts[:discardColor] || false
15
+ @devGems = {}
16
+ @gemConfig = {}
17
+ @fileHistory = {}
18
+ load_gemfile_deps
19
+ load_gemspec_deps
20
+ end
21
+
22
+ def load_gemfile_deps
23
+ gdef = Bundler::Definition.build(gemfile_file, nil, {})
24
+ gdef.dependencies.each do |d|
25
+ if not d.source.nil? and d.source.path.to_s != "."
26
+ @devGems[d.name] = d.source.path.to_s
27
+ end
28
+ end
29
+ end
30
+
31
+ def load_gemspec_deps
32
+ gs = ::Gem::Specification.load(gemspec_file)
33
+ gs.dependencies.each do |d|
34
+ if not d.source.nil? and d.source.path.to_s != "."
35
+ @devGems[d.name] = d.source.path.to_s
36
+ end
37
+ end
38
+ end
39
+
40
+ def has_development_gem?
41
+ not_empty?(@devGems)
42
+ end
43
+
44
+ def development_gem
45
+ @devGems
46
+ end
47
+
48
+ def configure_gem(name, opts = { type: :runtime, version: "" })
49
+ raise GemDepError, "Given option to configure the gem is empty" if is_empty?(opts)
50
+ raise GemDepError, "Given option is not a hash. Hash wity keys :type and/or :version (can be empty) is expected" if not opts.is_a?(Hash)
51
+ raise GemDepError, "Production gem type not given. Please provide the gem type via key :type (valid value is either :runtime or :dev)" if is_empty?(opts[:type])
52
+
53
+ if @devGems.keys.include?(name.to_s)
54
+ @gemConfig[name.to_s] = opts
55
+ else
56
+ raise GemDepError, "Name '#{name}' is not in the list of development gems. Valid value including : #{@devGems.keys.join(", ")}"
57
+ end
58
+ end
59
+
60
+ def transfer_gem
61
+ if not all_dev_gems_has_config?
62
+ raise GemDepError, "Not all gem has configuration. Gem required configuration includes: #{not_configured_gem.join(", ")}"
63
+ end
64
+
65
+ remove_dev_gem_from_gemfile
66
+ add_gem_to_gemspec(@gemConfig)
67
+
68
+ end
69
+
70
+ def all_dev_gems_has_config?
71
+ not_configured_gem.length == 0
72
+ end
73
+
74
+ def not_configured_gem
75
+ @devGems.keys.difference(@gemConfig.keys)
76
+ end
77
+
78
+ def restore_dev_gem
79
+ @fileHistory.each do |k,v|
80
+ FileUtils.mv(k,"#{k}.prod")
81
+ FileUtils.cp(v,k)
82
+ end
83
+ @fileHistory.clear
84
+ end
85
+
86
+ def infect_gem(gem_root,name, &block)
87
+ ri = ReleaseInfector.new(gem_root, name)
88
+ ri.infect(&block)
89
+ ri.trigger_release_gem(&block)
90
+ end
91
+
92
+ private
93
+ def remove_dev_gem_from_gemfile
94
+ if has_development_gem?
95
+ orin = gemfile_file
96
+ dest = "#{gemfile_file}.dev"
97
+ FileUtils.cp(orin, dest)
98
+ @fileHistory[orin] = dest
99
+
100
+ tmpOut = "#{orin}.tmp"
101
+
102
+ File.open(tmpOut, "w") do |f|
103
+ cont = File.read(dest)
104
+ cont.each_line do |l|
105
+ next if l =~ /^gem ('|")(#{development_gem.keys.join("|")})('|")/
106
+ f.puts l
107
+ end
108
+ end
109
+
110
+ FileUtils.rm(orin)
111
+ FileUtils.mv(tmpOut, orin)
112
+
113
+ # to make sure has_development_gem? return false in subsequent run
114
+ load_gemfile_deps
115
+
116
+ end
117
+ end
118
+
119
+ def add_gem_to_gemspec(spec = {})
120
+
121
+ if has_development_gem?
122
+
123
+ orin = gemspec_file
124
+ dest = "#{gemspec_file}.dev"
125
+ FileUtils.cp(orin, dest)
126
+ @fileHistory[orin] = dest
127
+
128
+ tmpOut = "#{orin}.tmp"
129
+
130
+ cont = File.read(gemspec_file)
131
+ lastEnd = cont.rindex("end")
132
+
133
+ File.open(tmpOut, "w") do |f|
134
+ f.write cont[0...lastEnd]
135
+ spec.each do |k,v|
136
+ case v[:type]
137
+ when :runtime
138
+ f.puts " spec.add_dependency \"#{k}\"#{is_empty?(v[:version]) ? "" : ", \"#{v[:version]}\""}"
139
+ when :dev
140
+ f.puts " spec.add_development_dependency \"#{k}\"#{is_empty?(v[:version]) ? "" : ", \"#{v[:version]}\""}"
141
+ end
142
+ end
143
+
144
+ f.puts "end"
145
+ end
146
+
147
+ FileUtils.rm(orin)
148
+ FileUtils.mv(tmpOut, orin)
149
+
150
+ # to make sure has_development_gem? return false in subsequent run
151
+ load_gemspec_deps
152
+
153
+ end
154
+
155
+
156
+ end
157
+
158
+ def gemspec_file
159
+ if @_gemspec.nil?
160
+ @_gemspec = Dir.glob(File.join(@root,"*.gemspec"))
161
+ raise GemDepError, "Cannot find gemspec at '#{@root}'" if is_empty?(@_gemspec)
162
+ @_gemspec = @_gemspec.first
163
+ end
164
+ @_gemspec
165
+ end
166
+
167
+ def gemfile_file
168
+ if @_gemfile_file.nil?
169
+ @_gemfile_file = Dir.glob(File.join(@root,"Gemfile"))
170
+ raise GemDepError, "Cannot find Gemfile at '#{@root}'" if is_empty?(@_gemfile_file)
171
+ @_gemfile_file = @_gemfile_file.first
172
+ end
173
+ @_gemfile_file
174
+ end
175
+
176
+ end
177
+ end
178
+ end
@@ -12,6 +12,8 @@ module Release
12
12
  opts[:ui] = TTY::Prompt.new
13
13
  @inst = Action::VcsAction.new(root,opts)
14
14
  @prmt = TTY::Prompt.new
15
+ @color = opts[:msgColor] || :yellow
16
+ @discardColor = opts[:discardColor] || false
15
17
  end
16
18
 
17
19
  def exec(&block)
@@ -38,7 +40,7 @@ module Release
38
40
  case ops
39
41
  when :select_files_to_commit
40
42
  mfiles = args.first
41
- @prmt.puts "\n Files already added to staging : ".yellow
43
+ @prmt.puts pmsg("\n Files already added to staging : ")
42
44
  mfiles[:staged].each do |k,v|
43
45
  v.each do |vv|
44
46
  @prmt.puts " * #{vv}"
@@ -47,7 +49,7 @@ module Release
47
49
 
48
50
  @prmt.puts ""
49
51
 
50
- sel = @prmt.multi_select "\n Following are files that could be added to version control : ".yellow do |m|
52
+ sel = @prmt.multi_select pmsg("\n Following are files that could be added to version control : ") do |m|
51
53
 
52
54
  [:modified, :new, :deleted].each do |cat|
53
55
  mfiles[cat].each do |k,v|
@@ -74,9 +76,9 @@ module Release
74
76
  if not_empty?(s)
75
77
  st, cres = add_to_staging(*s) if not_empty?(s)
76
78
  if st
77
- @prmt.puts "\n Files added successfully".green
79
+ @prmt.puts pmsg("\n Files added successfully", :green)
78
80
  else
79
- @prmt.puts "\n Files failed to be added. Message was : #{cres}".red
81
+ @prmt.puts pmsg("\n Files failed to be added. Message was : #{cres}", :red)
80
82
  end
81
83
  end
82
84
 
@@ -87,8 +89,8 @@ module Release
87
89
  when :commit_message
88
90
  msg = ""
89
91
  loop do
90
- msg = @prmt.ask("\n Commit message : ".yellow, required: true)
91
- confirm = @prmt.yes?(" Commit message : #{msg}\n Proceed? No to provide a new commit message ".yellow)
92
+ msg = @prmt.ask(pmsg("\n Commit message : "), required: true)
93
+ confirm = @prmt.yes?(pmsg(" Commit message : #{msg}\n Proceed? No to provide a new commit message "))
92
94
  if confirm
93
95
  break
94
96
  end
@@ -99,7 +101,7 @@ module Release
99
101
  when :staged_elements_of_commit
100
102
 
101
103
  elements = args.first
102
- @prmt.puts "\n Following files/directories shall be committed in this session : ".yellow
104
+ @prmt.puts pmsg("\n Following files/directories shall be committed in this session : ")
103
105
  elements.each do |k,v|
104
106
  v.each do |vv|
105
107
  @prmt.puts " * #{vv}"
@@ -107,11 +109,11 @@ module Release
107
109
  end
108
110
 
109
111
  when :commit_successful
110
- @prmt.puts "\n Changes committed".green
112
+ @prmt.puts pmsg("\n Changes committed",:green)
111
113
  @prmt.puts args.first
112
114
 
113
115
  when :commit_failed
114
- @prmt.puts "\n Changes failed to be committed. Error was : #{args.first}"
116
+ @prmt.puts pmsg("\n Changes failed to be committed. Error was : #{args.first}")
115
117
 
116
118
  end
117
119
  end
@@ -139,17 +141,17 @@ module Release
139
141
 
140
142
  case ops
141
143
  when :tag_message
142
- @prmt.ask("\n Please provide message for the tag : ".yellow, value: "Auto tagging by gem-release gem during releasing version #{@selVer}", required: true)
144
+ @prmt.ask(pmsg("\n Please provide message for the tag : "), value: "Auto tagging by gem-release gem during releasing version #{@selVer}", required: true)
143
145
 
144
146
  when :tagging_success
145
- @prmt.puts "\n Tagging of source code is successful.".green
147
+ @prmt.puts pmsg("\n Tagging of source code is successful.", :green)
146
148
  @prmt.puts args.first
147
149
 
148
150
  when :tagging_failed
149
- @prmt.puts "\n Tagging of source code failed. Error was : #{args.first}".red
151
+ @prmt.puts pmsg("\n Tagging of source code failed. Error was : #{args.first}", :red)
150
152
 
151
153
  when :no_tagging_required
152
- @prmt.puts "\n No tagging required. Source head is the tagged item ".green
154
+ @prmt.puts pmsg("\n No tagging required. Source head is the tagged item ", :green)
153
155
 
154
156
  end
155
157
  end # preset ?
@@ -178,7 +180,7 @@ module Release
178
180
  case ops
179
181
  when :select_remote
180
182
  val = args.first
181
- sel = @prmt.select("\n Please select one of the remote config below : ") do |m|
183
+ sel = @prmt.select(pmsg("\n Please select one of the remote config below : ")) do |m|
182
184
  val.each do |k,v|
183
185
  m.choice k, k
184
186
  end
@@ -190,14 +192,14 @@ module Release
190
192
  sel
191
193
 
192
194
  when :no_remote_repos_defined
193
- add = @prmt.yes?("\n No remote configuration defined. Add one now?")
195
+ add = @prmt.yes?(pmsg("\n No remote configuration defined. Add one now?"))
194
196
  if add
195
- name = @prmt.ask("\n Name of the repository : ", value: "origin", required: true)
196
- url = @prmt.ask("\n URL of the repository : ", required: true)
197
+ name = @prmt.ask(pmsg("\n Name of the repository : "), value: "origin", required: true)
198
+ url = @prmt.ask(pmsg(" URL of the repository : "), required: true)
197
199
 
198
200
  st, res = add_remote(name, url)
199
201
  if st
200
- @prmt.puts "\n Remote configuration added successfully".green
202
+ @prmt.puts pmsg("\n Remote configuration added successfully",:green)
201
203
  name
202
204
  else
203
205
  raise Release::Gem::Abort, "Failed to add remote configuration. Error was : #{res}"
@@ -205,15 +207,15 @@ module Release
205
207
  end
206
208
 
207
209
  when :push_successful
208
- @prmt.puts "\n Push success!".green
210
+ @prmt.puts pmsg("\n Push success!",:green)
209
211
  @prmt.puts args.first
210
212
 
211
213
  when :push_failed
212
- @prmt.puts "\nPush failed. Error was : #{args.first}".red
214
+ @prmt.puts pmsg("\nPush failed. Error was : #{args.first}",:red)
213
215
 
214
216
  when :no_changes_to_push
215
217
  val = args.first
216
- @prmt.puts "\n Local is in sync with remote (#{val[:remote]}/#{val[:branch]}). Push is not required. "
218
+ @prmt.puts pmsg("\n Local is in sync with remote (#{val[:remote]}/#{val[:branch]}). Push is not required. ")
217
219
  end
218
220
  end
219
221
 
@@ -225,6 +227,22 @@ module Release
225
227
  @inst.send(mtd, *args, &block)
226
228
  end
227
229
 
230
+ def pmsg(msg, color = nil)
231
+ if not msg.nil?
232
+ if @discardColor == true
233
+ msg
234
+ else
235
+ if not_empty?(color)
236
+ msg.send(color)
237
+ elsif not_empty?(@msgColor)
238
+ msg.send(@msgColor)
239
+ else
240
+ msg
241
+ end
242
+ end
243
+ end
244
+ end
245
+
228
246
  end
229
247
  end
230
248
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Release
4
4
  module Gem
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.5"
6
6
  end
7
7
  end
data/lib/release/gem.rb CHANGED
@@ -10,6 +10,7 @@ require 'tty/command'
10
10
 
11
11
  require_relative "gem/version"
12
12
  require_relative 'gem/gem_engine'
13
+ require_relative 'gem/release_infector'
13
14
 
14
15
 
15
16
  module Release
@@ -17,6 +17,9 @@ Release::Gem.engine(:gem, root: Dir.getwd) do
17
17
 
18
18
  # step 3 : build the gem
19
19
  st, ver = build
20
+
21
+ dependency_restore
22
+
20
23
  if st
21
24
  # step 4, push the gem to rubygems
22
25
  push(version: ver)
@@ -25,6 +28,7 @@ Release::Gem.engine(:gem, root: Dir.getwd) do
25
28
 
26
29
  end # gem_cli_action
27
30
 
31
+
28
32
  vcs_cli_action do
29
33
  @selVer = value(:selected_version)
30
34
 
@@ -43,7 +47,7 @@ Release::Gem.engine(:gem, root: Dir.getwd) do
43
47
  rescue TTY::Reader::InputInterrupt => ex
44
48
  rescue Exception => ex
45
49
  STDERR.puts "\n -- Error thrown. Message was : #{ex.message}".red
46
- STDERR.puts "\n#{ex.backtrace.join("\n")}" if ENV["RELGEM_DEBUG"] == true
50
+ STDERR.puts "\n#{ex.backtrace.join("\n")}" if ENV["RELGEM_DEBUG"] == "true"
47
51
  ensure
48
52
  gem_dependency_restore
49
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: release-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
@@ -125,6 +125,7 @@ files:
125
125
  - lib/release/gem/gem_action.rb
126
126
  - lib/release/gem/gem_cli_action.rb
127
127
  - lib/release/gem/gem_engine.rb
128
+ - lib/release/gem/gemdep.rb
128
129
  - lib/release/gem/vcs_action.rb
129
130
  - lib/release/gem/vcs_cli_action.rb
130
131
  - lib/release/gem/version.rb