roro 0.3.5 → 0.3.6
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 +3 -0
- data/Guardfile +9 -5
- data/lib/roro.rb +1 -1
- data/lib/roro/cli.rb +5 -1
- data/lib/roro/cli/base/base.rb +2 -1
- data/lib/roro/cli/base/base_files.rb +1 -7
- data/lib/roro/cli/base/check_dependencies.rb +98 -0
- data/lib/roro/cli/base/insert_gems.rb +15 -7
- data/lib/roro/cli/base/insertions.rb +3 -1
- data/lib/roro/cli/configuration.rb +68 -0
- data/lib/roro/cli/generate/config.rb +13 -0
- data/lib/roro/cli/generate/config/rails.rb +17 -0
- data/lib/roro/cli/generate/generate.rb +1 -0
- data/lib/roro/cli/generate/generate_keys.rb +79 -0
- data/lib/roro/cli/greenfield.rb +15 -16
- data/lib/roro/cli/rollon.rb +66 -20
- data/lib/roro/cli/rollon/database/database.rb +31 -0
- data/lib/roro/cli/rollon/database/with_mysql.rb +22 -0
- data/lib/roro/cli/rollon/database/with_postgres.rb +21 -0
- data/lib/roro/cli/rollon/stories.rb +3 -3
- data/lib/roro/cli/roro_configurator.yml +157 -0
- data/{.keep → lib/roro/cli/templates/base/.env/.keep} +0 -0
- data/lib/roro/cli/templates/base/.env/database.mysql.env.tt +4 -0
- data/lib/roro/cli/templates/base/.env/database.pg.env.tt +5 -0
- data/lib/roro/cli/templates/base/.env/web.env.tt +1 -0
- data/lib/roro/cli/templates/base/.roro_config.yml +15 -0
- data/lib/roro/cli/templates/base/Dockerfile.tt +44 -0
- data/lib/roro/cli/templates/base/config/database.mysql.yml +19 -0
- data/lib/roro/cli/templates/base/config/{database.yml.pg.tt → database.pg.yml} +0 -0
- data/lib/roro/cli/templates/{base/circleci → circleci}/config.yml.tt +0 -0
- data/lib/roro/cli/templates/greenfield/Dockerfile.tt +29 -7
- data/lib/roro/cli/templates/{base/livereload → livereload}/hosts.example +0 -0
- data/lib/roro/cli/templates/{base/roro → roro}/.keep +0 -0
- data/lib/roro/cli/templates/{greenfield → roro}/docker-compose.yml.tt +18 -13
- data/lib/roro/cli/templates/{base/roro/containers → roro/roro}/.keep +0 -0
- data/lib/roro/cli/templates/{base/roro/containers/app → roro/roro/containers}/.keep +0 -0
- data/lib/roro/cli/templates/{base/roro/containers/frontend → roro/roro/containers/app}/.keep +0 -0
- data/lib/roro/cli/templates/roro/roro/containers/frontend/.keep +0 -0
- data/lib/roro/cli/templates/roro/roro/docker-entrypoint.sh.tt +8 -0
- data/lib/roro/cli/templates/stories/.keep +0 -0
- data/lib/roro/cli/templates/stories/with_mysql/_service.yml +10 -0
- data/lib/roro/cli/templates/stories/with_postgresql/.keep +0 -0
- data/lib/roro/cli/templates/stories/with_postgresql/_service.yml +7 -0
- data/lib/roro/version.rb +1 -1
- metadata +33 -25
- data/lib/roro/cli/base/configuration.rb +0 -118
- data/lib/roro/cli/rollon/rollon_as_dockerize.rb +0 -42
- data/lib/roro/cli/rollon/rollon_as_quickstart.rb +0 -17
- data/lib/roro/cli/rollon/rollon_as_roro.rb +0 -30
- data/lib/roro/cli/templates/base/docker-compose.yml.tt +0 -53
- data/lib/roro/cli/templates/base/pg/config/database.yml.pg.tt +0 -20
- data/lib/roro/cli/templates/base/pg/database.yml.pg.tt +0 -20
- data/lib/roro/cli/templates/base/roro/containers/app/Dockerfile.tt +0 -32
- data/lib/roro/cli/templates/base/roro/containers/app/development.env.tt +0 -1
- data/lib/roro/cli/templates/base/roro/containers/app/docker-entrypoint.sh +0 -8
- data/lib/roro/cli/templates/base/roro/containers/app/test.env.tt +0 -1
- data/lib/roro/cli/templates/base/roro/containers/database/development.env.tt +0 -4
- data/lib/roro/cli/templates/base/roro/containers/database/test.env.tt +0 -4
- data/roro-0.3.4.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c448ed5c19cb319a371d294aac99449fbddadf605d0b46e1e694066b0807d7c9
|
4
|
+
data.tar.gz: f668e36a0fd1e5866a9165fea9a6459a45197d0f2188aa84800001541d0cd089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3727071acdd794946a8ca8bbd67644f589896d5bddd6675c7c1dfa61ba80dfe91f0c642553c9df09115e1fadc76bd01e8d7064c0808a9f1b08f61b8716800ff
|
7
|
+
data.tar.gz: cccd90560e9664c9f38b6b56ac0d6f2f1266f6a4a7f93f7f7638e95593b26232480c1673c5e70b2950b41618daba87c27fac5a21d7a59fad69f91779c4d42226
|
data/.gitignore
CHANGED
data/Guardfile
CHANGED
@@ -2,18 +2,22 @@
|
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
4
|
options = {
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
cli: '-f',
|
6
|
+
all_on_start: true,
|
7
|
+
all_after_pass: false
|
8
8
|
}
|
9
9
|
|
10
10
|
guard :minitest, options do
|
11
11
|
|
12
12
|
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
13
13
|
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
|
14
|
-
watch(%r{^lib/roro/cli/(.+)\.rb$}) { |m| "test/
|
14
|
+
watch(%r{^lib/roro/cli/(.+)\.rb$}) { |m| "test/cli/#{m[1]}_test.rb" }
|
15
15
|
watch(%r{^lib/roro/cli/rollon/*.rb$}) { 'test/generators' }
|
16
|
-
watch(%r{^lib/roro/cli/
|
16
|
+
watch(%r{^lib/roro/cli/roro_configurator.yml$}) { 'test/cli/configuration_test.rb' }
|
17
|
+
# watch(%r{^lib/roro/cli/(.+).rb$}) { 'test' }
|
18
|
+
# watch(%r{^lib/roro/cli/templates/roro(.+).rb$}) do
|
19
|
+
# 'test/generators/rollon/rollon_as_roro_test.rb'
|
20
|
+
# end
|
17
21
|
|
18
22
|
|
19
23
|
watch(%r{^test/thor_helper\.rb$}) { 'test' }
|
data/lib/roro.rb
CHANGED
data/lib/roro/cli.rb
CHANGED
@@ -6,12 +6,16 @@ require 'roro/cli/generate_keys'
|
|
6
6
|
require 'roro/cli/obfuscate'
|
7
7
|
require 'roro/cli/expose'
|
8
8
|
require 'roro/cli/ruby_gem'
|
9
|
+
require 'roro/cli/generate/config/rails'
|
10
|
+
require 'roro/cli/generate/config'
|
11
|
+
require 'roro/cli/configuration'
|
9
12
|
|
10
13
|
module Roro
|
14
|
+
|
11
15
|
class CLI < Thor
|
12
16
|
|
13
17
|
include Thor::Actions
|
14
|
-
|
18
|
+
|
15
19
|
def self.source_root
|
16
20
|
File.dirname(__FILE__) + '/cli/templates'
|
17
21
|
end
|
data/lib/roro/cli/base/base.rb
CHANGED
@@ -16,14 +16,8 @@ module Roro
|
|
16
16
|
template "base/docker-compose.yml", 'docker-compose.yml', @env_hash
|
17
17
|
end
|
18
18
|
|
19
|
-
def copy_roro
|
20
|
-
directory 'base/roro/containers/app', "roro/containers/#{@env_hash[:app_name]}", @env_hash
|
21
|
-
directory 'base/roro/containers/database', "roro/containers/#{@env_hash[:database_container]}", @env_hash
|
22
|
-
directory 'base/roro/containers/frontend', "roro/containers/#{@env_hash[:frontend_container]}", @env_hash
|
23
|
-
end
|
24
|
-
|
25
19
|
def copy_database_yml_pg
|
26
|
-
copy_file "base/config/database.yml
|
20
|
+
copy_file "base/config/database.pg.yml", 'config/database.yml', force: @env_hash[:use_force]
|
27
21
|
end
|
28
22
|
end
|
29
23
|
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Roro
|
2
|
+
|
3
|
+
class CLI < Thor
|
4
|
+
|
5
|
+
no_commands do
|
6
|
+
|
7
|
+
def confirm_directory_not_empty
|
8
|
+
confirm_dependency({
|
9
|
+
system_query: "ls -A",
|
10
|
+
warning: "This is an empty directory. You can generate a new and fully
|
11
|
+
dockerized Rails app using the 'greenfield' command here here but if
|
12
|
+
you want to containerize an existing app -- which is what the 'rollon'
|
13
|
+
command is for -- you'll need to navigate to a directory with an app we
|
14
|
+
can roll onto.",
|
15
|
+
suggestion: "$ roro greenfield",
|
16
|
+
conditional: "!Dir.glob('*').empty?" })
|
17
|
+
end
|
18
|
+
|
19
|
+
def confirm_directory_empty
|
20
|
+
confirm = confirm_dependency({
|
21
|
+
system_query: "ls -A",
|
22
|
+
warning: "this is not an empty directory. Roro will not greenfield a new Rails app unless either a) the current directory is empty or b) you run greenfield with the --force flag",
|
23
|
+
suggestion: "$ roro greenfield --force",
|
24
|
+
conditional: "Dir.glob('*').empty?" })
|
25
|
+
confirm || true
|
26
|
+
end
|
27
|
+
|
28
|
+
def remove_roro_artifacts
|
29
|
+
appname = Dir.pwd.split('/').last
|
30
|
+
check_for_clashes = "docker ps --filter name=#{appname}* -aq"
|
31
|
+
no_artifact_containers = IO.popen(check_for_clashes).count.eql?(0)
|
32
|
+
no_artifact_volumes = IO.popen("docker volume ls --filter name=greenfield*").count > (1)
|
33
|
+
unless (no_artifact_containers && no_artifact_volumes)
|
34
|
+
remove_clashes = ["docker ps --filter name=#{appname}* -aq | xargs docker stop | xargs docker rm"]
|
35
|
+
volumes = %w(db_data app)
|
36
|
+
volumes.each {|v| remove_clashes << "docker volume rm #{appname}_#{v}"}
|
37
|
+
question = [
|
38
|
+
"\n\nWe found some container and volume artifacts which may clash",
|
39
|
+
"with RoRo moving forward. You can verify their existence in a ",
|
40
|
+
"separate terminal with:",
|
41
|
+
"\n\t$ #{check_for_clashes}'\n",
|
42
|
+
"You can remove these artifacts with something like:\n"
|
43
|
+
]
|
44
|
+
remove_clashes.each { |c| question << "\t$ #{c}"}
|
45
|
+
question << "\nWould you like RoRo to attempt to remove them for you?"
|
46
|
+
question = question.join("\n")
|
47
|
+
|
48
|
+
prompt = [question]
|
49
|
+
choices = {'y' => 'Yes', 'n' => 'No'}
|
50
|
+
choices.each { |k,v| prompt << "(#{k}) #{v.to_s}" }
|
51
|
+
answer = ask((prompt.join("\n\n") + "\n\n"),
|
52
|
+
default: 'y', limited_to: choices.keys)
|
53
|
+
remove_clashes.each {|c| system c }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def confirm_dependency(options)
|
58
|
+
msg = []
|
59
|
+
msg << ""
|
60
|
+
msg << delineator
|
61
|
+
msg << "It looks like #{options[:warning]}. The following bash command returns false:"
|
62
|
+
msg << "\t$ #{options[:system_query]}"
|
63
|
+
msg << "Please try these instructions:"
|
64
|
+
msg << ("\t" + options[:suggestion])
|
65
|
+
msg << delineator
|
66
|
+
conditional = options[:conditional] ? eval(options[:conditional]) : system(options[:system_query])
|
67
|
+
if conditional == false
|
68
|
+
raise(Roro::Error.new(msg.join("\n\n")))
|
69
|
+
else
|
70
|
+
true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def confirm_dependencies
|
75
|
+
dependencies = [
|
76
|
+
{
|
77
|
+
system_query: "which docker",
|
78
|
+
warning: "Docker isn't installed",
|
79
|
+
suggestion: "https://docs.docker.com/install/"
|
80
|
+
}, {
|
81
|
+
system_query: "which docker-compose",
|
82
|
+
warning: "Docker Compose isn't installed",
|
83
|
+
suggestion: "https://docs.docker.com/compose/install/"
|
84
|
+
|
85
|
+
}, {
|
86
|
+
system_query: "docker info",
|
87
|
+
warning: "the Docker daemon isn't running",
|
88
|
+
suggestion: "https://docs.docker.com/config/daemon/#start-the-daemon-manually"
|
89
|
+
}
|
90
|
+
]
|
91
|
+
|
92
|
+
dependencies.each do |dependency|
|
93
|
+
confirm_dependency(dependency)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -6,17 +6,25 @@ module Roro
|
|
6
6
|
no_commands do
|
7
7
|
|
8
8
|
def insert_roro_gem_into_gemfile
|
9
|
-
insert_into_file 'Gemfile', "gem 'roro'", before: "group :development, :test do"
|
9
|
+
insert_into_file 'Gemfile', "gem 'roro'\n\n", before: "group :development, :test do"
|
10
10
|
end
|
11
|
-
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
|
12
|
+
def insert_db_gem(gem)
|
13
|
+
gem_lines = [
|
14
|
+
/gem\s['"]sqlite3['"]/,
|
15
|
+
/gem\s['"]mysql2['"]/,
|
16
|
+
/gem\s['"]pg['"]/,
|
17
|
+
|
18
|
+
]
|
19
|
+
gem_lines.each do |line|
|
20
|
+
comment_lines 'Gemfile', line
|
21
|
+
gsub_file 'Gemfile', line, 'gem copied over by roro'
|
22
|
+
end
|
23
|
+
insert_into_file 'Gemfile', "gem '#{gem}'\n\n", before: "group :development, :test"
|
16
24
|
end
|
17
25
|
|
18
26
|
def insert_hfci_gem_into_gemfile
|
19
|
-
insert_into_file 'Gemfile', "gem 'handsome_fencer-test'", after: "group :development, :test do"
|
27
|
+
insert_into_file 'Gemfile', "gem 'handsome_fencer-test'\n\n", after: "group :development, :test do"
|
20
28
|
end
|
21
29
|
end
|
22
30
|
end
|
@@ -6,7 +6,9 @@ module Roro
|
|
6
6
|
no_commands do
|
7
7
|
|
8
8
|
def config_std_out_true
|
9
|
-
|
9
|
+
file = 'config/boot.rb'
|
10
|
+
line = "$stdout.sync = true\n\n"
|
11
|
+
prepend_to_file(file, line, force: true)
|
10
12
|
end
|
11
13
|
|
12
14
|
def gitignore_sensitive_files
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Roro
|
2
|
+
class Configuration < Thor
|
3
|
+
|
4
|
+
attr_reader :master, :app, :choices, :thor_actions
|
5
|
+
|
6
|
+
def initialize(options={})
|
7
|
+
@options = options || {}
|
8
|
+
@master = YAML.load_file(File.dirname(__FILE__) + '/roro_configurator.yml')
|
9
|
+
@master['services']['server_app']['vendors']['rails']['version'] = `ruby -v`.scan(/\d.\d/).first
|
10
|
+
@choices = @master['services']['server_app']['vendors']['rails']['choices']
|
11
|
+
@app = {}
|
12
|
+
@thor_actions = {}
|
13
|
+
configure
|
14
|
+
end
|
15
|
+
|
16
|
+
no_commands do
|
17
|
+
|
18
|
+
def configure
|
19
|
+
set_from_defaults
|
20
|
+
case
|
21
|
+
when @options['interactive'] && File.exist?('.roro_config.yml')
|
22
|
+
set_from_roro_config
|
23
|
+
set_from_interactive
|
24
|
+
when File.exist?('.roro_config.yml')
|
25
|
+
set_from_roro_config
|
26
|
+
when @options['interactive']
|
27
|
+
set_from_interactive
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_from_defaults
|
32
|
+
svcs = @master['services']
|
33
|
+
rails = svcs['server_app']['vendors']['rails']
|
34
|
+
@app = {
|
35
|
+
'main_app_name' => Dir.pwd.split('/').last,
|
36
|
+
'database_host' => rails['env_vars']['DATABASE_HOST'],
|
37
|
+
'ruby_version' => rails['version'],
|
38
|
+
'frontend_service' => svcs['frontend']['name'],
|
39
|
+
'webserver_service' => svcs['webserver']['default'],
|
40
|
+
'database_service' => svcs['database']['name'],
|
41
|
+
'database_vendor' => svcs['database']['vendor'],
|
42
|
+
}
|
43
|
+
@choices.each { |key, value| @thor_actions[key] = value["default"] }
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_from_roro_config
|
47
|
+
yaml = YAML.load_file(Dir.pwd + '/.roro_config.yml')
|
48
|
+
yaml.each { |key, value| @app[key] = value }
|
49
|
+
if yaml['thor_actions']
|
50
|
+
yaml['thor_actions'].each do |key, value|
|
51
|
+
@thor_actions[key] = value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def set_from_interactive
|
57
|
+
@choices.each do |key, v|
|
58
|
+
prompt = ["\n\n" + v['question']]
|
59
|
+
v['choices'].each { |k,v| prompt << "(#{k}) #{v.to_s}" }
|
60
|
+
answer = ask((prompt.join("\n\n") + "\n\n"),
|
61
|
+
default: v['default'],
|
62
|
+
limited_to: v['choices'].keys)
|
63
|
+
@thor_actions[key] = answer
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Roro
|
2
|
+
class CLI < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
desc "generate::config::roro", "Generates a config file at .roro_config.yml"
|
6
|
+
map "generate::config::roro" => "generate_roro_config"
|
7
|
+
|
8
|
+
|
9
|
+
def generate_roro_config
|
10
|
+
create_file ".roro_config.yml", @config.app.to_yaml
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# module Roro
|
2
|
+
# class CLI < Thor
|
3
|
+
# include Thor::Actions
|
4
|
+
|
5
|
+
# desc "generate::config::rails", "Generates a config file to use roro with
|
6
|
+
# a rails app at .roro.yml"
|
7
|
+
# map "generate::config::rails" => "generate_config_rails"
|
8
|
+
|
9
|
+
# def generate_config_rails
|
10
|
+
# master_config = YAML.load_file(ENV['PWD'] + "/lib/roro/cli/roro_configurator.yml")
|
11
|
+
# template 'base/.roro_config.yml', '.roro_config.yml'
|
12
|
+
# end
|
13
|
+
|
14
|
+
# no_commands do
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
# end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'config/rails'
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# require 'openssl'
|
2
|
+
# require 'base64'
|
3
|
+
# require 'handsome_fencer/crypto'
|
4
|
+
|
5
|
+
# module Roro
|
6
|
+
|
7
|
+
# class CLI < Thor
|
8
|
+
|
9
|
+
# include Thor::Actions
|
10
|
+
# include HandsomeFencer::Crypto
|
11
|
+
|
12
|
+
# desc "generate_keys", "Generates keys for all environments. If you have .env files like './**/production.env' and './**/staging.env' this command assumes you need keys for the production and staging environments, and will generate them for you."
|
13
|
+
|
14
|
+
# def generate_keys
|
15
|
+
# generate_key
|
16
|
+
# end
|
17
|
+
|
18
|
+
# desc "generate_key", "Generate a key for each environment"
|
19
|
+
# method_option :environment, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
|
20
|
+
|
21
|
+
# def generate_key(*args)
|
22
|
+
# environments = args.first ? [args.first] : gather_environments
|
23
|
+
# environments.each do |environment|
|
24
|
+
# confirm_files_decrypted?(environment)
|
25
|
+
# create_file "docker/keys/#{environment}.key", encoded_key
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
# no_commands do
|
30
|
+
|
31
|
+
# def encoded_key
|
32
|
+
# @cipher = OpenSSL::Cipher.new 'AES-128-CBC'
|
33
|
+
# @salt = '8 octets'
|
34
|
+
# @new_key = @cipher.random_key
|
35
|
+
# Base64.encode64(@new_key)
|
36
|
+
# end
|
37
|
+
|
38
|
+
# def gather_environments
|
39
|
+
# environments = []
|
40
|
+
# ['.env', '.env.enc'].each do |extension|
|
41
|
+
|
42
|
+
# HandsomeFencer::Crypto.source_files('.', extension).each do |env_file|
|
43
|
+
# environments << env_file.split('/').last.split(extension).last
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
# environments.uniq
|
47
|
+
# end
|
48
|
+
|
49
|
+
# def confirm_files_decrypted?(environment)
|
50
|
+
# orphan_encrypted = []
|
51
|
+
# HandsomeFencer::Crypto.source_files('.', '.env.enc').each do |file|
|
52
|
+
# orphan_encrypted << file unless File.exist? file.split('.enc').first
|
53
|
+
# end
|
54
|
+
|
55
|
+
# if !orphan_encrypted.empty?
|
56
|
+
# raise Roro::Error.new("You have an encrypted files (.env.enc) #{orphan_encrypted} that do not have corresponding decrypted files (.env). Please decrypt or remove these encrypted files before generating a new key for #{environment}.")
|
57
|
+
# end
|
58
|
+
# true
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
|
63
|
+
# # desc "generate keys", "Generate keys on a per-environment basis"
|
64
|
+
# #
|
65
|
+
# # method_option :environment, type: :string, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
|
66
|
+
# #
|
67
|
+
|
68
|
+
# # def generate_keys
|
69
|
+
# # default_environments = %w[circleci development production]
|
70
|
+
# # environments = args.first ? [args.first] : default_environments
|
71
|
+
# # environments.each do |environment|
|
72
|
+
# # @cipher = OpenSSL::Cipher.new 'AES-128-CBC'
|
73
|
+
# # @salt = '8 octets'
|
74
|
+
# # @new_key = @cipher.random_key
|
75
|
+
# #
|
76
|
+
# # create_file "docker/keys/#{environment}.key", Base64.encode64(@new_key)
|
77
|
+
# # end
|
78
|
+
# # end
|
79
|
+
# end
|
data/lib/roro/cli/greenfield.rb
CHANGED
@@ -7,36 +7,35 @@ module Roro
|
|
7
7
|
include Thor::Actions
|
8
8
|
|
9
9
|
desc "greenfield", "Greenfield a brand new rails app using Docker's instructions"
|
10
|
-
|
10
|
+
|
11
11
|
method_option :env_vars, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "key1:value1 key2:value2"
|
12
12
|
method_option :interactive, desc: "Set up your environment variables as you go."
|
13
13
|
method_option :force, desc: "force over-write of existing files"
|
14
14
|
|
15
15
|
|
16
16
|
def greenfield
|
17
|
+
confirm_directory_empty
|
17
18
|
confirm_dependencies
|
18
|
-
|
19
|
-
|
20
|
-
warning: "this is not an empty directory. Roro will not greenfield a new Rails app unless either a) the current directory is empty or b) you run greenfield with the --force flag",
|
21
|
-
suggestion: "$ roro greenfield --force",
|
22
|
-
conditional: "Dir.glob('*').empty?" })
|
23
|
-
get_configuration_variables
|
19
|
+
remove_roro_artifacts
|
20
|
+
configure_for_greenfielding
|
24
21
|
copy_greenfield_files
|
25
|
-
|
26
|
-
@env_hash[:use_force] = { force: true }
|
27
|
-
rollon
|
22
|
+
run_greenfield_commands
|
28
23
|
end
|
29
24
|
|
30
25
|
no_commands do
|
31
|
-
|
32
|
-
def copy_greenfield_files
|
33
|
-
template 'greenfield/Dockerfile.tt', 'Dockerfile', @env_hash
|
34
|
-
template 'greenfield/docker-compose.yml.tt', 'docker-compose.yml', @env_hash
|
35
|
-
end
|
36
26
|
|
37
|
-
def
|
27
|
+
def configure_for_greenfielding
|
28
|
+
@config ||= Roro::Configuration.new(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_greenfield_commands
|
38
32
|
system "DOCKER_BUILDKIT=1 docker build --file Dockerfile --output . ."
|
33
|
+
rollon
|
39
34
|
end
|
35
|
+
|
36
|
+
def copy_greenfield_files
|
37
|
+
template 'greenfield/Dockerfile.tt', 'Dockerfile', @config.app
|
38
|
+
end
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|