roro 0.3.21 → 0.3.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +95 -67
  3. data/.gitignore +38 -8
  4. data/.ruby-version +1 -0
  5. data/CODE_OF_CONDUCT.md +25 -17
  6. data/Gemfile +1 -1
  7. data/Guardfile +23 -11
  8. data/README.md +9 -10
  9. data/bin/console +1 -1
  10. data/bin/setup +1 -1
  11. data/docker-compose.yml +3 -3
  12. data/lib/roro/cli/generate/generate.rb +52 -1
  13. data/lib/roro/cli/generate/generate_containers.rb +23 -0
  14. data/lib/roro/cli/generate/generate_environments.rb +25 -0
  15. data/lib/roro/cli/generate/generate_exposed.rb +11 -0
  16. data/lib/roro/cli/generate/generate_keys.rb +15 -0
  17. data/lib/roro/cli/generate/generate_mise.rb +13 -0
  18. data/lib/roro/cli/generate/generate_obfuscated.rb +14 -0
  19. data/lib/roro/cli/roll_your_own.rb +12 -0
  20. data/lib/roro/cli/rollon.rb +11 -138
  21. data/lib/roro/cli.rb +30 -20
  22. data/lib/roro/common/file_reflection.rb +33 -0
  23. data/lib/roro/common/utilities.rb +185 -0
  24. data/lib/roro/configurator.rb +14 -14
  25. data/lib/roro/configurators/adventure_case_builder.rb +65 -0
  26. data/lib/roro/configurators/adventure_chooser.rb +46 -0
  27. data/lib/roro/configurators/adventure_picker.rb +68 -0
  28. data/lib/roro/configurators/adventure_writer.rb +34 -0
  29. data/lib/roro/configurators/catalog_builder.rb +17 -0
  30. data/lib/roro/configurators/configurator.rb +64 -0
  31. data/lib/roro/configurators/eligibility.rb +141 -0
  32. data/lib/roro/configurators/question_asker.rb +29 -0
  33. data/lib/roro/configurators/question_builder.rb +83 -0
  34. data/lib/roro/configurators/structure_builder.rb +34 -0
  35. data/lib/roro/configurators/utilities.rb +188 -0
  36. data/lib/roro/configurators/validator.rb +109 -0
  37. data/lib/roro/crypto/cipher.rb +35 -0
  38. data/lib/roro/crypto/exposer.rb +33 -0
  39. data/lib/roro/crypto/file_writer.rb +14 -0
  40. data/lib/roro/crypto/key_writer.rb +35 -0
  41. data/lib/roro/crypto/obfuscator.rb +25 -0
  42. data/lib/roro/error.rb +31 -0
  43. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/fatsufodo.yml +1 -0
  44. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/django.yml +38 -0
  45. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/templates/stage_one/Dockerfile.tt +7 -0
  46. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/templates/stage_one/docker-compose.yml.tt +20 -0
  47. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/templates/stage_one/requirements.txt.tt +2 -0
  48. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/templates/stage_two/settings.py +130 -0
  49. data/lib/roro/{templates/base/jumpstart → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/test/stage_one/dummy}/.keep +0 -0
  50. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/test/stage_one/stage_one_test.rb +37 -0
  51. data/lib/roro/{templates/base/roro → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/django/test/stage_two/dummy}/.keep +0 -0
  52. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/expressjs/expressjs.yml +8 -0
  53. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/expressjs/templates/stage_one/Dockerfile.tt +14 -0
  54. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/expressjs/templates/stage_one/docker-compose.yml.tt +21 -0
  55. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/flask.yml +14 -0
  56. data/lib/roro/{templates/base/roro/roro → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/templates/stage_one}/.keep +0 -0
  57. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/templates/stage_one/Dockerfile +11 -0
  58. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/templates/stage_one/app.py +23 -0
  59. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/templates/stage_one/docker-compose.yml +8 -0
  60. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/templates/stage_one/requirements.txt +2 -0
  61. data/lib/roro/{templates/base/roro/roro/containers → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/test}/.keep +0 -0
  62. data/lib/roro/{templates/base/roro/roro/containers/app → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/test/stage_one}/.keep +0 -0
  63. data/lib/roro/{templates/base/roro/roro/containers/frontend → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/test/stage_one/stage_dummy}/.keep +0 -0
  64. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/flask/test/stage_one/stage_test.rb +37 -0
  65. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/rails/rails.yml +12 -0
  66. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/rails/templates/stage_one/Dockerfile.tt +16 -0
  67. data/lib/roro/{templates/rails/.circleci/.keep → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/rails/templates/stage_one/Gemfile.lock.tt} +0 -0
  68. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/rails/templates/stage_one/Gemfile.tt +2 -0
  69. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/rails/templates/stage_one/docker-compose.yml.tt +9 -0
  70. data/lib/roro/{templates/base/roro/roro/docker-entrypoint.sh.tt → stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/rails/templates/stage_one/entrypoint.sh} +1 -1
  71. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/rails/templates/stage_two/database.yml.tt +16 -0
  72. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/wordpress/templates/stage_one/docker-compose.yml.tt +31 -0
  73. data/lib/roro/stacks/catalog/unstoppable/developer_styles/fatsufodo/stories/wordpress/wordpress.yml +17 -0
  74. data/lib/roro/stacks/catalog/unstoppable/developer_styles/okonomi/okonomi.yml +1 -0
  75. data/lib/roro/stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/roll_your_own.yml +23 -0
  76. data/lib/roro/stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/templates/stage_one/%interpolated_stack_path%/%interpolated_story_name%.yml.tt +10 -0
  77. data/lib/roro/{templates/rails → stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/templates/stage_one/%interpolated_stack_path%/templates/stage_one}/.keep +0 -0
  78. data/lib/roro/{templates/rails/database/with_postgresql → stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/templates/stage_one/%interpolated_stack_path%/test}/.keep +0 -0
  79. data/lib/roro/{templates/rails/dotenv → stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/templates/stage_one/%interpolated_stack_path%/test/stage_one}/.keep +0 -0
  80. data/lib/roro/{templates/rails/roro → stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/templates/stage_one/%interpolated_stack_path%/test/stage_one/stage_dummy}/.keep +0 -0
  81. data/lib/roro/stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/templates/stage_one/%interpolated_stack_path%/test/stage_one/stage_test.rb.tt +37 -0
  82. data/lib/roro/{templates/rails/roro/containers → stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/test/stage_one/dummy}/.keep +0 -0
  83. data/lib/roro/stacks/catalog/unstoppable/developer_styles/okonomi/stories/roll_your_own/test/stage_one/stage_one_test.rb +58 -0
  84. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/omakase.yml +1 -0
  85. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/rails/rails.yml +13 -0
  86. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/rails/templates/stage_one/Dockerfile.tt +16 -0
  87. data/lib/roro/{templates/rails/roro/containers/app/.keep → stacks/catalog/unstoppable/developer_styles/omakase/stories/rails/templates/stage_one/Gemfile.lock.tt} +0 -0
  88. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/rails/templates/stage_one/Gemfile.tt +2 -0
  89. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/rails/templates/stage_one/docker-compose.yml.tt +17 -0
  90. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/rails/templates/stage_one/entrypoint.sh +8 -0
  91. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/rails/templates/stage_two/database.yml.tt +16 -0
  92. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/.env +38 -0
  93. data/lib/roro/{templates/rails/roro/containers/frontend → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one}/.keep +0 -0
  94. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/LICENSE +674 -0
  95. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/README.md +346 -0
  96. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/build.sh +39 -0
  97. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/config/nginx/cfg/nginx-custom-configs.conf +117 -0
  98. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/config/nginx/cfg/nginx-wp-hardening.conf +131 -0
  99. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/config/nginx/tpl/nginx-http.conf.template +103 -0
  100. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/config/nginx/tpl/nginx-https.conf.example +123 -0
  101. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/config/php.conf.ini +3 -0
  102. data/lib/roro/{templates/rails/roro/kube/.keep → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/data/certbot/conf/.placeholder} +0 -0
  103. data/lib/roro/{templates/rails/roro/kube/certificate.yml.tt → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/data/certbot/www/.placeholder} +0 -0
  104. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/docker-compose-build.yml +24 -0
  105. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/docker-compose-dev.yml +96 -0
  106. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/docker-compose-prod.yml +147 -0
  107. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/dump_mysql.sh +16 -0
  108. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/init_letsencrypt.sh +80 -0
  109. data/lib/roro/{templates/rails/roro/kube/cluster-issuer.yml.tt → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/mysql-dumps/.placeholder} +0 -0
  110. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/push.sh +22 -0
  111. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/wordpress/Dockerfile +14 -0
  112. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/wordpress/adduser.sh +15 -0
  113. data/lib/roro/{templates/rails/roro/kube/ingress.yml.tt → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/wordpress-sql/.placeholder} +0 -0
  114. data/lib/roro/{templates/rails/roro/kube/job-migrate.yml.tt → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/templates/stage_one/wordpress-src/.placeholder} +0 -0
  115. data/lib/roro/{templates/ruby_gem/.circleci → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/test}/.keep +0 -0
  116. data/lib/roro/{templates/ruby_gem/roro/containers → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/test/stage_one}/.keep +0 -0
  117. data/lib/roro/{templates/ruby_gem/roro/keys → stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/test/stage_one/stage_dummy}/.keep +0 -0
  118. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/test/stage_one/stage_test.rb +40 -0
  119. data/lib/roro/stacks/catalog/unstoppable/developer_styles/omakase/stories/wordpress/wordpress.yml +76 -0
  120. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/fatsufodo.yml +1 -0
  121. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/django.yml +36 -0
  122. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/templates/stage_one/Dockerfile.tt +7 -0
  123. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/templates/stage_one/docker-compose.yml.tt +20 -0
  124. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/templates/stage_one/requirements.txt.tt +2 -0
  125. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/templates/stage_two/settings.py +130 -0
  126. data/{roro/containers → lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/test/stage_one/dummy}/.keep +0 -0
  127. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/test/stage_one/stage_one_test.rb +37 -0
  128. data/{roro/keys → lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/django/test/stage_two/dummy}/.keep +0 -0
  129. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/expressjs/expressjs.yml +7 -0
  130. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/expressjs/templates/stage_one/Dockerfile.tt +14 -0
  131. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/expressjs/templates/stage_one/docker-compose.yml.tt +21 -0
  132. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/rails/rails.yml +12 -0
  133. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/rails/templates/stage_one/Dockerfile.tt +16 -0
  134. data/{sandbox/.keep → lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/rails/templates/stage_one/Gemfile.lock.tt} +0 -0
  135. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/rails/templates/stage_one/Gemfile.tt +2 -0
  136. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/rails/templates/stage_one/docker-compose.yml.tt +17 -0
  137. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/rails/templates/stage_one/entrypoint.sh +8 -0
  138. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/rails/templates/stage_two/database.yml.tt +16 -0
  139. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/__MACOSX/scripts/._.DS_Store +0 -0
  140. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/.DS_Store +0 -0
  141. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/base/bundler.sh +22 -0
  142. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/base/git.sh +21 -0
  143. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/base/rvm.sh +38 -0
  144. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/base/utilities.sh +53 -0
  145. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/base.sh +6 -0
  146. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/initialize/clone_idea.sh +14 -0
  147. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/initialize/clone_repos.sh +33 -0
  148. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/initialize/install_correct_bundler.sh +21 -0
  149. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/initialize/install_rubies.sh +6 -0
  150. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/initialize.sh +18 -0
  151. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/roro.sh +15 -0
  152. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/source.sh +28 -0
  153. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/utility/bundle_all.sh +12 -0
  154. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/utility/git_pull_all.sh +15 -0
  155. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/utility/rvm_install_all.sh +12 -0
  156. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/roro/templates/scripts/utility/yarn_install_all.sh +10 -0
  157. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/wordpress/templates/stage_one/docker-compose.yml.tt +31 -0
  158. data/lib/roro/stacks/catalog/unstoppable/developer_styles/sashimi/stories/wordpress/wordpress.yml +16 -0
  159. data/lib/roro/stacks/library/roro/.keep +0 -0
  160. data/lib/roro/stacks/library/roro/docker_compose/docker-compose.yml +22 -0
  161. data/lib/roro/stacks/library/roro/k8s/k8s.yml +15 -0
  162. data/lib/roro/stacks/library/roro/plots/node/.keep +0 -0
  163. data/lib/roro/stacks/library/roro/plots/node/node.yml +22 -0
  164. data/lib/roro/stacks/library/roro/plots/php/.keep +0 -0
  165. data/lib/roro/stacks/library/roro/plots/php/php.yml +22 -0
  166. data/lib/roro/stacks/library/roro/plots/python/plots/django/.keep +0 -0
  167. data/lib/roro/stacks/library/roro/plots/python/plots/django/django.yml +10 -0
  168. data/lib/roro/stacks/library/roro/plots/python/plots/django/templates/Dockerfile +7 -0
  169. data/lib/roro/stacks/library/roro/plots/python/plots/django/templates/docker-compose.yml +20 -0
  170. data/lib/roro/stacks/library/roro/plots/python/plots/django/templates/requirements.txt +2 -0
  171. data/lib/roro/stacks/library/roro/plots/python/plots/flask/flask.yml +0 -0
  172. data/lib/roro/stacks/library/roro/plots/python/python.yml +1 -0
  173. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/databases/.keep +0 -0
  174. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/databases/mysql.yml +22 -0
  175. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/databases/postgres.yml +22 -0
  176. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/plots/rails/rails.yml +22 -0
  177. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/plots/rails/templates/.keep +0 -0
  178. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/plots/rails_react/rails_react.yml +22 -0
  179. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/plots/rails_react/templates/.keep +0 -0
  180. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/plots/rails_vue/rails_vue.yml +22 -0
  181. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/plots/rails_vue/templates/.keep +0 -0
  182. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/rails.yml +16 -0
  183. data/lib/roro/stacks/library/roro/plots/ruby/plots/rails/templates/.keep +0 -0
  184. data/lib/roro/stacks/library/roro/plots/ruby/plots/ruby_gem/ruby_gem.yml +22 -0
  185. data/lib/roro/stacks/library/roro/plots/ruby/ruby.yml +22 -0
  186. data/lib/roro/stacks/library/roro/roro/roro.yml +15 -0
  187. data/lib/roro/{stories → stacks/stories_v1}/greenfield/rails.yml +2 -2
  188. data/lib/roro/stacks/stories_v1/greenfield/roro.yml +7 -0
  189. data/lib/roro/{stories → stacks/stories_v1}/greenfield.yml +0 -0
  190. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/ci_cd/circleci.yml +0 -0
  191. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/ci_cd.yml +0 -0
  192. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/database/mysql.yml +1 -1
  193. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/database/postgresql.yml +1 -1
  194. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/database.yml +0 -0
  195. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/kubernetes/postgresql/default.yml +0 -0
  196. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/kubernetes/postgresql/edge.yml +0 -0
  197. data/lib/roro/stacks/stories_v1/rollon/rails/kubernetes/postgresql.yml +10 -0
  198. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails/kubernetes.yml +0 -0
  199. data/lib/roro/{stories → stacks/stories_v1}/rollon/rails.yml +7 -7
  200. data/lib/roro/stacks/stories_v1/rollon/roro.yml +5 -0
  201. data/lib/roro/{stories → stacks/stories_v1}/rollon/ruby_gem.yml +0 -0
  202. data/lib/roro/{stories → stacks/stories_v1}/rollon.yml +0 -0
  203. data/lib/roro/stacks/stories_v1/templates/rails/.circleci/.keep +0 -0
  204. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/.circleci/config.yml.tt +0 -0
  205. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/.circleci/jobs/_build.yml +1 -1
  206. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/.circleci/jobs/_push.yml +1 -1
  207. data/lib/roro/stacks/stories_v1/templates/rails/.circleci/jobs/_test.yml +12 -0
  208. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/.circleci/setup-gem-credentials.sh +0 -0
  209. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/.circleci/workflows/_build_test_push.yml +0 -0
  210. data/lib/roro/stacks/stories_v1/templates/rails/.keep +0 -0
  211. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/Dockerfile.greenfield.tt +1 -1
  212. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/config/database.mysql.yml +0 -0
  213. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/config/database.pg.yml +0 -0
  214. data/lib/roro/stacks/stories_v1/templates/rails/database/with_mysql/_service.yml +10 -0
  215. data/lib/roro/stacks/stories_v1/templates/rails/database/with_postgresql/.keep +0 -0
  216. data/lib/roro/stacks/stories_v1/templates/rails/database/with_postgresql/_service.yml +7 -0
  217. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/docker-compose.yml.tt +0 -0
  218. data/lib/roro/stacks/stories_v1/templates/rails/dotenv/.keep +0 -0
  219. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/dotenv/database.mysql.env.tt +0 -0
  220. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/dotenv/database.pg.env.tt +0 -0
  221. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/dotenv/web.env.tt +0 -0
  222. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/kube.rake.tt +0 -0
  223. data/lib/roro/stacks/stories_v1/templates/rails/roro/.keep +0 -0
  224. data/lib/roro/stacks/stories_v1/templates/rails/roro/containers/.keep +0 -0
  225. data/lib/roro/stacks/stories_v1/templates/rails/roro/containers/app/.keep +0 -0
  226. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/containers/app/Dockerfile.tt +0 -0
  227. data/lib/roro/stacks/stories_v1/templates/rails/roro/containers/frontend/.keep +0 -0
  228. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/docker-entrypoint.sh +0 -0
  229. data/lib/roro/stacks/stories_v1/templates/rails/roro/keys/.keep +0 -0
  230. data/lib/roro/stacks/stories_v1/templates/rails/roro/kube/.keep +0 -0
  231. data/lib/roro/stacks/stories_v1/templates/rails/roro/kube/certificate.yml.tt +0 -0
  232. data/lib/roro/stacks/stories_v1/templates/rails/roro/kube/cluster-issuer.yml.tt +0 -0
  233. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/deployment.yml.tt +0 -0
  234. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/deployments/postgres_deploy.yaml +3 -3
  235. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/deployments/rails_deploy.yaml +5 -5
  236. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/deployments/redis_deploy.yaml +2 -2
  237. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/deployments/sidekiq_deploy.yaml +3 -3
  238. data/lib/roro/stacks/stories_v1/templates/rails/roro/kube/ingress.yml.tt +0 -0
  239. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/ingresses/ingress.yaml +0 -0
  240. data/lib/roro/stacks/stories_v1/templates/rails/roro/kube/job-migrate.yml.tt +0 -0
  241. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/jobs/setup.yaml +1 -1
  242. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/secret-digital-ocean.yml.tt +0 -0
  243. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/service.yml.tt +0 -0
  244. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/services/postgres_svc.yaml +2 -2
  245. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/services/rails_svc.yaml +3 -3
  246. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/services/redis_svc.yaml +2 -2
  247. data/lib/roro/{templates → stacks/stories_v1/templates}/rails/roro/kube/volumes/postgres_volumes.yaml +0 -0
  248. data/lib/roro/stacks/stories_v1/templates/roro/containers/.keep +0 -0
  249. data/lib/roro/stacks/stories_v1/templates/roro/containers/database/env/.keep +0 -0
  250. data/lib/roro/stacks/stories_v1/templates/roro/containers/database/scripts/.keep +0 -0
  251. data/lib/roro/stacks/stories_v1/templates/roro/env/.keep +0 -0
  252. data/lib/roro/stacks/stories_v1/templates/roro/keys/.keep +0 -0
  253. data/lib/roro/stacks/stories_v1/templates/roro/scripts/.keep +0 -0
  254. data/lib/roro/stacks/stories_v1/templates/roro/scripts/base/bundler.sh +22 -0
  255. data/lib/roro/stacks/stories_v1/templates/roro/scripts/base/git.sh +21 -0
  256. data/lib/roro/stacks/stories_v1/templates/roro/scripts/base/rvm.sh +38 -0
  257. data/lib/roro/stacks/stories_v1/templates/roro/scripts/base/utilities.sh +53 -0
  258. data/lib/roro/stacks/stories_v1/templates/roro/scripts/base.sh +6 -0
  259. data/lib/roro/stacks/stories_v1/templates/roro/scripts/initialize/clone_idea.sh +14 -0
  260. data/lib/roro/stacks/stories_v1/templates/roro/scripts/initialize/clone_repos.sh +33 -0
  261. data/lib/roro/stacks/stories_v1/templates/roro/scripts/initialize/install_correct_bundler.sh +21 -0
  262. data/lib/roro/stacks/stories_v1/templates/roro/scripts/initialize/install_rubies.sh +6 -0
  263. data/lib/roro/stacks/stories_v1/templates/roro/scripts/initialize.sh +18 -0
  264. data/lib/roro/stacks/stories_v1/templates/roro/scripts/roro.sh +15 -0
  265. data/lib/roro/stacks/stories_v1/templates/roro/scripts/source.sh +28 -0
  266. data/lib/roro/stacks/stories_v1/templates/roro/scripts/utility/bundle_all.sh +12 -0
  267. data/lib/roro/stacks/stories_v1/templates/roro/scripts/utility/git_pull_all.sh +15 -0
  268. data/lib/roro/stacks/stories_v1/templates/roro/scripts/utility/rvm_install_all.sh +12 -0
  269. data/lib/roro/stacks/stories_v1/templates/roro/scripts/utility/yarn_install_all.sh +10 -0
  270. data/lib/roro/stacks/stories_v1/templates/ruby_gem/.circleci/.keep +0 -0
  271. data/lib/roro/{templates → stacks/stories_v1/templates}/ruby_gem/.circleci/config.yml.tt +0 -0
  272. data/lib/roro/{templates → stacks/stories_v1/templates}/ruby_gem/.circleci/jobs/_test.yml +0 -0
  273. data/lib/roro/{templates → stacks/stories_v1/templates}/ruby_gem/.circleci/setup-gem-credentials.sh +0 -0
  274. data/lib/roro/{templates → stacks/stories_v1/templates}/ruby_gem/docker-compose.yml +1 -1
  275. data/lib/roro/stacks/stories_v1/templates/ruby_gem/roro/containers/.keep +0 -0
  276. data/lib/roro/{templates → stacks/stories_v1/templates}/ruby_gem/roro/containers/ruby_image/Dockerfile.tt +0 -0
  277. data/lib/roro/{templates → stacks/stories_v1/templates}/ruby_gem/roro/containers/ruby_image/ci.env.tt +0 -0
  278. data/lib/roro/stacks/stories_v1/templates/ruby_gem/roro/keys/.keep +0 -0
  279. data/lib/roro/version.rb +1 -1
  280. data/lib/roro.rb +60 -6
  281. data/mise/containers/ruby_gem/Dockerfile +16 -0
  282. data/{roro/containers/app/Dockerfile → mise/containers/ruby_gem/Dockerfile-app} +0 -0
  283. data/{roro/containers/ruby_image/Dockerfile → mise/containers/ruby_gem/Dockerfile-ruby_gem} +0 -0
  284. data/mise/containers/ruby_gem/env/.keep +0 -0
  285. data/mise/containers/ruby_gem/env/base.env.enc +1 -0
  286. data/mise/containers/ruby_gem/env/ci.env.enc +2 -0
  287. data/mise/containers/ruby_gem/env/development.env.enc +1 -0
  288. data/mise/containers/ruby_gem/env/production.env.enc +1 -0
  289. data/mise/containers/ruby_gem/scripts/.keep +0 -0
  290. data/mise/env/base.env.enc +1 -0
  291. data/mise/env/ci.env.enc +1 -0
  292. data/mise/env/development.env.enc +1 -0
  293. data/mise/env/production.env.enc +1 -0
  294. data/mise/mise.roro +0 -0
  295. data/roro.gemspec +7 -1
  296. metadata +338 -119
  297. data/lib/roro/cli/generate/exposed.rb +0 -14
  298. data/lib/roro/cli/generate/keys.rb +0 -69
  299. data/lib/roro/cli/generate/obfuscated.rb +0 -17
  300. data/lib/roro/cli/generate/story.rb +0 -18
  301. data/lib/roro/cli/greenfield/rails.rb +0 -14
  302. data/lib/roro/cli/rollon/rails/base/base.rb +0 -4
  303. data/lib/roro/cli/rollon/rails/base/insert_gems.rb +0 -23
  304. data/lib/roro/cli/rollon/rails/base/insertions.rb +0 -27
  305. data/lib/roro/cli/rollon/rails/database/with_mysql.rb +0 -22
  306. data/lib/roro/cli/rollon/rails/database/with_postgresql.rb +0 -20
  307. data/lib/roro/cli/rollon/rails/database.rb +0 -26
  308. data/lib/roro/cli/rollon/ruby_gem/with_ci_cd.rb +0 -45
  309. data/lib/roro/cli/rollon/ruby_gem.rb +0 -1
  310. data/lib/roro/cli/rollon/stories.rb +0 -2
  311. data/lib/roro/configurator/eligibility.rb +0 -137
  312. data/lib/roro/configurator/okonomi.rb +0 -28
  313. data/lib/roro/configurator/omakase.rb +0 -170
  314. data/lib/roro/crypto.rb +0 -73
  315. data/lib/roro/stories/rollon/rails/kubernetes/postgresql.yml +0 -10
  316. data/lib/roro/templates/base/.circleci/_aliases.yml +0 -8
  317. data/lib/roro/templates/base/.circleci/_commands.yml +0 -31
  318. data/lib/roro/templates/base/.circleci/_defaults.yml +0 -5
  319. data/lib/roro/templates/base/.circleci/_executors.yml +0 -11
  320. data/lib/roro/templates/base/.circleci/_major_only.yml +0 -4
  321. data/lib/roro/templates/base/.circleci/_version.yml +0 -1
  322. data/lib/roro/templates/base/.circleci/_workflow.yml +0 -2
  323. data/lib/roro/templates/base/.circleci/config.job-example.yml +0 -33
  324. data/lib/roro/templates/base/.circleci/jobs/_build.yml +0 -4
  325. data/lib/roro/templates/base/.circleci/jobs/_release.yml +0 -12
  326. data/lib/roro/templates/base/.circleci/workflows/_build_release.yml +0 -10
  327. data/lib/roro/templates/base/.dockerignore +0 -51
  328. data/lib/roro/templates/base/dotenv +0 -1
  329. data/lib/roro/templates/base/jumpstart/Dockerfile.tt +0 -30
  330. data/lib/roro/templates/base/jumpstart/docker-compose.yml +0 -59
  331. data/lib/roro/templates/base/jumpstart/docker-entrypoint.sh +0 -16
  332. data/lib/roro/templates/base/livereload/hosts.example +0 -7
  333. data/lib/roro/templates/rails/.circleci/jobs/_test.yml +0 -12
  334. data/lib/roro/templates/rails/database/with_mysql/_service.yml +0 -10
  335. data/lib/roro/templates/rails/database/with_postgresql/_service.yml +0 -7
  336. data/roro/containers/ruby_image/ci.env.enc +0 -2
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roro
4
+ module Configurators
5
+ class CatalogBuilder
6
+ attr_reader :structure
7
+
8
+ def self.build(override=nil)
9
+ override || self.base
10
+ end
11
+
12
+ def self.base
13
+ Roro::CLI.catalog_root
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Roro
6
+ module Configurators
7
+ class Configurator
8
+ include Utilities
9
+
10
+ attr_reader :structure, :itinerary, :manifest, :stack, :env
11
+
12
+ def initialize(options = {} )
13
+ @options = options ? options : {}
14
+ @stack = options[:stack] || CatalogBuilder.build
15
+ @validator = Validator.new(@stack)
16
+ @adventure = AdventureChooser.new
17
+ @builder = QuestionBuilder.new
18
+ @structure = StructureBuilder.build
19
+ @asker = QuestionAsker.new
20
+ @writer = AdventureWriter.new
21
+ end
22
+
23
+ def rollon
24
+ validate_stack
25
+ choose_adventure
26
+ build_env
27
+ write_story
28
+ end
29
+
30
+ def validate_stack
31
+ @validator.validate(@stack)
32
+ end
33
+
34
+ def choose_adventure
35
+ @adventure.build_itinerary(@stack)
36
+ @itinerary = @adventure.itinerary
37
+ @manifest = @adventure.manifest
38
+ end
39
+
40
+ def build_env
41
+ @env = @structure[:env]
42
+ manifest.each { |story| accrete_story(story) }
43
+ override_environment_variables
44
+ end
45
+
46
+ def accrete_story(story)
47
+ content = read_yaml(story)[:env]
48
+ content.keys.each { |k| @env[k].merge!(content[k]) } if content
49
+ end
50
+
51
+ def override_environment_variables
52
+ @env.each do |e, v| v.each do |k, v|
53
+ answer = @asker.confirm_default(@builder.override(e, k, v))
54
+ v[:value] = answer unless answer.eql?('y')
55
+ end
56
+ end
57
+ end
58
+
59
+ def write_story
60
+ @manifest.each { |m| @writer.write(@env, m) }
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ module Roro
6
+ module Configurators
7
+ module Eligibility
8
+ def screen_target_directory
9
+ @structure[:greenfield] ? confirm_directory_empty : confirm_directory_app
10
+ handle_roro_artifacts
11
+ end
12
+
13
+ def confirm_directory_app
14
+ confirm_dependency({
15
+ system_query: 'ls -A',
16
+ warning: "This is an empty directory. You can generate a new and fully
17
+ dockerized Rails backend using the 'omakase' command here here but if
18
+ you want to containerize an existing backend -- which is what the 'rollon'
19
+ command is for -- you'll need to navigate to a directory with an backend we
20
+ can roll onto.",
21
+ suggestion: '$ roro omakase',
22
+ conditional: "!Dir.glob('*').empty?"
23
+ })
24
+ end
25
+
26
+ def confirm_directory_empty
27
+ confirm = confirm_dependency({
28
+ system_query: 'ls -A',
29
+ warning: 'this is not an empty directory. Roro will not omakase a new Rails backend unless either a) the current directory is empty or b) you run omakase with the --force flag',
30
+ suggestion: '$ roro omakase --force',
31
+ conditional: "Dir.glob('*').empty?" # || (Dir.glob('*').size.eql?(1) && Dir.glob('roro_configurator.yml'))"
32
+ })
33
+ confirm || true
34
+ end
35
+
36
+ def artifacts?
37
+ @appname = @env[:main_app_name]
38
+ @artifacts = {}
39
+ hash = {
40
+ containers: {
41
+ list: "docker ps --filter name=#{@appname}\ -a",
42
+ remove: ' -q | xargs docker stop | xargs docker rm -f'
43
+ },
44
+ volumes: {
45
+ list: "docker volume ls --filter name=#{@appname}*",
46
+ remove: ' -q | xargs docker volume rm -f'
47
+ },
48
+ networks: {
49
+ list: "docker network ls --filter name=#{@appname}",
50
+ remove: ' -q | xargs docker network rm'
51
+ },
52
+ images: {
53
+ list: "docker image ls #{@appname}*",
54
+ remove: ' -q | xargs docker rmi -f'
55
+ }
56
+ }
57
+ hash.each do |k, v|
58
+ check = IO.popen("#{v[:list]} -q").count.positive?
59
+ @artifacts[k] = v if check
60
+ end
61
+ true if @artifacts.empty?
62
+ end
63
+
64
+ def handle_roro_artifacts
65
+ return if artifacts?
66
+
67
+ question = [
68
+ "\n\nThis machine has some docker artifacts which may clash with ",
69
+ "RoRo moving forward. You can verify their existence with:\n"
70
+ ]
71
+ @artifacts.each { |_k, v| question << "\t$ #{v[:list]}" }
72
+ question << "\nYou can remove these artifacts with something like:\n"
73
+ @artifacts.each { |_k, v| question << "\t$ #{v[:list]} #{v[:remove]}" }
74
+ question << "\nWould you like RoRo to attempt to remove them for you?"
75
+ choices = { 'y' => 'Yes', 'n' => 'No' }
76
+
77
+ choices.each { |k, v| question << "(#{k}) #{v}" }
78
+
79
+ prompt = question.join
80
+ answer = ask(prompt, default: 'y', limited_to: choices.keys)
81
+
82
+ if answer.eql?('y')
83
+
84
+ @artifacts.each do |k, v|
85
+ puts "Attempting to remove #{k}"
86
+ system(v[:list] + v[:remove])
87
+ end
88
+ end
89
+ end
90
+
91
+ def confirm_dependency(options)
92
+ msg = []
93
+ msg << ''
94
+ msg << delineator
95
+ msg << "It looks like #{options[:warning]}. The following bash command returns false:"
96
+ msg << "\t$ #{options[:system_query]}"
97
+ msg << 'Try this:'
98
+ msg << ("\t#{options[:suggestion]}")
99
+ msg << delineator
100
+ conditional = options[:conditional] ? eval(options[:conditional]) : system(options[:system_query])
101
+ query = options[:system_query]
102
+ if conditional == false
103
+
104
+ raise Roro::Error, msg.join("\n\n")
105
+ else
106
+ true
107
+ end
108
+ end
109
+
110
+ def confirm_dependencies
111
+ dependencies.each do |dependency|
112
+ confirm_dependency(dependency)
113
+ end
114
+ end
115
+
116
+ private
117
+
118
+ def delineator
119
+ ('-' * 80)
120
+ end
121
+
122
+ def dependencies
123
+ [
124
+ {
125
+ system_query: 'which docker',
126
+ warning: "Docker isn't installed",
127
+ suggestion: 'https://docs.docker.com/install/'
128
+ }, {
129
+ system_query: 'which docker-compose',
130
+ warning: "Docker Compose isn't installed",
131
+ suggestion: 'https://docs.docker.com/compose/install/'
132
+ }, {
133
+ system_query: 'docker info',
134
+ warning: "the Docker daemon isn't running",
135
+ suggestion: 'https://docs.docker.com/config/daemon/#start-the-daemon-manually'
136
+ }
137
+ ]
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roro
4
+ module Configurators
5
+ class QuestionAsker < Thor
6
+
7
+ include Thor::Actions
8
+
9
+ no_commands do
10
+ def override_default(question)
11
+ prompt = "Please supply a value:"
12
+ answer = ask([question, prompt].join("\n"))
13
+ answer.size > 1 ? answer : override_default(question)
14
+ end
15
+
16
+ def confirm_default(question)
17
+ options = { "y": "yes", "n": "no"}
18
+ humanized_options = options.map {|key, value|
19
+ "(#{key}) #{value}"
20
+ }
21
+ getsome = "Would you like to accept the default value?\n"
22
+ prompt = [question, getsome, humanized_options, "\n"].join("\n")
23
+ answer = ask(prompt, limited_to: options.keys.map(&:to_s))
24
+ answer.eql?('n') ? override_default(question) : 'y'
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roro
4
+ module Configurators
5
+ class QuestionBuilder
6
+
7
+ attr_reader :question, :storyfile, :inflection
8
+
9
+ def initialize(args={})
10
+ case
11
+ when args[:inflection]
12
+ @inflection = args[:inflection]
13
+ when args[:storyfile]
14
+ @storyfile = args[:storyfile]
15
+ end
16
+ end
17
+
18
+ def override(environment, key, value, override_value=nil)
19
+ @question = "#{override_prompt(environment, key, value)}"
20
+ end
21
+
22
+ def override_prompt(environment, key, value)
23
+ name = value.dig(:name) || key
24
+ prompt = "Would you like to accept the default value for #{name}?\n"
25
+ help = value.dig(:help) ? "#{value.dig(:help)}" : nil
26
+ default = "#{key}=#{value[:value]}"
27
+ ["\nEnvironment: #{environment}",
28
+ " name: #{name}",
29
+ " key: #{key}",
30
+ " variable: #{value[:value]}",
31
+ " default: #{default}",
32
+ " help: #{help}\n"
33
+ ].join("\n")
34
+ end
35
+
36
+ def build_inflection
37
+ prompt = inflection_prompt
38
+ options = inflection_options
39
+ prompt_options = humanize(options)
40
+ @question = ["#{prompt} #{prompt_options}", limited_to: options.keys]
41
+ end
42
+
43
+ def inflection_prompt
44
+ prompt = 'Please choose from these'
45
+ collection = name(@inflection).gsub('_', ' ') + ":\n"
46
+ [prompt, stack_parent(@inflection), collection].join(' ')
47
+ end
48
+
49
+ def inflection_options
50
+ Hash.new.tap do |h|
51
+ children(@inflection)
52
+ .map { |f| name(f) }
53
+ .sort
54
+ .each_with_index do |c, i|
55
+ h[(i + 1).to_s] = name(c)
56
+ end
57
+ end
58
+ end
59
+
60
+ def humanize(hash)
61
+ array = []
62
+ hash.map do |key, value|
63
+ preface = get_story_preface("#{@inflection}/#{value}")
64
+ array << "\n(#{key}) #{value}:\n #{preface}"
65
+ end
66
+ array.join
67
+ end
68
+
69
+ def get_story_preface(story)
70
+ storyfile = "#{story}/#{name(story)}.yml"
71
+ if stack_is_storyfile?(storyfile)
72
+ read_yaml("#{story}/#{name(story)}.yml")[:preface]
73
+ else
74
+ nil
75
+ end
76
+ end
77
+
78
+ def story_from(key)
79
+ inflection_options[key]
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roro
4
+ module Configurators
5
+ class StructureBuilder
6
+ attr_reader :structure
7
+
8
+ def self.build(override=nil)
9
+ base.merge(override ||= {})
10
+ end
11
+
12
+ def self.base
13
+ @structure = {
14
+ actions: [''],
15
+ env: {
16
+ base: {},
17
+ development: {},
18
+ staging: {},
19
+ production: {}
20
+ },
21
+ preface: '',
22
+ questions: [
23
+ {
24
+ question: '',
25
+ help: '',
26
+ action: ''
27
+ }
28
+ ],
29
+ success: ''
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,188 @@
1
+ # # frozen_string_literal: true
2
+ # require 'json'
3
+ # require 'yaml'
4
+ #
5
+ # module Roro
6
+ # module Configurators
7
+ #
8
+ # module Utilities
9
+ #
10
+ # def stack_type(stack)
11
+ # case
12
+ # when stack_not_present?(stack)
13
+ # :nonexistent
14
+ # when stack_is_ignored?(stack)
15
+ # :ignored
16
+ # when stack_is_dotfile?(stack)
17
+ # :dotfile
18
+ # when stack_is_storyfile?(stack)
19
+ # :storyfile
20
+ # when stack_is_templates?(stack)
21
+ # :templates
22
+ # when stack_is_inflection?(stack)
23
+ # :inflection
24
+ # when stack_is_stack?(stack)
25
+ # :stack
26
+ # when stack_is_story?(stack)
27
+ # :story
28
+ # end
29
+ # end
30
+ #
31
+ # def stack_is_stack?(stack)
32
+ # children(stack).any? do |c|
33
+ # stack_is_inflection?(c) || stack_is_story?(c)
34
+ # end
35
+ # end
36
+ #
37
+ # def stack_is_story?(stack)
38
+ # children(stack).any? { |c| story_name(stack).eql?(file_name(c)) }
39
+ # end
40
+ #
41
+ # def stack_is_file?(stack)
42
+ # File.file?(stack)
43
+ # end
44
+ #
45
+ # def stack_is_dotfile?(stack)
46
+ # stack_is_file?(stack) &&
47
+ # %w[keep gitkeep].include?(file_extension(stack))
48
+ # end
49
+ #
50
+ # def stack_is_storyfile?(stack)
51
+ # stack_is_file?(stack) &&
52
+ # %w[yml yaml].include?(file_extension(stack))
53
+ # end
54
+ #
55
+ # def stack_unpermitted?(stack)
56
+ # stack_is_file?(stack) &&
57
+ # !stack_is_storyfile?(stack) &&
58
+ # !stack_is_dotfile?(stack)
59
+ # end
60
+ #
61
+ # def stack_is_inflection?(stack)
62
+ # stack_stories(stack).empty? &&
63
+ # !File.file?(stack) &&
64
+ # !stack_is_ignored?(stack) &&
65
+ # !stack_is_templates?(stack)
66
+ # end
67
+ #
68
+ # def story_is_empty?(story)
69
+ # stack_is_storyfile?(story) &&
70
+ # !read_yaml(story)
71
+ # end
72
+ #
73
+ # def stack_not_present?(stack)
74
+ # !File.exist?(stack)
75
+ # end
76
+ #
77
+ # def stack_is_nil?(stack)
78
+ # !File.exist?(stack)
79
+ # end
80
+ #
81
+ # def stack_is_story_path?(stack)
82
+ # !stack_is_parent?(stack) &&
83
+ # !stack_is_templates?(stack) &&
84
+ # stack_is_node?(stack)
85
+ # end
86
+ #
87
+ # def stack_is_itinerary_path?(stack)
88
+ # !stack_is_parent?(stack) &&
89
+ # !stack_is_templates?(stack) &&
90
+ # stack_is_node?(stack)
91
+ # end
92
+ #
93
+ # def stack_is_parent?(stack)
94
+ # children(stack).any? { |c| stack_is_inflection?(c) }
95
+ # end
96
+ #
97
+ # def story_paths(stack)
98
+ # children(stack).select { |c| stack_is_story_path?(c) }
99
+ # end
100
+ #
101
+ # def stack_stories(stack)
102
+ # children(stack).select { |c| stack_is_storyfile?(c) }
103
+ # end
104
+ #
105
+ # def stack_is_templates?(stack)
106
+ # stack.split('/').last.match?('templates')
107
+ # end
108
+ #
109
+ # def stack_is_ignored?(stack)
110
+ # ignored = %w[test_dummy story_test test]
111
+ # ignored.include?(stack.split('/').last)
112
+ # end
113
+ #
114
+ # def all_inflections(stack)
115
+ # children(stack).select { |c| stack_is_inflection?(c) }
116
+ # end
117
+ #
118
+ # def children(stack)
119
+ # Dir.glob("#{stack}/*")
120
+ # end
121
+ #
122
+ # def stack_is_node?(stack)
123
+ # children(stack).any? { |w| w.include?('.yml') } && !stack_is_templates?(stack)
124
+ # end
125
+ #
126
+ # def stack_parent(stack)
127
+ # tree = stack.split('/')
128
+ # tree[-2]
129
+ # end
130
+ #
131
+ # def stack_parent_path(stack)
132
+ # stack.split("/#{name(stack)}").first
133
+ # end
134
+ #
135
+ # def stack_is_empty?(stack)
136
+ # !stack_is_file?(stack) &&
137
+ # Dir.glob("#{stack}/**").empty?
138
+ # end
139
+ #
140
+ # def build_paths(stack, story_paths = nil)
141
+ # story_paths ||= []
142
+ # story_paths << stack if stack_is_story_path?(stack)
143
+ # children(stack).each { |c| build_paths(c, story_paths) }
144
+ # story_paths
145
+ # end
146
+ #
147
+ # def sanitize(hash)
148
+ # (hash ||= {}).transform_keys!(&:to_sym).each do |key, value|
149
+ # case value
150
+ # when Array
151
+ # value.each { |vs| sanitize(vs) }
152
+ # when Hash
153
+ # sanitize(value)
154
+ # when true
155
+ # hash[key] = true
156
+ # when String || Symbol
157
+ # hash[key] = value.to_sym
158
+ # end
159
+ # end
160
+ # end
161
+ #
162
+ # def name(stack)
163
+ # stack.split('/').last
164
+ # end
165
+ #
166
+ # def file_name(story_file)
167
+ # story_file.split('/').last.split('.').first
168
+ # end
169
+ #
170
+ # def file_extension(file)
171
+ # file.split('.').last
172
+ # end
173
+ #
174
+ # def story_name(stack)
175
+ # stack.split('/').last
176
+ # end
177
+ #
178
+ #
179
+ # def sentence_from(array)
180
+ # array[1] ? "#{array[0..-2].join(', ')} and #{array[-1]}" : array[0]
181
+ # end
182
+ #
183
+ # def read_yaml(yaml_file)
184
+ # JSON.parse(YAML.load_file(yaml_file).to_json, symbolize_names: true)
185
+ # end
186
+ # end
187
+ # end
188
+ # end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roro
4
+ module Configurators
5
+ class Validator
6
+ include Utilities
7
+ attr_reader :stack, :structure, :permitted_hidden_extensions, :permitted_story_extensions, :ext_permitted
8
+
9
+ def initialize(stack = nil, structure = nil)
10
+ @stack = stack || Roro::CLI.catalog_root
11
+ @structure = structure || StructureBuilder.build
12
+ @error = Roro::CatalogError
13
+ @permitted_story_extensions = %w[yml yaml]
14
+ @permitted_hidden_extensions = %w[.keep .gitkeep]
15
+ @permitted_extensions = @permitted_story_extensions +
16
+ @permitted_hidden_extensions
17
+ end
18
+
19
+ ## TODO: validate ambiguous
20
+ # Add validation to ensure story directory has either a) a matching storyfile or b)
21
+ # at least one child stack, story, or inflection.
22
+
23
+ def base_validate(s)
24
+ case
25
+ when stack_is_nil?(s)
26
+ @msg = 'Catalog not present'
27
+ when stack_is_ignored?(s)
28
+ return
29
+ when stack_is_empty?(s)
30
+ @msg = 'Catalog cannot be an empty folder'
31
+ when stack_unpermitted?(s)
32
+ @msg = 'Catalog has unpermitted extension'
33
+ when stack_unrecognized?(s)
34
+ @msg = 'Catalog must be a story, a stack, or an inflection'
35
+ end
36
+ end
37
+
38
+ def stack_unrecognized?(stack)
39
+ stack_type(stack).nil?
40
+ end
41
+
42
+ def validate(stack = nil)
43
+ @msg = nil
44
+ stack ||= @stack
45
+ @stack_root ||= stack
46
+ base_validate(stack)
47
+ case stack_type(stack)
48
+ when :storyfile
49
+ validate_plot(read_yaml(stack))
50
+ when :story
51
+ children(stack).each { |c| validate(c) }
52
+ when :inflection
53
+ children(stack).each { |c| validate(c) }
54
+ when :stack
55
+ children(stack).each { |c| validate(c) }
56
+ end
57
+ raise(@error, "#{@msg} in #{stack}") unless @msg.nil?
58
+ end
59
+
60
+ def validate_plot(plot, structure = @structure)
61
+ case status(plot, structure)
62
+ when :plot_empty
63
+ @msg = 'Story file is empty'
64
+ when :unexpected_class
65
+ @msg = "'#{plot}' must be an instance of #{structure.class}"
66
+ when :array_empty
67
+ @msg = 'Story contains an empty array'
68
+ when :unpermitted_keys
69
+ @msg = "#{@unpermitted} not in permitted keys: #{@permitted}"
70
+ when :hash_value_nil
71
+ @msg = "Value for :#{plot.key(nil)} must not be nil"
72
+ when :array_valid
73
+ plot.each { |item| validate_plot(item, structure[0]) }
74
+ when :hash_expecting_values
75
+ plot.each { |k, v| validate_plot(v, structure[k]) }
76
+ end
77
+ end
78
+
79
+ def status(plot, structure)
80
+ case
81
+ when !plot
82
+ :plot_empty
83
+ when !plot.is_a?(structure.class)
84
+ :unexpected_class
85
+ when plot.is_a?(Array) && plot.any?(nil)
86
+ :array_empty
87
+ when plot.is_a?(Hash) && story_has_unpermitted_keys?(plot, structure)
88
+ :unpermitted_keys
89
+ when plot.is_a?(Hash) && story_has_nil_value?(plot)
90
+ :hash_value_nil
91
+ when plot.is_a?(Hash) && structure.keys&.any?
92
+ :hash_expecting_values
93
+ when plot.is_a?(Array)
94
+ :array_valid
95
+ end
96
+ end
97
+
98
+ def story_has_unpermitted_keys?(content, structure)
99
+ @permitted = structure&.keys
100
+ @unpermitted = content.keys - @permitted
101
+ @permitted.any? && @unpermitted.any?
102
+ end
103
+
104
+ def story_has_nil_value?(content)
105
+ content&.values&.include?(nil)
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roro
4
+ module Crypto
5
+ class Cipher
6
+
7
+ def initialize(options = {})
8
+ @standard = options[:standard] || 'AES-128-CBC'
9
+ @salt = options[:salt] || '8 octets'
10
+ @cipher = OpenSSL::Cipher.new @standard
11
+ end
12
+
13
+ def generate_key
14
+ Base64.encode64(@cipher.random_key)
15
+ end
16
+
17
+ def encrypt(decrypted, key)
18
+ build_cipher(key)
19
+ Base64.encode64(@cipher.update(decrypted) + @cipher.final)
20
+ end
21
+
22
+ def decrypt(encrypted, key)
23
+ build_cipher(key)
24
+ @cipher.decrypt.pkcs5_keyivgen @key, @salt
25
+ @cipher.update(Base64.decode64 encrypted) + @cipher.final
26
+ end
27
+
28
+ private
29
+
30
+ def build_cipher(key)
31
+ @cipher.encrypt.pkcs5_keyivgen @key=key, @salt
32
+ end
33
+ end
34
+ end
35
+ end