meroku 2.0.22 → 2.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +0 -10
- data/Guardfile +43 -0
- data/LICENSE.txt +1 -1
- data/README.md +29 -89
- data/bin/meroku +5 -3
- data/{frontend → data}/etc_nginx_sites-enabled_template +0 -0
- data/guard +25 -0
- data/lib/meroku.rb +17 -20
- data/lib/meroku/api.rb +15 -3
- data/lib/meroku/aws.rb +69 -6
- data/lib/meroku/cli.rb +23 -91
- data/lib/meroku/error.rb +11 -0
- data/lib/meroku/node.rb +70 -70
- data/lib/meroku/options.rb +79 -0
- data/lib/meroku/secrets.rb +38 -0
- data/lib/meroku/shared.rb +23 -0
- data/lib/meroku/user.rb +25 -0
- data/lib/meroku/version.rb +3 -1
- data/meroku.gemspec +10 -19
- metadata +20 -319
- data/circle.yml +0 -23
- data/frontend/.gitignore +0 -23
- data/frontend/.ruby-version +0 -2
- data/frontend/Gemfile +0 -61
- data/frontend/Gemfile.lock +0 -236
- data/frontend/README.md +0 -24
- data/frontend/Rakefile +0 -6
- data/frontend/app/assets/config/manifest.js +0 -3
- data/frontend/app/assets/images/.keep +0 -0
- data/frontend/app/assets/javascripts/application.js +0 -15
- data/frontend/app/assets/javascripts/apps.coffee +0 -3
- data/frontend/app/assets/javascripts/cable.js +0 -13
- data/frontend/app/assets/javascripts/channels/.keep +0 -0
- data/frontend/app/assets/javascripts/pages.coffee +0 -3
- data/frontend/app/assets/javascripts/publickeys.coffee +0 -3
- data/frontend/app/assets/stylesheets/application.css +0 -15
- data/frontend/app/assets/stylesheets/apps.scss +0 -3
- data/frontend/app/assets/stylesheets/pages.scss +0 -3
- data/frontend/app/assets/stylesheets/publickeys.scss +0 -3
- data/frontend/app/assets/stylesheets/scaffolds.scss +0 -84
- data/frontend/app/channels/application_cable/channel.rb +0 -4
- data/frontend/app/channels/application_cable/connection.rb +0 -4
- data/frontend/app/controllers/application_controller.rb +0 -4
- data/frontend/app/controllers/apps_controller.rb +0 -83
- data/frontend/app/controllers/concerns/.keep +0 -0
- data/frontend/app/controllers/publickeys_controller.rb +0 -82
- data/frontend/app/controllers/users/confirmations_controller.rb +0 -28
- data/frontend/app/controllers/users/omniauth_callbacks_controller.rb +0 -28
- data/frontend/app/controllers/users/passwords_controller.rb +0 -32
- data/frontend/app/controllers/users/registrations_controller.rb +0 -74
- data/frontend/app/controllers/users/sessions_controller.rb +0 -34
- data/frontend/app/controllers/users/unlocks_controller.rb +0 -28
- data/frontend/app/helpers/application_helper.rb +0 -2
- data/frontend/app/helpers/apps_helper.rb +0 -2
- data/frontend/app/helpers/pages_helper.rb +0 -2
- data/frontend/app/helpers/publickeys_helper.rb +0 -2
- data/frontend/app/jobs/application_job.rb +0 -2
- data/frontend/app/lib/cmd.rb +0 -11
- data/frontend/app/mailers/application_mailer.rb +0 -4
- data/frontend/app/models/app.rb +0 -37
- data/frontend/app/models/application_record.rb +0 -3
- data/frontend/app/models/concerns/.keep +0 -0
- data/frontend/app/models/publickey.rb +0 -15
- data/frontend/app/models/user.rb +0 -22
- data/frontend/app/policies/application_policy.rb +0 -53
- data/frontend/app/policies/publickey_policy.rb +0 -7
- data/frontend/app/serializable/serializable_app.rb +0 -6
- data/frontend/app/serializable/serializable_publickey.rb +0 -7
- data/frontend/app/serializable/serializable_user.rb +0 -8
- data/frontend/app/serializers/app_serializer.rb +0 -3
- data/frontend/app/serializers/publickey_serializer.rb +0 -4
- data/frontend/app/views/apps/_app.json.jbuilder +0 -2
- data/frontend/app/views/apps/_form.html.erb +0 -22
- data/frontend/app/views/apps/edit.html.erb +0 -6
- data/frontend/app/views/apps/index.html.erb +0 -27
- data/frontend/app/views/apps/index.json.jbuilder +0 -1
- data/frontend/app/views/apps/new.html.erb +0 -5
- data/frontend/app/views/apps/show.html.erb +0 -9
- data/frontend/app/views/apps/show.json.jbuilder +0 -1
- data/frontend/app/views/devise/confirmations/new.html.erb +0 -16
- data/frontend/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
- data/frontend/app/views/devise/mailer/email_changed.html.erb +0 -7
- data/frontend/app/views/devise/mailer/password_change.html.erb +0 -3
- data/frontend/app/views/devise/mailer/reset_password_instructions.html.erb +0 -8
- data/frontend/app/views/devise/mailer/unlock_instructions.html.erb +0 -7
- data/frontend/app/views/devise/passwords/edit.html.erb +0 -25
- data/frontend/app/views/devise/passwords/new.html.erb +0 -16
- data/frontend/app/views/devise/registrations/edit.html.erb +0 -43
- data/frontend/app/views/devise/registrations/new.html.erb +0 -29
- data/frontend/app/views/devise/sessions/new.html.erb +0 -26
- data/frontend/app/views/devise/shared/_links.html.erb +0 -25
- data/frontend/app/views/devise/unlocks/new.html.erb +0 -16
- data/frontend/app/views/layouts/application.html.erb +0 -16
- data/frontend/app/views/layouts/mailer.html.erb +0 -13
- data/frontend/app/views/layouts/mailer.text.erb +0 -1
- data/frontend/app/views/publickeys/_form.html.erb +0 -32
- data/frontend/app/views/publickeys/_publickey.json.jbuilder +0 -2
- data/frontend/app/views/publickeys/edit.html.erb +0 -6
- data/frontend/app/views/publickeys/index.html.erb +0 -31
- data/frontend/app/views/publickeys/index.json.jbuilder +0 -1
- data/frontend/app/views/publickeys/new.html.erb +0 -5
- data/frontend/app/views/publickeys/show.html.erb +0 -19
- data/frontend/app/views/publickeys/show.json.jbuilder +0 -1
- data/frontend/bin/bundle +0 -3
- data/frontend/bin/rails +0 -9
- data/frontend/bin/rake +0 -9
- data/frontend/bin/setup +0 -38
- data/frontend/bin/spring +0 -17
- data/frontend/bin/update +0 -29
- data/frontend/bin/yarn +0 -11
- data/frontend/config.ru +0 -5
- data/frontend/config/application.rb +0 -18
- data/frontend/config/boot.rb +0 -3
- data/frontend/config/cable.yml +0 -10
- data/frontend/config/database.yml +0 -87
- data/frontend/config/environment.rb +0 -5
- data/frontend/config/environments/development.rb +0 -56
- data/frontend/config/environments/production.rb +0 -97
- data/frontend/config/environments/test.rb +0 -42
- data/frontend/config/initializers/ams.rb +0 -3
- data/frontend/config/initializers/application_controller_renderer.rb +0 -8
- data/frontend/config/initializers/assets.rb +0 -14
- data/frontend/config/initializers/backtrace_silencers.rb +0 -7
- data/frontend/config/initializers/cookies_serializer.rb +0 -5
- data/frontend/config/initializers/devise.rb +0 -277
- data/frontend/config/initializers/filter_parameter_logging.rb +0 -4
- data/frontend/config/initializers/inflections.rb +0 -16
- data/frontend/config/initializers/mime_types.rb +0 -4
- data/frontend/config/initializers/wrap_parameters.rb +0 -14
- data/frontend/config/locales/devise.en.yml +0 -64
- data/frontend/config/locales/en.yml +0 -33
- data/frontend/config/puma.rb +0 -66
- data/frontend/config/routes.rb +0 -11
- data/frontend/config/secrets.yml +0 -32
- data/frontend/config/spring.rb +0 -6
- data/frontend/db/migrate/20171023223732_devise_create_users.rb +0 -42
- data/frontend/db/migrate/20171025203706_create_apps.rb +0 -9
- data/frontend/db/migrate/20171025223804_add_user_to_apps.rb +0 -5
- data/frontend/db/migrate/20171026071440_create_publickeys.rb +0 -11
- data/frontend/db/migrate/20171028150506_add_apisecret_to_users.rb +0 -6
- data/frontend/db/schema.rb +0 -32
- data/frontend/db/seeds.rb +0 -7
- data/frontend/etc_nginx_sites-enabled_default +0 -29
- data/frontend/lib/assets/.keep +0 -0
- data/frontend/lib/tasks/.keep +0 -0
- data/frontend/log/.keep +0 -0
- data/frontend/package.json +0 -5
- data/frontend/public/404.html +0 -67
- data/frontend/public/422.html +0 -67
- data/frontend/public/500.html +0 -66
- data/frontend/public/Meroku.html +0 -140
- data/frontend/public/Meroku/Api.html +0 -129
- data/frontend/public/Meroku/Api/Request.html +0 -221
- data/frontend/public/Meroku/Aws/Ec2.html +0 -477
- data/frontend/public/Meroku/CLI.html +0 -796
- data/frontend/public/Meroku/CLI/Help.html +0 -224
- data/frontend/public/Meroku/CLI/Secrets.html +0 -191
- data/frontend/public/Meroku/CLI/Session.html +0 -456
- data/frontend/public/Meroku/Extensions.html +0 -405
- data/frontend/public/Meroku/Infrastructure.html +0 -279
- data/frontend/public/Meroku/Infrastructure/Server.html +0 -373
- data/frontend/public/Meroku/Node.html +0 -845
- data/frontend/public/Meroku/Tunnelable.html +0 -247
- data/frontend/public/_index.html +0 -273
- data/frontend/public/apple-touch-icon-precomposed.png +0 -0
- data/frontend/public/apple-touch-icon.png +0 -0
- data/frontend/public/class_list.html +0 -51
- data/frontend/public/css/common.css +0 -1
- data/frontend/public/css/full_list.css +0 -58
- data/frontend/public/css/style.css +0 -492
- data/frontend/public/favicon.ico +0 -0
- data/frontend/public/file.README.html +0 -179
- data/frontend/public/file_list.html +0 -56
- data/frontend/public/frames.html +0 -17
- data/frontend/public/index.html +0 -179
- data/frontend/public/js/app.js +0 -248
- data/frontend/public/js/full_list.js +0 -216
- data/frontend/public/js/jquery.js +0 -4
- data/frontend/public/method_list.html +0 -395
- data/frontend/public/robots.txt +0 -2
- data/frontend/public/top-level-namespace.html +0 -110
- data/frontend/test/application_system_test_case.rb +0 -5
- data/frontend/test/controllers/.keep +0 -0
- data/frontend/test/controllers/apps_controller_test.rb +0 -48
- data/frontend/test/controllers/pages_controller_test.rb +0 -9
- data/frontend/test/controllers/publickeys_controller_test.rb +0 -48
- data/frontend/test/fixtures/.keep +0 -0
- data/frontend/test/fixtures/apps.yml +0 -7
- data/frontend/test/fixtures/files/.keep +0 -0
- data/frontend/test/fixtures/publickeys.yml +0 -11
- data/frontend/test/fixtures/users.yml +0 -11
- data/frontend/test/helpers/.keep +0 -0
- data/frontend/test/integration/.keep +0 -0
- data/frontend/test/mailers/.keep +0 -0
- data/frontend/test/models/.keep +0 -0
- data/frontend/test/models/app_test.rb +0 -7
- data/frontend/test/models/publickey_test.rb +0 -7
- data/frontend/test/models/user_test.rb +0 -7
- data/frontend/test/policies/publickey_policy_test.rb +0 -19
- data/frontend/test/system/.keep +0 -0
- data/frontend/test/system/apps_test.rb +0 -9
- data/frontend/test/system/publickeys_test.rb +0 -9
- data/frontend/test/test_helper.rb +0 -9
- data/frontend/tmp/.keep +0 -0
- data/frontend/vendor/.keep +0 -0
- data/lib/meroku/api/request.rb +0 -17
- data/lib/meroku/aws/ec2.rb +0 -59
- data/lib/meroku/cli/help.rb +0 -27
- data/lib/meroku/cli/secrets.rb +0 -23
- data/lib/meroku/cli/session.rb +0 -46
- data/lib/meroku/extensions.rb +0 -32
- data/lib/meroku/infrastructure.rb +0 -23
- data/lib/meroku/infrastructure/server.rb +0 -20
- data/lib/meroku/tunnelable.rb +0 -35
- data/modified-cedar-14.sh +0 -171
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 816206f9563347d62b87cfdc0efe4a2245655603
|
4
|
+
data.tar.gz: f324cd878df16907747cf2f8026ed2fa74ac1893
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81712892db6f34cce5e201865d6c1147ab69f5e0dbe7b9be63a2b7bda74b1d647c24195b4a6a30f7c6a9529f6112c8cf72e70cb407d7c65d3d02f036ea8c1c19
|
7
|
+
data.tar.gz: 79120b685b9abba3109b8a4348d67fb342e9fd19d8c2c829b42a89e9c6bf9ad78fc613bb664ec0e8af38d891509773cbd522e05b4258c9355034fe4c8c0431ed
|
data/.gitignore
CHANGED
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
data/README.md
CHANGED
@@ -1,108 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
[![
|
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
|
-
[![
|
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
|
-
|
17
|
+
## Installation
|
13
18
|
|
14
|
-
|
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
|
-
|
25
|
+
And then execute:
|
20
26
|
|
21
27
|
$ gem install meroku
|
22
28
|
|
23
|
-
|
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
|
-
|
33
|
+
## Development
|
85
34
|
|
86
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
42
|
+
## Contributing
|
104
43
|
|
105
|
-
|
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
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
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Meroku
|
4
|
-
#
|
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
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Meroku
|
4
|
-
#
|
4
|
+
# Mostly wrappers around aws library functions
|
5
5
|
module Aws
|
6
|
-
|
6
|
+
include Meroku::Shared
|
7
7
|
|
8
|
-
|
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.
|
11
|
-
|
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
|
-
|
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
|
7
|
-
|
8
|
-
|
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
|
11
|
-
|
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
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
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
|
47
|
-
|
48
|
-
|
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
|