release-gem 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,260 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gem/release'
4
+
5
+ require 'tty/prompt'
6
+
7
+ pmt = TTY::Prompt.new
8
+
9
+ pmt.puts "\n Standard GEM release flow version #{Release::Gem::VERSION}\n".yellow
10
+
11
+ begin
12
+
13
+ Release::Gem.engine(:gem, root: Dir.getwd, ui: STDOUT) do
14
+
15
+ # step 1 : run test
16
+ run_test(:rspec)
17
+
18
+ gem_action do
19
+
20
+ # step 2 : check dependency
21
+ release_dependencies
22
+
23
+ # step 3 : build the gem
24
+ st, ver = build do |ops, *args|
25
+ case ops
26
+ when :action_start
27
+ pmt.say " Gem building starting...\n".yellow
28
+ when :select_version
29
+ opts = args.first
30
+ res = pmt.select("\n Please select new gem version : \n".yellow) do |m|
31
+ opts[:proposed_next].reverse.each do |v|
32
+ m.choice v,v
33
+ end
34
+ m.choice "#{opts[:current_version]} -> Current version ", opts[:current_version]
35
+ m.choice "Custom version", :custom
36
+ m.choice "Abort", :abort
37
+ end
38
+
39
+ raise Release::Gem::Abort, "Abort by user" if res == :abort
40
+
41
+ if res == :custom
42
+ loop do
43
+ res = pmt.ask("\n Please provide custom version number for the release : ".yellow,required: true)
44
+ proceed = pmt.yes?("\n Use version '#{res}'? No to try again")
45
+ break if proceed
46
+ end
47
+ end
48
+
49
+ res
50
+
51
+ when :multiple_version_files_found
52
+ res = pmt.select("\n There are multiple version file found. Please select which one to update : ".yellow) do |m|
53
+ opts = args.first
54
+ opts.each do |f|
55
+ m.choice f,f
56
+ end
57
+ m.choice "Abort", :abort
58
+ end
59
+
60
+ raise Release::Gem::Abort, "Abort by user" if res == :abort
61
+ res
62
+ when :new_version_number
63
+ @selVersion = args.first
64
+
65
+ when :gem_build_successfully
66
+ pmt.puts "\n Gem version '#{args.first}' built successfully".green
67
+ register(:selected_version, args.first)
68
+
69
+ end
70
+ end
71
+
72
+ if st
73
+
74
+ # step 4, push the gem to rubygems
75
+ push(version: @selVer) do |ops, *args|
76
+ case ops
77
+ when :multiple_rubygems_account
78
+ creds = args.first
79
+ res = pmt.select("\n Multiple rubygems account detected. Please select one : ".yellow) do |m|
80
+ creds.each do |k,v|
81
+ m.choice k,k
82
+ end
83
+ m.choice "Skip gem push", :skip
84
+ m.choice "Abort", :abort
85
+ end
86
+
87
+ raise Release::Gem::Abort, "Abort by user" if res == :abort
88
+ res
89
+ end
90
+ end
91
+
92
+ # step 5: install gem into system
93
+ sysInst = pmt.yes?("\n Install release into system? ".yellow)
94
+ if sysInst
95
+ install(version: @selVer)
96
+ end
97
+
98
+ end
99
+
100
+ end # gem_action
101
+
102
+ vcs_action do
103
+ @selVer = value(:selected_version)
104
+
105
+ # step 6 : commit vcs
106
+ res = commit do |ops, *args|
107
+ case ops
108
+ when :select_files_to_commit
109
+ mfiles = args.first
110
+ pmt.puts "\n Files already added to staging : ".yellow
111
+ mfiles[:staged].each do |k,v|
112
+ v.each do |vv|
113
+ pmt.puts " * #{vv}"
114
+ end
115
+ end
116
+
117
+ pmt.puts ""
118
+
119
+ sel = pmt.multi_select "\n Following are files that could be added to version control : ".yellow do |m|
120
+
121
+ [:modified, :new, :deleted].each do |cat|
122
+ mfiles[cat].each do |k,v|
123
+ v.each do |vv|
124
+ m.choice vv, vv.path
125
+ end
126
+ end
127
+
128
+ end
129
+
130
+ m.choice "Skip", :skip if mfiles[:counter] == 0
131
+ m.choice "Done", :done
132
+ m.choice "Abort", :abort
133
+ end
134
+
135
+ if sel.include?(:abort)
136
+ raise Release::Gem::Abort, "User aborted"
137
+ elsif sel.include?(:skip)
138
+ :skip
139
+ else
140
+ res = :done if sel.include?(:done)
141
+ s = sel.clone
142
+ s.delete_if { |e| e == :done }
143
+ if not_empty?(s)
144
+ st, cres = add_to_staging(*s) if not_empty?(s)
145
+ if st
146
+ pmt.puts "\n Files added successfully".green
147
+ else
148
+ pmt.puts "\n Files failed to be added. Message was : #{cres}".red
149
+ end
150
+ end
151
+
152
+ res
153
+ end
154
+
155
+ when :commit_message
156
+ msg = ""
157
+ loop do
158
+ msg = pmt.ask("\n Commit message : ".yellow, required: true)
159
+ confirm = pmt.yes?(" Commit message : #{msg}\n Proceed? No to provide a new commit message ".yellow)
160
+ if confirm
161
+ break
162
+ end
163
+ end
164
+ msg
165
+
166
+ when :staged_elements_of_commit
167
+ elements = args.first
168
+ pmt.puts "\n Following files/directories shall be committed in this session : ".yellow
169
+ elements.each do |k,v|
170
+ v.each do |vv|
171
+ pmt.puts " * #{vv}"
172
+ end
173
+ end
174
+
175
+ when :commit_successful
176
+ pmt.puts "\n Changes committed".green
177
+
178
+ when :commit_failed
179
+ pmt.puts "\n Changes failed to be committed. Error was : #{args.first}"
180
+
181
+ end
182
+ end # commit
183
+
184
+ # step 7 : tag the source code
185
+ # if the top of the changes is not tagged, means there are changes after last tagged
186
+ tag({ tag: @selVer }) do |ops, *args|
187
+ case ops
188
+ when :tag_message
189
+ pmt.ask("\n Please provide message for the tag : ".yellow, value: "Auto tagging by gem-release gem during releasing version #{@selVer}", required: true)
190
+ when :tagging_success
191
+ pmt.puts "\n Tagging of source code is successful.".green
192
+
193
+ when :tagging_failed
194
+ pmt.puts "\n Tagging of source code failed. Error was : #{args.first}".red
195
+
196
+ when :no_tagging_required
197
+ pmt.puts "\n No tagging required. Source head is the tagged item ".green
198
+
199
+ end
200
+ end
201
+
202
+
203
+ push do |ops, *args|
204
+ case ops
205
+ when :select_remote
206
+ val = args.first
207
+ sel = pmt.select("\n Please select one of the remote config below : ") do |m|
208
+ val.each do |k,v|
209
+ m.choice k, k
210
+ end
211
+ m.choice "Skip pushing source code", :skip
212
+ m.choice "Abort", :abort
213
+ end
214
+ raise Release::Gem::Abort, "User aborted" if sel == :abort
215
+ sel
216
+
217
+ when :no_remote_repos_defined
218
+ add = pmt.yes?("\n No remote configuration defined. Add one now?")
219
+ if add
220
+ name = pmt.ask("\n Name of the repository : ", value: "origin", required: true)
221
+ url = pmt.ask("\n URL of the repository : ", required: true)
222
+
223
+ st, res = add_remote(name, url)
224
+ if st
225
+ pmt.puts "\n Remote configuration added successfully".green
226
+ name
227
+ else
228
+ raise Release::Gem::Abort, "Failed to add remote configuration. Error was : #{res}"
229
+ end
230
+ end
231
+
232
+ when :push_successful
233
+ pmt.puts "\n Push success!".green
234
+
235
+ when :push_failed
236
+ pmt.puts "\nPush failed. Error was : #{args.first}".red
237
+
238
+ when :no_changes_to_push
239
+ val = args.first
240
+ pmt.puts "\n Local is in sync with remote (#{val[:remote]}/#{val[:branch]}). Push is not required. "
241
+ end
242
+
243
+ end
244
+
245
+ end # vcs_action block
246
+
247
+ end # Release::Gem::Engine block
248
+
249
+ pmt.puts "\n *** GEM standard release flow done!\n".green
250
+
251
+ rescue Release::Gem::Abort => ex
252
+ pmt.puts "\n -- Aborted by user. Message was : #{ex.message}\n".red
253
+ rescue TTY::Reader::InputInterrupt => ex
254
+ rescue Exception => ex
255
+ pmt.puts "\n -- Error thrown. Message was : #{ex.message}".red
256
+ end
257
+
258
+
259
+
260
+
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
@@ -89,11 +89,21 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - ".rspec"
91
91
  - Gemfile
92
+ - Gemfile.lock
92
93
  - README.md
93
94
  - Rakefile
95
+ - lib/release/Rakefile
94
96
  - lib/release/gem.rb
97
+ - lib/release/gem/gem_action.rb
98
+ - lib/release/gem/gem_cli_action.rb
99
+ - lib/release/gem/gem_engine.rb
100
+ - lib/release/gem/vcs_action.rb
101
+ - lib/release/gem/vcs_cli_action.rb
95
102
  - lib/release/gem/version.rb
96
103
  - sig/release/gem.rbs
104
+ - tasks/standard.rake
105
+ - templates/standard_cli_flow.rb
106
+ - templates/standard_flow.rb
97
107
  homepage: ''
98
108
  licenses: []
99
109
  metadata: {}