regolith 0.1.26 → 0.1.27

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: b0ac619eb909b91c979771e9238eb1706bca5c53c77c1891c3fff99d2e82fd8c
4
- data.tar.gz: 415b5a6f37bd51b5e0067f4ecf18880d27a555780e79e347d26f6e27d341a59d
3
+ metadata.gz: 973264713948f2e5db2ff16f9e3b8c1d3a8655658315965fd40ddd4e977d9a6e
4
+ data.tar.gz: 5643b91bcf2e95c3f2e47851409e28c2c0993a72fea4f7ab42d18911fa0314a9
5
5
  SHA512:
6
- metadata.gz: 1e70b07ed8e9bb4caf3713824b655e53e23525fe7ac0824d5ce26f6b2dfff9869472346197f5c1d89f1852f3a68d3d5cae07df7e4a4e02936531941a1a30777b
7
- data.tar.gz: d2166421a7ac77330c152a44b1eab6295fa1494738c5c6095d01803e39d2d8bf667275cce8e60c5795ae25de879dc4476565468fdfd96f709b712bdf3eb726cd
6
+ metadata.gz: e934b3a272665af2195a4a0987705605477f2a0ff0fc53f38406c19ccbb50d94fef8696df638272d31cf0f18431d1207445a4d894d797c1b77abd5708c6d5b26
7
+ data.tar.gz: f6d5df82730c20811d366b100aa9d666cd1662e060aa71387c2b571014d36105952ee5d7d90bf8afd3b1e2cf844070e0dcf7b4d2214339b76d600e9d6407c900
data/lib/regolith/cli.rb CHANGED
@@ -177,7 +177,45 @@ module Regolith
177
177
  puts "→ Next: regolith generate service <another_service> or regolith server"
178
178
  end
179
179
 
180
- # --- FIXED: Helper to make Bootsnap optional ---
180
+ # --- Port collision prevention ---
181
+ def port_available?(port)
182
+ # Check if port is free on the system
183
+ begin
184
+ server = TCPServer.new('127.0.0.1', port)
185
+ server.close
186
+ true
187
+ rescue Errno::EADDRINUSE, Errno::EACCES
188
+ false
189
+ end
190
+ end
191
+
192
+ def find_available_port(config, starting_port = 3001)
193
+ used_ports = config['services'].values.map { |s| s['port'] }.compact
194
+ port = starting_port
195
+
196
+ loop do
197
+ if !used_ports.include?(port) && port_available?(port)
198
+ puts "🔌 Assigned port #{port}"
199
+ return port
200
+ end
201
+
202
+ if used_ports.include?(port)
203
+ puts "⚠️ Port #{port} already used by another Regolith service"
204
+ else
205
+ puts "⚠️ Port #{port} already in use by system"
206
+ end
207
+
208
+ port += 1
209
+
210
+ # Safety check - don't go crazy high
211
+ if port > 4000
212
+ puts "❌ Error: No available ports found in range #{starting_port}-4000"
213
+ exit 1
214
+ end
215
+ end
216
+ end
217
+
218
+ # --- Helper to make Bootsnap optional ---
181
219
  def make_bootsnap_optional(service_dir)
182
220
  boot_rb_path = File.join(service_dir, "config", "boot.rb")
183
221
  return unless File.exist?(boot_rb_path)
@@ -1,4 +1,4 @@
1
1
  # lib/regolith/version.rb
2
2
  module Regolith
3
- VERSION = "0.1.26"
3
+ VERSION = "0.1.27"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regolith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Regolith Team