actionmailbox 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +159 -0
- data/LICENSE +21 -0
- data/README.md +278 -0
- data/Rakefile +27 -0
- data/actionmailbox.gemspec +27 -0
- data/app/controllers/action_mailbox/base_controller.rb +43 -0
- data/app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb +50 -0
- data/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb +99 -0
- data/app/controllers/action_mailbox/ingresses/mandrill/inbound_emails_controller.rb +78 -0
- data/app/controllers/action_mailbox/ingresses/postfix/inbound_emails_controller.rb +55 -0
- data/app/controllers/action_mailbox/ingresses/sendgrid/inbound_emails_controller.rb +50 -0
- data/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb +27 -0
- data/app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb +15 -0
- data/app/controllers/rails/conductor/base_controller.rb +10 -0
- data/app/jobs/action_mailbox/incineration_job.rb +18 -0
- data/app/jobs/action_mailbox/routing_job.rb +9 -0
- data/app/models/action_mailbox/inbound_email.rb +43 -0
- data/app/models/action_mailbox/inbound_email/incineratable.rb +18 -0
- data/app/models/action_mailbox/inbound_email/incineratable/incineration.rb +22 -0
- data/app/models/action_mailbox/inbound_email/message_id.rb +36 -0
- data/app/models/action_mailbox/inbound_email/routable.rb +22 -0
- data/app/views/layouts/rails/conductor.html.erb +7 -0
- data/app/views/rails/conductor/action_mailbox/inbound_emails/index.html.erb +15 -0
- data/app/views/rails/conductor/action_mailbox/inbound_emails/new.html.erb +42 -0
- data/app/views/rails/conductor/action_mailbox/inbound_emails/show.html.erb +15 -0
- data/bin/test +5 -0
- data/config/routes.rb +19 -0
- data/db/migrate/20180917164000_create_action_mailbox_tables.rb +11 -0
- data/lib/action_mailbox.rb +15 -0
- data/lib/action_mailbox/base.rb +111 -0
- data/lib/action_mailbox/callbacks.rb +32 -0
- data/lib/action_mailbox/engine.rb +34 -0
- data/lib/action_mailbox/mail_ext.rb +4 -0
- data/lib/action_mailbox/mail_ext/address_equality.rb +5 -0
- data/lib/action_mailbox/mail_ext/address_wrapping.rb +5 -0
- data/lib/action_mailbox/mail_ext/addresses.rb +25 -0
- data/lib/action_mailbox/mail_ext/from_source.rb +5 -0
- data/lib/action_mailbox/mail_ext/recipients.rb +5 -0
- data/lib/action_mailbox/postfix_relayer.rb +67 -0
- data/lib/action_mailbox/router.rb +38 -0
- data/lib/action_mailbox/router/route.rb +38 -0
- data/lib/action_mailbox/routing.rb +20 -0
- data/lib/action_mailbox/test_case.rb +8 -0
- data/lib/action_mailbox/test_helper.rb +42 -0
- data/lib/action_mailbox/version.rb +3 -0
- data/lib/tasks/ingress.rake +24 -0
- data/lib/tasks/install.rake +20 -0
- data/lib/templates/installer.rb +4 -0
- data/lib/templates/mailboxes/application_mailbox.rb +3 -0
- data/test/controllers/ingresses/amazon/inbound_emails_controller_test.rb +20 -0
- data/test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb +89 -0
- data/test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb +58 -0
- data/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb +54 -0
- data/test/controllers/ingresses/sendgrid/inbound_emails_controller_test.rb +44 -0
- data/test/dummy/.babelrc +18 -0
- data/test/dummy/.gitignore +3 -0
- data/test/dummy/.postcssrc.yml +3 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +80 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/javascript/packs/application.js +0 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailboxes/application_mailbox.rb +2 -0
- data/test/dummy/app/mailboxes/messages_mailbox.rb +4 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +36 -0
- data/test/dummy/bin/update +31 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +19 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +63 -0
- data/test/dummy/config/environments/production.rb +96 -0
- data/test/dummy/config/environments/test.rb +46 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/content_security_policy.rb +22 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +34 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config/storage.yml +35 -0
- data/test/dummy/config/webpack/development.js +3 -0
- data/test/dummy/config/webpack/environment.js +3 -0
- data/test/dummy/config/webpack/production.js +3 -0
- data/test/dummy/config/webpack/test.js +3 -0
- data/test/dummy/config/webpacker.yml +65 -0
- data/test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb +11 -0
- data/test/dummy/db/migrate/20180212164506_create_active_storage_tables.active_storage.rb +26 -0
- data/test/dummy/db/schema.rb +43 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/package.json +11 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/storage/.keep +0 -0
- data/test/dummy/yarn.lock +6071 -0
- data/test/fixtures/files/welcome.eml +631 -0
- data/test/jobs/incineration_job_test.rb +17 -0
- data/test/test_helper.rb +54 -0
- data/test/unit/inbound_email/incineration_test.rb +45 -0
- data/test/unit/inbound_email/message_id_test.rb +13 -0
- data/test/unit/inbound_email_test.rb +13 -0
- data/test/unit/mail_ext/address_equality_test.rb +9 -0
- data/test/unit/mail_ext/address_wrapping_test.rb +11 -0
- data/test/unit/mail_ext/recipients_test.rb +33 -0
- data/test/unit/mailbox/bouncing_test.rb +29 -0
- data/test/unit/mailbox/callbacks_test.rb +75 -0
- data/test/unit/mailbox/routing_test.rb +30 -0
- data/test/unit/mailbox/state_test.rb +49 -0
- data/test/unit/postfix_relayer_test.rb +90 -0
- data/test/unit/router_test.rb +137 -0
- metadata +355 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
ENV["MANDRILL_INGRESS_API_KEY"] = "1l9Qf7lutEf7h73VXfBwhw"
|
|
4
|
+
|
|
5
|
+
class ActionMailbox::Ingresses::Mandrill::InboundEmailsControllerTest < ActionDispatch::IntegrationTest
|
|
6
|
+
setup do
|
|
7
|
+
ActionMailbox.ingress = :mandrill
|
|
8
|
+
@events = JSON.generate([{ event: "inbound", msg: { raw_msg: file_fixture("../files/welcome.eml").read } }])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "receiving an inbound email from Mandrill" do
|
|
12
|
+
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
|
|
13
|
+
post rails_mandrill_inbound_emails_url,
|
|
14
|
+
headers: { "X-Mandrill-Signature" => "gldscd2tAb/G+DmpiLcwukkLrC4=" }, params: { mandrill_events: @events }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
assert_response :ok
|
|
18
|
+
|
|
19
|
+
inbound_email = ActionMailbox::InboundEmail.last
|
|
20
|
+
assert_equal file_fixture("../files/welcome.eml").read, inbound_email.raw_email.download
|
|
21
|
+
assert_equal "0CB459E0-0336-41DA-BC88-E6E28C697DDB@37signals.com", inbound_email.message_id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test "rejecting a forged inbound email from Mandrill" do
|
|
25
|
+
assert_no_difference -> { ActionMailbox::InboundEmail.count } do
|
|
26
|
+
post rails_mandrill_inbound_emails_url,
|
|
27
|
+
headers: { "X-Mandrill-Signature" => "forged" }, params: { mandrill_events: @events }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
assert_response :unauthorized
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "raising when Mandrill API key is nil" do
|
|
34
|
+
switch_key_to nil do
|
|
35
|
+
assert_raises ArgumentError do
|
|
36
|
+
post rails_mandrill_inbound_emails_url,
|
|
37
|
+
headers: { "X-Mandrill-Signature" => "gldscd2tAb/G+DmpiLcwukkLrC4=" }, params: { mandrill_events: @events }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test "raising when Mandrill API key is blank" do
|
|
43
|
+
switch_key_to "" do
|
|
44
|
+
assert_raises ArgumentError do
|
|
45
|
+
post rails_mandrill_inbound_emails_url,
|
|
46
|
+
headers: { "X-Mandrill-Signature" => "gldscd2tAb/G+DmpiLcwukkLrC4=" }, params: { mandrill_events: @events }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
def switch_key_to(new_key)
|
|
53
|
+
previous_key, ENV["MANDRILL_INGRESS_API_KEY"] = ENV["MANDRILL_INGRESS_API_KEY"], new_key
|
|
54
|
+
yield
|
|
55
|
+
ensure
|
|
56
|
+
ENV["MANDRILL_INGRESS_API_KEY"] = previous_key
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ActionMailbox::Ingresses::Postfix::InboundEmailsControllerTest < ActionDispatch::IntegrationTest
|
|
4
|
+
setup { ActionMailbox.ingress = :postfix }
|
|
5
|
+
|
|
6
|
+
test "receiving an inbound email from Postfix" do
|
|
7
|
+
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
|
|
8
|
+
post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "message/rfc822" },
|
|
9
|
+
params: file_fixture("../files/welcome.eml").read
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
assert_response :no_content
|
|
13
|
+
|
|
14
|
+
inbound_email = ActionMailbox::InboundEmail.last
|
|
15
|
+
assert_equal file_fixture("../files/welcome.eml").read, inbound_email.raw_email.download
|
|
16
|
+
assert_equal "0CB459E0-0336-41DA-BC88-E6E28C697DDB@37signals.com", inbound_email.message_id
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "rejecting an unauthorized inbound email from Postfix" do
|
|
20
|
+
assert_no_difference -> { ActionMailbox::InboundEmail.count } do
|
|
21
|
+
post rails_postfix_inbound_emails_url, headers: { "Content-Type" => "message/rfc822" },
|
|
22
|
+
params: file_fixture("../files/welcome.eml").read
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
assert_response :unauthorized
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test "rejecting an inbound email of an unsupported media type from Postfix" do
|
|
29
|
+
assert_no_difference -> { ActionMailbox::InboundEmail.count } do
|
|
30
|
+
post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "text/plain" },
|
|
31
|
+
params: file_fixture("../files/welcome.eml").read
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
assert_response :unsupported_media_type
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "raising when the configured password is nil" do
|
|
38
|
+
switch_password_to nil do
|
|
39
|
+
assert_raises ArgumentError do
|
|
40
|
+
post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "message/rfc822" },
|
|
41
|
+
params: file_fixture("../files/welcome.eml").read
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
test "raising when the configured password is blank" do
|
|
47
|
+
switch_password_to "" do
|
|
48
|
+
assert_raises ArgumentError do
|
|
49
|
+
post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "message/rfc822" },
|
|
50
|
+
params: file_fixture("../files/welcome.eml").read
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ActionMailbox::Ingresses::Sendgrid::InboundEmailsControllerTest < ActionDispatch::IntegrationTest
|
|
4
|
+
setup { ActionMailbox.ingress = :sendgrid }
|
|
5
|
+
|
|
6
|
+
test "receiving an inbound email from Sendgrid" do
|
|
7
|
+
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
|
|
8
|
+
post rails_sendgrid_inbound_emails_url,
|
|
9
|
+
headers: { authorization: credentials }, params: { email: file_fixture("../files/welcome.eml").read }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
assert_response :no_content
|
|
13
|
+
|
|
14
|
+
inbound_email = ActionMailbox::InboundEmail.last
|
|
15
|
+
assert_equal file_fixture("../files/welcome.eml").read, inbound_email.raw_email.download
|
|
16
|
+
assert_equal "0CB459E0-0336-41DA-BC88-E6E28C697DDB@37signals.com", inbound_email.message_id
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "rejecting an unauthorized inbound email from Sendgrid" do
|
|
20
|
+
assert_no_difference -> { ActionMailbox::InboundEmail.count } do
|
|
21
|
+
post rails_sendgrid_inbound_emails_url, params: { email: file_fixture("../files/welcome.eml").read }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
assert_response :unauthorized
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test "raising when the configured password is nil" do
|
|
28
|
+
switch_password_to nil do
|
|
29
|
+
assert_raises ArgumentError do
|
|
30
|
+
post rails_sendgrid_inbound_emails_url,
|
|
31
|
+
headers: { authorization: credentials }, params: { email: file_fixture("../files/welcome.eml").read }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
test "raising when the configured password is blank" do
|
|
37
|
+
switch_password_to "" do
|
|
38
|
+
assert_raises ArgumentError do
|
|
39
|
+
post rails_sendgrid_inbound_emails_url,
|
|
40
|
+
headers: { authorization: credentials }, params: { email: file_fixture("../files/welcome.eml").read }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/test/dummy/.babelrc
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"presets": [
|
|
3
|
+
["env", {
|
|
4
|
+
"modules": false,
|
|
5
|
+
"targets": {
|
|
6
|
+
"browsers": "> 1%",
|
|
7
|
+
"uglify": true
|
|
8
|
+
},
|
|
9
|
+
"useBuiltIns": true
|
|
10
|
+
}]
|
|
11
|
+
],
|
|
12
|
+
|
|
13
|
+
"plugins": [
|
|
14
|
+
"syntax-dynamic-import",
|
|
15
|
+
"transform-object-rest-spread",
|
|
16
|
+
["transform-class-properties", { "spec": true }]
|
|
17
|
+
]
|
|
18
|
+
}
|
data/test/dummy/Rakefile
ADDED
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
|
11
|
+
* It is generally better to create a new file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
body {
|
|
2
|
+
background-color: #fff;
|
|
3
|
+
color: #333;
|
|
4
|
+
margin: 33px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body, p, ol, ul, td {
|
|
8
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
9
|
+
font-size: 13px;
|
|
10
|
+
line-height: 18px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
pre {
|
|
14
|
+
background-color: #eee;
|
|
15
|
+
padding: 10px;
|
|
16
|
+
font-size: 11px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
a {
|
|
20
|
+
color: #000;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
a:visited {
|
|
24
|
+
color: #666;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
a:hover {
|
|
28
|
+
color: #fff;
|
|
29
|
+
background-color: #000;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
th {
|
|
33
|
+
padding-bottom: 5px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
td {
|
|
37
|
+
padding: 0 5px 7px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.field,
|
|
41
|
+
div.actions {
|
|
42
|
+
margin-bottom: 10px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#notice {
|
|
46
|
+
color: green;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.field_with_errors {
|
|
50
|
+
padding: 2px;
|
|
51
|
+
background-color: red;
|
|
52
|
+
display: table;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#error_explanation {
|
|
56
|
+
width: 450px;
|
|
57
|
+
border: 2px solid red;
|
|
58
|
+
padding: 7px 7px 0;
|
|
59
|
+
margin-bottom: 20px;
|
|
60
|
+
background-color: #f0f0f0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#error_explanation h2 {
|
|
64
|
+
text-align: left;
|
|
65
|
+
font-weight: bold;
|
|
66
|
+
padding: 5px 5px 5px 15px;
|
|
67
|
+
font-size: 12px;
|
|
68
|
+
margin: -7px -7px 0;
|
|
69
|
+
background-color: #c00;
|
|
70
|
+
color: #fff;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#error_explanation ul li {
|
|
74
|
+
font-size: 12px;
|
|
75
|
+
list-style: square;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
label {
|
|
79
|
+
display: block;
|
|
80
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= yield %>
|
data/test/dummy/bin/rake
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
include FileUtils
|
|
4
|
+
|
|
5
|
+
# path to your application root.
|
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
|
7
|
+
|
|
8
|
+
def system!(*args)
|
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
chdir APP_ROOT do
|
|
13
|
+
# This script is a starting point to setup your application.
|
|
14
|
+
# Add necessary setup steps to this file.
|
|
15
|
+
|
|
16
|
+
puts '== Installing dependencies =='
|
|
17
|
+
system! 'gem install bundler --conservative'
|
|
18
|
+
system('bundle check') || system!('bundle install')
|
|
19
|
+
|
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
|
21
|
+
# system('bin/yarn')
|
|
22
|
+
|
|
23
|
+
# puts "\n== Copying sample files =="
|
|
24
|
+
# unless File.exist?('config/database.yml')
|
|
25
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
|
26
|
+
# end
|
|
27
|
+
|
|
28
|
+
puts "\n== Preparing database =="
|
|
29
|
+
system! 'bin/rails db:setup'
|
|
30
|
+
|
|
31
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
32
|
+
system! 'bin/rails log:clear tmp:clear'
|
|
33
|
+
|
|
34
|
+
puts "\n== Restarting application server =="
|
|
35
|
+
system! 'bin/rails restart'
|
|
36
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
include FileUtils
|
|
4
|
+
|
|
5
|
+
# path to your application root.
|
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
|
7
|
+
|
|
8
|
+
def system!(*args)
|
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
chdir APP_ROOT do
|
|
13
|
+
# This script is a way to update your development environment automatically.
|
|
14
|
+
# Add necessary update steps to this file.
|
|
15
|
+
|
|
16
|
+
puts '== Installing dependencies =='
|
|
17
|
+
system! 'gem install bundler --conservative'
|
|
18
|
+
system('bundle check') || system!('bundle install')
|
|
19
|
+
|
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
|
21
|
+
# system('bin/yarn')
|
|
22
|
+
|
|
23
|
+
puts "\n== Updating database =="
|
|
24
|
+
system! 'bin/rails db:migrate'
|
|
25
|
+
|
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
27
|
+
system! 'bin/rails log:clear tmp:clear'
|
|
28
|
+
|
|
29
|
+
puts "\n== Restarting application server =="
|
|
30
|
+
system! 'bin/rails restart'
|
|
31
|
+
end
|