rrx_rails 8.0.2 → 8.0.3
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/rrx_rails/cli.rb +36 -1
- data/lib/rrx_rails/version.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef2d0e1f3424f242167d0350362c61d754375e3b7f3dd48f7426d40501937828
|
|
4
|
+
data.tar.gz: a2493bb1d2a2efa2394c1aba1014951561fe1e35703263fbeafca8ad05af8705
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe0a2840b7396397f54549a1ebf4fb4fabaaa87658105a57541a17dadd4588f5a05b94b681b7f100afa9a6e26dfd3b2b1114d8669a0031ca1cac9c8ef3035e61
|
|
7
|
+
data.tar.gz: 48602f318f14ab1cb4a0698d560b802417529216e52f3773901c949d511396f2a0b75b8aaf4904887cd63dbf9832fb630fc65709a390395d842ddb005034f261
|
data/lib/rrx_rails/cli.rb
CHANGED
|
@@ -36,6 +36,10 @@ module RrxRails
|
|
|
36
36
|
option :storage, type: :boolean, desc: 'Include ActiveStorage support'
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
def db!
|
|
40
|
+
option :db, type: :string, desc: 'Database type (sqlite, mysql, postgresql)', default: 'postgresql'
|
|
41
|
+
end
|
|
42
|
+
|
|
39
43
|
def jobs!
|
|
40
44
|
option :jobs, type: :boolean, desc: 'Include ActiveJob support'
|
|
41
45
|
end
|
|
@@ -56,6 +60,7 @@ module RrxRails
|
|
|
56
60
|
# :project_path
|
|
57
61
|
|
|
58
62
|
desc 'api APP_PATH', 'Create a new API project'
|
|
63
|
+
db!
|
|
59
64
|
mail!
|
|
60
65
|
storage!
|
|
61
66
|
jobs!
|
|
@@ -63,6 +68,7 @@ module RrxRails
|
|
|
63
68
|
|
|
64
69
|
def api(name)
|
|
65
70
|
validate_options!
|
|
71
|
+
validate_db!
|
|
66
72
|
init name, type: :api
|
|
67
73
|
create_project
|
|
68
74
|
inside do
|
|
@@ -102,6 +108,19 @@ module RrxRails
|
|
|
102
108
|
RAILS_NEW_SKIP = %w[js hotwire jbuilder rubocop test bundle action-mailbox asset-pipeline].freeze
|
|
103
109
|
RAILS_NEW_OPTIONS = %w[--api].concat(RAILS_NEW_SKIP.map { |s| "--skip-#{s}" }).freeze
|
|
104
110
|
|
|
111
|
+
DB_MAP = {
|
|
112
|
+
'sqlite' => 'sqlite3',
|
|
113
|
+
'mysql' => 'mysql',
|
|
114
|
+
'postgresql' => 'postgresql',
|
|
115
|
+
'pg' => 'postgresql'
|
|
116
|
+
}.freeze
|
|
117
|
+
|
|
118
|
+
DB_GEM = {
|
|
119
|
+
'sqlite3' => 'sqlite3',
|
|
120
|
+
'mysql' => 'mysql2',
|
|
121
|
+
'postgresql' => 'pg'
|
|
122
|
+
}.freeze
|
|
123
|
+
|
|
105
124
|
attr_reader :app_name, :type, :dependencies, :app_path
|
|
106
125
|
|
|
107
126
|
def setup_gem(name, engine: false)
|
|
@@ -119,7 +138,8 @@ module RrxRails
|
|
|
119
138
|
# @param [Symbol] type
|
|
120
139
|
# @param [Array<String>] deps
|
|
121
140
|
def init(app_path, type: :gem, deps: [])
|
|
122
|
-
|
|
141
|
+
basename = Pathname(app_path).basename.to_s
|
|
142
|
+
raise Thor::Error, 'Invalid app name' if basename !~ /^[a-z][a-z0-9_]*$/
|
|
123
143
|
|
|
124
144
|
@app_path = Pathname(app_path).expand_path
|
|
125
145
|
@app_name = @app_path.basename.to_s
|
|
@@ -133,6 +153,12 @@ module RrxRails
|
|
|
133
153
|
raise Thor::Error, 'Only one of --force, --skip, --pretend or --quiet is allowed'
|
|
134
154
|
end
|
|
135
155
|
|
|
156
|
+
def validate_db!
|
|
157
|
+
return unless options.key?(:db)
|
|
158
|
+
|
|
159
|
+
raise Thor::Error, "Invalid --db value '#{options[:db]}'. Valid options: #{DB_MAP.keys.join(', ')}" unless DB_MAP.key?(options[:db])
|
|
160
|
+
end
|
|
161
|
+
|
|
136
162
|
def comment(str)
|
|
137
163
|
Cli.comment str
|
|
138
164
|
end
|
|
@@ -172,6 +198,7 @@ module RrxRails
|
|
|
172
198
|
cmd << '--skip-active-storage' unless options[:storage]
|
|
173
199
|
cmd << '--skip-active-job' unless options[:jobs]
|
|
174
200
|
cmd << '--skip-action-cable' unless options[:sockets]
|
|
201
|
+
cmd << "--database=#{DB_MAP.fetch(options[:db], 'postgresql')}" if api?
|
|
175
202
|
cmd
|
|
176
203
|
end
|
|
177
204
|
|
|
@@ -279,9 +306,17 @@ module RrxRails
|
|
|
279
306
|
rrx_gem_spec('rrx_api')
|
|
280
307
|
]
|
|
281
308
|
gems << rrx_gem_spec('rrx_jobs') if options[:jobs]
|
|
309
|
+
gems << "gem '#{db_gem}'" if db_gem
|
|
282
310
|
gems
|
|
283
311
|
end
|
|
284
312
|
|
|
313
|
+
def db_gem
|
|
314
|
+
return nil unless api?
|
|
315
|
+
|
|
316
|
+
db_adapter = DB_MAP.fetch(options.fetch(:db, 'postgresql'), 'postgresql')
|
|
317
|
+
DB_GEM[db_adapter]
|
|
318
|
+
end
|
|
319
|
+
|
|
285
320
|
def dev_gem_list
|
|
286
321
|
[rrx_gem_spec('rrx_dev')]
|
|
287
322
|
end
|
data/lib/rrx_rails/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rrx_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.0.
|
|
4
|
+
version: 8.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dan Drew
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|