orats 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +231 -58
- data/lib/orats/cli.rb +63 -25
- data/lib/orats/commands/common.rb +47 -22
- data/lib/orats/commands/{outdated → diff}/compare.rb +5 -4
- data/lib/orats/commands/diff/exec.rb +86 -0
- data/lib/orats/commands/{outdated → diff}/parse.rb +5 -1
- data/lib/orats/commands/inventory.rb +121 -0
- data/lib/orats/commands/{play.rb → playbook.rb} +5 -5
- data/lib/orats/commands/project/exec.rb +74 -0
- data/lib/orats/commands/{new → project}/rails.rb +57 -81
- data/lib/orats/commands/{new → project}/server.rb +6 -4
- data/lib/orats/templates/auth.rb +26 -481
- data/lib/orats/templates/base.rb +74 -716
- data/lib/orats/templates/includes/common/LICENSE +22 -0
- data/lib/orats/templates/includes/new/rails/.env +43 -0
- data/lib/orats/templates/includes/{Gemfile → new/rails/Gemfile} +1 -1
- data/lib/orats/templates/includes/new/rails/Procfile +3 -0
- data/lib/orats/templates/includes/new/rails/README.md +3 -0
- data/lib/orats/templates/includes/{app → new/rails/app}/assets/favicon/favicon_base.png +0 -0
- data/lib/orats/templates/includes/new/rails/app/helpers/application_helper.rb +53 -0
- data/lib/orats/templates/includes/new/rails/app/models/account.rb +40 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/confirmations/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/reset_password_instructions.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/unlock_instructions.html.erb +8 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/edit.html.erb +28 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/edit.html.erb +51 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/new.html.erb +31 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/sessions/new.html.erb +39 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb +38 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/unlocks/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_comments_snippet.html.erb +19 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_count_snippet.html.erb +12 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_flash.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_footer.html.erb +2 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb +13 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_tracker.html.erb +4 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation.html.erb +18 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_auth.html.erb +15 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_links.html.erb +3 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/application.html.erb +48 -0
- data/lib/orats/templates/includes/new/rails/app/views/pages/home.html.erb +81 -0
- data/lib/orats/templates/includes/new/rails/config/database.yml +19 -0
- data/lib/orats/templates/includes/new/rails/config/environments/staging.rb +5 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/devise_async.rb +1 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/mini_profiler.rb +4 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/sidekiq.rb +16 -0
- data/lib/orats/templates/includes/new/rails/config/puma.rb +25 -0
- data/lib/orats/templates/includes/new/rails/config/secrets.yml +12 -0
- data/lib/orats/templates/includes/new/rails/config/sidekiq.yml +5 -0
- data/lib/orats/templates/includes/new/rails/config/sitemap.rb +20 -0
- data/lib/orats/templates/includes/new/rails/config/whenever.rb +7 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/config.rb +116 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/models/backup.rb +55 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/backup.rake +18 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/favicon.rake +48 -0
- data/lib/orats/templates/includes/new/rails/public/404.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/422.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/500.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/502.html +13 -0
- data/lib/orats/templates/includes/new/rails/test/fixtures/accounts.yml +27 -0
- data/lib/orats/templates/includes/new/rails/test/models/account_test.rb +46 -0
- data/lib/orats/templates/includes/{Galaxyfile → playbook/Galaxyfile} +0 -0
- data/lib/orats/templates/includes/playbook/site.yml +53 -0
- data/lib/orats/templates/playbook.rb +115 -0
- data/lib/orats/version.rb +1 -1
- data/test/integration/cli_test.rb +122 -75
- data/test/test_helper.rb +16 -8
- metadata +63 -14
- data/lib/orats/commands/new/ansible.rb +0 -98
- data/lib/orats/commands/new/exec.rb +0 -60
- data/lib/orats/commands/outdated/exec.rb +0 -46
- data/lib/orats/templates/play.rb +0 -185
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'orats/commands/ui'
|
2
|
-
require 'orats/commands/
|
2
|
+
require 'orats/commands/diff/parse'
|
3
3
|
|
4
4
|
module Orats
|
5
5
|
module Commands
|
@@ -8,13 +8,13 @@ module Orats
|
|
8
8
|
include Thor::Shell
|
9
9
|
include Thor::Actions
|
10
10
|
include UI
|
11
|
-
include
|
11
|
+
include Diff::Parse
|
12
12
|
|
13
13
|
RELATIVE_PATHS = {
|
14
|
-
galaxyfile: 'templates/includes/Galaxyfile',
|
14
|
+
galaxyfile: 'templates/includes/playbook/Galaxyfile',
|
15
15
|
hosts: 'templates/includes/inventory/hosts',
|
16
16
|
inventory: 'templates/includes/inventory/group_vars/all.yml',
|
17
|
-
playbook: 'templates/
|
17
|
+
playbook: 'templates/includes/playbook/site.yml',
|
18
18
|
version: 'version.rb'
|
19
19
|
}
|
20
20
|
|
@@ -34,7 +34,14 @@ module Orats
|
|
34
34
|
@behavior = :invoke
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
def self.copy_from_local_gem(source, dest)
|
38
|
+
base_path = File.join(File.expand_path(File.dirname(__FILE__)),
|
39
|
+
'..')
|
40
|
+
template_path = "#{base_path}/templates/includes"
|
41
|
+
|
42
|
+
system "mkdir -p #{File.dirname(dest)}" unless Dir.exist?(File.dirname(dest))
|
43
|
+
system "cp #{template_path}/#{source} #{dest}"
|
44
|
+
end
|
38
45
|
|
39
46
|
def base_path
|
40
47
|
File.join(File.expand_path(File.dirname(__FILE__)), '..')
|
@@ -44,20 +51,6 @@ module Orats
|
|
44
51
|
%w(https://raw.githubusercontent.com/nickjj/orats lib/orats)
|
45
52
|
end
|
46
53
|
|
47
|
-
def select_branch(branch, value)
|
48
|
-
"#{repo_path[0]}/#{branch}/#{repo_path[1]}/#{value}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def build_common_paths
|
52
|
-
@remote_paths[:version] = select_branch 'master', RELATIVE_PATHS[:version]
|
53
|
-
@remote_gem_version = gem_version
|
54
|
-
|
55
|
-
RELATIVE_PATHS.each_pair do |key, value|
|
56
|
-
@local_paths[key] = "#{base_path}/#{value}"
|
57
|
-
@remote_paths[key] = select_branch @remote_gem_version, value
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
54
|
def url_to_string(url)
|
62
55
|
begin
|
63
56
|
open(url).read
|
@@ -78,11 +71,15 @@ module Orats
|
|
78
71
|
end
|
79
72
|
end
|
80
73
|
|
81
|
-
def exit_if_path_exists
|
74
|
+
def exit_if_path_exists(extend_path='')
|
82
75
|
log_task 'Check if this path exists'
|
83
76
|
|
84
|
-
|
85
|
-
|
77
|
+
extended_path = @active_path.dup
|
78
|
+
extended_path = File.join(extended_path, extend_path) unless extend_path
|
79
|
+
.empty?
|
80
|
+
|
81
|
+
if Dir.exist?(extended_path) || File.exist?(extended_path)
|
82
|
+
log_error 'error', 'A file or directory already exists at this location', 'path', extended_path
|
86
83
|
exit 1
|
87
84
|
end
|
88
85
|
end
|
@@ -107,6 +104,34 @@ module Orats
|
|
107
104
|
end
|
108
105
|
end
|
109
106
|
|
107
|
+
private
|
108
|
+
|
109
|
+
def build_common_paths
|
110
|
+
@remote_paths[:version] = select_branch 'master', RELATIVE_PATHS[:version]
|
111
|
+
@remote_gem_version = gem_version
|
112
|
+
|
113
|
+
RELATIVE_PATHS.each_pair do |key, value|
|
114
|
+
@local_paths[key] = "#{base_path}/#{value}"
|
115
|
+
@remote_paths[key] = select_branch @remote_gem_version,
|
116
|
+
check_old_remote_file_paths(value)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def check_old_remote_file_paths(url)
|
121
|
+
new_url = url.dup
|
122
|
+
|
123
|
+
if @remote_gem_version[1..-1] < '0.6.6'
|
124
|
+
new_url.gsub!('playbook/', '')
|
125
|
+
new_url.gsub!('includes/site.yml', 'play.rb')
|
126
|
+
end
|
127
|
+
|
128
|
+
new_url
|
129
|
+
end
|
130
|
+
|
131
|
+
def select_branch(branch, value)
|
132
|
+
"#{repo_path[0]}/#{branch}/#{repo_path[1]}/#{value}"
|
133
|
+
end
|
134
|
+
|
110
135
|
def process_unusable?(command, process, phrase)
|
111
136
|
command_output = run(command, capture: true)
|
112
137
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Orats
|
2
2
|
module Commands
|
3
|
-
module
|
3
|
+
module Diff
|
4
4
|
module Compare
|
5
5
|
def remote_to_local_gem_versions
|
6
6
|
log_remote_info 'gem', 'Compare this version of orats to the latest orats version',
|
@@ -42,7 +42,8 @@ module Orats
|
|
42
42
|
item_diff_count = item_diff.size
|
43
43
|
|
44
44
|
log_remote_info label, "Compare this version of orats' #{label} to the latest version",
|
45
|
-
'file',
|
45
|
+
'file',
|
46
|
+
File.basename(Common::RELATIVE_PATHS[label.to_sym])
|
46
47
|
|
47
48
|
item_diff.each do |line|
|
48
49
|
log_status_bottom 'missing', line, :red, true unless local.include?(line)
|
@@ -59,7 +60,7 @@ module Orats
|
|
59
60
|
def local_to_user(label, keyword, flag_path, local)
|
60
61
|
user = yield
|
61
62
|
|
62
|
-
log_local_info label, "Compare this version of orats' #{label} to
|
63
|
+
log_local_info label, "Compare this version of orats' #{label} to yours",
|
63
64
|
'path', flag_path
|
64
65
|
|
65
66
|
missing_count = log_unmatched(local, user, 'missing', :red)
|
@@ -74,7 +75,7 @@ module Orats
|
|
74
75
|
|
75
76
|
if extra_count > 0
|
76
77
|
log_results "#{extra_count} extra #{keyword} were detected:",
|
77
|
-
"No problem but remember to add them to future #{
|
78
|
+
"No problem but remember to add them to future #{label}"
|
78
79
|
else
|
79
80
|
log_results "No extra #{keyword} were found:", "Extra #{keyword} are fine but you have none"
|
80
81
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'orats/commands/common'
|
2
|
+
require 'orats/commands/diff/parse'
|
3
|
+
require 'orats/commands/diff/compare'
|
4
|
+
require 'orats/version'
|
5
|
+
|
6
|
+
module Orats
|
7
|
+
module Commands
|
8
|
+
module Diff
|
9
|
+
class Exec < Commands::Common
|
10
|
+
include Parse
|
11
|
+
include Compare
|
12
|
+
|
13
|
+
def initialize(target_path = '', options = {})
|
14
|
+
super
|
15
|
+
|
16
|
+
@remote_galaxyfile = galaxyfile url_to_string(@remote_paths[:galaxyfile])
|
17
|
+
@remote_hosts = hosts url_to_string(@remote_paths[:hosts])
|
18
|
+
@remote_inventory = inventory url_to_string(@remote_paths[:inventory])
|
19
|
+
@remote_playbook = playbook url_to_string(@remote_paths[:playbook])
|
20
|
+
|
21
|
+
@local_galaxyfile = galaxyfile file_to_string(@local_paths[:galaxyfile])
|
22
|
+
@local_hosts = hosts file_to_string(@local_paths[:hosts])
|
23
|
+
@local_inventory = inventory file_to_string(@local_paths[:inventory])
|
24
|
+
@local_playbook = playbook file_to_string(@local_paths[:playbook])
|
25
|
+
end
|
26
|
+
|
27
|
+
def init
|
28
|
+
remote_to_local_gem_versions
|
29
|
+
remote_to_local_galaxyfiles
|
30
|
+
remote_to_local 'hosts', 'groups', @remote_hosts, @local_hosts
|
31
|
+
remote_to_local 'inventory', 'variables', @remote_inventory, @local_inventory
|
32
|
+
remote_to_local 'playbook', 'roles', @remote_playbook, @local_playbook
|
33
|
+
|
34
|
+
local_to_user_hosts @options[:hosts] unless @options[:hosts].empty?
|
35
|
+
|
36
|
+
unless @options[:inventory].empty?
|
37
|
+
inventory_path = @options[:inventory]
|
38
|
+
|
39
|
+
if File.directory?(inventory_path)
|
40
|
+
hosts_path = File.join(inventory_path, 'hosts')
|
41
|
+
|
42
|
+
inventory_path = File.join(inventory_path,
|
43
|
+
'group_vars/all.yml')
|
44
|
+
|
45
|
+
local_to_user_hosts hosts_path
|
46
|
+
end
|
47
|
+
|
48
|
+
local_to_user_inventory inventory_path
|
49
|
+
end
|
50
|
+
|
51
|
+
unless @options[:playbook].empty?
|
52
|
+
playbook_path = @options[:playbook]
|
53
|
+
|
54
|
+
if File.directory?(playbook_path)
|
55
|
+
playbook_path = File.join(playbook_path, 'site.yml')
|
56
|
+
|
57
|
+
local_to_user_playbook playbook_path
|
58
|
+
end
|
59
|
+
|
60
|
+
local_to_user_playbook playbook_path
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def local_to_user_hosts(path)
|
67
|
+
local_to_user('hosts', 'groups', path, @local_hosts) do
|
68
|
+
hosts file_to_string(path)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def local_to_user_inventory(path)
|
73
|
+
local_to_user('inventory', 'variables', path, @local_inventory) do
|
74
|
+
inventory file_to_string(path)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def local_to_user_playbook(path)
|
79
|
+
local_to_user('playbook', 'roles', path, @local_playbook) do
|
80
|
+
playbook file_to_string(path)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Orats
|
2
2
|
module Commands
|
3
|
-
module
|
3
|
+
module Diff
|
4
4
|
module Parse
|
5
5
|
def gem_version
|
6
6
|
"v#{url_to_string(@remote_paths[:version]).match(/'(.*)'/)[1..-1].first}"
|
@@ -10,6 +10,10 @@ module Orats
|
|
10
10
|
contents.split
|
11
11
|
end
|
12
12
|
|
13
|
+
def hosts(contents)
|
14
|
+
contents.scan(/^\[.*\]/)
|
15
|
+
end
|
16
|
+
|
13
17
|
def inventory(contents)
|
14
18
|
# pluck out all of the values contained with {{ }}
|
15
19
|
ansible_variables = contents.scan(/\{\{([^{{}}]*)\}\}/)
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'orats/commands/common'
|
3
|
+
require 'orats/commands/project/rails'
|
4
|
+
|
5
|
+
module Orats
|
6
|
+
module Commands
|
7
|
+
class Inventory < Common
|
8
|
+
include Project::Rails
|
9
|
+
|
10
|
+
def initialize(target_path = '', options = {})
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def init
|
15
|
+
exit_if_path_exists('inventory')
|
16
|
+
|
17
|
+
create_inventory
|
18
|
+
|
19
|
+
secrets_path = "#{@target_path}/secrets"
|
20
|
+
create_secrets secrets_path
|
21
|
+
|
22
|
+
log_task 'Update secrets path in group_vars/all.yml'
|
23
|
+
gsub_file "#{@target_path}/#{fix_path_for_user(Common::RELATIVE_PATHS[:inventory])}",
|
24
|
+
'/home/yourname/dev/testproj/secrets', File.expand_path(secrets_path)
|
25
|
+
|
26
|
+
log_task 'Update place holder app name in group_vars/all.yml'
|
27
|
+
gsub_file "#{@target_path}/#{fix_path_for_user(Common::RELATIVE_PATHS[:inventory])}",
|
28
|
+
'testproj', File.basename(@target_path)
|
29
|
+
|
30
|
+
log_task 'Add ssh keypair'
|
31
|
+
run "ssh-keygen -t rsa -P '' -f #{secrets_path}/id_rsa"
|
32
|
+
|
33
|
+
log_task 'Add self signed ssl certificates'
|
34
|
+
run create_rsa_certificate(secrets_path, 'sslkey.key', 'sslcert.crt')
|
35
|
+
|
36
|
+
log_task 'Add monit pem file'
|
37
|
+
run "#{create_rsa_certificate(secrets_path,
|
38
|
+
'monit.pem', 'monit.pem')} && openssl gendh 512 >> #{secrets_path}/monit.pem"
|
39
|
+
|
40
|
+
install_role_dependencies unless @options[:skip_galaxy]
|
41
|
+
|
42
|
+
log_success
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def create_inventory
|
48
|
+
log_task 'Add ansible inventory'
|
49
|
+
run "mkdir -p #{@target_path}/inventory/group_vars"
|
50
|
+
|
51
|
+
local_to_user Common::RELATIVE_PATHS[:hosts]
|
52
|
+
local_to_user Common::RELATIVE_PATHS[:inventory]
|
53
|
+
end
|
54
|
+
|
55
|
+
def local_to_user(file)
|
56
|
+
fixed_file = fix_path_for_user(file)
|
57
|
+
|
58
|
+
log_task "Add #{fixed_file}"
|
59
|
+
run "cp #{base_path}/#{file} #{@target_path}/#{fixed_file}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_secrets(secrets_path)
|
63
|
+
log_task 'Add ansible secrets'
|
64
|
+
run "mkdir #{secrets_path}"
|
65
|
+
|
66
|
+
save_secret_string "#{secrets_path}/postgres_password"
|
67
|
+
save_secret_string "#{secrets_path}/redis_password"
|
68
|
+
save_secret_string "#{secrets_path}/mail_password"
|
69
|
+
save_secret_string "#{secrets_path}/rails_token"
|
70
|
+
save_secret_string "#{secrets_path}/devise_token"
|
71
|
+
save_secret_string "#{secrets_path}/devise_pepper_token"
|
72
|
+
end
|
73
|
+
|
74
|
+
def save_secret_string(file)
|
75
|
+
File.open(file, 'w+') { |f| f.write(SecureRandom.hex(64)) }
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_rsa_certificate(secrets_path, keyout, out)
|
79
|
+
"openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -subj '/C=US/ST=Foo/L=Bar/O=Baz/CN=qux.com' -keyout #{secrets_path}/#{keyout} -out #{secrets_path}/#{out}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def install_role_dependencies
|
83
|
+
log_task 'Update ansible roles from the galaxy'
|
84
|
+
|
85
|
+
galaxy_install =
|
86
|
+
"ansible-galaxy install -r #{base_path}/#{Common::RELATIVE_PATHS[:galaxyfile]} --force"
|
87
|
+
|
88
|
+
galaxy_out = run(galaxy_install, capture: true)
|
89
|
+
|
90
|
+
if galaxy_out.include?('you do not have permission')
|
91
|
+
if @options[:sudo_password].empty?
|
92
|
+
sudo_galaxy_command = 'sudo'
|
93
|
+
else
|
94
|
+
sudo_galaxy_command = "echo #{@options[:sudo_password]} | sudo -S"
|
95
|
+
end
|
96
|
+
|
97
|
+
run("#{sudo_galaxy_command} #{galaxy_install}")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def log_success
|
102
|
+
log_status_top 'success', 'Everything has been setup successfully',
|
103
|
+
:cyan
|
104
|
+
puts
|
105
|
+
log_status_bottom 'question', 'Not sure what to do?', :yellow, true
|
106
|
+
log_status_bottom 'answer', 'Check out the inventory/hosts file',
|
107
|
+
:white, true
|
108
|
+
log_status_bottom 'answer', 'Check out the inventory/group_vars/all.yml file', :white
|
109
|
+
|
110
|
+
log_status_bottom 'question', 'Are you new to ansible?', :yellow, true
|
111
|
+
log_status_bottom 'answer',
|
112
|
+
'http://docs.ansible.com/intro_getting_started.html',
|
113
|
+
:white
|
114
|
+
end
|
115
|
+
|
116
|
+
def fix_path_for_user(file)
|
117
|
+
file.sub('templates/includes', '')
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'orats/commands/common'
|
2
|
-
require 'orats/commands/
|
2
|
+
require 'orats/commands/project/rails'
|
3
3
|
|
4
4
|
module Orats
|
5
5
|
module Commands
|
6
|
-
class
|
7
|
-
include
|
6
|
+
class Playbook < Common
|
7
|
+
include Project::Rails
|
8
8
|
|
9
9
|
def initialize(target_path = '', options = {})
|
10
10
|
super
|
@@ -13,8 +13,8 @@ module Orats
|
|
13
13
|
def init
|
14
14
|
exit_if_path_exists
|
15
15
|
|
16
|
-
rails_template '
|
17
|
-
custom_rails_template unless @options[:
|
16
|
+
rails_template 'playbook'
|
17
|
+
custom_rails_template unless @options[:custom].empty?
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'orats/commands/common'
|
2
|
+
require 'orats/commands/inventory'
|
3
|
+
require 'orats/commands/project/rails'
|
4
|
+
require 'orats/commands/project/server'
|
5
|
+
|
6
|
+
module Orats
|
7
|
+
module Commands
|
8
|
+
module Project
|
9
|
+
class Exec < Commands::Common
|
10
|
+
include Rails
|
11
|
+
include Server
|
12
|
+
|
13
|
+
PROJECT_TEMPLATES = {
|
14
|
+
auth: 'add authentication and authorization'
|
15
|
+
}
|
16
|
+
|
17
|
+
def initialize(target_path = '', options = {})
|
18
|
+
super
|
19
|
+
|
20
|
+
@active_path = services_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def list_templates
|
24
|
+
log_status_top 'templates', 'Available templates to choose from:',
|
25
|
+
:blue
|
26
|
+
puts
|
27
|
+
PROJECT_TEMPLATES.each_pair do |key, value|
|
28
|
+
log_status_bottom key, value, :cyan, true
|
29
|
+
log_status_bottom 'usage', "orats project /tmp/foo --template #{key}",
|
30
|
+
:white
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def init
|
35
|
+
check_exit_conditions
|
36
|
+
|
37
|
+
rails_template 'base' do
|
38
|
+
gsub_postgres_info
|
39
|
+
gsub_redis_info unless @options[:redis_password].empty?
|
40
|
+
gsub_project_path
|
41
|
+
gsub_readme
|
42
|
+
|
43
|
+
bundle_install
|
44
|
+
bundle_binstubs
|
45
|
+
spring_binstub
|
46
|
+
|
47
|
+
create_and_migrate_database
|
48
|
+
generate_home_page
|
49
|
+
generate_favicons
|
50
|
+
end
|
51
|
+
|
52
|
+
if template_exist?(@options[:template])
|
53
|
+
rails_template @options[:template], '--skip ' do
|
54
|
+
migrate_and_seed_database
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Commands::Inventory.new(@target_path,
|
59
|
+
@options).init unless @options[:skip_ansible]
|
60
|
+
|
61
|
+
custom_rails_template unless @options[:custom].empty?
|
62
|
+
|
63
|
+
server_start
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def services_path
|
69
|
+
"#{@target_path}/services/#{File.basename @target_path}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|