regolith 0.1.22 → 0.1.25

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: 5fa276472ded40f3c9b79460cc8c603063bba90b2c9f3fe678b96671c519e2e5
4
- data.tar.gz: 05a30e0848e755bc2e55d4e83dcdca7b81593ab6c9ecb7a3d5b26baaa086fc31
3
+ metadata.gz: d447572c7f8e6230414cfb4b13ffeb32de77ec6f79612bfaccb620e9140466bc
4
+ data.tar.gz: 16c7e26aad9c1f8261d9a27a5acdaf86fb5a80321fcac227ee79ac7aeeade7af
5
5
  SHA512:
6
- metadata.gz: 57a83ef606eace382435a56faaa26c2dff33319d4bf32a2e0822c7192f8b31f80517e202f48d7964d95b6706e1b595a1d267f2b3fe8fa6ef3d5c5a767af1aa4f
7
- data.tar.gz: f8a8f96681e5453b855d1b4158f59bb5de2646c8b28e7231a7d83476dfaba2a70dcadc5f8d2114475b9abd588ef9295617fd62136ad57870874788637a3928e2
6
+ metadata.gz: efb74771a03f353f38818391cdb8acf34d6ecc7081443a270e714b286a846917528da0adea6dd675924166790a2a81215b710ce2d817e0769a985ff1edb0f8cf
7
+ data.tar.gz: 22ec3dafdab950d8d25b2d7ab92c8db6e7c41361603756524f955c01782d8fdd26fe8ce1aad4f2ecfb68d49d55aa9b4e067b0bca2b15401a0c9339478e1fef54
data/lib/regolith/cli.rb CHANGED
@@ -116,6 +116,10 @@ module Regolith
116
116
  exit 1
117
117
  end
118
118
 
119
+ # Fix bootsnap issue IMMEDIATELY after rails new
120
+ puts "🔧 Making bootsnap optional..."
121
+ make_bootsnap_optional(service_dir)
122
+
119
123
  # Overwrite Gemfile before bundle install
120
124
  puts "🔧 Overwriting Gemfile to remove sqlite3 and other defaults..."
121
125
 
@@ -172,26 +176,23 @@ module Regolith
172
176
  puts "→ Next: regolith generate service <another_service> or regolith server"
173
177
  end
174
178
 
175
- # --- New helper to make Bootsnap optional ---
179
+ # --- FIXED: Helper to make Bootsnap optional ---
176
180
  def make_bootsnap_optional(service_dir)
177
181
  boot_rb_path = File.join(service_dir, "config", "boot.rb")
178
182
  return unless File.exist?(boot_rb_path)
179
183
 
180
184
  boot = File.read(boot_rb_path)
181
- patched = boot.sub(
182
- /^\s*require\s+["']bootsnap\/setup["']\s*$/,
183
- <<~'RUBY'.strip
184
- begin
185
- require "bootsnap/setup"
186
- rescue LoadError
187
- warn "[regolith] bootsnap not found; continuing without it"
188
- end
189
- RUBY
190
- )
185
+
186
+ # Replace the entire bootsnap line (with or without comment)
187
+ patched = boot.gsub(/require\s+["']bootsnap\/setup["'].*$/, <<~'RUBY'.strip)
188
+ begin
189
+ require "bootsnap/setup"
190
+ rescue LoadError
191
+ warn "[regolith] bootsnap not found; continuing without it"
192
+ end
193
+ RUBY
191
194
 
192
- if patched != boot
193
- File.write(boot_rb_path, patched)
194
- end
195
+ File.write(boot_rb_path, patched)
195
196
  end
196
197
 
197
198
  def patch_rails_app(service_dir, service_name, port)
@@ -200,29 +201,28 @@ module Regolith
200
201
  File.write("#{initializer_dir}/regolith.rb", generate_regolith_initializer(service_name))
201
202
  File.write("#{service_dir}/Dockerfile", generate_dockerfile)
202
203
 
203
- # Call the Bootsnap patcher here
204
- make_bootsnap_optional(service_dir)
205
-
206
204
  app_rb_path = "#{service_dir}/config/application.rb"
207
205
  app_rb_content = File.read(app_rb_path)
208
206
 
209
207
  cors_config = <<~RUBY
208
+ # Regolith configuration
209
+ config.middleware.insert_before 0, Rack::Cors do
210
+ allow do
211
+ origins '*'
212
+ resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options, :head]
213
+ end
214
+ end
210
215
 
211
- # Regolith configuration
212
- config.middleware.insert_before 0, Rack::Cors do
213
- allow do
214
- origins '*'
215
- resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options, :head]
216
- end
217
- end
218
-
219
- config.regolith_service_name = '#{service_name}'
220
- config.regolith_service_port = #{port}
216
+ config.regolith_service_name = '#{service_name}'
217
+ config.regolith_service_port = #{port}
221
218
  RUBY
222
219
 
223
- app_rb_content.gsub!(/class Application < Rails::Application.*?
224
- end/m) do |match|
225
- match.gsub(/(\n end)$/, "#{cors_config}\1")
220
+ # Find the end of the Application class and insert before it
221
+ if app_rb_content =~ /^(\s*)end\s*$/
222
+ app_rb_content.gsub!(/^(\s*)end\s*$/) do |match|
223
+ indent = $1
224
+ "#{cors_config}\n#{indent}end"
225
+ end
226
226
  end
227
227
 
228
228
  File.write(app_rb_path, app_rb_content)
@@ -393,7 +393,7 @@ module Regolith
393
393
 
394
394
  COMMANDS:
395
395
  new <app_name> Create a new Regolith application
396
- generate service <name> Generate a new microservice
396
+ generate service <n> Generate a new microservice
397
397
  server Start all services with Docker Compose
398
398
  console <service_name> Open Rails console for a service
399
399
  version Show version information
@@ -1,4 +1,4 @@
1
1
  # lib/regolith/version.rb
2
2
  module Regolith
3
- VERSION = "0.1.22"
3
+ VERSION = "0.1.25"
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.22
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Regolith Team