meroku 2.0.22 → 2.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +0 -10
  4. data/Guardfile +43 -0
  5. data/LICENSE.txt +1 -1
  6. data/README.md +29 -89
  7. data/bin/meroku +5 -3
  8. data/{frontend → data}/etc_nginx_sites-enabled_template +0 -0
  9. data/guard +25 -0
  10. data/lib/meroku.rb +17 -20
  11. data/lib/meroku/api.rb +15 -3
  12. data/lib/meroku/aws.rb +69 -6
  13. data/lib/meroku/cli.rb +23 -91
  14. data/lib/meroku/error.rb +11 -0
  15. data/lib/meroku/node.rb +70 -70
  16. data/lib/meroku/options.rb +79 -0
  17. data/lib/meroku/secrets.rb +38 -0
  18. data/lib/meroku/shared.rb +23 -0
  19. data/lib/meroku/user.rb +25 -0
  20. data/lib/meroku/version.rb +3 -1
  21. data/meroku.gemspec +10 -19
  22. metadata +20 -319
  23. data/circle.yml +0 -23
  24. data/frontend/.gitignore +0 -23
  25. data/frontend/.ruby-version +0 -2
  26. data/frontend/Gemfile +0 -61
  27. data/frontend/Gemfile.lock +0 -236
  28. data/frontend/README.md +0 -24
  29. data/frontend/Rakefile +0 -6
  30. data/frontend/app/assets/config/manifest.js +0 -3
  31. data/frontend/app/assets/images/.keep +0 -0
  32. data/frontend/app/assets/javascripts/application.js +0 -15
  33. data/frontend/app/assets/javascripts/apps.coffee +0 -3
  34. data/frontend/app/assets/javascripts/cable.js +0 -13
  35. data/frontend/app/assets/javascripts/channels/.keep +0 -0
  36. data/frontend/app/assets/javascripts/pages.coffee +0 -3
  37. data/frontend/app/assets/javascripts/publickeys.coffee +0 -3
  38. data/frontend/app/assets/stylesheets/application.css +0 -15
  39. data/frontend/app/assets/stylesheets/apps.scss +0 -3
  40. data/frontend/app/assets/stylesheets/pages.scss +0 -3
  41. data/frontend/app/assets/stylesheets/publickeys.scss +0 -3
  42. data/frontend/app/assets/stylesheets/scaffolds.scss +0 -84
  43. data/frontend/app/channels/application_cable/channel.rb +0 -4
  44. data/frontend/app/channels/application_cable/connection.rb +0 -4
  45. data/frontend/app/controllers/application_controller.rb +0 -4
  46. data/frontend/app/controllers/apps_controller.rb +0 -83
  47. data/frontend/app/controllers/concerns/.keep +0 -0
  48. data/frontend/app/controllers/publickeys_controller.rb +0 -82
  49. data/frontend/app/controllers/users/confirmations_controller.rb +0 -28
  50. data/frontend/app/controllers/users/omniauth_callbacks_controller.rb +0 -28
  51. data/frontend/app/controllers/users/passwords_controller.rb +0 -32
  52. data/frontend/app/controllers/users/registrations_controller.rb +0 -74
  53. data/frontend/app/controllers/users/sessions_controller.rb +0 -34
  54. data/frontend/app/controllers/users/unlocks_controller.rb +0 -28
  55. data/frontend/app/helpers/application_helper.rb +0 -2
  56. data/frontend/app/helpers/apps_helper.rb +0 -2
  57. data/frontend/app/helpers/pages_helper.rb +0 -2
  58. data/frontend/app/helpers/publickeys_helper.rb +0 -2
  59. data/frontend/app/jobs/application_job.rb +0 -2
  60. data/frontend/app/lib/cmd.rb +0 -11
  61. data/frontend/app/mailers/application_mailer.rb +0 -4
  62. data/frontend/app/models/app.rb +0 -37
  63. data/frontend/app/models/application_record.rb +0 -3
  64. data/frontend/app/models/concerns/.keep +0 -0
  65. data/frontend/app/models/publickey.rb +0 -15
  66. data/frontend/app/models/user.rb +0 -22
  67. data/frontend/app/policies/application_policy.rb +0 -53
  68. data/frontend/app/policies/publickey_policy.rb +0 -7
  69. data/frontend/app/serializable/serializable_app.rb +0 -6
  70. data/frontend/app/serializable/serializable_publickey.rb +0 -7
  71. data/frontend/app/serializable/serializable_user.rb +0 -8
  72. data/frontend/app/serializers/app_serializer.rb +0 -3
  73. data/frontend/app/serializers/publickey_serializer.rb +0 -4
  74. data/frontend/app/views/apps/_app.json.jbuilder +0 -2
  75. data/frontend/app/views/apps/_form.html.erb +0 -22
  76. data/frontend/app/views/apps/edit.html.erb +0 -6
  77. data/frontend/app/views/apps/index.html.erb +0 -27
  78. data/frontend/app/views/apps/index.json.jbuilder +0 -1
  79. data/frontend/app/views/apps/new.html.erb +0 -5
  80. data/frontend/app/views/apps/show.html.erb +0 -9
  81. data/frontend/app/views/apps/show.json.jbuilder +0 -1
  82. data/frontend/app/views/devise/confirmations/new.html.erb +0 -16
  83. data/frontend/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
  84. data/frontend/app/views/devise/mailer/email_changed.html.erb +0 -7
  85. data/frontend/app/views/devise/mailer/password_change.html.erb +0 -3
  86. data/frontend/app/views/devise/mailer/reset_password_instructions.html.erb +0 -8
  87. data/frontend/app/views/devise/mailer/unlock_instructions.html.erb +0 -7
  88. data/frontend/app/views/devise/passwords/edit.html.erb +0 -25
  89. data/frontend/app/views/devise/passwords/new.html.erb +0 -16
  90. data/frontend/app/views/devise/registrations/edit.html.erb +0 -43
  91. data/frontend/app/views/devise/registrations/new.html.erb +0 -29
  92. data/frontend/app/views/devise/sessions/new.html.erb +0 -26
  93. data/frontend/app/views/devise/shared/_links.html.erb +0 -25
  94. data/frontend/app/views/devise/unlocks/new.html.erb +0 -16
  95. data/frontend/app/views/layouts/application.html.erb +0 -16
  96. data/frontend/app/views/layouts/mailer.html.erb +0 -13
  97. data/frontend/app/views/layouts/mailer.text.erb +0 -1
  98. data/frontend/app/views/publickeys/_form.html.erb +0 -32
  99. data/frontend/app/views/publickeys/_publickey.json.jbuilder +0 -2
  100. data/frontend/app/views/publickeys/edit.html.erb +0 -6
  101. data/frontend/app/views/publickeys/index.html.erb +0 -31
  102. data/frontend/app/views/publickeys/index.json.jbuilder +0 -1
  103. data/frontend/app/views/publickeys/new.html.erb +0 -5
  104. data/frontend/app/views/publickeys/show.html.erb +0 -19
  105. data/frontend/app/views/publickeys/show.json.jbuilder +0 -1
  106. data/frontend/bin/bundle +0 -3
  107. data/frontend/bin/rails +0 -9
  108. data/frontend/bin/rake +0 -9
  109. data/frontend/bin/setup +0 -38
  110. data/frontend/bin/spring +0 -17
  111. data/frontend/bin/update +0 -29
  112. data/frontend/bin/yarn +0 -11
  113. data/frontend/config.ru +0 -5
  114. data/frontend/config/application.rb +0 -18
  115. data/frontend/config/boot.rb +0 -3
  116. data/frontend/config/cable.yml +0 -10
  117. data/frontend/config/database.yml +0 -87
  118. data/frontend/config/environment.rb +0 -5
  119. data/frontend/config/environments/development.rb +0 -56
  120. data/frontend/config/environments/production.rb +0 -97
  121. data/frontend/config/environments/test.rb +0 -42
  122. data/frontend/config/initializers/ams.rb +0 -3
  123. data/frontend/config/initializers/application_controller_renderer.rb +0 -8
  124. data/frontend/config/initializers/assets.rb +0 -14
  125. data/frontend/config/initializers/backtrace_silencers.rb +0 -7
  126. data/frontend/config/initializers/cookies_serializer.rb +0 -5
  127. data/frontend/config/initializers/devise.rb +0 -277
  128. data/frontend/config/initializers/filter_parameter_logging.rb +0 -4
  129. data/frontend/config/initializers/inflections.rb +0 -16
  130. data/frontend/config/initializers/mime_types.rb +0 -4
  131. data/frontend/config/initializers/wrap_parameters.rb +0 -14
  132. data/frontend/config/locales/devise.en.yml +0 -64
  133. data/frontend/config/locales/en.yml +0 -33
  134. data/frontend/config/puma.rb +0 -66
  135. data/frontend/config/routes.rb +0 -11
  136. data/frontend/config/secrets.yml +0 -32
  137. data/frontend/config/spring.rb +0 -6
  138. data/frontend/db/migrate/20171023223732_devise_create_users.rb +0 -42
  139. data/frontend/db/migrate/20171025203706_create_apps.rb +0 -9
  140. data/frontend/db/migrate/20171025223804_add_user_to_apps.rb +0 -5
  141. data/frontend/db/migrate/20171026071440_create_publickeys.rb +0 -11
  142. data/frontend/db/migrate/20171028150506_add_apisecret_to_users.rb +0 -6
  143. data/frontend/db/schema.rb +0 -32
  144. data/frontend/db/seeds.rb +0 -7
  145. data/frontend/etc_nginx_sites-enabled_default +0 -29
  146. data/frontend/lib/assets/.keep +0 -0
  147. data/frontend/lib/tasks/.keep +0 -0
  148. data/frontend/log/.keep +0 -0
  149. data/frontend/package.json +0 -5
  150. data/frontend/public/404.html +0 -67
  151. data/frontend/public/422.html +0 -67
  152. data/frontend/public/500.html +0 -66
  153. data/frontend/public/Meroku.html +0 -140
  154. data/frontend/public/Meroku/Api.html +0 -129
  155. data/frontend/public/Meroku/Api/Request.html +0 -221
  156. data/frontend/public/Meroku/Aws/Ec2.html +0 -477
  157. data/frontend/public/Meroku/CLI.html +0 -796
  158. data/frontend/public/Meroku/CLI/Help.html +0 -224
  159. data/frontend/public/Meroku/CLI/Secrets.html +0 -191
  160. data/frontend/public/Meroku/CLI/Session.html +0 -456
  161. data/frontend/public/Meroku/Extensions.html +0 -405
  162. data/frontend/public/Meroku/Infrastructure.html +0 -279
  163. data/frontend/public/Meroku/Infrastructure/Server.html +0 -373
  164. data/frontend/public/Meroku/Node.html +0 -845
  165. data/frontend/public/Meroku/Tunnelable.html +0 -247
  166. data/frontend/public/_index.html +0 -273
  167. data/frontend/public/apple-touch-icon-precomposed.png +0 -0
  168. data/frontend/public/apple-touch-icon.png +0 -0
  169. data/frontend/public/class_list.html +0 -51
  170. data/frontend/public/css/common.css +0 -1
  171. data/frontend/public/css/full_list.css +0 -58
  172. data/frontend/public/css/style.css +0 -492
  173. data/frontend/public/favicon.ico +0 -0
  174. data/frontend/public/file.README.html +0 -179
  175. data/frontend/public/file_list.html +0 -56
  176. data/frontend/public/frames.html +0 -17
  177. data/frontend/public/index.html +0 -179
  178. data/frontend/public/js/app.js +0 -248
  179. data/frontend/public/js/full_list.js +0 -216
  180. data/frontend/public/js/jquery.js +0 -4
  181. data/frontend/public/method_list.html +0 -395
  182. data/frontend/public/robots.txt +0 -2
  183. data/frontend/public/top-level-namespace.html +0 -110
  184. data/frontend/test/application_system_test_case.rb +0 -5
  185. data/frontend/test/controllers/.keep +0 -0
  186. data/frontend/test/controllers/apps_controller_test.rb +0 -48
  187. data/frontend/test/controllers/pages_controller_test.rb +0 -9
  188. data/frontend/test/controllers/publickeys_controller_test.rb +0 -48
  189. data/frontend/test/fixtures/.keep +0 -0
  190. data/frontend/test/fixtures/apps.yml +0 -7
  191. data/frontend/test/fixtures/files/.keep +0 -0
  192. data/frontend/test/fixtures/publickeys.yml +0 -11
  193. data/frontend/test/fixtures/users.yml +0 -11
  194. data/frontend/test/helpers/.keep +0 -0
  195. data/frontend/test/integration/.keep +0 -0
  196. data/frontend/test/mailers/.keep +0 -0
  197. data/frontend/test/models/.keep +0 -0
  198. data/frontend/test/models/app_test.rb +0 -7
  199. data/frontend/test/models/publickey_test.rb +0 -7
  200. data/frontend/test/models/user_test.rb +0 -7
  201. data/frontend/test/policies/publickey_policy_test.rb +0 -19
  202. data/frontend/test/system/.keep +0 -0
  203. data/frontend/test/system/apps_test.rb +0 -9
  204. data/frontend/test/system/publickeys_test.rb +0 -9
  205. data/frontend/test/test_helper.rb +0 -9
  206. data/frontend/tmp/.keep +0 -0
  207. data/frontend/vendor/.keep +0 -0
  208. data/lib/meroku/api/request.rb +0 -17
  209. data/lib/meroku/aws/ec2.rb +0 -59
  210. data/lib/meroku/cli/help.rb +0 -27
  211. data/lib/meroku/cli/secrets.rb +0 -23
  212. data/lib/meroku/cli/session.rb +0 -46
  213. data/lib/meroku/extensions.rb +0 -32
  214. data/lib/meroku/infrastructure.rb +0 -23
  215. data/lib/meroku/infrastructure/server.rb +0 -20
  216. data/lib/meroku/tunnelable.rb +0 -35
  217. data/modified-cedar-14.sh +0 -171
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 644b170886bbccc668dcbd9f7c85e12fd7f3fdd7
4
- data.tar.gz: f2f9a6ceac6218ca01981f77999f3493976bb20e
3
+ metadata.gz: 816206f9563347d62b87cfdc0efe4a2245655603
4
+ data.tar.gz: f324cd878df16907747cf2f8026ed2fa74ac1893
5
5
  SHA512:
6
- metadata.gz: d4a8a319a22ac72f047737ac20a66ab94b8e42a83a4542e6b3017dbb253e51bf8a9dfafc75888796a9d400d7733ca126a6a68949dad12c029486406851677721
7
- data.tar.gz: 34497e672d4a3d8f5a271610ebaaee77549bb6295aa0e8bc1394b148bf80998f86e29fbb8fda5ff61b268d5985abf32db36f01acbae8d23aec60685a76beb099
6
+ metadata.gz: 81712892db6f34cce5e201865d6c1147ab69f5e0dbe7b9be63a2b7bda74b1d647c24195b4a6a30f7c6a9529f6112c8cf72e70cb407d7c65d3d02f036ea8c1c19
7
+ data.tar.gz: 79120b685b9abba3109b8a4348d67fb342e9fd19d8c2c829b42a89e9c6bf9ad78fc613bb664ec0e8af38d891509773cbd522e05b4258c9355034fe4c8c0431ed
data/.gitignore CHANGED
@@ -7,4 +7,3 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- .env
data/.travis.yml CHANGED
@@ -1,15 +1,5 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=3e24c46585775714440d71d0412f6b27b469f8709ca05483191a43a2dc39dc6c
4
1
  sudo: false
5
2
  language: ruby
6
3
  rvm:
7
4
  - 2.4.2
8
- before_script:
9
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
10
- - chmod +x ./cc-test-reporter
11
- - ./cc-test-reporter before-build
12
-
13
5
  before_install: gem install bundler -v 1.15.4
14
- after_script:
15
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Guardfile ADDED
@@ -0,0 +1,43 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :minitest do
19
+ watch(%r{^.*})
20
+ # with Minitest::Unit
21
+ #watch(%r{^test/(.*)\/?test_(.*)\.rb$})
22
+ #watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
23
+ #watch(%r{^test/test_helper\.rb$}) { 'test' }
24
+
25
+ # with Minitest::Spec
26
+ # watch(%r{^spec/(.*)_spec\.rb$})
27
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
28
+ # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
29
+
30
+ # Rails 4
31
+ # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
32
+ # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
33
+ # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
34
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
35
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
36
+ # watch(%r{^test/.+_test\.rb$})
37
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
38
+
39
+ # Rails < 4
40
+ # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
41
+ # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
42
+ # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
43
+ end
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Meroku
3
+ Copyright (c) 2017 Meroku System
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,108 +1,48 @@
1
-
2
-
3
- [![Build Status](https://travis-ci.org/meroku/meroku.svg?branch=master)](https://travis-ci.org/meroku/meroku)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/cfec7757799809e85194/test_coverage)](https://codeclimate.com/github/meroku/meroku/test_coverage)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/cfec7757799809e85194/maintainability)](https://codeclimate.com/github/meroku/meroku/maintainability)
6
- [![Dependency Status](https://gemnasium.com/badges/github.com/meroku/meroku.svg)](https://gemnasium.com/github.com/meroku/meroku)
1
+ Meroku
2
+ ======
3
+
4
+ because hosting 100 apps costs $700 ($7x100) at you-know-where.com
5
+
6
+ [![Quality](https://img.shields.io/codeclimate/github/meroku/meroku.svg?style=flat-square)](https://codeclimate.com/github/meroku/meroku)
7
+ [![Coverage](https://img.shields.io/codeclimate/coverage/github/meroku/meroku.svg?style=flat-square)](https://codeclimate.com/github/meroku/meroku)
8
+ [![Build](https://img.shields.io/travis-ci/meroku/meroku.svg?style=flat-square)](https://travis-ci.org/meroku/meroku)
9
+ [![Dependencies](https://img.shields.io/gemnasium/meroku/meroku.svg?style=flat-square)](https://gemnasium.com/meroku/meroku)
10
+ [![Downloads](https://img.shields.io/gem/meroku/meroku.svg?style=flat-square)](https://rubygems.org/gems/meroku)
11
+ [![Issues](https://img.shields.io/github/issues/meroku/meroku.svg?style=flat-square)](https://github.com/meroku/meroku/issues)
12
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT)
7
13
  [![Gem Version](https://badge.fury.io/rb/meroku.svg)](https://badge.fury.io/rb/meroku)
8
- [![Gratipay](https://img.shields.io/gratipay/user/meroku.svg)](https://gratipay.com/meroku/)
14
+ [![Donate](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/meroku/donate)
9
15
 
10
- ## My Heroku (Meroku), because hosting 100 apps costs $700 ($7x100) at heroku.com
11
16
 
12
- Ruby on Rails is a popular web framework written in Ruby. This guide covers using Rails 5 on Meroku. To follow along, you need
17
+ ## Installation
13
18
 
14
- - Basic Ruby/Rails knowledge.
15
- - A locally installed version of Ruby 2.4.2+, Rubygems, Bundler, and Rails 5+.
16
- - Basic Git knowledge.
19
+ Make sure you have the latest stable ruby installed
17
20
 
21
+ ```bash
22
+ ruby --version
23
+ ```
18
24
 
19
- Install the meroku gem on your local workstation
25
+ And then execute:
20
26
 
21
27
  $ gem install meroku
22
28
 
23
- Once installed, you’ll have access to the `$ meroku` command from your command shell.
24
-
25
- $ meroku signup # if you haven't done already
26
-
27
- Make sure you're running the latest version of ruby
28
-
29
- $ cd ~; ruby --version
30
- ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
31
-
32
- Install the rails gem if you haven't done already
33
-
34
- $ gem install rails --no-ri --no-rdoc
35
- Successfully installed rails-5.1.4
36
- 1 gem installed
37
-
38
-
39
- Then create a new app:
40
-
41
- $ rails new myapp --database=postgresql
42
-
43
- Then move into your application directory.
44
-
45
- $ cd myapp
46
-
47
- Mention you want to the latest ruby version
48
-
49
- $ echo "2.4.2" > .ruby-version
50
-
51
- And commit it
52
-
53
- $ git add --all; git commit -m "Added ruby version";
54
-
55
- Register your application with meroku
56
-
57
- $ meroku create
58
- Creating app... done
59
-
60
- Add your public key to meroku
61
-
62
- $ meroku keys:add
63
-
64
- And deploy
65
-
66
- $ git push meroku master
67
- $ meroku run rake db:migrate
68
-
69
-
70
-
71
- ## DOCUMENTATION FOR MAINTAINERS
72
-
73
-
74
- ### Secrets
75
-
76
- The meroku secret is a 12 charactor hex string, eg. 'dcb528615aa4'
77
- All other secrets are derived/downloaded from it.
78
- To do administrative commands such as spawn, despawn, you would need to
79
- do this first,
80
-
81
- export SECRET="example"
29
+ ## Usage
82
30
 
31
+ $ meroku --help
83
32
 
84
- ### Commands
33
+ ## Development
85
34
 
86
- $ meroku infrastructure spawn
87
- $ meroku infrastructure despawn
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
36
 
89
- $ rubocop -D -F --except FrozenStringLiteralComment,StringLiterals,MutableConstant lib/
90
- Inspecting 15 files
91
- ...............
92
-
93
- 15 files inspected, no offenses detected
94
- $
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
38
 
96
- ### TODO
97
39
 
98
- - Only latest stable ruby is supported at the moment
99
- - Only latest stable rails is supported at the moment
100
- - Only RAILS_ENV=procution is supported at the moment
101
- - Only puma is supported at the moment
40
+ $ ./guard # keeps an eye on test fails and rubocop warnings
102
41
 
103
- ### To Run tests
42
+ ## Contributing
104
43
 
105
- rake
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/meroku/meroku.
106
45
 
46
+ ## License
107
47
 
108
-
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/bin/meroku CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
2
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
4
3
  require 'meroku'
5
4
 
6
- Meroku::CLI::Session.new ARGV
5
+ cli = Meroku::CLI.new
6
+ result = 0
7
+ result = cli.run
8
+ exit result
File without changes
data/guard ADDED
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+
3
+ trap "echo Exited!; exit;" SIGINT SIGTERM
4
+
5
+ result_tests_coverage='na'
6
+ result_tests='na'
7
+ result_rubocop='na'
8
+ while :
9
+ do
10
+ echo " $result_tests $result_tests_coverage $result_rubocop";
11
+ rm /tmp/result_tests_coverage 2>/dev/null
12
+ result_tests_coverage='na'
13
+ result_tests='na'
14
+ result_rubocop='na'
15
+ fswatch --latency=0.3 -1 ./ >/dev/null
16
+ reset
17
+ bundle exec rake
18
+ result_tests=$?
19
+ if [ $result_tests -ne 0 ]; then continue; fi;
20
+ result_tests_coverage=$(cat /tmp/result_tests_coverage 2>/dev/null)
21
+ rubocop lib/
22
+ result_rubocop=$?
23
+ done
24
+
25
+
data/lib/meroku.rb CHANGED
@@ -1,21 +1,18 @@
1
- require "fileutils"
2
- require "active_support/core_ext/object/try"
3
- require "net/ssh"
4
- require "net/http"
5
- require "escape"
6
- require "aws-sdk-ec2"
7
- require "dotenv"
8
- require "byebug"
9
- require "rest-client"
10
- require "meroku/extensions"
11
- require "meroku/aws"
12
- require "meroku/version"
13
- require "meroku/tunnelable"
14
- require "meroku/node"
15
- require "meroku/infrastructure"
16
- require "meroku/api"
17
- require "meroku/cli"
1
+ # frozen_string_literal: true
18
2
 
19
- # My Heroku (Meroku)
20
- module Meroku
21
- end
3
+ require 'optparse'
4
+ require 'byebug'
5
+ require 'rest-client'
6
+ require 'open-uri'
7
+ require 'net/ssh'
8
+ require 'aws-sdk-ec2'
9
+ require 'meroku/version'
10
+ require 'meroku/user'
11
+ require 'meroku/secrets'
12
+ require 'meroku/shared'
13
+ require 'meroku/aws'
14
+ require 'meroku/node'
15
+ require 'meroku/api'
16
+ require 'meroku/options'
17
+ require 'meroku/error'
18
+ require 'meroku/cli'
data/lib/meroku/api.rb CHANGED
@@ -1,8 +1,20 @@
1
- require 'meroku/api/request'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Meroku
4
- # The api is the rails app/service running on the ec2 server
5
- # handling login, logout, keys:add etc
4
+ # Logic related to making rest api calls to backend rails server
6
5
  module Api
6
+ def post(data)
7
+ # response = RestClient.post "https://www.example.net", data.to_json
8
+ # puts "DB8 #{response.inspect}"
9
+ # true
10
+ # response = RestClient.post(url, data.to_json,
11
+ # timeout: 1,
12
+ # content_type: :json,
13
+ # accept: :json)
14
+ # r = JSON.parse(response)
15
+ # yield(r["data"]) if r.key?("data")
16
+ # return unless r.key?("errors") && r["errors"].size.positive?
17
+ # puts "error: #{r['errors'].map { |x| x['detail'] }.join('. ')}"
18
+ end
7
19
  end
8
20
  end
data/lib/meroku/aws.rb CHANGED
@@ -1,14 +1,77 @@
1
- require 'meroku/aws/ec2'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Meroku
4
- # Stuff related to Amazon Web Services
4
+ # Mostly wrappers around aws library functions
5
5
  module Aws
6
- IP = '34.239.241.218'
6
+ include Meroku::Shared
7
7
 
8
- KEY_NAME = "#{Dir.home}/.meroku/meroku.id_rsa"
8
+ def make_instance
9
+ @instance_id = Meroku::Shared.ec2_client.run_instances(
10
+ image_id: 'ami-841f46ff',
11
+ min_count: 1,
12
+ max_count: 1,
13
+ key_name: 'meroku.id_rsa',
14
+ instance_type: 't2.micro',
15
+ tag_specifications: [tag]
16
+ ).instances.first.instance_id
17
+ end
18
+
19
+ def associate_address
20
+ retries ||= 0
21
+ sleep 10
22
+ begin
23
+ puts Meroku::Shared.ec2_client.associate_address(
24
+ allocation_id: allocation_id, instance_id: instance_id
25
+ ).class
26
+ sleep 20
27
+ rescue ::Aws::EC2::Errors::InvalidInstanceID
28
+ (retries += 1) < 10 ? retry : raise
29
+ end
30
+ end
31
+
32
+ # Private S3 Bucket
33
+ # The only security here is not no one knows the bucket name,
34
+ # which is a uuid
35
+ def bucket
36
+ "http://s3.amazonaws.com/#{Meroku::Shared.secrets.meroku_secret}/"
37
+ end
38
+
39
+ def self.terminate_all(tag: nil)
40
+ Meroku::Shared.ec2_client.describe_instances(
41
+ filters: running_filter(tag)
42
+ ).reservations.map do |r|
43
+ id = r.instances.first.instance_id
44
+ puts "Will terminate #{id}"
45
+ Meroku::Shared.ec2_client.terminate_instances(instance_ids: [id])
46
+ end
47
+ end
48
+
49
+ # Our elastic ip allocation
50
+ def allocation_id
51
+ 'eipalloc-139f7823'
52
+ end
53
+
54
+ def ip_address
55
+ '34.239.241.218'
56
+ end
57
+
58
+ def tag
59
+ {
60
+ resource_type: 'instance',
61
+ tags: [
62
+ {
63
+ key: 'Name',
64
+ value: 'node'
65
+ }
66
+ ]
67
+ }
68
+ end
9
69
 
10
- def self.bucket_url
11
- "https://s3.amazonaws.com/#{ENV['SECRET']}"
70
+ def self.running_filter(tag)
71
+ [
72
+ { name: 'tag:Name', values: [tag] },
73
+ { name: 'instance-state-name', values: %w[running pending] }
74
+ ]
12
75
  end
13
76
  end
14
77
  end
data/lib/meroku/cli.rb CHANGED
@@ -1,104 +1,36 @@
1
- require 'meroku/cli/help'
2
- require 'meroku/cli/secrets'
3
- require 'meroku/cli/session'
1
+ # frozen_string_literal: true
4
2
 
5
3
  module Meroku
6
- # The CLI is used by end users and also maintainers
7
- module CLI
8
- include Meroku::Aws::Ec2
4
+ # The CLI is a class responsible of handling all the command line interface
5
+ # logic.
6
+ class CLI
7
+ include Meroku::Shared
8
+ include Meroku::Api
9
+ attr_reader :options
9
10
 
10
- def signup
11
- email, pw = Meroku::Extensions.mgets(%i[email password])
12
- Meroku::Api::Request.post(
13
- 'https://www.meroku.com/users.json',
14
- user: { email: email, password: pw, password_confirmation: pw }
15
- ) do |response|
16
- puts "Signed up #{response['attributes']['email']}"
17
- save_setting('apiusername', response['attributes']['apiusername'])
18
- save_setting('apisecret', response['attributes']['apisecret'])
19
- end
20
- true
11
+ def initialize
12
+ @options = {}
21
13
  end
22
14
 
23
- def login
24
- email, password = Meroku::Extensions.mgets(%i[email password])
25
- Meroku::Api::Request.post(
26
- 'https://www.meroku.com/users/sign_in.json',
27
- user: { email: email, password: password }
28
- ) do |response|
29
- puts "Signed in as #{response['attributes']['email']}"
30
- save_setting('apiusername', response['attributes']['apiusername'])
31
- save_setting('apisecret', response['attributes']['apisecret'])
32
- end
33
- true
15
+ def run(args = ARGV)
16
+ @options = Options.new.parse(args)
17
+ act_on_options
18
+ rescue Meroku::Error => e
19
+ puts "Error: #{e.message}"
20
+ return 2
34
21
  end
35
22
 
36
- def logout
37
- [
38
- "#{Dir.home}/.meroku/.apiusername",
39
- "#{Dir.home}/.meroku/.apisecret"
40
- ].each do |f|
41
- File.delete(f) if File.exist?(f)
42
- end
43
- true
44
- end
23
+ private
45
24
 
46
- def create
47
- Meroku::Api::Request.post(
48
- 'https://www.meroku.com/apps.json',
49
- app: { name: 'unnamed' }, apisecret: `cat ~/.meroku/.apisecret`.chomp
50
- ) do |response|
51
- puts "Created #{response['attributes']['name']}, adding git remote"
52
- add_git_remote(
53
- 'meroku',
54
- "#{apiusername}@www.meroku.com:#{response['attributes']['name']}.git"
55
- )
25
+ def act_on_options
26
+ if @options[:meroku_secret]
27
+ Meroku::Shared.secrets.meroku_secret = @options[:meroku_secret]
56
28
  end
29
+ Node.new if @options[:spawn]
30
+ User.login(@options[:email], @options[:password]) if @options[:login]
31
+ User.logout if @options[:logout]
32
+ Meroku::Aws.terminate_all(tag: 'node') if @options[:despawn]
57
33
  true
58
34
  end
59
-
60
- def apiusername
61
- `cat ~/.meroku/.apiusername.chomp`
62
- end
63
-
64
- def add_git_remote(name, uri)
65
- puts "git remote remove #{name}"
66
- `git remote remove #{name} 2>/dev/null`
67
- puts "git remote add #{name} #{uri}"
68
- `git remote add #{name} #{uri}`
69
- end
70
-
71
- def keys_add
72
- file = "#{Dir.home}/.ssh/id_rsa.pub"
73
- apisecret = `cat ~/.meroku/.apisecret`.chomp
74
- abort "error: #{file} not found" unless File.exist?(file)
75
- Meroku::Api::Request.post(
76
- 'https://www.meroku.com/publickeys.json',
77
- publickey: { name: 'id_rsa.pub', data: `cat ~/.ssh/id_rsa.pub`.chomp },
78
- apisecret: apisecret
79
- ) do |response|
80
- puts "Added #{response['attributes']['name']}"
81
- end
82
- true
83
- end
84
-
85
- def spawn
86
- Meroku::CLI::Secrets.load(admin: true)
87
- node = Meroku::Node.new
88
- node.associate_address.configure_keys.add_sources.ubuntu_updates
89
- node.install_packages.database_inits.git_clone.nginx_configs.start_rails
90
- true
91
- end
92
-
93
- def despawn
94
- Meroku::CLI::Secrets.load(admin: true)
95
- Meroku::Infrastructure.each_server(&:shutdown)
96
- true
97
- end
98
-
99
- def save_setting(name, value)
100
- FileUtils.mkdir_p "#{Dir.home}/.meroku"
101
- IO.write("#{Dir.home}/.meroku/.#{name}", value)
102
- end
103
35
  end
104
36
  end