inquirex-tools 0.8.0 → 0.9.4

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.
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Inquirex
4
- module Tools
5
- module Commands
6
- # Reports and enforces version parity across the lockstep packages.
7
- #
8
- # Plural on purpose: `inquirex version` prints this tool's own version,
9
- # `inquirex versions` manages the family's.
10
- class Versions < Dry::CLI::Command
11
- desc "Check, set, or preflight the family's lockstep version"
12
-
13
- option :set, type: :string, desc: "Move every lockstep package to this version"
14
- option :preflight, type: :boolean, default: false,
15
- desc: "Also check clean trees, main branch, and tags"
16
-
17
- example [
18
- " # report parity, exit 1 on drift",
19
- "--set 0.8.0 # move all five packages",
20
- "--preflight # release readiness"
21
- ]
22
-
23
- # @param set [String, nil] target version
24
- # @param preflight [Boolean]
25
- # @return [void]
26
- def call(set: nil, preflight: false, **)
27
- versions = Inquirex::Tools::Versions.new
28
- ok =
29
- if set then versions.set(set)
30
- elsif preflight then versions.preflight
31
- else versions.check
32
- end
33
- exit(1) unless ok
34
- rescue Inquirex::Tools::Error => e
35
- warn "ERROR: #{e.message}"
36
- exit 1
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubygems/version"
4
- require_relative "workspace"
5
-
6
- module Inquirex
7
- module Tools
8
- # Reports and enforces version parity across the lockstep packages.
9
- #
10
- # @example Check for drift
11
- # Inquirex::Tools::Versions.new.check # => false when versions differ
12
- class Versions
13
- # @param workspace [Workspace]
14
- # @param out [IO] where report output goes
15
- def initialize(workspace: Workspace.new, out: $stdout)
16
- @workspace = workspace
17
- @out = out
18
- end
19
-
20
- # Prints the current state of every lockstep package.
21
- #
22
- # @return [Boolean] true when all packages agree on one version
23
- def check
24
- versions = @workspace.versions
25
- print_table(versions)
26
- verdict(versions)
27
- end
28
-
29
- # Moves every lockstep package to one version.
30
- #
31
- # Refuses to move backwards: a version already published cannot be
32
- # reissued, so the target must exceed every current value.
33
- #
34
- # @param version [String] target, MAJOR.MINOR.PATCH
35
- # @return [Boolean] true when written
36
- def set(version)
37
- unless /\A\d+\.\d+\.\d+\z/.match?(version.to_s)
38
- @out.puts "ERROR: #{version.inspect} is not MAJOR.MINOR.PATCH"
39
- return false
40
- end
41
-
42
- current = @workspace.versions.values.compact
43
- highest = current.max_by { Gem::Version.new(_1) }
44
- if highest && Gem::Version.new(highest) > Gem::Version.new(version)
45
- @out.puts "ERROR: #{version} is below the highest existing version (#{highest}) — versions only go forward"
46
- return false
47
- end
48
-
49
- @out.puts "Setting all lockstep packages to #{version}:"
50
- @workspace.versions.each do |name, was|
51
- @workspace.write_version(name, version)
52
- @out.puts format(" %-16s %s -> %s", name, was || "?", version)
53
- end
54
- @out.puts
55
- @out.puts "Unchanged (excluded): #{Workspace::EXCLUDED.join(", ")}"
56
- true
57
- end
58
-
59
- # Parity plus git readiness: clean tree, on main, tagged at the version.
60
- #
61
- # @return [Boolean] true when every package could be published now
62
- def preflight
63
- ok = check
64
- target = @workspace.versions.values.compact.uniq.first
65
- @out.puts
66
- @out.puts "Release readiness:"
67
-
68
- Workspace::LOCKSTEP.each_key do |name|
69
- problems = readiness_problems(name, target)
70
- @out.puts format(" %<name>-16s %<state>s", name: name, state: problems.empty? ? "ready" : problems.join(", "))
71
- ok &&= problems.empty?
72
- end
73
-
74
- @out.puts
75
- @out.puts ok ? "ALL READY — publish with `gem push` / `npm publish`" : "NOT READY — resolve the above"
76
- ok
77
- end
78
-
79
- private
80
-
81
- # @param versions [Hash{String => String, nil}]
82
- # @return [void]
83
- def print_table(versions)
84
- @out.puts "Lockstep packages (#{Workspace::EXCLUDED.join(", ")} excluded by design):"
85
- versions.each do |name, version|
86
- @out.puts format(" %<name>-16s %<kind>-4s %<version>s",
87
- name: name, kind: Workspace::LOCKSTEP[name], version: version || "MISSING")
88
- end
89
- @out.puts
90
- end
91
-
92
- # @param versions [Hash{String => String, nil}]
93
- # @return [Boolean] true when every package agrees on one version
94
- def verdict(versions)
95
- distinct = versions.values.compact.uniq
96
- if versions.value?(nil)
97
- @out.puts "DRIFT: a version could not be read (MISSING above)"
98
- false
99
- elsif distinct.one?
100
- @out.puts "OK: all #{versions.size} at #{distinct.first}"
101
- true
102
- else
103
- @out.puts "DRIFT: #{distinct.sort.join(", ")} — run `inquirex versions --set <version>`"
104
- false
105
- end
106
- end
107
-
108
- # Why a package is not publishable right now.
109
- #
110
- # @param name [String] package name
111
- # @param target [String, nil] the version its tag must match
112
- # @return [Array<String>] empty when ready
113
- def readiness_problems(name, target)
114
- state = @workspace.git_state(name)
115
- return [ "no git checkout" ] if state[:clean].nil?
116
-
117
- problems = []
118
- problems << "DIRTY" unless state[:clean]
119
- problems << "on #{state[:branch]}" unless state[:branch] == "main"
120
- problems << "untagged" unless state[:tags].any? { |tag| tag.delete_prefix("v") == target }
121
- problems
122
- end
123
- end
124
- end
125
- end