Class: Inquirex::Tools::VersionChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/inquirex/tools/version_checker.rb

Overview

Reports version parity across the lockstep packages.

Read-only by construction: nothing here writes a version file. Bumping is VersionBumper's job. The split means a check can be run anywhere — CI, a dirty tree, a colleague's checkout — with no chance of editing something, and the two behaviours no longer share a flag that decides which happens.

Examples:

Check for drift

Inquirex::Tools::VersionChecker.new.call   # => false when versions differ

Instance Method Summary collapse

Constructor Details

#initialize(workspace: Workspace.new, out: $stdout) ⇒ VersionChecker

Returns a new instance of VersionChecker.

Parameters:

  • workspace (Workspace) (defaults to: Workspace.new)

    the ecosystem checkout to inspect

  • out (IO) (defaults to: $stdout)

    where report output goes



20
21
22
23
# File 'lib/inquirex/tools/version_checker.rb', line 20

def initialize(workspace: Workspace.new, out: $stdout)
  @workspace = workspace
  @out = out
end

Instance Method Details

#callBoolean

Prints the current state of every lockstep package.

Returns:

  • (Boolean)

    true when all packages agree on one version



28
29
30
31
32
# File 'lib/inquirex/tools/version_checker.rb', line 28

def call
  versions = workspace.versions
  print_table(versions)
  verdict(versions)
end

#preflightBoolean

Parity plus git readiness: clean tree, on main, tagged at the version.

Returns:

  • (Boolean)

    true when every package could be published now



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/inquirex/tools/version_checker.rb', line 37

def preflight
  ok = call
  target = workspace.versions.values.compact.uniq.first
  out.puts
  out.puts "Release readiness:"

  Workspace::LOCKSTEP.each_key do |name|
    problems = readiness_problems(name, target)
    # `.green`, not `.bright_green`: colored2 defines no such method, so
    # the ready branch raised NoMethodError — and only the ready branch,
    # which is why a preflight that found problems looked fine.
    out.puts format("  %<name>-16s %<state>s", name: name, state: problems.empty? ? "ready".green : problems.join(", ").red)
    ok &&= problems.empty?
  end

  out.puts
  out.puts ok ? "ALL READY — publish with `gem push` / `npm publish`" : "NOT READY — resolve the above"
  ok
end