yamine 0.8.0 → 0.8.1

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
2
  SHA256:
3
- metadata.gz: 04f00c2029bf4cda65d187225d251fc594bacf538092e6a56d9c5a03f9aa47fd
4
- data.tar.gz: 963f1c74d64ddb94199d42325f6d8631a5dd2d618119554a4e1a72849394c5bc
3
+ metadata.gz: 46a9c0208ca1d5581c3c25d45b60370a6e37c7dd4fcf721bda7a5573fc1c70db
4
+ data.tar.gz: 0b534671965987794b3872969dcc3065dfca5532a401f12701e531a0779e7820
5
5
  SHA512:
6
- metadata.gz: 2e02efba8d7c16767b0c4b8908d295f4c095f7c32f5ef90885e1ecf0a50aa68d61cb9e0c780d3729f703fcc14fc282eed46430d4efce631762dbb832ddecf408
7
- data.tar.gz: 6d36c287b907fcfba07da2db3ecf1904ff4b396fb2bf8df277e0f9dfb23515e9245d574fb0bed85a034cd9f41fae14834842c722c3ac298e9f0fafedb1d30b45
6
+ metadata.gz: 339e64fabec8dab3c019bfdec8ec8f9f558dc4700b647fd462c4898e4f8796f93c1b65078d9ff171c338f38c70d055a8185b1d21bb547c63831bd816c5b7c6de
7
+ data.tar.gz: a71d56eef8327103f46a050307bb01095810ccd70085f3728a430617d3230cf567ffe3e9a04047428d6988d63efa7dd6965546bbb5e689f270991f8d4cc55d6d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.1] — 2026-09-10
4
+
5
+ ### Fixed
6
+
7
+ - **An already-correct `/etc/hosts` no longer reports a failure.**
8
+ `Hosts.sync` rewrote the file unconditionally, so on a normal machine
9
+ (where `/etc/hosts` is root-owned) it raised `Errno::EACCES`, returned
10
+ false, and made `yamine start` print "could not write /etc/hosts (try
11
+ sudo yamine hosts sync)" on every boot — pointing at an elevated write
12
+ for a file that already had exactly the right block. `synced?` existed
13
+ for precisely this guard but `sync` never consulted it. `sync` is now a
14
+ no-op returning true when the block already matches, and the setup step
15
+ reports "already lists N hostname(s)" instead of implying a failure.
16
+ Chrome/Firefox/Edge resolve `*.localhost` natively anyway; the file only
17
+ matters for Safari and custom TLDs.
18
+
19
+
3
20
  ## [0.8.0] — 2026-09-10
4
21
 
5
22
  ### Fixed
@@ -220,6 +220,8 @@ module Yamine
220
220
  hostnames = ctx.store.load_routes.map { |r| r["hostname"] }
221
221
  if hostnames.empty?
222
222
  puts " No routes registered yet — hosts sync will happen on the next boot."
223
+ elsif Yamine::Hosts.synced?(hostnames)
224
+ puts " /etc/hosts already lists #{hostnames.length} hostname(s)."
223
225
  elsif Yamine::Hosts.sync(hostnames)
224
226
  puts " Synced #{hostnames.length} hostname(s) to /etc/hosts."
225
227
  else
@@ -758,8 +760,12 @@ module Yamine
758
760
  end
759
761
  end
760
762
 
761
- # 3. Hosts (best-effort: only needed for Safari; warn, don't fail)
762
- unless Hosts.sync(ctx.store.load_routes.map { |r| r["hostname"] })
763
+ # 3. Hosts (best-effort: only needed for Safari and custom TLDs —
764
+ # Chrome/Firefox/Edge resolve *.localhost natively). Already-synced
765
+ # is the common case and must stay silent: warning there sent
766
+ # people to a sudo write for a file that needed nothing.
767
+ hostnames = ctx.store.load_routes.map { |r| r["hostname"] }
768
+ unless hostnames.empty? || Yamine::Hosts.synced?(hostnames) || Hosts.sync(hostnames)
763
769
  warn "Warning: could not write /etc/hosts (try sudo yamine hosts sync)."
764
770
  end
765
771
  end
data/lib/yamine/hosts.rb CHANGED
@@ -41,7 +41,20 @@ module Yamine
41
41
  names
42
42
  end
43
43
 
44
+ # Bring the managed block to exactly these hostnames. Idempotent: when
45
+ # the block already matches, this is a no-op returning true.
46
+ #
47
+ # The short-circuit is load-bearing, not an optimization. /etc/hosts is
48
+ # root-owned on a normal machine, so a rewrite fails without sudo — and
49
+ # `setup` and every boot's workstation check run this. Without the
50
+ # guard, a machine whose hosts file was already correct got a
51
+ # "could not write /etc/hosts (try sudo yamine hosts sync)" warning on
52
+ # every run, sending people to an elevated write for a file that
53
+ # needed nothing. (Chrome/Firefox/Edge resolve *.localhost natively;
54
+ # /etc/hosts only matters for Safari and custom TLDs.)
44
55
  def sync(hostnames, path = PATH)
56
+ return true if synced?(hostnames, path)
57
+
45
58
  content = read(path)
46
59
  block = managed_block(hostnames)
47
60
  if content.include?(BEGIN_MARKER)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yamine
4
- VERSION = "0.8.0"
4
+ VERSION = "0.8.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto