regolith 0.1.23 → 0.1.26

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: 41ea8405c6a144230c7f4be3a1e2605cc2f80f05524850bad3e680e37d4187b4
4
- data.tar.gz: c4ba815538da010c8f3b23b3b27b2c84b107d1d3ad64c267a7d0efe5c6ce4487
3
+ metadata.gz: b0ac619eb909b91c979771e9238eb1706bca5c53c77c1891c3fff99d2e82fd8c
4
+ data.tar.gz: 415b5a6f37bd51b5e0067f4ecf18880d27a555780e79e347d26f6e27d341a59d
5
5
  SHA512:
6
- metadata.gz: d2b4ca0d0e63b168706b29a54cb5344b7fe1a83cbc184773f848eafd73155aba7ed0748177ae22fab09c9e0c9df6c55ab0bf685e27104d9713831290fa1fe7d8
7
- data.tar.gz: 757cf66d57106245541095029d9aea8f24b43aaae2a231afabc715dc3546308509c6f5077c631fe7722ed066150f9f586dc21a1bbba17a5a1bb7b0fd622bd1d6
6
+ metadata.gz: 1e70b07ed8e9bb4caf3713824b655e53e23525fe7ac0824d5ce26f6b2dfff9869472346197f5c1d89f1852f3a68d3d5cae07df7e4a4e02936531941a1a30777b
7
+ data.tar.gz: d2166421a7ac77330c152a44b1eab6295fa1494738c5c6095d01803e39d2d8bf667275cce8e60c5795ae25de879dc4476565468fdfd96f709b712bdf3eb726cd
data/lib/regolith/cli.rb CHANGED
@@ -3,6 +3,7 @@ require 'yaml'
3
3
  require 'erb'
4
4
  require 'timeout'
5
5
  require 'rubygems'
6
+ require 'socket'
6
7
 
7
8
  module Regolith
8
9
  class CLI
@@ -85,7 +86,7 @@ module Regolith
85
86
  def generate_service(service_name)
86
87
  puts "🔧 Creating service '#{service_name}'..."
87
88
  config = load_regolith_config
88
- port = 3001 + (config['services']&.size || 0)
89
+ port = find_available_port(config)
89
90
  service_dir = "services/#{service_name}_service"
90
91
 
91
92
  puts " → Generating Rails API app..."
@@ -176,26 +177,23 @@ module Regolith
176
177
  puts "→ Next: regolith generate service <another_service> or regolith server"
177
178
  end
178
179
 
179
- # --- Helper to make Bootsnap optional ---
180
+ # --- FIXED: Helper to make Bootsnap optional ---
180
181
  def make_bootsnap_optional(service_dir)
181
182
  boot_rb_path = File.join(service_dir, "config", "boot.rb")
182
183
  return unless File.exist?(boot_rb_path)
183
184
 
184
185
  boot = File.read(boot_rb_path)
185
- patched = boot.sub(
186
- /^\s*require\s+["']bootsnap\/setup["']\s*$/,
187
- <<~'RUBY'.strip
188
- begin
189
- require "bootsnap/setup"
190
- rescue LoadError
191
- warn "[regolith] bootsnap not found; continuing without it"
192
- end
193
- RUBY
194
- )
186
+
187
+ # Replace the entire bootsnap line (with or without comment)
188
+ patched = boot.gsub(/require\s+["']bootsnap\/setup["'].*$/, <<~'RUBY'.strip)
189
+ begin
190
+ require "bootsnap/setup"
191
+ rescue LoadError
192
+ warn "[regolith] bootsnap not found; continuing without it"
193
+ end
194
+ RUBY
195
195
 
196
- if patched != boot
197
- File.write(boot_rb_path, patched)
198
- end
196
+ File.write(boot_rb_path, patched)
199
197
  end
200
198
 
201
199
  def patch_rails_app(service_dir, service_name, port)
@@ -208,22 +206,24 @@ module Regolith
208
206
  app_rb_content = File.read(app_rb_path)
209
207
 
210
208
  cors_config = <<~RUBY
209
+ # Regolith configuration
210
+ config.middleware.insert_before 0, Rack::Cors do
211
+ allow do
212
+ origins '*'
213
+ resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options, :head]
214
+ end
215
+ end
211
216
 
212
- # Regolith configuration
213
- config.middleware.insert_before 0, Rack::Cors do
214
- allow do
215
- origins '*'
216
- resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options, :head]
217
- end
218
- end
219
-
220
- config.regolith_service_name = '#{service_name}'
221
- config.regolith_service_port = #{port}
217
+ config.regolith_service_name = '#{service_name}'
218
+ config.regolith_service_port = #{port}
222
219
  RUBY
223
220
 
224
- app_rb_content.gsub!(/class Application < Rails::Application.*?
225
- end/m) do |match|
226
- match.gsub(/(\n end)$/, "#{cors_config}\1")
221
+ # Find the end of the Application class and insert before it
222
+ if app_rb_content =~ /^(\s*)end\s*$/
223
+ app_rb_content.gsub!(/^(\s*)end\s*$/) do |match|
224
+ indent = $1
225
+ "#{cors_config}\n#{indent}end"
226
+ end
227
227
  end
228
228
 
229
229
  File.write(app_rb_path, app_rb_content)
@@ -394,7 +394,7 @@ module Regolith
394
394
 
395
395
  COMMANDS:
396
396
  new <app_name> Create a new Regolith application
397
- generate service <name> Generate a new microservice
397
+ generate service <n> Generate a new microservice
398
398
  server Start all services with Docker Compose
399
399
  console <service_name> Open Rails console for a service
400
400
  version Show version information
@@ -1,4 +1,4 @@
1
1
  # lib/regolith/version.rb
2
2
  module Regolith
3
- VERSION = "0.1.23"
3
+ VERSION = "0.1.26"
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.23
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Regolith Team