devops_assist 0.2.1 → 0.3.4

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: ebdaf870d19aabb7f4090b013bc6b470504d09362a02882d25409be9c0aa0934
4
- data.tar.gz: 47c4a2020605840ec5b38ee040a77a7d86cc9708404332292314d28d2d8d6dbb
3
+ metadata.gz: 6b5575312117dafd5eca9cae17c2671652bd9ed3bfd1a82441a972267aa6da04
4
+ data.tar.gz: c54728232443d37e0de8b723bb92c63463fb873353501efdfb89965ecd84f997
5
5
  SHA512:
6
- metadata.gz: 870d8999ad101743581295ac9cc0fbcf02f9ef40cb169dc178dbfa53f33095fc9f77064cc9a31832d65ea0506b8359d4745e11a42be595552331b571d9e34d9b
7
- data.tar.gz: 5d350ea750ebd164a163922c1905c69c6b7b6a4f0c88b8f08536b11152910cdf3b81e52448b85cb925f0a63957197377b48a6c4ba56ae36af928b52fc1e4d551
6
+ metadata.gz: 8a2cb7d4992b9faa39f34e905b8d3ac077d70147553f9f54c3e4917e49cfd58048d3a5f3a137a6560a626204cd318c66950ee40643a5ca56ca72e674892ede04
7
+ data.tar.gz: 833da63cc73361babc7a0dcbe1374d46a7d55d0fc08cb957f53b45420f39e7c2e6b63eb07fea7f53afeabb3461aa9d49a1f6ddf1e81cf6e22fb01c300b197d89
data/.release_history.yml CHANGED
@@ -12,3 +12,15 @@ devops_assist:
12
12
  :timestamp: 1637846341.0877914
13
13
  - :version: 0.2.0
14
14
  :timestamp: 1657610885.1882625
15
+ - :version: 0.2.1
16
+ :timestamp: 1660213921.2263613
17
+ - :version: 0.3.0
18
+ :timestamp: 1661973921.357578
19
+ - :version: 0.3.1
20
+ :timestamp: 1664976434.566908
21
+ - :version: 0.3.2
22
+ :timestamp: 1679806218.9064217
23
+ - :version: 0.3.4
24
+ :timestamp: 1679814741.9125335
25
+ - :version: 0.3.4
26
+ :timestamp: 1679814912.2051551
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devops_assist (0.1.3)
4
+ devops_assist (0.3.1)
5
5
  git_cli
6
6
  git_cli_prompt
7
7
  gvcs
8
- tlogger
8
+ teLogger
9
9
  toolrack
10
10
  tty-prompt
11
11
 
@@ -13,14 +13,14 @@ GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
15
  base58 (0.2.3)
16
- diff-lcs (1.4.4)
17
- git_cli (0.9.0)
16
+ diff-lcs (1.5.0)
17
+ git_cli (0.10.0)
18
18
  gvcs
19
19
  ptools (~> 1.4.0)
20
- tlogger
20
+ teLogger
21
21
  toolrack
22
- git_cli_prompt (0.2.2)
23
- tlogger
22
+ git_cli_prompt (0.3.1)
23
+ teLogger
24
24
  toolrack
25
25
  tty-prompt
26
26
  gvcs (0.1.0)
@@ -28,23 +28,22 @@ GEM
28
28
  tty-color (~> 0.5)
29
29
  ptools (1.4.2)
30
30
  rake (13.0.6)
31
- rspec (3.10.0)
32
- rspec-core (~> 3.10.0)
33
- rspec-expectations (~> 3.10.0)
34
- rspec-mocks (~> 3.10.0)
35
- rspec-core (3.10.1)
36
- rspec-support (~> 3.10.0)
37
- rspec-expectations (3.10.1)
31
+ rspec (3.11.0)
32
+ rspec-core (~> 3.11.0)
33
+ rspec-expectations (~> 3.11.0)
34
+ rspec-mocks (~> 3.11.0)
35
+ rspec-core (3.11.0)
36
+ rspec-support (~> 3.11.0)
37
+ rspec-expectations (3.11.1)
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.10.0)
40
- rspec-mocks (3.10.2)
39
+ rspec-support (~> 3.11.0)
40
+ rspec-mocks (3.11.1)
41
41
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.10.0)
43
- rspec-support (3.10.3)
44
- tlogger (0.26.3)
45
- toolrack (0.17.0)
42
+ rspec-support (~> 3.11.0)
43
+ rspec-support (3.11.1)
44
+ teLogger (0.2.0)
45
+ toolrack (0.19.1)
46
46
  base58
47
- tlogger
48
47
  tty-color (0.6.0)
49
48
  tty-cursor (0.7.1)
50
49
  tty-prompt (0.23.1)
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require_relative './lib/devops_assist'
8
+ #require_relative './lib/devops_assist'
9
+ require File.join(File.dirname(__FILE__),"lib","devops_assist") #'./lib/devops_assist'
9
10
 
10
11
  task default: :spec
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency 'toolrack'
34
- #spec.add_dependency 'tlogger'
35
34
  spec.add_dependency 'teLogger'
36
35
  spec.add_dependency 'tty-prompt'
37
36
 
@@ -1,18 +1,19 @@
1
1
 
2
2
  require 'yaml'
3
3
 
4
- require_relative 'gemspec'
5
-
6
4
  module DevopsAssist
7
- module Gem
5
+ class GemUtils
8
6
  include TR::CondUtils
9
- include Gemspec
10
7
 
11
- class GemError < StandardError; end
8
+ class GemUtilsError < StandardError; end
9
+
10
+ def initialize(gemRoot)
11
+ @root = gemRoot
12
+ end
12
13
 
13
- def update_gem_version(root, newVersion, &block)
14
+ def update_gem_version(newVersion, &block)
14
15
 
15
- version_file = find_gem_version_file(root)
16
+ version_file = find_gem_version_file
16
17
 
17
18
  if version_file.length > 1
18
19
  if block
@@ -25,7 +26,7 @@ module DevopsAssist
25
26
  selVerFile = version_file.first
26
27
  end
27
28
 
28
- tmpFile = File.join(File.dirname(selVerFile),"version.rb.tmp")
29
+ tmpFile = File.join(File.dirname(selVerFile),"version-da.bak")
29
30
  FileUtils.mv(selVerFile,tmpFile)
30
31
 
31
32
  File.open(selVerFile,"w") do |f|
@@ -40,22 +41,18 @@ module DevopsAssist
40
41
  end
41
42
  end
42
43
 
43
- FileUtils.rm tmpFile
44
+ FileUtils.rm(tmpFile)
44
45
 
45
46
  selVerFile
46
47
 
47
48
  end
48
49
 
49
- def find_gem_version_file(root)
50
- if is_empty?(root)
51
- raise GemError, "Root path '#{root}' to find_gem_version_file is empty"
52
- else
53
- Dir.glob(File.join(root,"**/version.rb"))
54
- end
50
+ def find_gem_version_file
51
+ raise GemUtilsError, "Root path '#{@root}' to find_gem_version_file is empty" if is_empty?(@root)
52
+ Dir.glob(File.join(@root,"**/version.rb"))
55
53
  end
56
54
 
57
-
58
- def publish_gem(version, opts = { }, &block)
55
+ def self.publish_gem(version, opts = { }, &block)
59
56
 
60
57
  cred = find_rubygems_api_key
61
58
 
@@ -90,7 +87,7 @@ module DevopsAssist
90
87
 
91
88
  end
92
89
 
93
- def publish_gem_file(gemfile, opts = { }, &block)
90
+ def self.publish_gem_file(gemfile, opts = { }, &block)
94
91
 
95
92
  cred = find_rubygems_api_key
96
93
 
@@ -116,17 +113,43 @@ module DevopsAssist
116
113
 
117
114
  end
118
115
 
116
+ def gem_name
117
+ gemspec.name
118
+ end
119
+
120
+ def gem_version_string
121
+ gem_version.version
122
+ end
123
+
124
+ def gem_version
125
+ gemspec.version
126
+ end
127
+
128
+ def gemspec
129
+ raise GemUtilsError, "Root path is not given" if is_empty?(@root)
130
+
131
+ if @_gemSpec.nil?
132
+ @_gemSpec = ::Gem::Specification.load(Dir.glob(File.join(@root,"*.gemspec")).first)
133
+ raise GemUtilsError, "Cannot find gemspec from #{@root}" if @_gemSpec.nil?
134
+ end
135
+
136
+ @_gemSpec
137
+ end
119
138
 
120
139
  private
121
- def logger
140
+ def self.logger
122
141
  if @logger.nil?
123
142
  @logger = TeLogger::Tlogger.new
124
- @logger.tag = :gem
143
+ @logger.tag = :gem_utils
125
144
  end
126
145
  @logger
127
146
  end
128
147
 
129
- def find_rubygems_api_key
148
+ def logger
149
+ self.class.logger
150
+ end
151
+
152
+ def self.find_rubygems_api_key
130
153
  if TR::RTUtils.on_windows?
131
154
  credFile = File.join(ENV['USERPROFILE'],".gem","credentials")
132
155
  else
@@ -23,7 +23,7 @@ module DevopsAssist
23
23
  raise ReleaseLogError, "Release name cannot be empty" if is_empty?(relName)
24
24
  raise ReleaseLogError, "Version cannot be empty" if is_empty?(version)
25
25
 
26
- raise ReleaseLogError, "Version '#{version}' already in the log file for release '#{relName}'" if is_version_exist?(version, relName)
26
+ #raise ReleaseLogError, "Version '#{version}' already in the log file for release '#{relName}'" if is_version_exist?(version, relName)
27
27
 
28
28
  rec = { version: version, timestamp: Time.now.to_f }
29
29
  if block
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
1
+
2
2
 
3
3
  module DevopsAssist
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.4"
5
5
  end
@@ -3,43 +3,51 @@ require 'tty/prompt'
3
3
 
4
4
  module DevopsAssist
5
5
  module VersionManager
6
- extend DevopsAssist::Gem
7
6
  extend TR::VUtils
8
7
 
9
- def self.prompt_version(gemName, last_version = "0.0.0")
8
+ def self.prompt_version(gemName, last_version = "0.1.0")
10
9
 
11
- begin
10
+ #begin
12
11
 
13
- last_version = "0.0.0" if is_empty?(last_version)
12
+ last_version = "0.1.0" if is_empty?(last_version)
14
13
 
15
14
  pmt = TTY::Prompt.new
16
15
  vers = possible_versions(last_version)
17
16
 
18
- vers << "Custom"
19
- vers << "Quit"
17
+ vv = []
18
+ vv << vers[2]
19
+ vv << vers[1]
20
+ vv << vers[0]
21
+
22
+ vv << "Custom"
23
+ vv << "Quit"
20
24
  #vers << [ \
21
25
  # "Maybe not now..." \
22
26
  # ,"Nah, forget it..." \
23
27
  #].sample
24
28
 
25
29
  vsel = pmt.select(" Please select one of the versions below:") do |menu|
26
- vers.each do |v|
30
+ menu.choice "#{last_version} (current version - no change in version)", :no_change
31
+ #vers.each do |v|
32
+ vv.each do |v|
27
33
  menu.choice v
28
34
  end
29
35
  end
30
36
 
31
37
  case vsel
38
+ when :no_change
39
+ vsel = last_version
32
40
  when "Custom"
33
41
  vsel = pmt.ask(" Please provide custom version no:", required: true)
34
- when vers[-1]
42
+ when vv[-1]
35
43
  raise DevopsAssist::Error, " Aborted. Have a nice day! "
36
44
  end
37
45
 
38
46
  vsel
39
47
 
40
- rescue TTY::Reader::InputInterrupt
41
- raise DevopsAssist::Error
42
- end
48
+ #rescue TTY::Reader::InputInterrupt
49
+ # raise DevopsAssist::Error
50
+ #end
43
51
 
44
52
  end
45
53
 
data/lib/devops_assist.rb CHANGED
@@ -5,7 +5,7 @@ require_relative 'devops_assist/release_log/release_log'
5
5
 
6
6
  require_relative 'devops_assist/vcs/git/cli_prompt'
7
7
 
8
- require_relative 'devops_assist/gem/gem'
8
+ require_relative 'devops_assist/gem/gem_utils'
9
9
 
10
10
  require_relative 'devops_assist/version_manager'
11
11
 
@@ -15,9 +15,12 @@ require 'teLogger'
15
15
  module DevopsAssist
16
16
  class Error < StandardError; end
17
17
  # Your code goes here...
18
+
19
+ EnvKey = "DEVOPS_ASSIST"
20
+ EnvKeyGemReleasing = "#{EnvKey}_GEM_RELEASING"
21
+
18
22
  end
19
23
 
20
24
  # load the rake tasks
21
25
  rf = File.join(File.dirname(__FILE__),"Rakefile")
22
26
  load rf
23
-
@@ -3,35 +3,42 @@
3
3
  require_relative '../lib/devops_assist'
4
4
  require 'tty/prompt'
5
5
 
6
+ include DevopsAssist
7
+
6
8
  namespace :devops do
7
9
 
10
+ desc "Initialize the directory"
11
+ task :init do
12
+
13
+ root = Dir.getwd
14
+
15
+ gu = GemUtils.new(root)
16
+
17
+ end
18
+
8
19
  desc "Release gem file project"
9
20
  task :release do
10
21
 
22
+ root = Dir.getwd
23
+ gu = GemUtils.new(root)
11
24
  begin
12
25
 
13
26
  pmt = TTY::Prompt.new
14
27
 
15
- root = Dir.getwd
16
28
 
17
- gemName = find_gem_name(root)
18
-
19
- pmt.say " Starting gem release for gem #{gemName}", color: :yellow
20
-
21
- # check in source code
22
- res = Rake::Task["devops:vcs:checkin_changes"].execute
23
- pmt.say " Workspace check in done\n", color: :yellow
29
+ # let's mark the session to allow automated context switching
30
+ ENV[DevopsAssist::EnvKeyGemReleasing] = "true"
24
31
 
25
- proceed = pmt.yes?(" Proceed with release? ")
26
- raise GitCliPrompt::UserAborted if not proceed
32
+ gemName = gu.gem_name
27
33
 
28
- rl = DevopsAssist::ReleaseLogger.load
34
+ pmt.say " Starting gem release for gem #{gemName}", color: :yellow
29
35
 
30
- # select version
31
- ver = DevopsAssist::VersionManager.prompt_version(gemName, rl.last_version_number(gemName))
36
+ # select version
37
+ #ver = DevopsAssist::VersionManager.prompt_version(gemName, rl.last_version_number(gemName))
38
+ ver = DevopsAssist::VersionManager.prompt_version(gemName, gu.gem_version_string)
32
39
  pmt.say " Version no. '#{ver}' chosen", color: :yellow
33
40
 
34
- selVerFile = update_gem_version(root, ver) do |*args|
41
+ selVerFile = gu.update_gem_version(ver) do |*args|
35
42
  ops = args.first
36
43
  case ops
37
44
  when :select_version_file
@@ -42,31 +49,77 @@ namespace :devops do
42
49
  end
43
50
  pmt.say " Version file updated", color: :yellow
44
51
 
45
- # build the gem
52
+
53
+ # check in source code
54
+ # Check in must be done 1st or else the 'gem build' process will fail
55
+ # because build will use git command. For any files that already deleted,
56
+ # the build will failed to find the files and throw exception
57
+ res = Rake::Task["devops:vcs:checkin_changes"].execute
58
+ pmt.say " Workspace check in done\n", color: :yellow
59
+
60
+ proceed = pmt.yes?(" Proceed to build the gem? ")
61
+ raise GitCliPrompt::UserAborted if not proceed
62
+
63
+
64
+ # test build the gem, make sure there is no error
65
+ # If error expected the scripts stops here
46
66
  Rake::Task["build"].execute
47
67
 
68
+ # Record the version number in the log files
69
+ # for reporting traceability
70
+ rl = DevopsAssist::ReleaseLogger.load
48
71
  rl.log_release(gemName, ver)
49
- pmt.say " Release version number is logged", color: :yellow
72
+ #pmt.say " Release version number is logged after successful test built", color: :yellow
73
+
74
+ ## If successfully built, following files shall be changed
75
+ #miscFiles = []
76
+ #miscFiles << selVerFile # version.rb
77
+ #miscFiles << DevopsAssist::ReleaseLogger::LOG_NAME # release_history.yml
78
+ #miscFiles << 'Gemfile.lock'
79
+ #Rake::Task["devops:vcs:checkin_misc_files"].execute({ root: root, files: miscFiles, version: ver })
80
+ #pmt.say " Updated files during release prep have committed into version control", color: :yellow
81
+
82
+ ## check in source code
83
+ #res = Rake::Task["devops:vcs:checkin_changes"].execute
84
+ #pmt.say " Workspace check in done\n", color: :yellow
85
+
86
+ #proceed = pmt.yes?(" Proceed with release? ")
87
+ #raise GitCliPrompt::UserAborted if not proceed
88
+
89
+ #
90
+ # Actual building the real gems build the gem
91
+ # Any possible reasons here error but not the one above?
92
+ #
93
+ # Main reason to do double build is to avoid to generate
94
+ # 2 log entries in Git for each build, which the 2nd (latest)
95
+ # log is just about the version updates (version pre 0.4.x way)
96
+ #
97
+ #Rake::Task["build"].execute
98
+
99
+ #rl.log_release(gemName, ver)
100
+ #pmt.say " Release version number is logged", color: :yellow
50
101
 
51
102
  # publish gem
52
103
  Rake::Task["devops:gem:publish_gem"].execute({ version: ver, pmt: pmt })
53
104
 
54
105
  # following files shall change when gem is built
55
- miscFiles = []
56
- miscFiles << selVerFile
57
- miscFiles << DevopsAssist::ReleaseLogger::LOG_NAME
58
- miscFiles << 'Gemfile.lock'
59
- Rake::Task["devops:vcs:checkin_misc_files"].execute({ root: root, files: miscFiles, version: ver })
60
- pmt.say " Updated files during release prep have committed into version control", color: :yellow
106
+ #miscFiles = []
107
+ #miscFiles << selVerFile
108
+ #miscFiles << DevopsAssist::ReleaseLogger::LOG_NAME
109
+ #miscFiles << 'Gemfile.lock'
110
+ #Rake::Task["devops:vcs:checkin_misc_files"].execute({ root: root, files: miscFiles, version: ver })
111
+ #pmt.say " Updated files during release prep have committed into version control", color: :yellow
61
112
 
62
113
  Rake::Task["devops:vcs:tag_source_code"].execute({ root: root, version: ver })
63
114
  pmt.say " Source code is tagged as version #{ver}", color: :yellow
64
115
 
65
116
  Rake::Task["devops:vcs:push_source_code"].execute({ root: root, pmt: pmt })
66
117
 
67
- rescue GitCliPrompt::UserAborted, GitCliPrompt::UserChangedMind
118
+ rescue GitCliPrompt::UserAborted, GitCliPrompt::UserChangedMind, TTY::Reader::InputInterrupt
119
+ STDOUT.puts
68
120
  rescue Exception => ex
69
121
  STDERR.puts ex.message
122
+ STDOUT.puts "\n\nAborted\n"
70
123
  #STDERR.puts ex.backtrace.join('\n')
71
124
  end
72
125
 
data/tasks/gem.rake CHANGED
@@ -3,7 +3,7 @@ require_relative '../lib/devops_assist'
3
3
 
4
4
  require 'tty/prompt'
5
5
 
6
- include DevopsAssist::Gem
6
+ #include DevopsAssist::Gem
7
7
  include TR::VUtils
8
8
 
9
9
  namespace :devops do
@@ -14,7 +14,9 @@ namespace :devops do
14
14
 
15
15
  root = Dir.getwd
16
16
 
17
- selVerFile = update_gem_version(root, args) do |*args|
17
+ gu = GemUtils.new(root)
18
+
19
+ selVerFile = gu.update_gem_version(args) do |*args|
18
20
  ops = args.first
19
21
  case ops
20
22
  when :select_version_file
@@ -36,7 +38,7 @@ namespace :devops do
36
38
 
37
39
  ans = pmt.yes?(" Proceed to publish the gem to Rubygems?")
38
40
  if ans
39
- res, tg, out = publish_gem(version) do |*args|
41
+ res, tg, out = GemUtils.publish_gem(version) do |*args|
40
42
  ops = args.first
41
43
  case ops
42
44
  when :multiple_rubygems_account
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devops_assist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Liaw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-11 00:00:00.000000000 Z
11
+ date: 2023-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toolrack
@@ -112,8 +112,7 @@ files:
112
112
  - devops_assist.gemspec
113
113
  - lib/Rakefile
114
114
  - lib/devops_assist.rb
115
- - lib/devops_assist/gem/gem.rb
116
- - lib/devops_assist/gem/gemspec.rb
115
+ - lib/devops_assist/gem/gem_utils.rb
117
116
  - lib/devops_assist/release_log/release_log.rb
118
117
  - lib/devops_assist/vcs/git/cli_prompt.rb
119
118
  - lib/devops_assist/vcs/vcs.rb
@@ -140,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
139
  - !ruby/object:Gem::Version
141
140
  version: '0'
142
141
  requirements: []
143
- rubygems_version: 3.2.22
142
+ rubygems_version: 3.4.6
144
143
  signing_key:
145
144
  specification_version: 4
146
145
  summary: ''
@@ -1,28 +0,0 @@
1
-
2
-
3
- module DevopsAssist
4
- module Gem
5
- module Gemspec
6
- include TR::CondUtils
7
-
8
- class GemspecError < StandardError; end
9
-
10
- def find_gem_name(root)
11
- spec = find_gemspec(root)
12
- s = ::Gem::Specification.load(spec)
13
- s.name
14
- end
15
-
16
- private
17
- def find_gemspec(root)
18
- if is_empty?(root)
19
- raise GemspecError, "Root path '#{root}' to find_gemspec is empty"
20
- else
21
- Dir.glob(File.join(root,"*.gemspec")).first
22
- end
23
- end
24
-
25
- end
26
- end
27
- end
28
-