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 +4 -4
- data/lib/regolith/cli.rb +29 -29
- data/lib/regolith/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0ac619eb909b91c979771e9238eb1706bca5c53c77c1891c3fff99d2e82fd8c
|
4
|
+
data.tar.gz: 415b5a6f37bd51b5e0067f4ecf18880d27a555780e79e347d26f6e27d341a59d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
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
|
-
|
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
|
-
|
213
|
-
|
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
|
-
|
225
|
-
|
226
|
-
|
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 <
|
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
|
data/lib/regolith/version.rb
CHANGED