orats 0.7.3 → 0.8.0
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/.gitignore +2 -1
- data/Gemfile +1 -1
- data/{LICENSE.txt → LICENSE} +21 -21
- data/README.md +51 -346
- data/Rakefile +1 -1
- data/bin/orats +5 -2
- data/lib/orats/argv_adjust.rb +61 -0
- data/lib/orats/cli.rb +53 -141
- data/lib/orats/cli_help/new +27 -0
- data/lib/orats/cli_help/nuke +19 -0
- data/lib/orats/commands/new/exec.rb +59 -0
- data/lib/orats/commands/new/rails.rb +197 -0
- data/lib/orats/commands/new/server.rb +67 -0
- data/lib/orats/commands/nuke.rb +66 -44
- data/lib/orats/common.rb +76 -0
- data/lib/orats/postgres.rb +90 -0
- data/lib/orats/process.rb +35 -0
- data/lib/orats/redis.rb +25 -0
- data/lib/orats/shell.rb +12 -0
- data/lib/orats/templates/auth.rb +96 -82
- data/lib/orats/templates/base.rb +115 -110
- data/lib/orats/templates/includes/new/rails/.env +28 -28
- data/lib/orats/templates/includes/new/rails/Gemfile +4 -4
- data/lib/orats/templates/includes/new/rails/config/{whenever.rb → schedule.rb} +0 -0
- data/lib/orats/ui.rb +33 -0
- data/lib/orats/version.rb +3 -2
- data/lib/orats.rb +2 -1
- data/orats.gemspec +7 -5
- data/test/integration/cli_test.rb +28 -177
- data/test/test_helper.rb +24 -9
- metadata +17 -29
- data/lib/orats/commands/common.rb +0 -146
- data/lib/orats/commands/diff/compare.rb +0 -106
- data/lib/orats/commands/diff/exec.rb +0 -60
- data/lib/orats/commands/diff/parse.rb +0 -66
- data/lib/orats/commands/inventory.rb +0 -100
- data/lib/orats/commands/playbook.rb +0 -60
- data/lib/orats/commands/project/exec.rb +0 -74
- data/lib/orats/commands/project/rails.rb +0 -162
- data/lib/orats/commands/project/server.rb +0 -57
- data/lib/orats/commands/role.rb +0 -70
- data/lib/orats/commands/ui.rb +0 -47
- data/lib/orats/templates/includes/inventory/group_vars/all.yml +0 -202
- data/lib/orats/templates/includes/inventory/hosts +0 -8
- data/lib/orats/templates/includes/playbook/Galaxyfile +0 -15
- data/lib/orats/templates/includes/playbook/common.yml +0 -23
- data/lib/orats/templates/includes/playbook/site.yml +0 -36
- data/lib/orats/templates/includes/role/.travis.yml +0 -19
- data/lib/orats/templates/includes/role/README.md +0 -62
- data/lib/orats/templates/includes/role/meta/main.yml +0 -123
- data/lib/orats/templates/includes/role/tests/inventory +0 -1
- data/lib/orats/templates/includes/role/tests/main.yml +0 -7
- data/lib/orats/templates/playbook.rb +0 -119
- data/lib/orats/templates/role.rb +0 -144
data/lib/orats/templates/auth.rb
CHANGED
@@ -19,31 +19,30 @@ def method_to_sentence(method)
|
|
19
19
|
method
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def task(message, color = :blue)
|
23
23
|
puts
|
24
|
-
say_status 'task',
|
25
|
-
puts '-'*80, ''; sleep 0.25
|
24
|
+
say_status 'task', set_color(message, :bold), color
|
26
25
|
end
|
27
26
|
|
28
|
-
def
|
27
|
+
def commit(message)
|
29
28
|
git add: '-A'
|
30
29
|
git commit: "-m '#{message}'"
|
31
30
|
end
|
32
31
|
|
33
|
-
def migrate(table_name, migration='')
|
34
|
-
utc_now = Time.now.getutc.strftime(
|
32
|
+
def migrate(table_name, migration = '')
|
33
|
+
utc_now = Time.now.getutc.strftime('%Y%m%d%H%M%S')
|
35
34
|
class_name = table_name.to_s.classify.pluralize
|
36
35
|
|
37
|
-
file "db/migrate/#{utc_now}_create_#{table_name}.rb", %
|
36
|
+
file "db/migrate/#{utc_now}_create_#{table_name}.rb", %(
|
38
37
|
class Create#{class_name} < ActiveRecord::Migration
|
39
38
|
def change
|
40
39
|
#{migration}
|
41
40
|
end
|
42
41
|
end
|
43
|
-
|
42
|
+
)
|
44
43
|
end
|
45
44
|
|
46
|
-
def
|
45
|
+
def orats_to_local(source, dest = '')
|
47
46
|
dest = source if dest.empty?
|
48
47
|
|
49
48
|
base_path = "#{File.expand_path File.dirname(__FILE__)}/includes/new/rails"
|
@@ -59,7 +58,7 @@ def delete_app_css
|
|
59
58
|
end
|
60
59
|
|
61
60
|
def update_gemfile
|
62
|
-
|
61
|
+
task __method__
|
63
62
|
|
64
63
|
inject_into_file 'Gemfile', before: "\ngem 'kaminari'" do
|
65
64
|
<<-S
|
@@ -69,11 +68,11 @@ gem 'devise-async', '~> 0.9.0'
|
|
69
68
|
gem 'pundit', '~> 0.2.3'
|
70
69
|
S
|
71
70
|
end
|
72
|
-
|
71
|
+
commit 'Add authentication related gems'
|
73
72
|
end
|
74
73
|
|
75
74
|
def update_dotenv
|
76
|
-
|
75
|
+
task __method__
|
77
76
|
|
78
77
|
inject_into_file '.env', before: "\nSMTP_ADDRESS" do
|
79
78
|
<<-CODE
|
@@ -87,34 +86,37 @@ TOKEN_DEVISE_PEPPER: #{generate_token}
|
|
87
86
|
ACTION_MAILER_DEVISE_DEFAULT_FROM: info@#{app_name}.com
|
88
87
|
CODE
|
89
88
|
end
|
90
|
-
|
89
|
+
commit 'Add devise tokens and default e-mail'
|
91
90
|
end
|
92
91
|
|
93
92
|
def run_bundle_install
|
94
|
-
|
93
|
+
task __method__
|
95
94
|
|
96
95
|
run 'bundle install'
|
97
96
|
end
|
98
97
|
|
99
98
|
def add_pundit
|
100
|
-
|
99
|
+
task __method__
|
101
100
|
|
102
101
|
generate 'pundit:install'
|
103
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
102
|
+
inject_into_file 'app/controllers/application_controller.rb',
|
103
|
+
after: "::Base\n" do
|
104
104
|
<<-S
|
105
105
|
include Pundit
|
106
106
|
|
107
107
|
S
|
108
108
|
end
|
109
109
|
|
110
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
110
|
+
inject_into_file 'app/controllers/application_controller.rb',
|
111
|
+
after: ":exception\n" do
|
111
112
|
<<-S
|
112
113
|
|
113
114
|
rescue_from Pundit::NotAuthorizedError, with: :account_not_authorized
|
114
115
|
S
|
115
116
|
end
|
116
117
|
|
117
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
118
|
+
inject_into_file 'app/controllers/application_controller.rb',
|
119
|
+
after: " #end\n" do
|
118
120
|
<<-S
|
119
121
|
|
120
122
|
def account_not_authorized
|
@@ -122,55 +124,63 @@ def add_pundit
|
|
122
124
|
end
|
123
125
|
S
|
124
126
|
end
|
125
|
-
|
127
|
+
commit 'Add pundit policy and controller logic'
|
126
128
|
end
|
127
129
|
|
128
130
|
def add_devise_initializers
|
129
|
-
|
131
|
+
task __method__
|
130
132
|
|
131
|
-
|
133
|
+
orats_to_local 'config/initializers/devise_async.rb'
|
132
134
|
generate 'devise:install'
|
133
|
-
|
135
|
+
commit 'Add the devise and devise async initializers'
|
134
136
|
end
|
135
137
|
|
136
138
|
def update_devise_initializer
|
137
|
-
|
139
|
+
task 'Update the devise initializer'
|
138
140
|
|
139
141
|
gsub_file 'config/initializers/devise.rb',
|
140
|
-
"'please-change-me-at-config-initializers-devise@example.com'",
|
141
|
-
|
142
|
-
gsub_file 'config/initializers/devise.rb', /(?<=
|
143
|
-
|
142
|
+
"'please-change-me-at-config-initializers-devise@example.com'",
|
143
|
+
"ENV['ACTION_MAILER_DEVISE_DEFAULT_EMAIL']"
|
144
|
+
gsub_file 'config/initializers/devise.rb', /(?<=key = )'\w{128}'/,
|
145
|
+
"ENV['TOKEN_DEVISE_SECRET']"
|
146
|
+
gsub_file 'config/initializers/devise.rb', /(?<=pepper = )'\w{128}'/,
|
147
|
+
"ENV['TOKEN_DEVISE_PEPPER']"
|
148
|
+
gsub_file 'config/initializers/devise.rb',
|
149
|
+
'# config.timeout_in = 30.minutes',
|
144
150
|
'config.timeout_in = 2.hours'
|
145
151
|
|
146
|
-
gsub_file 'config/initializers/devise.rb',
|
152
|
+
gsub_file 'config/initializers/devise.rb',
|
153
|
+
'# config.expire_auth_token_on_timeout = false',
|
147
154
|
'config.expire_auth_token_on_timeout = true'
|
148
|
-
gsub_file 'config/initializers/devise.rb',
|
155
|
+
gsub_file 'config/initializers/devise.rb',
|
156
|
+
'# config.lock_strategy = :failed_attempts',
|
149
157
|
'config.lock_strategy = :failed_attempts'
|
150
|
-
gsub_file 'config/initializers/devise.rb',
|
158
|
+
gsub_file 'config/initializers/devise.rb',
|
159
|
+
'# config.unlock_strategy = :both',
|
151
160
|
'config.unlock_strategy = :both'
|
152
161
|
gsub_file 'config/initializers/devise.rb', '# config.maximum_attempts = 20',
|
153
162
|
'config.maximum_attempts = 7'
|
154
163
|
gsub_file 'config/initializers/devise.rb', '# config.unlock_in = 1.hour',
|
155
164
|
'config.unlock_in = 2.hours'
|
156
|
-
gsub_file 'config/initializers/devise.rb',
|
165
|
+
gsub_file 'config/initializers/devise.rb',
|
166
|
+
'# config.last_attempt_warning = false',
|
157
167
|
'config.last_attempt_warning = true'
|
158
|
-
|
168
|
+
commit 'Update the devise defaults'
|
159
169
|
end
|
160
170
|
|
161
171
|
def update_sidekiq_config
|
162
|
-
|
172
|
+
task __method__
|
163
173
|
|
164
174
|
append_file 'config/sidekiq.yml' do
|
165
175
|
<<-S
|
166
176
|
- mailer
|
167
177
|
S
|
168
178
|
end
|
169
|
-
|
179
|
+
commit 'Add the devise mailer queue to sidekiq'
|
170
180
|
end
|
171
181
|
|
172
182
|
def update_routes
|
173
|
-
|
183
|
+
task __method__
|
174
184
|
|
175
185
|
gsub_file 'config/routes.rb', "mount Sidekiq::Web => '/sidekiq'\n", ''
|
176
186
|
inject_into_file 'config/routes.rb', after: "collection\n end\n" do
|
@@ -191,11 +201,11 @@ def update_routes
|
|
191
201
|
|
192
202
|
S
|
193
203
|
end
|
194
|
-
|
204
|
+
commit 'Add the devise route and protect sidekiq with authentication'
|
195
205
|
end
|
196
206
|
|
197
207
|
def add_en_locale_for_authorization
|
198
|
-
|
208
|
+
task __method__
|
199
209
|
|
200
210
|
gsub_file 'config/locales/en.yml', "hello: \"Hello world\"\n", ''
|
201
211
|
append_file 'config/locales/en.yml' do
|
@@ -204,11 +214,11 @@ authorization:
|
|
204
214
|
error: 'You are not authorized to perform this action.'
|
205
215
|
S
|
206
216
|
end
|
207
|
-
|
217
|
+
commit 'Add en locale entry for authorization errors'
|
208
218
|
end
|
209
219
|
|
210
220
|
def add_devise_migration
|
211
|
-
|
221
|
+
task __method__
|
212
222
|
|
213
223
|
migrate :accounts, %{
|
214
224
|
create_table(:accounts) do |t|
|
@@ -245,26 +255,27 @@ def add_devise_migration
|
|
245
255
|
add_index :accounts, :reset_password_token, :unique => true
|
246
256
|
add_index :accounts, :unlock_token, :unique => true
|
247
257
|
}
|
248
|
-
|
258
|
+
commit 'Add devise model migration'
|
249
259
|
end
|
250
260
|
|
251
261
|
def add_account_model
|
252
|
-
|
262
|
+
task __method__
|
253
263
|
|
254
|
-
|
255
|
-
|
264
|
+
orats_to_local 'app/models/account.rb'
|
265
|
+
commit 'Add account model'
|
256
266
|
end
|
257
267
|
|
258
268
|
def add_seed_user
|
259
|
-
|
269
|
+
task __method__
|
260
270
|
|
261
|
-
append_file 'db/seeds.rb', "\nAccount.create({ email:
|
271
|
+
append_file 'db/seeds.rb', "\nAccount.create({ email: " + \
|
272
|
+
" \"admin@#{app_name}.com\", password: \"password\",
|
262
273
|
role: \"admin\" })"
|
263
|
-
|
274
|
+
commit 'Add seed user'
|
264
275
|
end
|
265
276
|
|
266
277
|
def update_test_helper
|
267
|
-
|
278
|
+
task __method__
|
268
279
|
inject_into_file 'test/test_helper.rb', after: "end\n" do
|
269
280
|
<<-S
|
270
281
|
|
@@ -273,37 +284,39 @@ class ActionController::TestCase
|
|
273
284
|
end
|
274
285
|
S
|
275
286
|
end
|
276
|
-
|
287
|
+
commit 'Add devise test helper'
|
277
288
|
end
|
278
289
|
|
279
290
|
def add_account_fixtures
|
280
|
-
|
281
|
-
|
282
|
-
|
291
|
+
task __method__
|
292
|
+
orats_to_local 'test/fixtures/accounts.yml'
|
293
|
+
commit 'Add account fixtures'
|
283
294
|
end
|
284
295
|
|
285
296
|
def add_account_unit_tests
|
286
|
-
|
297
|
+
task __method__
|
287
298
|
|
288
|
-
|
289
|
-
|
299
|
+
orats_to_local 'test/models/account_test.rb'
|
300
|
+
commit 'Add account unit tests'
|
290
301
|
end
|
291
302
|
|
292
303
|
def add_current_user_alias
|
293
|
-
|
304
|
+
task __method__
|
294
305
|
|
295
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
306
|
+
inject_into_file 'app/controllers/application_controller.rb',
|
307
|
+
after: "::Base\n" do
|
296
308
|
<<-S
|
297
309
|
alias_method :current_user, :current_account
|
298
310
|
|
299
311
|
S
|
300
312
|
end
|
301
|
-
|
313
|
+
commit 'Add current_user alias'
|
302
314
|
end
|
303
315
|
|
304
316
|
def add_devise_controller_override
|
305
|
-
|
306
|
-
inject_into_file 'app/controllers/application_controller.rb',
|
317
|
+
task __method__
|
318
|
+
inject_into_file 'app/controllers/application_controller.rb',
|
319
|
+
before: "end\n" do
|
307
320
|
<<-S
|
308
321
|
|
309
322
|
private
|
@@ -318,32 +331,33 @@ def add_devise_controller_override
|
|
318
331
|
#end
|
319
332
|
S
|
320
333
|
end
|
321
|
-
|
334
|
+
commit 'Add devise after_sign_in_path_for override'
|
322
335
|
end
|
323
336
|
|
324
337
|
def add_devise_views
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
338
|
+
task __method__
|
339
|
+
|
340
|
+
orats_to_local 'app/views/devise/confirmations/new.html.erb'
|
341
|
+
orats_to_local 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
342
|
+
orats_to_local 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
343
|
+
orats_to_local 'app/views/devise/mailer/reset_password_instructions.html.erb'
|
344
|
+
orats_to_local 'app/views/devise/mailer/unlock_instructions.html.erb'
|
345
|
+
orats_to_local 'app/views/devise/passwords/edit.html.erb'
|
346
|
+
orats_to_local 'app/views/devise/passwords/new.html.erb'
|
347
|
+
orats_to_local 'app/views/devise/registrations/edit.html.erb'
|
348
|
+
orats_to_local 'app/views/devise/registrations/new.html.erb'
|
349
|
+
orats_to_local 'app/views/devise/sessions/new.html.erb'
|
350
|
+
orats_to_local 'app/views/devise/unlocks/new.html.erb'
|
351
|
+
orats_to_local 'app/views/devise/shared/_links.html.erb'
|
352
|
+
commit 'Add devise views'
|
340
353
|
end
|
341
354
|
|
342
355
|
def add_auth_links_to_the_navbar
|
343
|
-
|
356
|
+
task __method__
|
344
357
|
|
345
|
-
|
346
|
-
inject_into_file 'app/views/layouts/_navigation.html.erb',
|
358
|
+
orats_to_local 'app/views/layouts/_navigation_auth.html.erb'
|
359
|
+
inject_into_file 'app/views/layouts/_navigation.html.erb',
|
360
|
+
after: "</ul>\n" do
|
347
361
|
<<-S
|
348
362
|
<ul class="nav navbar-nav nav-auth">
|
349
363
|
<%= render 'layouts/navigation_auth' %>
|
@@ -361,14 +375,14 @@ def add_auth_links_to_the_navbar
|
|
361
375
|
}
|
362
376
|
S
|
363
377
|
end
|
364
|
-
|
378
|
+
commit 'Add authentication links to the layout'
|
365
379
|
end
|
366
380
|
|
367
381
|
def remove_unused_files_from_git
|
368
|
-
|
382
|
+
task __method__
|
369
383
|
|
370
384
|
git add: '-u'
|
371
|
-
|
385
|
+
commit 'Remove unused files'
|
372
386
|
end
|
373
387
|
|
374
388
|
# ---
|
@@ -393,4 +407,4 @@ add_current_user_alias
|
|
393
407
|
add_devise_controller_override
|
394
408
|
add_devise_views
|
395
409
|
add_auth_links_to_the_navbar
|
396
|
-
remove_unused_files_from_git
|
410
|
+
remove_unused_files_from_git
|