roro 0.3.4 → 0.3.9
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 +15 -2
- data/Guardfile +3 -6
- data/lib/roro.rb +1 -1
- data/lib/roro/cli.rb +75 -6
- data/lib/roro/cli/base/base.rb +2 -1
- data/lib/roro/cli/base/base_files.rb +4 -18
- 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/base/utilities.rb +22 -0
- data/lib/roro/cli/cli.rb +99 -0
- data/lib/roro/cli/configuration.rb +69 -0
- data/lib/roro/cli/expose.rb +8 -7
- 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 +47 -0
- data/lib/roro/cli/greenfield.rb +22 -91
- data/lib/roro/cli/obfuscate.rb +10 -11
- data/lib/roro/cli/rollon.rb +74 -18
- data/lib/roro/cli/rollon/stories.rb +2 -0
- data/{.keep → lib/roro/cli/rollon/stories/database.rb} +0 -0
- data/lib/roro/cli/rollon/stories/rails.rb +1 -0
- data/lib/roro/cli/{templates/base/roro → rollon/stories/rails}/.keep +0 -0
- data/lib/roro/cli/rollon/stories/rails/database.rb +33 -0
- data/lib/roro/cli/rollon/stories/rails/database/with_mysql.rb +22 -0
- data/lib/roro/cli/rollon/stories/rails/database/with_postgresql.rb +21 -0
- data/lib/roro/cli/rollon/stories/ruby_gem.rb +77 -0
- data/lib/roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb +81 -0
- data/lib/roro/cli/rollon/stories/stories.rb +3 -0
- data/lib/roro/cli/roro_configurator.yml +157 -0
- data/lib/roro/cli/ruby_gem.rb +60 -47
- data/lib/roro/cli/templates/base/.dockerignore +48 -10
- data/lib/roro/cli/templates/base/.roro_config.yml +15 -0
- data/lib/roro/cli/templates/base/Dockerfile.tt +82 -0
- data/lib/roro/cli/templates/base/config/database.mysql.yml +19 -0
- data/lib/roro/cli/templates/base/config/{database.yml → database.pg.yml} +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/containers → roro}/.keep +0 -0
- data/lib/roro/cli/templates/{dockerize/docker-compose.yml → roro/docker-compose.yml.tt} +18 -18
- data/lib/roro/cli/templates/{base/roro/containers/app → roro/roro}/.keep +0 -0
- data/lib/roro/cli/templates/{base/roro/containers/frontend → roro/roro/containers}/.keep +0 -0
- data/lib/roro/cli/templates/{dockerize/.env → roro/roro/containers/app}/.keep +0 -0
- data/lib/roro/cli/templates/{dockerize/.env/development → roro/roro/containers/frontend}/.keep +0 -0
- data/lib/roro/cli/templates/{quickstart/entrypoint.sh → roro/roro/docker-entrypoint.sh.tt} +1 -1
- data/lib/roro/cli/templates/ruby_gem/.circleci/config.yml +17 -0
- data/lib/roro/cli/templates/ruby_gem/docker-compose.yml +6 -4
- data/lib/roro/cli/templates/ruby_gem/roro/ci.env.tt +1 -0
- data/lib/roro/cli/templates/{dockerize → ruby_gem/roro/containers}/.keep +0 -0
- data/lib/roro/cli/templates/ruby_gem/roro/containers/ruby_image/Dockerfile.tt +16 -0
- data/lib/roro/cli/templates/ruby_gem/{docker/env_files → roro/keys}/.keep +0 -0
- data/lib/roro/cli/templates/{ruby_gem/docker/keys → 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
- data/roro.gemspec +5 -4
- data/sandbox/.keep +0 -0
- data/vendor/cache/concurrent-ruby-1.1.7.gem +0 -0
- data/vendor/cache/gem-release-2.1.1.gem +0 -0
- data/vendor/cache/mocha-1.11.2.gem +0 -0
- metadata +86 -55
- data/lib/roro/cli/base/configuration.rb +0 -63
- data/lib/roro/cli/generate_keys.rb +0 -79
- data/lib/roro/cli/rollon/as_dockerize.rb +0 -28
- data/lib/roro/cli/rollon/as_quickstart.rb +0 -17
- data/lib/roro/cli/rollon/as_roro.rb +0 -30
- data/lib/roro/cli/rollon/use_cases.rb +0 -3
- data/lib/roro/cli/templates/base/circleci/config.yml.tt +0 -70
- data/lib/roro/cli/templates/base/docker-compose.yml.tt +0 -53
- 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/lib/roro/cli/templates/dockerize/.env/development/database +0 -3
- data/lib/roro/cli/templates/dockerize/.env/development/web +0 -1
- data/lib/roro/cli/templates/dockerize/Dockerfile.tt +0 -23
- data/lib/roro/cli/templates/dockerize/docker-entrypoint.sh +0 -9
- data/lib/roro/cli/templates/greenfield/Gemfile +0 -2
- data/lib/roro/cli/templates/greenfield/config/database.yml.example +0 -16
- data/lib/roro/cli/templates/greenfield/docker-compose.yml +0 -17
- data/lib/roro/cli/templates/greenfield/docker-entrypoint.sh +0 -8
- data/lib/roro/cli/templates/quickstart/Dockerfile.tt +0 -20
- data/lib/roro/cli/templates/quickstart/database.yml +0 -85
- data/lib/roro/cli/templates/quickstart/docker-compose.yml +0 -17
- data/lib/roro/cli/templates/ruby_gem/.gitignore +0 -8
- data/lib/roro/cli/templates/ruby_gem/config.yml +0 -122
- data/lib/roro/cli/templates/ruby_gem/docker/containers/app/Dockerfile.tt +0 -10
- data/vendor/cache/concurrent-ruby-1.1.6.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: 04dbb241c4e833ddc92e4092594bafdc9be7d4e9a97f235ef2b3430af5c08081
|
4
|
+
data.tar.gz: 68dc2d2a07987ebeb819f7a4c15bc33ef43b2f1f544caf628706970a5f239bbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4debcc463150555b50360924374028fa74664955a33d47cf67f6362b3a9c1f84f2b2694551da8c342104e6e5d1386303f7018219b82549873b2a7d413747fea6
|
7
|
+
data.tar.gz: 0ec3c8fb00c1378007f6cad61e729b157b56b7be0d3bb4438f33e974365d6323f29bf1ded3dfb55293d24e23fab125f6bae02db786e77f3ea64766e865b95fea
|
data/.gitignore
CHANGED
@@ -5,7 +5,20 @@
|
|
5
5
|
/doc/
|
6
6
|
/pkg/
|
7
7
|
/spec/reports/
|
8
|
-
tmp/*
|
9
8
|
Gemfile.lock
|
10
9
|
.byebug_history
|
11
|
-
|
10
|
+
|
11
|
+
roro/**/*.env
|
12
|
+
roro/**/*.key
|
13
|
+
|
14
|
+
*.key
|
15
|
+
*.env
|
16
|
+
|
17
|
+
tmp/*
|
18
|
+
tmp/*
|
19
|
+
!tmp/.gitkeep
|
20
|
+
sandbox/*
|
21
|
+
!sandbox/.keep
|
22
|
+
!sandbox/greenfield
|
23
|
+
sandbox/greenfield/*
|
24
|
+
!sandbox/greenfield/.keep
|
data/Guardfile
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
4
|
options = {
|
5
|
-
cli: '',
|
6
|
-
|
5
|
+
cli: '-f',
|
6
|
+
all_on_start: true,
|
7
7
|
all_after_pass: true
|
8
8
|
}
|
9
9
|
|
@@ -11,10 +11,7 @@ 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/
|
15
|
-
|
14
|
+
watch(%r{^lib/roro/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
16
15
|
watch(%r{^test/thor_helper\.rb$}) { 'test' }
|
17
|
-
|
18
16
|
watch(%r{^test/fixtures/files/(.*/)?([^/]+)\.yml$}) { 'test' }
|
19
|
-
|
20
17
|
end
|
data/lib/roro.rb
CHANGED
data/lib/roro/cli.rb
CHANGED
@@ -1,20 +1,89 @@
|
|
1
|
-
require 'byebug'
|
2
|
-
require 'thor'
|
3
1
|
require 'roro/cli/base/base'
|
4
|
-
require 'roro/cli/rollon'
|
5
2
|
require 'roro/cli/greenfield'
|
6
|
-
require 'roro/cli/generate_keys'
|
7
3
|
require 'roro/cli/obfuscate'
|
8
4
|
require 'roro/cli/expose'
|
9
|
-
require 'roro/cli/
|
5
|
+
require 'roro/cli/generate/config/rails'
|
6
|
+
require 'roro/cli/generate/config'
|
7
|
+
require 'roro/cli/generate/generate_keys'
|
8
|
+
require 'roro/cli/configuration'
|
10
9
|
|
10
|
+
require 'roro/cli/rollon'
|
11
11
|
module Roro
|
12
|
+
|
12
13
|
class CLI < Thor
|
13
14
|
|
14
15
|
include Thor::Actions
|
15
|
-
|
16
|
+
|
16
17
|
def self.source_root
|
17
18
|
File.dirname(__FILE__) + '/cli/templates'
|
18
19
|
end
|
20
|
+
|
21
|
+
|
22
|
+
desc "rollon::rails", "Generates files for and makes changes to your app
|
23
|
+
so it can run using Docker containers."
|
24
|
+
method_option :interactive, desc: "Set up your environment variables as
|
25
|
+
you go."
|
26
|
+
map "rollon::rails" => "rollon_rails"
|
27
|
+
|
28
|
+
def rollon_rails
|
29
|
+
rollon
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
desc "greenfield::rails", "Greenfield a new, dockerized rails app with
|
34
|
+
either MySQL or PostgreSQL in a separate container."
|
35
|
+
|
36
|
+
method_option :env_vars, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "key1:value1 key2:value2"
|
37
|
+
method_option :interactive, desc: "Set up your environment variables as you go."
|
38
|
+
method_option :force, desc: "force over-write of existing files"
|
39
|
+
|
40
|
+
map "greenfield::rails" => "greenfield_rails"
|
41
|
+
|
42
|
+
def greenfield_rails(*args)
|
43
|
+
greenfield(*args)
|
44
|
+
end
|
45
|
+
desc "generate::exposed", "Generate private .env files from
|
46
|
+
encrypted .env.enc files inside the roro directory."
|
47
|
+
map "generate::exposed" => "generate_exposed"
|
48
|
+
|
49
|
+
def generate_exposed(*args)
|
50
|
+
expose(*args)
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "generate::key", "Generate a key inside roro/keys. Takes the name of
|
54
|
+
an environment as an argument to private .env files from
|
55
|
+
encrypted .env.enc files inside the roro directory.
|
56
|
+
Expose encrypted files"
|
57
|
+
|
58
|
+
map "generate::key" => "generate_key"
|
59
|
+
method_option :environment, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
|
60
|
+
|
61
|
+
def generate_key(*args)
|
62
|
+
generate_key_or_keys(*args)
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "generate::keys", "Generate keys for each environment inside roro/keys.
|
66
|
+
If you have .env files like 'roro/containers/app/[staging_env].env' and
|
67
|
+
'roro/[circle_ci_env].env' it will generate '/roro/keys/[staging_env].key'
|
68
|
+
and '/roro/keys/[circle_ci_env].key'."
|
69
|
+
map "generate::keys" => "generate_keys"
|
70
|
+
|
71
|
+
def generate_keys(*args)
|
72
|
+
generate_key(*args)
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "generate::config", "Generate a config file at .roro_config.yml"
|
76
|
+
map "generate::config" => "generate_config"
|
77
|
+
|
78
|
+
def generate_config
|
79
|
+
create_file ".roro_config.yml", @config.app.to_yaml
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "generate::obfuscated", "obfuscates any files matching the pattern ./roro/**/*.env"
|
83
|
+
map "generate::obfuscated" => "generate_obfuscated"
|
84
|
+
|
85
|
+
def generate_obfuscated(*args)
|
86
|
+
obfuscate(*args)
|
87
|
+
end
|
19
88
|
end
|
20
89
|
end
|
data/lib/roro/cli/base/base.rb
CHANGED
@@ -5,8 +5,7 @@ module Roro
|
|
5
5
|
no_commands do
|
6
6
|
|
7
7
|
def copy_dockerignore
|
8
|
-
copy_file 'base/.dockerignore', '.dockerignore'
|
9
|
-
|
8
|
+
copy_file 'base/.dockerignore', '.dockerignore'
|
10
9
|
end
|
11
10
|
|
12
11
|
def copy_host_example
|
@@ -14,24 +13,11 @@ module Roro
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def copy_docker_compose
|
17
|
-
template "base/docker-compose.yml", 'docker-compose.yml', @env_hash
|
18
|
-
end
|
19
|
-
|
20
|
-
def copy_roro
|
21
|
-
directory 'base/roro/containers/app', "roro/containers/#{@env_hash[:app_name]}", @env_hash
|
22
|
-
directory 'base/roro/containers/database', "roro/containers/#{@env_hash[:database_container]}", @env_hash
|
23
|
-
directory 'base/roro/containers/frontend', "roro/containers/#{@env_hash[:frontend_container]}", @env_hash
|
16
|
+
template "base/docker-compose.yml", 'docker-compose.yml', @env_hash
|
24
17
|
end
|
25
18
|
|
26
|
-
def
|
27
|
-
copy_file "base/config/database.yml", 'config/database.yml', @env_hash[:use_force]
|
28
|
-
end
|
29
|
-
|
30
|
-
def copy_base_files
|
31
|
-
copy_circleci
|
32
|
-
copy_roro
|
33
|
-
copy_docker_compose
|
34
|
-
copy_config_database_yml
|
19
|
+
def copy_database_yml_pg
|
20
|
+
copy_file "base/config/database.pg.yml", 'config/database.yml', force: @env_hash[:use_force]
|
35
21
|
end
|
36
22
|
end
|
37
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
|
@@ -12,6 +12,28 @@ module Roro
|
|
12
12
|
def own_if_required
|
13
13
|
system 'sudo chown -R $USER .'
|
14
14
|
end
|
15
|
+
|
16
|
+
def as_system(command)
|
17
|
+
command = OS.linux? ? "sudo #{command}" : command
|
18
|
+
system command
|
19
|
+
end
|
20
|
+
|
21
|
+
def chown_if_required()
|
22
|
+
warning = "It looks like you're running Docker on some flavor of Linux, in which case the files created by your containers are owned by the root user of the container, and not by the user of the host machine. Please change their ownership by supplying your password at the prompt.",
|
23
|
+
action = "system 'sudo chown -R $USER .'"
|
24
|
+
msg = []
|
25
|
+
msg << ""
|
26
|
+
msg << delineator
|
27
|
+
msg << warning
|
28
|
+
msg << ""
|
29
|
+
msg.join("\n\n")
|
30
|
+
puts msg
|
31
|
+
eval(action)
|
32
|
+
end
|
33
|
+
|
34
|
+
def delineator
|
35
|
+
("-" * 80)
|
36
|
+
end
|
15
37
|
end
|
16
38
|
end
|
17
39
|
end
|
data/lib/roro/cli/cli.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'roro/cli/base/base'
|
3
|
+
require 'roro/cli/rollon/stories'
|
4
|
+
require 'roro/cli/rollon'
|
5
|
+
require 'roro/cli/greenfield'
|
6
|
+
require 'roro/cli/obfuscate'
|
7
|
+
require 'roro/cli/expose'
|
8
|
+
require 'roro/cli/ruby_gem'
|
9
|
+
require 'roro/cli/generate/config/rails'
|
10
|
+
require 'roro/cli/generate/config'
|
11
|
+
require 'roro/cli/generate/generate_keys'
|
12
|
+
require 'roro/cli/configuration'
|
13
|
+
|
14
|
+
module Roro
|
15
|
+
|
16
|
+
class CLI < Thor
|
17
|
+
|
18
|
+
include Thor::Actions
|
19
|
+
|
20
|
+
def self.source_root
|
21
|
+
File.dirname(__FILE__) + '/cli/templates'
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "rollon::ruby_gem", "Generate files for containerized gem testing, CircleCI, and releasing to RubyGems."
|
25
|
+
method_option :rubies, type: :array, banner: "2.5.3 2.4.2"
|
26
|
+
map "rollon::ruby_gem" => "rollon_ruby_gem"
|
27
|
+
|
28
|
+
def rollon_ruby_gem(*args)
|
29
|
+
ruby_gem(*args)
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "rollon::rails", "Generates files for and makes changes to your app
|
33
|
+
so it can run using Docker containers."
|
34
|
+
method_option :interactive, desc: "Set up your environment variables as
|
35
|
+
you go."
|
36
|
+
map "rollon::rails" => "rollon_rails"
|
37
|
+
|
38
|
+
def rollon_rails
|
39
|
+
rollon
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
desc "greenfield::rails", "Greenfield a new, dockerized rails app with
|
44
|
+
either MySQL or PostgreSQL in a separate container."
|
45
|
+
|
46
|
+
method_option :env_vars, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "key1:value1 key2:value2"
|
47
|
+
method_option :interactive, desc: "Set up your environment variables as you go."
|
48
|
+
method_option :force, desc: "force over-write of existing files"
|
49
|
+
|
50
|
+
map "greenfield::rails" => "greenfield_rails"
|
51
|
+
|
52
|
+
def greenfield_rails(*args)
|
53
|
+
greenfield(*args)
|
54
|
+
end
|
55
|
+
desc "generate::exposed", "Generate private .env files from
|
56
|
+
encrypted .env.enc files inside the roro directory."
|
57
|
+
map "generate::exposed" => "generate_exposed"
|
58
|
+
|
59
|
+
def generate_exposed(*args)
|
60
|
+
expose(*args)
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "generate::key", "Generate a key inside roro/keys. Takes the name of
|
64
|
+
an environment as an argument to private .env files from
|
65
|
+
encrypted .env.enc files inside the roro directory.
|
66
|
+
Expose encrypted files"
|
67
|
+
|
68
|
+
map "generate::key" => "generate_key"
|
69
|
+
method_option :environment, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
|
70
|
+
|
71
|
+
def generate_key(*args)
|
72
|
+
generate_key_or_keys(*args)
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "generate::keys", "Generate keys for each environment inside roro/keys.
|
76
|
+
If you have .env files like 'roro/containers/app/[staging_env].env' and
|
77
|
+
'roro/[circle_ci_env].env' it will generate '/roro/keys/[staging_env].key'
|
78
|
+
and '/roro/keys/[circle_ci_env].key'."
|
79
|
+
map "generate::keys" => "generate_keys"
|
80
|
+
|
81
|
+
def generate_keys(*args)
|
82
|
+
generate_key(*args)
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "generate::config", "Generate a config file at .roro_config.yml"
|
86
|
+
map "generate::config" => "generate_config"
|
87
|
+
|
88
|
+
def generate_config
|
89
|
+
create_file ".roro_config.yml", @config.app.to_yaml
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "generate::obfuscated", "obfuscates any files matching the pattern ./roro/**/*.env"
|
93
|
+
map "generate::obfuscated" => "generate_obfuscated"
|
94
|
+
|
95
|
+
def generate_obfuscated(*args)
|
96
|
+
obfuscate(*args)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|