roro 0.3.12 → 0.3.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +5 -5
  2. data/{lib/roro/cli/rollon/stories/rails → .circleci}/.keep +0 -0
  3. data/.circleci/config.yml +93 -0
  4. data/{lib/roro/cli/templates/ruby_gem → .circleci}/setup-gem-credentials.sh +1 -1
  5. data/.gitignore +5 -4
  6. data/Guardfile +8 -10
  7. data/README.md +2 -1
  8. data/{lib/roro/cli/templates/ruby_gem/docker-compose.yml → docker-compose.yml} +6 -2
  9. data/lib/roro.rb +2 -1
  10. data/lib/roro/cli.rb +16 -74
  11. data/lib/roro/cli/generate/exposed.rb +14 -0
  12. data/lib/roro/cli/generate/{generate_keys.rb → keys.rb} +22 -0
  13. data/lib/roro/cli/generate/obfuscated.rb +17 -0
  14. data/lib/roro/cli/generate/story.rb +18 -0
  15. data/lib/roro/cli/greenfield/rails.rb +14 -0
  16. data/lib/roro/cli/rollon.rb +126 -63
  17. data/lib/roro/cli/rollon/rails/base/base.rb +4 -0
  18. data/lib/roro/cli/{base → rollon/rails/base}/insert_gems.rb +2 -10
  19. data/lib/roro/cli/{base → rollon/rails/base}/insertions.rb +8 -0
  20. data/lib/roro/cli/rollon/rails/database.rb +26 -0
  21. data/lib/roro/cli/rollon/{stories/rails → rails}/database/with_mysql.rb +4 -4
  22. data/lib/roro/cli/rollon/{stories/rails → rails}/database/with_postgresql.rb +5 -6
  23. data/lib/roro/cli/rollon/ruby_gem.rb +1 -0
  24. data/lib/roro/cli/rollon/ruby_gem/with_ci_cd.rb +45 -0
  25. data/lib/roro/cli/rollon/stories.rb +2 -2
  26. data/lib/roro/configurator.rb +15 -0
  27. data/lib/roro/configurator/eligibility.rb +137 -0
  28. data/lib/roro/configurator/okonomi.rb +28 -0
  29. data/lib/roro/configurator/omakase.rb +170 -0
  30. data/lib/roro/stories/greenfield.yml +1 -0
  31. data/lib/roro/stories/greenfield/rails.yml +9 -0
  32. data/lib/roro/stories/rollon.yml +42 -0
  33. data/lib/roro/stories/rollon/rails.yml +76 -0
  34. data/lib/roro/stories/rollon/rails/ci_cd.yml +1 -0
  35. data/lib/roro/stories/rollon/rails/ci_cd/circleci.yml +2 -0
  36. data/lib/roro/stories/rollon/rails/database.yml +9 -0
  37. data/lib/roro/stories/rollon/rails/database/mysql.yml +17 -0
  38. data/lib/roro/stories/rollon/rails/database/postgresql.yml +15 -0
  39. data/lib/roro/stories/rollon/rails/kubernetes.yml +1 -0
  40. data/lib/roro/stories/rollon/rails/kubernetes/postgresql.yml +10 -0
  41. data/lib/roro/stories/rollon/rails/kubernetes/postgresql/default.yml +1 -0
  42. data/lib/roro/stories/rollon/rails/kubernetes/postgresql/edge.yml +1 -0
  43. data/lib/roro/stories/rollon/ruby_gem.yml +5 -0
  44. data/lib/roro/templates/base/.circleci/_aliases.yml +8 -0
  45. data/lib/roro/templates/base/.circleci/_commands.yml +31 -0
  46. data/lib/roro/templates/base/.circleci/_defaults.yml +5 -0
  47. data/lib/roro/templates/base/.circleci/_executors.yml +11 -0
  48. data/lib/roro/templates/base/.circleci/_major_only.yml +4 -0
  49. data/lib/roro/templates/base/.circleci/_version.yml +1 -0
  50. data/lib/roro/templates/base/.circleci/_workflow.yml +2 -0
  51. data/lib/roro/templates/base/.circleci/config.job-example.yml +33 -0
  52. data/lib/roro/templates/base/.circleci/jobs/_build.yml +4 -0
  53. data/lib/roro/templates/base/.circleci/jobs/_release.yml +12 -0
  54. data/lib/roro/templates/base/.circleci/workflows/_build_release.yml +10 -0
  55. data/lib/roro/{cli/templates → templates}/base/.dockerignore +2 -2
  56. data/lib/roro/templates/base/dotenv +1 -0
  57. data/lib/roro/{cli/templates/base → templates/base/jumpstart}/.keep +0 -0
  58. data/lib/roro/{cli/templates → templates/base}/jumpstart/Dockerfile.tt +0 -0
  59. data/lib/roro/{cli/templates → templates/base}/jumpstart/docker-compose.yml +0 -0
  60. data/lib/roro/{cli/templates → templates/base}/jumpstart/docker-entrypoint.sh +0 -0
  61. data/lib/roro/{cli/templates → templates/base}/livereload/hosts.example +0 -0
  62. data/lib/roro/{cli/templates/jumpstart → templates/base/roro}/.keep +0 -0
  63. data/lib/roro/{cli/templates → templates/base/roro}/roro/.keep +0 -0
  64. data/lib/roro/{cli/templates/roro/roro → templates/base/roro/roro/containers}/.keep +0 -0
  65. data/lib/roro/{cli/templates/roro/roro/containers → templates/base/roro/roro/containers/app}/.keep +0 -0
  66. data/lib/roro/{cli/templates/roro/roro/containers/app → templates/base/roro/roro/containers/frontend}/.keep +0 -0
  67. data/lib/roro/{cli/templates → templates/base}/roro/roro/docker-entrypoint.sh.tt +0 -0
  68. data/lib/roro/{cli/templates/roro/roro/containers/frontend → templates/rails/.circleci}/.keep +0 -0
  69. data/lib/roro/templates/rails/.circleci/config.yml.tt +11 -0
  70. data/lib/roro/templates/rails/.circleci/jobs/_build.yml +14 -0
  71. data/lib/roro/templates/rails/.circleci/jobs/_push.yml +11 -0
  72. data/lib/roro/templates/rails/.circleci/jobs/_test.yml +12 -0
  73. data/lib/roro/templates/rails/.circleci/setup-gem-credentials.sh +3 -0
  74. data/lib/roro/templates/rails/.circleci/workflows/_build_test_push.yml +12 -0
  75. data/lib/roro/{cli/templates/ruby_gem/roro/containers → templates/rails}/.keep +0 -0
  76. data/lib/roro/templates/rails/Dockerfile.greenfield.tt +51 -0
  77. data/lib/roro/{cli/templates/base → templates/rails}/config/database.mysql.yml +0 -0
  78. data/lib/roro/{cli/templates/base → templates/rails}/config/database.pg.yml +2 -3
  79. data/lib/roro/templates/rails/database/with_mysql/_service.yml +10 -0
  80. data/lib/roro/{cli/templates/ruby_gem/roro/keys → templates/rails/database/with_postgresql}/.keep +0 -0
  81. data/lib/roro/templates/rails/database/with_postgresql/_service.yml +7 -0
  82. data/lib/roro/{cli/templates/roro → templates/rails}/docker-compose.yml.tt +9 -10
  83. data/lib/roro/{cli/templates/stories → templates/rails/dotenv}/.keep +0 -0
  84. data/lib/roro/templates/rails/dotenv/database.mysql.env.tt +6 -0
  85. data/lib/roro/templates/rails/dotenv/database.pg.env.tt +4 -0
  86. data/lib/roro/templates/rails/dotenv/web.env.tt +2 -0
  87. data/lib/roro/templates/rails/kube.rake.tt +114 -0
  88. data/lib/roro/{cli/templates/stories/with_postgresql → templates/rails/roro}/.keep +0 -0
  89. data/lib/roro/{cli/rollon/stories/database.rb → templates/rails/roro/containers/.keep} +0 -0
  90. data/lib/roro/templates/rails/roro/containers/app/.keep +0 -0
  91. data/lib/roro/templates/rails/roro/containers/app/Dockerfile.tt +34 -0
  92. data/lib/roro/templates/rails/roro/containers/frontend/.keep +0 -0
  93. data/lib/roro/templates/rails/roro/docker-entrypoint.sh +8 -0
  94. data/lib/roro/templates/rails/roro/kube/.keep +0 -0
  95. data/lib/roro/templates/rails/roro/kube/certificate.yml.tt +0 -0
  96. data/lib/roro/templates/rails/roro/kube/cluster-issuer.yml.tt +0 -0
  97. data/lib/roro/templates/rails/roro/kube/deployment.yml.tt +50 -0
  98. data/lib/roro/templates/rails/roro/kube/deployments/postgres_deploy.yaml +47 -0
  99. data/lib/roro/templates/rails/roro/kube/deployments/rails_deploy.yaml +62 -0
  100. data/lib/roro/templates/rails/roro/kube/deployments/redis_deploy.yaml +23 -0
  101. data/lib/roro/templates/rails/roro/kube/deployments/sidekiq_deploy.yaml +56 -0
  102. data/lib/roro/templates/rails/roro/kube/ingress.yml.tt +0 -0
  103. data/lib/roro/templates/rails/roro/kube/ingresses/ingress.yaml +13 -0
  104. data/lib/roro/templates/rails/roro/kube/job-migrate.yml.tt +0 -0
  105. data/lib/roro/templates/rails/roro/kube/jobs/setup.yaml +42 -0
  106. data/lib/roro/templates/rails/roro/kube/secret-digital-ocean.yml.tt +4 -0
  107. data/lib/roro/templates/rails/roro/kube/service.yml.tt +10 -0
  108. data/lib/roro/templates/rails/roro/kube/services/postgres_svc.yaml +13 -0
  109. data/lib/roro/templates/rails/roro/kube/services/rails_svc.yaml +13 -0
  110. data/lib/roro/templates/rails/roro/kube/services/redis_svc.yaml +13 -0
  111. data/lib/roro/templates/rails/roro/kube/volumes/postgres_volumes.yaml +25 -0
  112. data/lib/roro/templates/ruby_gem/.circleci/.keep +0 -0
  113. data/lib/roro/templates/ruby_gem/.circleci/config.yml.tt +16 -0
  114. data/lib/roro/templates/ruby_gem/.circleci/jobs/_test.yml +4 -0
  115. data/lib/roro/templates/ruby_gem/.circleci/setup-gem-credentials.sh +3 -0
  116. data/lib/roro/templates/ruby_gem/docker-compose.yml +15 -0
  117. data/lib/roro/templates/ruby_gem/roro/containers/.keep +0 -0
  118. data/lib/roro/templates/ruby_gem/roro/containers/ruby_image/Dockerfile.tt +16 -0
  119. data/lib/roro/templates/ruby_gem/roro/containers/ruby_image/ci.env.tt +1 -0
  120. data/lib/roro/templates/ruby_gem/roro/keys/.keep +0 -0
  121. data/lib/roro/version.rb +1 -1
  122. data/roro.gemspec +10 -10
  123. data/roro/containers/.keep +0 -0
  124. data/roro/containers/ruby_image/Dockerfile +16 -0
  125. data/roro/containers/ruby_image/ci.env.enc +2 -0
  126. data/roro/keys/.keep +0 -0
  127. data/tmp/.keep +0 -0
  128. metadata +177 -157
  129. data/lib/roro/cli/base/base.rb +0 -8
  130. data/lib/roro/cli/base/base_files.rb +0 -24
  131. data/lib/roro/cli/base/check_dependencies.rb +0 -98
  132. data/lib/roro/cli/base/continuous_integration.rb +0 -13
  133. data/lib/roro/cli/base/utilities.rb +0 -39
  134. data/lib/roro/cli/cli.rb +0 -99
  135. data/lib/roro/cli/configuration.rb +0 -69
  136. data/lib/roro/cli/expose.rb +0 -14
  137. data/lib/roro/cli/generate/config.rb +0 -13
  138. data/lib/roro/cli/generate/config/rails.rb +0 -17
  139. data/lib/roro/cli/greenfield.rb +0 -31
  140. data/lib/roro/cli/obfuscate.rb +0 -19
  141. data/lib/roro/cli/rollon/stories/rails.rb +0 -1
  142. data/lib/roro/cli/rollon/stories/rails/database.rb +0 -33
  143. data/lib/roro/cli/rollon/stories/ruby_gem.rb +0 -77
  144. data/lib/roro/cli/rollon/stories/ruby_gem/with_ci_cd.rb +0 -81
  145. data/lib/roro/cli/rollon/stories/stories.rb +0 -3
  146. data/lib/roro/cli/roro_configurator.yml +0 -157
  147. data/lib/roro/cli/ruby_gem.rb +0 -67
  148. data/lib/roro/cli/templates/base/.roro_config.yml +0 -15
  149. data/lib/roro/cli/templates/base/Dockerfile.tt +0 -82
  150. data/lib/roro/cli/templates/greenfield/Dockerfile.tt +0 -43
  151. data/lib/roro/cli/templates/ruby_gem/.circleci/config.yml +0 -17
  152. data/lib/roro/cli/templates/ruby_gem/roro/ci.env.tt +0 -1
  153. data/lib/roro/cli/templates/ruby_gem/roro/containers/ruby_image/Dockerfile.tt +0 -16
  154. data/lib/roro/cli/templates/stories/with_mysql/_service.yml +0 -10
  155. data/lib/roro/cli/templates/stories/with_postgresql/_service.yml +0 -7
  156. data/lib/tasks/deploy.rake +0 -126
  157. data/vendor/cache/actionpack-6.0.3.2.gem +0 -0
  158. data/vendor/cache/actionview-6.0.3.2.gem +0 -0
  159. data/vendor/cache/activesupport-6.0.3.2.gem +0 -0
  160. data/vendor/cache/addressable-2.7.0.gem +0 -0
  161. data/vendor/cache/builder-3.2.4.gem +0 -0
  162. data/vendor/cache/byebug-11.1.3.gem +0 -0
  163. data/vendor/cache/coderay-1.1.3.gem +0 -0
  164. data/vendor/cache/concurrent-ruby-1.1.7.gem +0 -0
  165. data/vendor/cache/crass-1.0.6.gem +0 -0
  166. data/vendor/cache/em-websocket-0.5.1.gem +0 -0
  167. data/vendor/cache/erubi-1.9.0.gem +0 -0
  168. data/vendor/cache/eventmachine-1.2.7.gem +0 -0
  169. data/vendor/cache/ffi-1.13.1.gem +0 -0
  170. data/vendor/cache/formatador-0.2.5.gem +0 -0
  171. data/vendor/cache/gem-release-2.1.1.gem +0 -0
  172. data/vendor/cache/given_core-3.8.0.gem +0 -0
  173. data/vendor/cache/guard-2.16.2.gem +0 -0
  174. data/vendor/cache/guard-compat-1.2.1.gem +0 -0
  175. data/vendor/cache/guard-livereload-2.5.2.gem +0 -0
  176. data/vendor/cache/guard-minitest-2.4.6.gem +0 -0
  177. data/vendor/cache/handsome_fencer-crypto-0.1.6.gem +0 -0
  178. data/vendor/cache/handsome_fencer-test-0.1.1.gem +0 -0
  179. data/vendor/cache/http_parser.rb-0.6.0.gem +0 -0
  180. data/vendor/cache/i18n-1.8.5.gem +0 -0
  181. data/vendor/cache/launchy-2.5.0.gem +0 -0
  182. data/vendor/cache/listen-3.2.1.gem +0 -0
  183. data/vendor/cache/loofah-2.6.0.gem +0 -0
  184. data/vendor/cache/lumberjack-1.2.7.gem +0 -0
  185. data/vendor/cache/method_source-1.0.0.gem +0 -0
  186. data/vendor/cache/mini_portile2-2.4.0.gem +0 -0
  187. data/vendor/cache/minitest-5.14.1.gem +0 -0
  188. data/vendor/cache/minitest-given-3.8.0.gem +0 -0
  189. data/vendor/cache/minitest-matchers_vaccine-1.0.4.gem +0 -0
  190. data/vendor/cache/minitest-rails-6.0.1.gem +0 -0
  191. data/vendor/cache/mocha-1.11.2.gem +0 -0
  192. data/vendor/cache/multi_json-1.15.0.gem +0 -0
  193. data/vendor/cache/nenv-0.3.0.gem +0 -0
  194. data/vendor/cache/net-scp-3.0.0.gem +0 -0
  195. data/vendor/cache/net-ssh-6.1.0.gem +0 -0
  196. data/vendor/cache/nokogiri-1.10.10.gem +0 -0
  197. data/vendor/cache/notiffany-0.1.3.gem +0 -0
  198. data/vendor/cache/os-1.0.0.gem +0 -0
  199. data/vendor/cache/pry-0.13.1.gem +0 -0
  200. data/vendor/cache/public_suffix-4.0.5.gem +0 -0
  201. data/vendor/cache/rack-2.2.3.gem +0 -0
  202. data/vendor/cache/rack-livereload-0.3.17.gem +0 -0
  203. data/vendor/cache/rack-test-1.1.0.gem +0 -0
  204. data/vendor/cache/rails-dom-testing-2.0.3.gem +0 -0
  205. data/vendor/cache/rails-html-sanitizer-1.3.0.gem +0 -0
  206. data/vendor/cache/railties-6.0.3.2.gem +0 -0
  207. data/vendor/cache/rake-13.0.1.gem +0 -0
  208. data/vendor/cache/rb-fsevent-0.10.4.gem +0 -0
  209. data/vendor/cache/rb-inotify-0.10.1.gem +0 -0
  210. data/vendor/cache/shellany-0.0.1.gem +0 -0
  211. data/vendor/cache/shoulda-4.0.0.gem +0 -0
  212. data/vendor/cache/shoulda-context-2.0.0.gem +0 -0
  213. data/vendor/cache/shoulda-matchers-4.3.0.gem +0 -0
  214. data/vendor/cache/sorcerer-2.0.1.gem +0 -0
  215. data/vendor/cache/sshkit-1.18.2.gem +0 -0
  216. data/vendor/cache/thor-1.0.1.gem +0 -0
  217. data/vendor/cache/thread_safe-0.3.6.gem +0 -0
  218. data/vendor/cache/tzinfo-1.2.7.gem +0 -0
  219. data/vendor/cache/zeitwerk-2.4.0.gem +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: c6bf9813b07f7c2c2f34a0e0e4578130062af0752865da885f4da75c4def51c2
4
- data.tar.gz: 2ff26062242671ba49fdffd5b6e87d0477ffb906fb5af967b758440fb4dade1d
2
+ SHA1:
3
+ metadata.gz: 28419719167db581fa026244d2628fa4c86c9d3b
4
+ data.tar.gz: b46403289b09d42a550ac9dff3a4edcc717f2c63
5
5
  SHA512:
6
- metadata.gz: d272d16756b148c197ec2b0dcaf25463f0669e88ad4c79ff2f9fc19a2508be72d7ebd13b33ef595df1d146bd22346a8f9413f99ce4d61139167ee0923e103dc7
7
- data.tar.gz: 1ce050d03045da0c39d93f8f6ecbf9e4a92782ee7a7594aa976dbdea7350b53964612cd6b970f852749d016b071ccc8c56afca4ce71ed8ab632360150f086fd8
6
+ metadata.gz: 3b2075ccae46a264f2d64bf2d2c09fb678bf95a44d534b0263dcb2a9e5cbf6345663d683bea3219ec728512e65eca391e1715a7334d304d4e46411a3e75f6ec1
7
+ data.tar.gz: 5ef3392e89e8e72af5e190a79f45ff7e107db744c0fe2a886b6e0e11bf6829c0fc723c6e298c0ad51d20a7b4882dbd84035b3b966a2eabdf5484e4c32827ae28
@@ -0,0 +1,93 @@
1
+ aliases:
2
+ - &workspace-location
3
+ at: /tmp/workspace
4
+ - &copy-ci-dotenv |
5
+ cp -rf /tmp/workspace/roro .
6
+ - &source-ci-variables |
7
+ echo 'source roro/containers/app/ci.env' >> $BASH_ENV
8
+ source $BASH_ENV
9
+
10
+ defaults: &defaults
11
+ executor: machine-executor
12
+ working_directory: ~/project
13
+
14
+ major_only: &major_only
15
+ filters:
16
+ branches:
17
+ only: master, release
18
+
19
+ version: 2.1
20
+
21
+ executors:
22
+ machine-executor:
23
+ machine: true
24
+ ruby-executor:
25
+ docker:
26
+ - image: cimg/ruby:2.7
27
+
28
+ jobs:
29
+
30
+ build:
31
+ <<: *defaults
32
+ steps:
33
+ - checkout
34
+
35
+ test-rollon-rails:
36
+ executor: ruby-executor
37
+ steps:
38
+ - checkout
39
+ - setup_remote_docker:
40
+ version: 19.03.12
41
+ - run: |
42
+ rake install
43
+ mkdir greenfield
44
+ cd greenfield
45
+ (yes || true) | roro greenfield
46
+ - run: echo 'success'
47
+
48
+ test:
49
+ <<: *defaults
50
+ steps:
51
+ - checkout
52
+ - run: RUBY_VERSION=2.5 docker-compose build ruby_gem
53
+ - run: RUBY_VERSION=2.5 docker-compose up -d --force-recreate ruby_gem
54
+ - run: RUBY_VERSION=2.5 docker-compose run ruby_gem bundle exec rake test
55
+ - run: RUBY_VERSION=2.6 docker-compose build ruby_gem
56
+ - run: RUBY_VERSION=2.6 docker-compose up -d --force-recreate ruby_gem
57
+ - run: RUBY_VERSION=2.6 docker-compose run ruby_gem bundle exec rake test
58
+ - run: RUBY_VERSION=2.7 docker-compose build ruby_gem
59
+ - run: RUBY_VERSION=2.7 docker-compose up -d --force-recreate ruby_gem
60
+ - run: RUBY_VERSION=2.7 docker-compose run ruby_gem bundle exec rake test
61
+
62
+ release:
63
+ <<: *defaults
64
+ steps:
65
+ - checkout
66
+ - run: gem install roro
67
+ - run: roro generate::exposed ci
68
+ - run: |
69
+ echo $(cat ./roro/containers/ruby_image/ci.env) >> $BASH_ENV
70
+ source $BASH_ENV
71
+ - run: chmod +x ./.circleci/setup-gem-credentials.sh
72
+ - run: ./.circleci/setup-gem-credentials.sh
73
+ - run: chmod 0600 ~/.gem/credentials
74
+ - run: git checkout .
75
+ - run: gem release
76
+
77
+ workflows:
78
+ version: 2
79
+
80
+ build-cli:
81
+ jobs:
82
+ - build
83
+ - test-rollon-rails:
84
+ <<: *major_only
85
+ - test:
86
+ <<: *major_only
87
+
88
+ - release:
89
+ requires:
90
+ - build
91
+ filters:
92
+ branches:
93
+ only: release
@@ -1,3 +1,3 @@
1
1
  mkdir ~/.gem
2
2
  echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
3
- chmod 0600 /home/circleci/.gem/credentials
3
+ chmod 0600 /home/circleci/.gem/credentials
data/.gitignore CHANGED
@@ -13,12 +13,13 @@ roro/**/*.key
13
13
 
14
14
  *.key
15
15
  *.env
16
-
17
- tmp/*
16
+ !/.gitignore
17
+ *.gem
18
18
  tmp/*
19
- !tmp/.gitkeep
19
+ !tmp/.keep
20
20
  sandbox/*
21
21
  !sandbox/.keep
22
22
  !sandbox/greenfield
23
23
  sandbox/greenfield/*
24
- !sandbox/greenfield/.keep
24
+ !sandbox/greenfield/.keep
25
+ TUTORIAL.md
data/Guardfile CHANGED
@@ -1,17 +1,15 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
1
  options = {
5
- cli: '-f',
6
- all_on_start: true,
7
- all_after_pass: true
2
+ all_on_start: false,
3
+ all_after_pass: false,
8
4
  }
9
5
 
10
6
  guard :minitest, options do
11
7
 
12
- watch(%r{^test/(.*)\/?test_(.*)\.rb$})
13
8
  watch(%r{^test/(.*)\/?(.*)_test\.rb$})
14
- watch(%r{^lib/roro/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
15
- watch(%r{^test/thor_helper\.rb$}) { 'test' }
16
- watch(%r{^test/fixtures/files/(.*/)?([^/]+)\.yml$}) { 'test' }
9
+ watch(%r{^test/helpers/(.*)\.rb$}) { 'test' }
10
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
11
+ watch(%r{^lib/roro/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
12
+ watch(%r{^lib/roro/cli/(.+)\.rb$}) { |m| "test/cli/#{m[1]}_test.rb" }
13
+ watch(%r{^lib/roro/cli/(.+)\.yml$}) { |m| "test/cli" }
14
+ watch(%r{^lib/roro/cli/(.+)\.tt$}) { |m| "test/cli" }
17
15
  end
data/README.md CHANGED
@@ -217,4 +217,5 @@ $ docker system prune -af --volumes
217
217
  This gem and its associated practices are just one way of using these tools and not the canonical way. My purpose in publishing it is to get a conversation started about what conventions around these tools might look like. If you have ideas on how to make it better please put in an issue -- or fork the repo, make your changes, write your tests, and send me a pull request. It'll make me feel warm inside.
218
218
 
219
219
  ## License
220
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
220
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
221
+
@@ -7,5 +7,9 @@ services:
7
7
  context: .
8
8
  dockerfile: roro/containers/ruby_image/Dockerfile
9
9
  environment:
10
- - RUBY_IMAGE=${RUBY_IMAGE}
11
- command: bundle exec rake test
10
+ - RUBY_VERSION=${RUBY_VERSION}
11
+ volumes:
12
+ - gem_cache:/gems
13
+
14
+ volumes:
15
+ gem_cache:
@@ -1,6 +1,7 @@
1
- require "roro/version"
2
1
  require "thor"
2
+ require "roro/version"
3
3
  require "roro/cli"
4
+ require "roro/configurator"
4
5
 
5
6
  module Roro
6
7
  class Error < StandardError; end
@@ -1,89 +1,31 @@
1
- require 'roro/cli/base/base'
2
- require 'roro/cli/greenfield'
3
- require 'roro/cli/obfuscate'
4
- require 'roro/cli/expose'
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'
9
1
 
2
+ require 'roro/cli/generate/exposed'
3
+ require 'roro/cli/generate/keys'
4
+ require 'roro/cli/generate/obfuscated'
5
+ require 'roro/cli/generate/story'
6
+ require 'roro/cli/greenfield/rails'
10
7
  require 'roro/cli/rollon'
8
+ require 'roro/cli/rollon/rails/base/base'
9
+ require 'roro/cli/rollon/rails/database/with_mysql'
10
+ require 'roro/cli/rollon/rails/database/with_postgresql'
11
+
12
+ require 'roro/cli/rollon/ruby_gem'
13
+
11
14
  module Roro
12
-
13
15
  class CLI < Thor
14
16
 
15
17
  include Thor::Actions
16
18
 
17
19
  def self.source_root
18
- File.dirname(__FILE__) + '/cli/templates'
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)
20
+ File.dirname(__FILE__) + '/templates'
44
21
  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
22
 
49
- def generate_exposed(*args)
50
- expose(*args)
23
+ def self.story_root
24
+ File.dirname(__FILE__) + '/stories'
51
25
  end
52
26
 
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)
27
+ def self.roro_environments
28
+ %w(development production test staging ci)
87
29
  end
88
30
  end
89
31
  end
@@ -0,0 +1,14 @@
1
+ module Roro
2
+ class CLI < Thor
3
+
4
+ desc "generate::exposed", "Generate private .env files from encrypted .env.enc files inside the roro directory."
5
+ map "generate::exposed" => "generate_exposed"
6
+
7
+ def generate_exposed(*args)
8
+ environments = args.first ? [args.first] : gather_environments
9
+ environments.each do |environment|
10
+ HandsomeFencer::Crypto.expose(environment, 'roro')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,6 +2,28 @@ module Roro
2
2
 
3
3
  class CLI < Thor
4
4
 
5
+ desc "generate::key", "Generate a key inside roro/keys. Takes the name of
6
+ an environment as an argument to private .env files from
7
+ encrypted .env.enc files inside the roro directory.
8
+ Expose encrypted files"
9
+
10
+ map "generate::key" => "generate_key"
11
+ method_option :environment, type: :hash, default: {}, desc: "Pass a list of environment variables like so: env:var", banner: "development, staging"
12
+
13
+ def generate_key(*args)
14
+ generate_key_or_keys(*args)
15
+ end
16
+
17
+ desc "generate::keys", "Generate keys for each environment inside roro/keys.
18
+ If you have .env files like 'roro/containers/app/[staging_env].env' and
19
+ 'roro/[circle_ci_env].env' it will generate '/roro/keys/[staging_env].key'
20
+ and '/roro/keys/[circle_ci_env].key'."
21
+ map "generate::keys" => "generate_keys"
22
+
23
+ def generate_keys(*args)
24
+ generate_key(*args)
25
+ end
26
+
5
27
  no_commands do
6
28
 
7
29
  def generate_key_or_keys(*args)
@@ -0,0 +1,17 @@
1
+ require 'handsome_fencer/crypto'
2
+
3
+ module Roro
4
+
5
+ class CLI < Thor
6
+
7
+ desc "generate::obfuscated", "obfuscates any files matching the pattern ./roro/**/*.env"
8
+ map "generate::obfuscated" => "generate_obfuscated"
9
+
10
+ def generate_obfuscated(*args)
11
+ environments = args.first ? [args.first] : gather_environments
12
+ environments.each do |environment|
13
+ HandsomeFencer::Crypto.obfuscate(environment, 'roro')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Roro
2
+ class CLI < Thor
3
+
4
+ desc "generate::story", "Generate a config file at .roro_config.yml to use later"
5
+ map "generate::story" => "generate_story"
6
+
7
+ def generate_story
8
+
9
+ @config ||= Roro::Configuration.new(options)
10
+ # configuration = {
11
+ # env_vars: @config.env.keys,
12
+ # intentions: @config.intentions,
13
+ # story: @config.structure['story']
14
+ # }
15
+ # create_file ".roro_configurator.yml", @config.env.to_yaml
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module Roro
2
+
3
+ class CLI < Thor
4
+
5
+ desc "greenfield::rails", "Greenfield a new, dockerized rails app with
6
+ either MySQL or PostgreSQL in a separate container."
7
+
8
+ map "greenfield::rails" => "greenfield_rails"
9
+
10
+ def greenfield_rails
11
+ greenfield( { story: :rails } )
12
+ end
13
+ end
14
+ end
@@ -1,84 +1,147 @@
1
- require 'roro/cli/rollon/stories'
2
-
3
1
  module Roro
4
-
5
2
  class CLI < Thor
6
3
 
7
- desc "rollon", "Generates files for and makes changes to your app
8
- so it can run using Docker containers."
9
- method_option :interactive, desc: "Set up your environment variables as
10
- you go."
11
-
12
- def rollon
13
- confirm_directory_not_empty
14
- confirm_dependencies
15
- remove_roro_artifacts
4
+ class << self
5
+ private
6
+ def shared_options!
7
+ method_option :omakase, default: :omakase, desc: "Use the Roro setup with some configuring. 'Omakase' translates as 'I'll leave it up to you.'", aliases: ['-d', '--default']
8
+ method_option :fatsutofodo, desc: 'Use the Roro setup without having to think.', aliases: ['-f', '--fast']
9
+ method_option :okonomi, desc: "Use Roro how you like. 'Okonomi' has the opposite meaning of omakase.", aliases: ['-i', '--interactive']
10
+ end
11
+
12
+ alias_method :orig_desc, :desc
13
+
14
+ def desc(*args)
15
+ orig_desc(*args)
16
+ shared_options!
17
+ end
18
+ end
19
+ rollonto = ' into Roro.'
20
+ desc "rollon", "Roll an existing app#{rollonto}"
21
+ def rollon(args={})
22
+ @config ||= Roro::Configuration.new(args, options)
23
+ greenfield_actions
24
+ greenfield_commands
25
+ manifest_actions
26
+ manifest_intentions
27
+ congratulations
28
+ startup_commands
29
+ end
30
+
31
+ desc "greenfield", "Greenfield a new app and roll it#{rollonto}"
32
+ def greenfield(args={})
33
+ args[:greenfield] = :greenfield
16
34
 
17
- configure_for_rollon
18
-
19
- copy_roro_files
20
- generate_config
21
- startup_commands
35
+ rollon(args)
22
36
  end
23
37
 
24
- no_commands do
25
-
26
- def configure_for_rollon
38
+ desc "greenfield::rails", "Greenfield a new Rails app and roll it#{rollonto}"
39
+
40
+ map "greenfield::rails" => "greenfield_rails"
41
+
42
+ def greenfield_rails
43
+ greenfield( { story: :rails } )
44
+ end
45
+
46
+ desc "rollon::rails", "Roll an existing app#{rollonto}"
47
+ map "rollon::rails" => "rollon_rails"
48
+
49
+ def rollon_rails(args={})
50
+ rollon( { story: :rails } )
51
+ end
52
+
53
+ desc "rollon::rails::kubernetes", "Adds Kubernetes for production."
54
+ map "rollon::rails::kubernetes" => "rollon_rails_kubernetes"
55
+
56
+ def rollon_rails_kubernetes(args={})
57
+ story = {
58
+ rails: [
59
+ { database: :postgresql },
60
+ { kubernetes: :postgresql },
61
+ { ci_cd: :circleci}
62
+ ]
63
+ }
64
+ rollon( { story: story } )
65
+ end
66
+
67
+ desc "greenfield::rails::kubernetes", "Adds Kubernetes for production."
68
+ map "greenfield::rails::kubernetes" => "greenfield_rails_kubernetes"
69
+
70
+ def greenfield_rails_kubernetes(args={})
71
+ story = {
72
+ rails: [
73
+ { database: :postgresql },
74
+ { kubernetes: :postgresql },
75
+ { ci_cd: :circleci}
76
+ ]
77
+ }
78
+ rollon( { story: story } )
79
+ end
80
+
81
+ no_commands do
82
+
83
+ def configure_for_rollon(aroptions=nil)
27
84
  @config ||= Roro::Configuration.new(options)
28
85
  end
29
-
30
- def yaml_from_template(file)
31
- File.read(File.dirname(__FILE__) + "/templates/#{file}")
86
+
87
+ def manifest_actions
88
+ @config.structure[:actions].each {|a| eval a }
32
89
  end
33
90
 
34
- def copy_roro_files
35
- configure_database
36
- directory 'roro', './', @config.app
37
- template 'base/Dockerfile.tt', 'roro/containers/app/Dockerfile', @config.app
38
- take_thor_actions
39
- end
91
+ def manifest_intentions
92
+ @config.intentions.each {|k, v| eval(k.to_s) if v.eql?('y') }
93
+ end
40
94
 
41
- def take_thor_actions
42
- @config.thor_actions.each {|k, v| eval(k) if v.eql?('y') }
43
- end
44
-
45
- def startup_commands
46
- system 'docker-compose build'
47
- system 'docker-compose run web bundle'
48
- system 'docker-compose run web bin/rails webpacker:install'
49
- system 'docker-compose run web bin/rails yarn:install'
50
- system 'docker-compose run web bin/rails db:create'
51
- system 'docker-compose run web bin/rails db:migrate'
52
- system 'docker-compose up'
53
- end
95
+ def greenfield_actions
96
+ return unless @config.structure[:greenfield_actions]
97
+ @config.structure[:greenfield_actions].each {|a| eval a }
98
+ end
54
99
 
55
- def confirm_directory_empty
56
- confirm = confirm_dependency({
57
- system_query: "ls -A",
58
- 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",
59
- suggestion: "$ roro greenfield --force",
60
- conditional: "Dir.glob('*').empty?" })
61
- confirm || true
100
+ def greenfield_commands
101
+ return unless @config.structure[:greenfield_actions]
102
+ @config.structure[:greenfield_commands].each {|a| eval a }
62
103
  end
63
104
 
64
-
65
- def confirm_dependency(options)
66
- msg = []
67
- msg << ""
68
- msg << delineator
69
- msg << "It looks like #{options[:warning]}. The following bash command returns false:"
70
- msg << "\t$ #{options[:system_query]}"
71
- msg << "Please try these instructions:"
72
- msg << ("\t" + options[:suggestion])
73
- msg << delineator
74
- conditional = options[:conditional] ? eval(options[:conditional]) : system(options[:system_query])
75
- if conditional == false
76
- raise(Roro::Error.new(msg.join("\n\n")))
105
+ def congratulations(story=nil)
106
+ ( @config.story[:rollon])
107
+ if @config.structure[:greenfield]
108
+ usecase = 'greenfielded a new '
77
109
  else
78
- true
110
+ usecase = 'rolled your existing '
111
+ end
112
+ array = ["You've successfully "]
113
+ array << usecase
114
+ congrats = array.join("")
115
+ puts congrats
116
+ end
117
+
118
+ def startup_commands
119
+ congratulations( @config.story[:rollon])
120
+ cmd = @config.structure[:startup]
121
+ commands = cmd[:commands]
122
+ question = []
123
+ question << "\n\n You can start your app up with some combination of these commands:\n"
124
+ commands.each { |c| question << "\t#{c}"}
125
+ question << "\nOr if you'd like Roro to try and do it for you:"
126
+ question = question.join("\n")
127
+ if ask(question, default: 'y', limited_to: ['y', 'n']).eql?("y")
128
+ commands.each {|a| system(a) }
129
+ puts "\n\n#{cmd[:success]}\n\n"
79
130
  end
80
131
  end
81
132
 
133
+ def yaml_from_template(file)
134
+ File.read(find_in_source_paths(file))
135
+ end
136
+
137
+ def generate_config_story
138
+ roro_story = {
139
+ story: @config.story,
140
+ env_vars: @config.env,
141
+ intentions: @config.intentions
142
+ }
143
+ create_file ".roro_story.yml", roro_story.to_yaml
144
+ end
82
145
  end
83
146
  end
84
147
  end