securial 2.1.0 → 2.1.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 +4 -4
- data/lib/securial/cli.rb +26 -0
- data/lib/securial/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9c7a709db9d2a74edcd0d7d4046d280049a2d83fe63fbb8aa5d15b209ac39aa
|
4
|
+
data.tar.gz: 520a658e2797e57cdcb7ef1d365324b84ba2c57e2e1197974c7d76f516d7977e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf133510e6d9923775356f1ce0d8674289dafc8cc52e0f87faf10a156b9c24285d62d07fa5db4c32363f82bd40c714266c70c8694016d6cbf46bedcc58aab1af
|
7
|
+
data.tar.gz: f150c5a04805ea5a8d92b0833dd1e926265d8fb574534e3f146b7865c9c49b38514b8edf8069be7ee5e3f92b752eff52e05191d123abb30ac69f5db4cd359c7b
|
data/lib/securial/cli.rb
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
# $ securial new myapi --api --database=postgresql
|
15
15
|
#
|
16
16
|
require "optparse"
|
17
|
+
require "yaml"
|
18
|
+
require "erb"
|
17
19
|
|
18
20
|
# rubocop:disable Rails/Exit, Rails/Output
|
19
21
|
|
@@ -171,6 +173,7 @@ module Securial
|
|
171
173
|
puts "🏗️ Creating new Rails app: #{app_name}"
|
172
174
|
|
173
175
|
create_rails_app(app_name, rails_options)
|
176
|
+
update_database_yml_host(app_name)
|
174
177
|
add_securial_gem(app_name)
|
175
178
|
install_gems(app_name)
|
176
179
|
install_securial(app_name)
|
@@ -189,6 +192,29 @@ module Securial
|
|
189
192
|
run(rails_command)
|
190
193
|
end
|
191
194
|
|
195
|
+
# Adds DB_HOST env. variable to as default host in `database.yml`.
|
196
|
+
#
|
197
|
+
# @param app_name [String] name of the Rails application
|
198
|
+
# @return [void]
|
199
|
+
#
|
200
|
+
def update_database_yml_host(app_name)
|
201
|
+
db_config_path = File.join(app_name, "config", "database.yml")
|
202
|
+
raw = File.read(db_config_path)
|
203
|
+
rendered = ERB.new(raw).result
|
204
|
+
config = YAML.safe_load(rendered, aliases: true) || {}
|
205
|
+
|
206
|
+
config["default"] ||= {}
|
207
|
+
return if config["default"]["adapter"].blank?
|
208
|
+
return unless ["mysql2", "postgresql"].include?(config["default"]["adapter"])
|
209
|
+
config["default"]["host"] = "<%= ENV.fetch(\"DB_HOST\", \"localhost\") %>"
|
210
|
+
config["default"]["username"] = "<%= ENV.fetch(\"DB_USERNAME\") { \"postgres\" } %>"
|
211
|
+
config["default"]["password"] = "<%= ENV.fetch(\"DB_PASSWORD\") { \"postgres\" } %>"
|
212
|
+
|
213
|
+
# Dump YAML manually to preserve formatting
|
214
|
+
yaml = config.to_yaml.gsub(/['"](<%= .*? %>)['"]/, '\1') # Unquote the ERB
|
215
|
+
File.write(db_config_path, yaml)
|
216
|
+
end
|
217
|
+
|
192
218
|
# Adds the Securial gem to the application's Gemfile.
|
193
219
|
#
|
194
220
|
# @param app_name [String] name of the Rails application
|
data/lib/securial/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: securial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aly Badawy
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-07-
|
10
|
+
date: 2025-07-10 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -201,7 +201,7 @@ licenses:
|
|
201
201
|
- MIT
|
202
202
|
metadata:
|
203
203
|
homepage_uri: https://github.com/AlyBadawy/Securial/wiki
|
204
|
-
release_date: '2025-07-
|
204
|
+
release_date: '2025-07-10'
|
205
205
|
allowed_push_host: https://rubygems.org
|
206
206
|
source_code_uri: https://github.com/AlyBadawy/Securial
|
207
207
|
documentation_uri: https://alybadawy.github.io/Securial/_index.html
|