Class: Inquirex::Tools::Versions
- Inherits:
-
Object
- Object
- Inquirex::Tools::Versions
- Defined in:
- lib/inquirex/tools/versions.rb
Overview
Reports and enforces version parity across the lockstep packages.
Instance Method Summary collapse
-
#check ⇒ Boolean
Prints the current state of every lockstep package.
-
#initialize(workspace: Workspace.new, out: $stdout) ⇒ Versions
constructor
A new instance of Versions.
-
#preflight ⇒ Boolean
Parity plus git readiness: clean tree, on main, tagged at the version.
-
#set(version) ⇒ Boolean
Moves every lockstep package to one version.
Constructor Details
Instance Method Details
#check ⇒ Boolean
Prints the current state of every lockstep package.
23 24 25 26 27 |
# File 'lib/inquirex/tools/versions.rb', line 23 def check versions = @workspace.versions print_table(versions) verdict(versions) end |
#preflight ⇒ Boolean
Parity plus git readiness: clean tree, on main, tagged at the version.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/inquirex/tools/versions.rb', line 62 def preflight ok = check target = @workspace.versions.values.compact.uniq.first @out.puts @out.puts "Release readiness:" Workspace::LOCKSTEP.each_key do |name| problems = readiness_problems(name, target) @out.puts format(" %<name>-16s %<state>s", name: name, state: problems.empty? ? "ready" : problems.join(", ")) ok &&= problems.empty? end @out.puts @out.puts ok ? "ALL READY — publish with `gem push` / `npm publish`" : "NOT READY — resolve the above" ok end |
#set(version) ⇒ Boolean
Moves every lockstep package to one version.
Refuses to move backwards: a version already published cannot be reissued, so the target must exceed every current value.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/inquirex/tools/versions.rb', line 36 def set(version) unless /\A\d+\.\d+\.\d+\z/.match?(version.to_s) @out.puts "ERROR: #{version.inspect} is not MAJOR.MINOR.PATCH" return false end current = @workspace.versions.values.compact highest = current.max_by { Gem::Version.new(_1) } if highest && Gem::Version.new(highest) > Gem::Version.new(version) @out.puts "ERROR: #{version} is below the highest existing version (#{highest}) — versions only go forward" return false end @out.puts "Setting all lockstep packages to #{version}:" @workspace.versions.each do |name, was| @workspace.write_version(name, version) @out.puts format(" %-16s %s -> %s", name, was || "?", version) end @out.puts @out.puts "Unchanged (excluded): #{Workspace::EXCLUDED.join(", ")}" true end |