revision 1.1.8 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3468f9abbbf29f495889d79516418d7c34bb656a
4
- data.tar.gz: c006ab6ee5fda1595435c063d9c46db21e0a2860
2
+ SHA256:
3
+ metadata.gz: d2d84d1534e531c997a760126339a1ef9e7971b2aac9d147fc1b59894e18ac48
4
+ data.tar.gz: 7f2f9c98c10b454cc4e719fec0414e83fcd127d5ede7f111708ab8cf2c23cd6a
5
5
  SHA512:
6
- metadata.gz: c1b33a1fcb7dc75f77b1f702d71314b20e70c8fa5645b325397d16008890f9f91c2b1960627adc6d9561dee3a422752ee47b82a17308c2102998fb8853955b25
7
- data.tar.gz: a77d3ab85ad9354eaca164df18a3d31ea1cd534aea6d8b15042378d9f6867f3904264637f361d2c545c8e46c92404c44e85ff0914403aeba34cdef3712c6b0e8
6
+ metadata.gz: b8351cbc09d81a425683be3d7ca049daf1cf0576310ed396812675ac1adb8b6e525bfdcb168b90e5b259d5e5d0bd90ebe7c8c79e1bd41a16f77083abbfe0a0a6
7
+ data.tar.gz: 5249761e6c2ec29ab1887688c96bdded06d298140c9919020f80fd7a19928824840888b0ad9ac8002b08bbe52b768736eac9232d765813eb99807d7c437f24fa
data/lib/revision/cli.rb CHANGED
@@ -17,9 +17,9 @@ module Revision
17
17
  @releasables = Releasable.from_folder(wd)
18
18
  break
19
19
  rescue Errors::NoDefinition
20
- break if wd == File.expand_path('..',wd)
20
+ break if wd == File.expand_path('..', wd)
21
21
  puts "No releasable found in #{wd}, trying parent..."
22
- wd = File.expand_path('..',wd)
22
+ wd = File.expand_path('..', wd)
23
23
  next
24
24
  end
25
25
  end
@@ -27,46 +27,63 @@ module Revision
27
27
  @id = options[:id] || @releasables.keys[0]
28
28
  end
29
29
 
30
- desc "info", 'Display info for all defined releasables'
30
+ desc 'info', 'Display info for all defined releasables'
31
31
  def info
32
32
  puts "Found #{@releasables.values.length} releasables"
33
33
  puts ''
34
- puts @releasables.values.map {|r| r.to_s}.join("\n\n")
34
+ puts @releasables.values.map(&:to_s).join("\n\n")
35
35
  puts ''
36
36
  puts "Default releasable ID: #{@id}"
37
37
  end
38
38
 
39
- desc "patch", "Increment patch revision index"
39
+ desc 'patch', 'Increment patch revision index'
40
40
  def patch
41
41
  do_increment('patch')
42
42
  end
43
43
 
44
- desc "minor", "Increment minor revision index"
44
+ desc 'minor', 'Increment minor revision index'
45
45
  def minor
46
46
  do_increment('minor')
47
47
  end
48
48
 
49
- desc "major", "Increment major revision index"
49
+ desc 'major', 'Increment major revision index'
50
50
  def major
51
51
  do_increment('major')
52
52
  end
53
53
 
54
- desc "archive", "Archive releasables"
54
+ desc 'build', 'Build releasable(s)'
55
+ method_option :skip, :aliases => "-s", :type => :numeric, :default => 0, :desc => "Skip the specified number of build steps"
56
+ def build
57
+ selected = options[:id].nil? ? @releasables.values : [@releasables[options[:id]]]
58
+ puts "Building #{selected.length} releasable(s)..."
59
+ # selected.each(&:build)
60
+ selected.each { |r| r.build(options[:skip])}
61
+ end
62
+
63
+ desc 'archive', 'Archive releasables'
55
64
  def archive
56
65
  selected = options[:id].nil? ? @releasables.values : [@releasables[options[:id]]]
57
66
  puts "Archiving #{selected.length} releasables..."
58
67
  selected.each do |r|
59
- r.build
60
68
  r.archive
61
69
  end
62
70
  end
63
71
 
64
- desc "changelog", "Display change log on stdout"
72
+ desc 'package', 'Build and archive releasables'
73
+ def package
74
+ selected = options[:id].nil? ? @releasables.values : [@releasables[options[:id]]]
75
+ puts "Building and archiving #{selected.length} releasables..."
76
+ selected.each do |r|
77
+ r.package
78
+ end
79
+ end
80
+
81
+ desc 'changelog', 'Display change log on stdout'
65
82
  def changelog
66
83
  select_one.output_changelog($stdout)
67
84
  end
68
85
 
69
- desc "tag", "Commit the current revision to a local git repo and add a version tag"
86
+ desc 'tag', 'Commit the current revision to a local git repo and add a version tag'
70
87
  def tag
71
88
  select_one.tag
72
89
  end
@@ -83,10 +100,13 @@ module Revision
83
100
  increment_method = "#{type}_increment!"
84
101
  say "Incrementing #{r.revision} to #{r.revision.public_send(increment_method)}"
85
102
  options[:dryrun] ? r.revision.write_to_file : r.revision.write!
86
- say ""
103
+ say ''
87
104
  say "The automatic commit / tag step assumes you're only checking in changes to existing files"
88
105
  say "You can answer 'n' at the prompt and use 'revision tag' to generate a commit with the latest changelog entry and an associated tag after manually adding any new files to the repo"
89
106
  say ""
107
+ if ask("Rebuild and archive any releasables (Y/n)?").upcase!='N'
108
+ r.package
109
+ end
90
110
  if ask("Commit changes to existing files and add a Git tag (y/N)?").upcase=='Y'
91
111
  r.tag
92
112
  if ask("Push changes/tag to origin (Y/n)?").upcase=='N' || !r.push
data/lib/revision/info.rb CHANGED
@@ -71,7 +71,7 @@ class Revision::Info
71
71
  text.gsub!(@regex) { |match| "#{$~[:prefix]}#{@major}#{$~[:sep1]}#{@minor}#{$~[:sep2]}#{@patch}#{$~[:postfix]}" }
72
72
 
73
73
  #Insert start/end tags if not present
74
- text += new_changelog unless text.match(CHANGELOG_START)
74
+ text += new_changelog_placeholder unless text.match(CHANGELOG_START)
75
75
 
76
76
  text.gsub!(CHANGELOG_START) { |match| [match, format_changelog_entry(entry)].join("\n") }
77
77
 
@@ -59,7 +59,7 @@ module Revision
59
59
  @root = Pathname.new(root).realpath
60
60
  @id = config[:id] || File.basename(@root)
61
61
  @revision = Info.new(File.join(@root,config[:revision][:src]), regex: config[:revision][:regex], comment_prefix: config[:revision][:comment_prefix])
62
- @build_steps = config[:build_steps]
62
+ @build_def = config[:build] ? config[:build] : { environment: { variables: {}}, steps: config[:build_steps]}
63
63
  @artefacts = config[:artefacts]
64
64
  @artefacts.each { |a| a[:dest] ||= a[:src] }
65
65
  end
@@ -68,21 +68,45 @@ module Revision
68
68
  <<~EOT
69
69
  #{@id} v#{@revision} @ #{@root}
70
70
 
71
+ Build environment:
72
+ #{@build_def[:environment]}
73
+
71
74
  Build pipeline:
72
- - #{@build_steps.join("\n - ")}
75
+ - #{@build_def[:steps].join("\n - ")}
73
76
 
74
77
  Build artefacts:
75
78
  #{artefacts.map{ |a| "- #{a[:src]}\n => #{a[:dest]}" }.join("\n")}
79
+
76
80
  EOT
77
81
  end
78
82
 
79
- def build
80
- puts "Executing #{@build_steps.length} build steps..."
83
+ def build(skip_steps = 0)
84
+ if @build_def.dig(:environment, :variables)
85
+ @build_def[:environment][:variables].each do |key, value|
86
+ if(key.match?('PATH'))
87
+ if Gem.win_platform?
88
+ value.gsub!(':', ';')
89
+ value.gsub!('/', '\\')
90
+ else
91
+ value.gsub!(':', ';')
92
+ value.gsub!('\\', '/')
93
+ end
94
+ # value.gsub!('/',Gem.win_platform? ? '\' : '/')
95
+ # value.gsub!('\',Gem.win_platform? ? '\' : '/')
96
+ value.gsub!('~', Dir.home)
97
+ end
98
+ puts "Setting environment variable '#{key}' to '#{value}'"
99
+ ENV[key] = value
100
+ end
101
+ end
102
+ steps = @build_def[:steps][skip_steps..-1]
103
+ puts "Executing #{steps.length} of #{@build_def[:steps].length} build steps..."
81
104
  Dir.chdir(@root) do
82
- @build_steps.each_with_index do |step, index|
83
- puts "... (#{index+1}/#{@build_steps.length}) #{step}"
105
+ steps.each_with_index do |step, index|
106
+ step_index = index+1+skip_steps
107
+ puts "... (#{step_index}/#{@build_def[:steps].length}) #{step}"
84
108
  system(step)
85
- puts "WARNING: build step #{index}: #{step} exit status #{$?.exitstatus}" unless $?.exitstatus.zero?
109
+ puts "WARNING: build step #{step_index}: #{step} exit status #{$?.exitstatus}" unless $?.exitstatus.zero?
86
110
  end
87
111
  end
88
112
  end
@@ -133,6 +157,11 @@ module Revision
133
157
  @artefacts.each_with_index do |a, index|
134
158
  src = a[:src].gsub(REVISION_PLACEHOLDER, @revision.to_s)
135
159
  dest = a[:dest].gsub(REVISION_PLACEHOLDER, @revision.to_s)
160
+ if Gem.win_platform? && !src.end_with?('.exe') && File.exist?(File.join(@root, src + '.exe'))
161
+ puts "... packing on windows -- appending '.exe'"
162
+ src += '.exe'
163
+ dest += '.exe' unless dest.end_with?('.exe')
164
+ end
136
165
  puts "... (#{index+1}/#{@artefacts.length}) #{src} => #{dest}"
137
166
  zipfile.add(dest, File.join(@root, src))
138
167
  end
@@ -141,6 +170,11 @@ module Revision
141
170
  end
142
171
  end
143
172
 
173
+ def package
174
+ build
175
+ archive
176
+ end
177
+
144
178
  def output_changelog(output_stream)
145
179
  output_stream.puts "Revision history for #{@id} version #{@revision}"
146
180
  output_stream.puts ""
File without changes
@@ -1,10 +1,23 @@
1
1
  # Defines the revision ID for the revision gem
2
2
  module Revision
3
- VERSION = "1.1.8"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
 
6
6
  # <BEGIN CHANGELOG>
7
7
  #
8
+ # Version 1.2.0 (06 Mar 2018)
9
+ # - Build definition improvements (and new yaml structure)
10
+ # - Added platform-agnostic environment variable definition (handles '~' replacement and :/; path separators)
11
+ # - Added platform-agnostic packaging of binaries (i.e. appending .exe for windows when archiving)
12
+ #
13
+ # Version 1.1.10 (16 Feb 2018)
14
+ # - Modified 'archive' command to just archive existing artefact -- i.e. skip build phase
15
+ # - Added 'package' command that builds AND archives
16
+ #
17
+ # Version 1.1.9 (16 Feb 2018)
18
+ # - Fixed bug when adding first changelog entry to file without existing placeholders
19
+ # - Added standalone build command
20
+ #
8
21
  # Version 1.1.8 (15 Dec 2017)
9
22
  # - Added .yardopts to build documentation
10
23
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revision
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cormac Cannon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-15 00:00:00.000000000 Z
11
+ date: 2018-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.6.13
145
+ rubygems_version: 2.7.7
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Language-agnostic revision management tool