release-gem 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/release/gem/gem_action.rb +9 -2
- data/lib/release/gem/gem_cli_action.rb +86 -17
- data/lib/release/gem/gemdep.rb +7 -0
- data/lib/release/gem/release_infector.rb +179 -0
- data/lib/release/gem/vcs_action.rb +72 -0
- data/lib/release/gem/vcs_cli_action.rb +139 -22
- data/lib/release/gem/version.rb +1 -1
- data/lib/release/gem.rb +1 -0
- data/templates/standard_cli_flow.rb +3 -1
- data/templates/standard_flow.rb +81 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5f829021df7a73c3e93c06b2e4d788f103a1f0ac096d3c472a7b4cfd575122c
|
4
|
+
data.tar.gz: 7c4a3acaa233d7bcff3a1ef308dbdfe3ea7b669f3418d3205072b6b2c5b9ada2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8cc062083ef870fd5ef74eff9b9d8b05072b2348096d10fddab73c8d1ad2cf3ad81ce52dcf5c5447787103429e6c14f970189729a3873293358a432bf83aeb8
|
7
|
+
data.tar.gz: 9ae8f560785f812de5578155547df4ab94deefafa4e741fb2d6b23af13f063c672ae93a75cbce10abc5067d5be7abf640d4aa46f359808ab26f9d66c5327049e
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
release-gem (0.1.
|
4
|
+
release-gem (0.1.6)
|
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.
|
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.
|
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
|
|
@@ -36,6 +36,13 @@ module Release
|
|
36
36
|
if block
|
37
37
|
|
38
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
|
+
|
39
46
|
keys = gemdepInst.development_gem.keys
|
40
47
|
loop do
|
41
48
|
begin
|
@@ -322,7 +329,7 @@ module Release
|
|
322
329
|
end
|
323
330
|
|
324
331
|
def method_missing(mtd, *args, &block)
|
325
|
-
if not @engine.nil?
|
332
|
+
if not @engine.nil?
|
326
333
|
@engine.send(mtd, *args, &block)
|
327
334
|
else
|
328
335
|
super
|
@@ -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"
|
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 "
|
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 ? "
|
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
|
|
@@ -58,10 +111,10 @@ module Release
|
|
58
111
|
config
|
59
112
|
|
60
113
|
when :development_gem_temporary_promoted
|
61
|
-
@pmt.puts "\n Development gem(s) temporary promoted to production status"
|
114
|
+
@pmt.puts pmsg("\n Development gem(s) temporary promoted to production status")
|
62
115
|
|
63
116
|
when :no_development_gems_found
|
64
|
-
@pmt.puts "\n No development gem(s) in used found"
|
117
|
+
@pmt.puts pmsg("\n No development gem(s) in used found")
|
65
118
|
|
66
119
|
end
|
67
120
|
end
|
@@ -73,7 +126,7 @@ module Release
|
|
73
126
|
@inst.build do |ops, *args|
|
74
127
|
case ops
|
75
128
|
when :action_start
|
76
|
-
@pmt.say " Gem building starting...\n"
|
129
|
+
@pmt.say pmsg(" Gem building starting...\n")
|
77
130
|
when :select_version
|
78
131
|
preset = false
|
79
132
|
if block
|
@@ -90,7 +143,7 @@ module Release
|
|
90
143
|
if preset
|
91
144
|
|
92
145
|
opts = args.first
|
93
|
-
res = @pmt.select("\n Please select new gem version : \n"
|
146
|
+
res = @pmt.select(pmsg("\n Please select new gem version : \n")) do |m|
|
94
147
|
opts[:proposed_next].reverse.each do |v|
|
95
148
|
m.choice v,v
|
96
149
|
end
|
@@ -103,8 +156,8 @@ module Release
|
|
103
156
|
|
104
157
|
if res == :custom
|
105
158
|
loop do
|
106
|
-
res = @pmt.ask("\n Please provide custom version number for the release : "
|
107
|
-
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"))
|
108
161
|
break if confirmed
|
109
162
|
end
|
110
163
|
end
|
@@ -128,7 +181,7 @@ module Release
|
|
128
181
|
|
129
182
|
if preset
|
130
183
|
|
131
|
-
res = @pmt.select("\n There are multiple version file found. Please select which one to update : "
|
184
|
+
res = @pmt.select(pmsg("\n There are multiple version file found. Please select which one to update : ")) do |m|
|
132
185
|
opts = args.first
|
133
186
|
opts.each do |f|
|
134
187
|
m.choice f,f
|
@@ -144,7 +197,7 @@ module Release
|
|
144
197
|
@selVersion = args.first
|
145
198
|
|
146
199
|
when :gem_build_successfully
|
147
|
-
@pmt.puts "\n Gem version '#{args.first}' built successfully"
|
200
|
+
@pmt.puts pmsg("\n Gem version '#{args.first}' built successfully", :green)
|
148
201
|
@inst.register(:selected_version, args.first)
|
149
202
|
[true, args.first]
|
150
203
|
end
|
@@ -158,7 +211,7 @@ module Release
|
|
158
211
|
case ops
|
159
212
|
when :multiple_rubygems_account
|
160
213
|
creds = args.first
|
161
|
-
res = @pmt.select("\n Multiple rubygems account detected. Please select one : "
|
214
|
+
res = @pmt.select(pmsg("\n Multiple rubygems account detected. Please select one : ")) do |m|
|
162
215
|
creds.each do |k,v|
|
163
216
|
m.choice k,k
|
164
217
|
end
|
@@ -173,9 +226,9 @@ module Release
|
|
173
226
|
st = pargs.first
|
174
227
|
res = pargs[1]
|
175
228
|
if st
|
176
|
-
@pmt.puts "\n Gem push successful."
|
229
|
+
@pmt.puts pmsg("\n Gem push successful.", :green)
|
177
230
|
else
|
178
|
-
@pmt.puts "\n Gem push failed. Error was :\n #{res}"
|
231
|
+
@pmt.puts pmsg("\n Gem push failed. Error was :\n #{res}", :red)
|
179
232
|
end
|
180
233
|
end
|
181
234
|
end
|
@@ -184,7 +237,7 @@ module Release
|
|
184
237
|
|
185
238
|
def install(*args, &block)
|
186
239
|
|
187
|
-
sysInst = @pmt.yes?("\n Install release into system? "
|
240
|
+
sysInst = @pmt.yes?(pmsg("\n Install release into system? "))
|
188
241
|
if sysInst
|
189
242
|
@inst.install(*args)
|
190
243
|
end
|
@@ -195,6 +248,22 @@ module Release
|
|
195
248
|
@inst.send(mtd,*args, &block)
|
196
249
|
end
|
197
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
|
+
|
198
267
|
end
|
199
268
|
end
|
200
269
|
end
|
data/lib/release/gem/gemdep.rb
CHANGED
@@ -11,6 +11,7 @@ module Release
|
|
11
11
|
|
12
12
|
def initialize(root, opts = { })
|
13
13
|
@root = root
|
14
|
+
@discardColor = opts[:discardColor] || false
|
14
15
|
@devGems = {}
|
15
16
|
@gemConfig = {}
|
16
17
|
@fileHistory = {}
|
@@ -82,6 +83,12 @@ module Release
|
|
82
83
|
@fileHistory.clear
|
83
84
|
end
|
84
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
|
+
|
85
92
|
private
|
86
93
|
def remove_dev_gem_from_gemfile
|
87
94
|
if has_development_gem?
|
@@ -0,0 +1,179 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Release
|
4
|
+
module Gem
|
5
|
+
|
6
|
+
class ReleaseInfectorError < StandardError; end
|
7
|
+
|
8
|
+
#
|
9
|
+
# Setup the release-gem into other gem project automatically!
|
10
|
+
#
|
11
|
+
class ReleaseInfector
|
12
|
+
include TR::CondUtils
|
13
|
+
include TR::TerminalUtils
|
14
|
+
|
15
|
+
def initialize(root, name)
|
16
|
+
@root = root
|
17
|
+
@name = name
|
18
|
+
@backupFiles = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def infect(&block)
|
22
|
+
if not is_release_gem_installed?
|
23
|
+
add_to_gemspec(&block)
|
24
|
+
Bundler.with_clean_env do
|
25
|
+
res = `cd #{@root} && bundle`
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if not is_rakefile_activated?
|
30
|
+
activate_rakefile(&block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def trigger_release_gem(&block)
|
35
|
+
|
36
|
+
block.call(:triggering_release_gem) if block
|
37
|
+
|
38
|
+
poss = tu_possible_terminal
|
39
|
+
raise ReleaseInfectorError, "No possible terminal found" if is_empty?(poss)
|
40
|
+
|
41
|
+
Bundler.with_clean_env do
|
42
|
+
|
43
|
+
cmd = "cd #{@root} && rake gem:release"
|
44
|
+
terminal = ""
|
45
|
+
if block
|
46
|
+
terminal = block.call(:select_terminal, name: @name, options: poss)
|
47
|
+
terminal = poss.first if is_empty?(terminal)
|
48
|
+
|
49
|
+
block.call(:new_terminal_launching, name: @name, terminal: terminal)
|
50
|
+
tu_new_terminal(terminal, cmd)
|
51
|
+
else
|
52
|
+
terminal = poss.first
|
53
|
+
block.call(:new_terminal_launching, name: @name, terminal: terminal)
|
54
|
+
tu_new_terminal(terminal, cmd)
|
55
|
+
end
|
56
|
+
|
57
|
+
block.call(:new_terminal_launched, name: @name, terminal: terminal) if block
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def is_release_gem_installed?
|
64
|
+
#Bundler.with_clean_env do
|
65
|
+
Bundler.with_unbundled_env do
|
66
|
+
|
67
|
+
res = `cd #{@root} && bundle 2>&1`
|
68
|
+
|
69
|
+
puts res
|
70
|
+
|
71
|
+
if $?.success?
|
72
|
+
found = false
|
73
|
+
res.each_line do |l|
|
74
|
+
if l =~ / release-gem /
|
75
|
+
found = true
|
76
|
+
break
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
found
|
81
|
+
else
|
82
|
+
raise ReleaseInfectorError, "Error running bundle in '#{@root}'. Error was :\n#{res}"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end # is_release_gem_installed?
|
87
|
+
|
88
|
+
def add_to_gemspec(&block)
|
89
|
+
|
90
|
+
|
91
|
+
gs = Dir.glob(File.join(@root,"*.gemspec"))
|
92
|
+
raise ReleaseInfectorError, "gemspec not found at '#{@root}'" if is_empty?(gs)
|
93
|
+
|
94
|
+
block.call(:adding_to_gemspec, gemspec: gs) if block
|
95
|
+
|
96
|
+
if gs.length > 1
|
97
|
+
if block
|
98
|
+
gs = block.call(:multiple_gemspecs, gs)
|
99
|
+
else
|
100
|
+
raise ReleaseInfectorError, "There are more than 1 gemspec file found (#{gs.length} found). Since no block to filter out the required one, this will be an error condition"
|
101
|
+
end
|
102
|
+
|
103
|
+
else
|
104
|
+
gs = gs.first
|
105
|
+
end
|
106
|
+
|
107
|
+
cont = File.read(gs)
|
108
|
+
lastEnd = cont.rindex("end")
|
109
|
+
|
110
|
+
FileUtils.mv(gs, "#{gs}.bak")
|
111
|
+
@backupFiles[gs] = "#{gs}.bak"
|
112
|
+
|
113
|
+
File.open(gs, "w") do |f|
|
114
|
+
f.write cont[0...lastEnd]
|
115
|
+
f.puts " spec.add_development_dependency 'release-gem'"
|
116
|
+
f.puts "end"
|
117
|
+
end
|
118
|
+
block.call(:gemspec_updated, name: @name, gemspec: gs )
|
119
|
+
|
120
|
+
end # add_to_gemspec
|
121
|
+
|
122
|
+
def activate_rakefile(&block)
|
123
|
+
|
124
|
+
rf = File.join(@root,"Rakefile")
|
125
|
+
if not File.exist?(rf)
|
126
|
+
rfCont <<-END
|
127
|
+
# frozen_string_literal: true
|
128
|
+
|
129
|
+
require "bundler/gem_tasks"
|
130
|
+
require "rspec/core/rake_task"
|
131
|
+
|
132
|
+
require "release/gem"
|
133
|
+
|
134
|
+
RSpec::Core::RakeTask.new(:spec)
|
135
|
+
|
136
|
+
task default: :spec
|
137
|
+
END
|
138
|
+
block.call(:creating_new_rakefile, rakefile: rf )
|
139
|
+
File.open(rf,"w") do |f|
|
140
|
+
f.write rfCont
|
141
|
+
end
|
142
|
+
else
|
143
|
+
|
144
|
+
block.call(:adding_to_rakefile, rakefile: rf )
|
145
|
+
|
146
|
+
cont = File.read(rf)
|
147
|
+
FileUtils.mv(rf, "#{rf}.bak")
|
148
|
+
@backupFiles[rf] = "#{rf}.bak"
|
149
|
+
|
150
|
+
File.open(rf,"w") do |f|
|
151
|
+
f.puts cont
|
152
|
+
f.puts "require 'release/gem'"
|
153
|
+
end
|
154
|
+
|
155
|
+
block.call(:rakefile_updated, name: @name, rakefile: rf) if block
|
156
|
+
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def is_rakefile_activated?
|
161
|
+
rf = File.join(@root,"Rakefile")
|
162
|
+
if not File.exist?(rf)
|
163
|
+
false
|
164
|
+
else
|
165
|
+
cont = File.read(rf)
|
166
|
+
found = false
|
167
|
+
cont.each_line do |l|
|
168
|
+
if l =~ /require ('|")(release\/gem)("|')/
|
169
|
+
found = true
|
170
|
+
break
|
171
|
+
end
|
172
|
+
end
|
173
|
+
found
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -42,6 +42,72 @@ module Release
|
|
42
42
|
instance_eval(&block) if block
|
43
43
|
end
|
44
44
|
|
45
|
+
#
|
46
|
+
# Special operation since the gem build will only include files from
|
47
|
+
# git ls-files
|
48
|
+
#
|
49
|
+
def commit_new_files(msg = nil, &block)
|
50
|
+
|
51
|
+
res = :value
|
52
|
+
if block
|
53
|
+
|
54
|
+
loop do
|
55
|
+
|
56
|
+
stgDir, stgFiles = @ws.staged_files
|
57
|
+
newDir, newFiles = @ws.new_files
|
58
|
+
|
59
|
+
if is_empty?(newFiles)
|
60
|
+
res = :skip
|
61
|
+
break
|
62
|
+
end
|
63
|
+
|
64
|
+
newFiles.delete_if { |f| stgFiles.include?(f) }
|
65
|
+
newDir.delete_if { |f| stgDir.include?(f) }
|
66
|
+
|
67
|
+
res = block.call(:select_files_to_commit, { new: { files: newFiles, dirs: newDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
|
68
|
+
|
69
|
+
break if res == :skip or res == :done
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
if res == :done
|
74
|
+
|
75
|
+
stgDir, stgFiles = @ws.staged_files
|
76
|
+
block.call(:staged_elements_of_commit, { files: stgFiles, dirs: stgDir })
|
77
|
+
|
78
|
+
msg = block.call(:commit_message) if is_empty?(msg)
|
79
|
+
raise VcsActionError, "Commit message is empty" if is_empty?(msg)
|
80
|
+
|
81
|
+
cp "Commit with user message : #{msg}"
|
82
|
+
st, res = @ws.commit(msg)
|
83
|
+
if st
|
84
|
+
block.call(:commit_successful, res) if block
|
85
|
+
else
|
86
|
+
block.call(:commit_failed, res) if block
|
87
|
+
end
|
88
|
+
[st, res]
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
elsif not_empty?(msg)
|
94
|
+
|
95
|
+
newDir, newFiles = @ws.new_files
|
96
|
+
add_to_staging(*newFiles)
|
97
|
+
|
98
|
+
cp "Commit with user message : #{msg}"
|
99
|
+
st, res = @ws.commit(msg)
|
100
|
+
if st
|
101
|
+
block.call(:commit_successful, res) if block
|
102
|
+
else
|
103
|
+
block.call(:commit_failed, res) if block
|
104
|
+
end
|
105
|
+
[st, res]
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
45
111
|
def commit(msg = nil, &block)
|
46
112
|
|
47
113
|
res = :value
|
@@ -57,6 +123,12 @@ module Release
|
|
57
123
|
|
58
124
|
modFiles.delete_if { |f| stgFiles.include?(f) }
|
59
125
|
modDir.delete_if { |f| stgDir.include?(f) }
|
126
|
+
|
127
|
+
newFiles.delete_if { |f| stgFiles.include?(f) }
|
128
|
+
newDir.delete_if { |f| stgDir.include?(f) }
|
129
|
+
|
130
|
+
delFiles.delete_if { |f| stgFiles.include?(f) }
|
131
|
+
delDir.delete_if { |f| stgDir.include?(f) }
|
60
132
|
|
61
133
|
# block should call vcs for add, remove, ignore and other operations
|
62
134
|
res = block.call(:select_files_to_commit, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, deleted: { files: delFiles, dirs: delDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self, counter: counter } )
|
@@ -12,12 +12,113 @@ 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)
|
18
20
|
instance_eval(&block) if block
|
19
21
|
end
|
20
22
|
|
23
|
+
def commit_new_files(*args, &block)
|
24
|
+
res = @inst.commit_new_files do |ops, *args|
|
25
|
+
|
26
|
+
preset = false
|
27
|
+
if block
|
28
|
+
res = block.call(ops, *args)
|
29
|
+
if res.nil?
|
30
|
+
preset = true
|
31
|
+
else
|
32
|
+
res
|
33
|
+
end
|
34
|
+
else
|
35
|
+
preset = true
|
36
|
+
end
|
37
|
+
|
38
|
+
if preset
|
39
|
+
|
40
|
+
case ops
|
41
|
+
when :select_files_to_commit
|
42
|
+
mfiles = args.first
|
43
|
+
@prmt.puts pmsg("\n Files already added to staging : ")
|
44
|
+
mfiles[:staged].each do |k,v|
|
45
|
+
v.each do |vv|
|
46
|
+
@prmt.puts " * #{vv}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
@prmt.puts ""
|
51
|
+
|
52
|
+
sel = @prmt.multi_select pmsg("\n Following are new files that could be added to version control : ") do |m|
|
53
|
+
|
54
|
+
mfiles[:new].each do |k,v|
|
55
|
+
v.each do |vv|
|
56
|
+
m.choice vv, vv.path
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
m.choice "Skip", :skip #if mfiles[:counter] == 0
|
61
|
+
m.choice "Done", :done
|
62
|
+
m.choice "Abort", :abort
|
63
|
+
end
|
64
|
+
|
65
|
+
if sel.include?(:abort)
|
66
|
+
raise Release::Gem::Abort, "User aborted"
|
67
|
+
elsif sel.include?(:skip)
|
68
|
+
:skip
|
69
|
+
else
|
70
|
+
res = :done if sel.include?(:done)
|
71
|
+
s = sel.clone
|
72
|
+
s.delete_if { |e| e == :done }
|
73
|
+
if not_empty?(s)
|
74
|
+
st, cres = add_to_staging(*s) if not_empty?(s)
|
75
|
+
if st
|
76
|
+
@prmt.puts pmsg("\n Files added successfully", :green)
|
77
|
+
else
|
78
|
+
@prmt.puts pmsg("\n Files failed to be added. Message was : #{cres}", :red)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
res
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
when :commit_message
|
87
|
+
msg = ""
|
88
|
+
loop do
|
89
|
+
msg = @prmt.ask(pmsg("\n Commit message : "), required: true)
|
90
|
+
confirm = @prmt.yes?(pmsg(" Commit message : #{msg}\n Proceed? No to provide a new commit message "))
|
91
|
+
if confirm
|
92
|
+
break
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
msg
|
97
|
+
|
98
|
+
when :staged_elements_of_commit
|
99
|
+
|
100
|
+
elements = args.first
|
101
|
+
@prmt.puts pmsg("\n Following new files/directories shall be committed in this session : ")
|
102
|
+
elements.each do |k,v|
|
103
|
+
v.each do |vv|
|
104
|
+
@prmt.puts " * #{vv}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
when :commit_successful
|
109
|
+
@prmt.puts pmsg("\n Changes committed",:green)
|
110
|
+
@prmt.puts args.first
|
111
|
+
|
112
|
+
when :commit_failed
|
113
|
+
@prmt.puts pmsg("\n Changes failed to be committed. Error was : #{args.first}")
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end # commit_new_files block
|
118
|
+
|
119
|
+
end # commit_new_files
|
120
|
+
|
121
|
+
|
21
122
|
def commit(*args, &block)
|
22
123
|
res = @inst.commit do |ops, *args|
|
23
124
|
|
@@ -38,7 +139,7 @@ module Release
|
|
38
139
|
case ops
|
39
140
|
when :select_files_to_commit
|
40
141
|
mfiles = args.first
|
41
|
-
@prmt.puts "\n Files already added to staging : "
|
142
|
+
@prmt.puts pmsg("\n Files already added to staging : ")
|
42
143
|
mfiles[:staged].each do |k,v|
|
43
144
|
v.each do |vv|
|
44
145
|
@prmt.puts " * #{vv}"
|
@@ -47,7 +148,7 @@ module Release
|
|
47
148
|
|
48
149
|
@prmt.puts ""
|
49
150
|
|
50
|
-
sel = @prmt.multi_select "\n Following are files that could be added to version control : "
|
151
|
+
sel = @prmt.multi_select pmsg("\n Following are files that could be added to version control : ") do |m|
|
51
152
|
|
52
153
|
[:modified, :new, :deleted].each do |cat|
|
53
154
|
mfiles[cat].each do |k,v|
|
@@ -58,7 +159,7 @@ module Release
|
|
58
159
|
|
59
160
|
end
|
60
161
|
|
61
|
-
m.choice "Skip", :skip if mfiles[:counter] == 0
|
162
|
+
m.choice "Skip", :skip #if mfiles[:counter] == 0
|
62
163
|
m.choice "Done", :done
|
63
164
|
m.choice "Abort", :abort
|
64
165
|
end
|
@@ -74,9 +175,9 @@ module Release
|
|
74
175
|
if not_empty?(s)
|
75
176
|
st, cres = add_to_staging(*s) if not_empty?(s)
|
76
177
|
if st
|
77
|
-
@prmt.puts "\n Files added successfully"
|
178
|
+
@prmt.puts pmsg("\n Files added successfully", :green)
|
78
179
|
else
|
79
|
-
@prmt.puts "\n Files failed to be added. Message was : #{cres}"
|
180
|
+
@prmt.puts pmsg("\n Files failed to be added. Message was : #{cres}", :red)
|
80
181
|
end
|
81
182
|
end
|
82
183
|
|
@@ -87,8 +188,8 @@ module Release
|
|
87
188
|
when :commit_message
|
88
189
|
msg = ""
|
89
190
|
loop do
|
90
|
-
msg = @prmt.ask("\n Commit message : "
|
91
|
-
confirm = @prmt.yes?(" Commit message : #{msg}\n Proceed? No to provide a new commit message "
|
191
|
+
msg = @prmt.ask(pmsg("\n Commit message : "), required: true)
|
192
|
+
confirm = @prmt.yes?(pmsg(" Commit message : #{msg}\n Proceed? No to provide a new commit message "))
|
92
193
|
if confirm
|
93
194
|
break
|
94
195
|
end
|
@@ -99,7 +200,7 @@ module Release
|
|
99
200
|
when :staged_elements_of_commit
|
100
201
|
|
101
202
|
elements = args.first
|
102
|
-
@prmt.puts "\n Following files/directories shall be committed in this session : "
|
203
|
+
@prmt.puts pmsg("\n Following files/directories shall be committed in this session : ")
|
103
204
|
elements.each do |k,v|
|
104
205
|
v.each do |vv|
|
105
206
|
@prmt.puts " * #{vv}"
|
@@ -107,11 +208,11 @@ module Release
|
|
107
208
|
end
|
108
209
|
|
109
210
|
when :commit_successful
|
110
|
-
@prmt.puts "\n Changes committed"
|
211
|
+
@prmt.puts pmsg("\n Changes committed",:green)
|
111
212
|
@prmt.puts args.first
|
112
213
|
|
113
214
|
when :commit_failed
|
114
|
-
@prmt.puts "\n Changes failed to be committed. Error was : #{args.first}"
|
215
|
+
@prmt.puts pmsg("\n Changes failed to be committed. Error was : #{args.first}")
|
115
216
|
|
116
217
|
end
|
117
218
|
end
|
@@ -139,17 +240,17 @@ module Release
|
|
139
240
|
|
140
241
|
case ops
|
141
242
|
when :tag_message
|
142
|
-
@prmt.ask("\n Please provide message for the tag : "
|
243
|
+
@prmt.ask(pmsg("\n Please provide message for the tag : "), value: "Auto tagging by gem-release gem during releasing version #{@selVer}", required: true)
|
143
244
|
|
144
245
|
when :tagging_success
|
145
|
-
@prmt.puts "\n Tagging of source code is successful."
|
246
|
+
@prmt.puts pmsg("\n Tagging of source code is successful.", :green)
|
146
247
|
@prmt.puts args.first
|
147
248
|
|
148
249
|
when :tagging_failed
|
149
|
-
@prmt.puts "\n Tagging of source code failed. Error was : #{args.first}"
|
250
|
+
@prmt.puts pmsg("\n Tagging of source code failed. Error was : #{args.first}", :red)
|
150
251
|
|
151
252
|
when :no_tagging_required
|
152
|
-
@prmt.puts "\n No tagging required. Source head is the tagged item "
|
253
|
+
@prmt.puts pmsg("\n No tagging required. Source head is the tagged item ", :green)
|
153
254
|
|
154
255
|
end
|
155
256
|
end # preset ?
|
@@ -178,7 +279,7 @@ module Release
|
|
178
279
|
case ops
|
179
280
|
when :select_remote
|
180
281
|
val = args.first
|
181
|
-
sel = @prmt.select("\n Please select one of the remote config below : ") do |m|
|
282
|
+
sel = @prmt.select(pmsg("\n Please select one of the remote config below : ")) do |m|
|
182
283
|
val.each do |k,v|
|
183
284
|
m.choice k, k
|
184
285
|
end
|
@@ -190,14 +291,14 @@ module Release
|
|
190
291
|
sel
|
191
292
|
|
192
293
|
when :no_remote_repos_defined
|
193
|
-
add = @prmt.yes?("\n No remote configuration defined. Add one now?")
|
294
|
+
add = @prmt.yes?(pmsg("\n No remote configuration defined. Add one now?"))
|
194
295
|
if add
|
195
|
-
name = @prmt.ask("\n Name of the repository : ", value: "origin", required: true)
|
196
|
-
url = @prmt.ask("
|
296
|
+
name = @prmt.ask(pmsg("\n Name of the repository : "), value: "origin", required: true)
|
297
|
+
url = @prmt.ask(pmsg(" URL of the repository : "), required: true)
|
197
298
|
|
198
299
|
st, res = add_remote(name, url)
|
199
300
|
if st
|
200
|
-
@prmt.puts "\n Remote configuration added successfully"
|
301
|
+
@prmt.puts pmsg("\n Remote configuration added successfully",:green)
|
201
302
|
name
|
202
303
|
else
|
203
304
|
raise Release::Gem::Abort, "Failed to add remote configuration. Error was : #{res}"
|
@@ -205,15 +306,15 @@ module Release
|
|
205
306
|
end
|
206
307
|
|
207
308
|
when :push_successful
|
208
|
-
@prmt.puts "\n Push success!"
|
309
|
+
@prmt.puts pmsg("\n Push success!",:green)
|
209
310
|
@prmt.puts args.first
|
210
311
|
|
211
312
|
when :push_failed
|
212
|
-
@prmt.puts "\nPush failed. Error was : #{args.first}"
|
313
|
+
@prmt.puts pmsg("\nPush failed. Error was : #{args.first}",:red)
|
213
314
|
|
214
315
|
when :no_changes_to_push
|
215
316
|
val = args.first
|
216
|
-
@prmt.puts "\n Local is in sync with remote (#{val[:remote]}/#{val[:branch]}). Push is not required. "
|
317
|
+
@prmt.puts pmsg("\n Local is in sync with remote (#{val[:remote]}/#{val[:branch]}). Push is not required. ")
|
217
318
|
end
|
218
319
|
end
|
219
320
|
|
@@ -225,6 +326,22 @@ module Release
|
|
225
326
|
@inst.send(mtd, *args, &block)
|
226
327
|
end
|
227
328
|
|
329
|
+
def pmsg(msg, color = nil)
|
330
|
+
if not msg.nil?
|
331
|
+
if @discardColor == true
|
332
|
+
msg
|
333
|
+
else
|
334
|
+
if not_empty?(color)
|
335
|
+
msg.send(color)
|
336
|
+
elsif not_empty?(@msgColor)
|
337
|
+
msg.send(@msgColor)
|
338
|
+
else
|
339
|
+
msg
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
228
345
|
end
|
229
346
|
end
|
230
347
|
end
|
data/lib/release/gem/version.rb
CHANGED
data/lib/release/gem.rb
CHANGED
@@ -15,6 +15,8 @@ Release::Gem.engine(:gem, root: Dir.getwd) do
|
|
15
15
|
# step 2 : check dependency
|
16
16
|
release_dependencies
|
17
17
|
|
18
|
+
vcs_commit_new_files
|
19
|
+
|
18
20
|
# step 3 : build the gem
|
19
21
|
st, ver = build
|
20
22
|
|
@@ -47,7 +49,7 @@ Release::Gem.engine(:gem, root: Dir.getwd) do
|
|
47
49
|
rescue TTY::Reader::InputInterrupt => ex
|
48
50
|
rescue Exception => ex
|
49
51
|
STDERR.puts "\n -- Error thrown. Message was : #{ex.message}".red
|
50
|
-
STDERR.puts "\n#{ex.backtrace.join("\n")}" if ENV["RELGEM_DEBUG"] == true
|
52
|
+
STDERR.puts "\n#{ex.backtrace.join("\n")}" if ENV["RELGEM_DEBUG"] == "true"
|
51
53
|
ensure
|
52
54
|
gem_dependency_restore
|
53
55
|
end
|
data/templates/standard_flow.rb
CHANGED
@@ -59,6 +59,87 @@ Release::Gem.engine(:gem, root: Dir.getwd, ui: STDOUT) do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
## Check in NEW file first or else the gem build will not pick up by the git ls-files
|
63
|
+
vcs_commit_new_files do |ops, *args|
|
64
|
+
|
65
|
+
case ops
|
66
|
+
when :select_files_to_commit
|
67
|
+
mfiles = args.first
|
68
|
+
pmt.puts "\n Files already added to staging : ".yellow
|
69
|
+
mfiles[:staged].each do |k,v|
|
70
|
+
v.each do |vv|
|
71
|
+
pmt.puts " * #{vv}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
pmt.puts ""
|
76
|
+
|
77
|
+
sel = pmt.multi_select "\n Following are new files that could be added to version control : ".yellow do |m|
|
78
|
+
|
79
|
+
[:modified, :new, :deleted].each do |cat|
|
80
|
+
mfiles[cat].each do |k,v|
|
81
|
+
v.each do |vv|
|
82
|
+
m.choice vv, vv.path
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
m.choice "Skip", :skip if mfiles[:counter] == 0
|
89
|
+
m.choice "Done", :done
|
90
|
+
m.choice "Abort", :abort
|
91
|
+
end
|
92
|
+
|
93
|
+
if sel.include?(:abort)
|
94
|
+
raise Release::Gem::Abort, "User aborted"
|
95
|
+
elsif sel.include?(:skip)
|
96
|
+
:skip
|
97
|
+
else
|
98
|
+
res = :done if sel.include?(:done)
|
99
|
+
s = sel.clone
|
100
|
+
s.delete_if { |e| e == :done }
|
101
|
+
if not_empty?(s)
|
102
|
+
st, cres = add_to_staging(*s) if not_empty?(s)
|
103
|
+
if st
|
104
|
+
pmt.puts "\n Files added successfully".green
|
105
|
+
else
|
106
|
+
pmt.puts "\n Files failed to be added. Message was : #{cres}".red
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
res
|
111
|
+
end
|
112
|
+
|
113
|
+
when :commit_message
|
114
|
+
msg = ""
|
115
|
+
loop do
|
116
|
+
msg = pmt.ask("\n Commit message : ".yellow, required: true)
|
117
|
+
confirm = pmt.yes?(" Commit message : #{msg}\n Proceed? No to provide a new commit message ".yellow)
|
118
|
+
if confirm
|
119
|
+
break
|
120
|
+
end
|
121
|
+
end
|
122
|
+
msg
|
123
|
+
|
124
|
+
when :staged_elements_of_commit
|
125
|
+
elements = args.first
|
126
|
+
pmt.puts "\n Following files/directories shall be committed in this session : ".yellow
|
127
|
+
elements.each do |k,v|
|
128
|
+
v.each do |vv|
|
129
|
+
pmt.puts " * #{vv}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
when :commit_successful
|
134
|
+
pmt.puts "\n Changes committed".green
|
135
|
+
|
136
|
+
when :commit_failed
|
137
|
+
pmt.puts "\n Changes failed to be committed. Error was : #{args.first}"
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
62
143
|
# step 3 : build the gem
|
63
144
|
st, ver = build do |ops, *args|
|
64
145
|
case ops
|
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.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/release/gem/gem_cli_action.rb
|
127
127
|
- lib/release/gem/gem_engine.rb
|
128
128
|
- lib/release/gem/gemdep.rb
|
129
|
+
- lib/release/gem/release_infector.rb
|
129
130
|
- lib/release/gem/vcs_action.rb
|
130
131
|
- lib/release/gem/vcs_cli_action.rb
|
131
132
|
- lib/release/gem/version.rb
|