onotole 1.0.17 → 1.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 +4 -4
- data/Gemfile +0 -2
- data/README.md +11 -2
- data/lib/onotole/adapters/heroku.rb +1 -1
- data/lib/onotole/app_builder.rb +1 -1
- data/lib/onotole/default_frontend.rb +3 -2
- data/lib/onotole/default_scripts.rb +9 -4
- data/lib/onotole/mail.rb +2 -2
- data/lib/onotole/version.rb +1 -1
- data/spec/adapters/heroku_spec.rb +2 -6
- data/spec/features/heroku_spec.rb +2 -5
- data/spec/features/new_project_spec.rb +2 -2
- data/spec/support/onotole.rb +4 -0
- data/templates/Procfile.erb +2 -0
- data/templates/app.json.erb +6 -6
- data/templates/dotenv.erb +13 -0
- data/templates/{puma.rb → puma.rb.erb} +3 -3
- data/templates/secrets.yml +1 -1
- data/templates/smtp.rb.erb +10 -0
- metadata +6 -6
- data/templates/Procfile +0 -2
- data/templates/dotfiles/.env +0 -13
- data/templates/smtp.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68a3157ab702129ca0c8d08a375737a13438f9a9
|
4
|
+
data.tar.gz: 0cd75e6d0032cdd98a9fef728f41de62c6f621a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9447a725d61a612fb3e197a455a8f95438e24ec36a4765cb6e9f234f3fdaa839053d224daf14989bb7d76011f7b39178edc7c62c465779ebadbc8f07de133c
|
7
|
+
data.tar.gz: e4d1fbd54f3c5da017a960cdcb80ff138d2079286475fed5d51cdc3495954c9531cd971a90bf140592d7da95d05d552b1bacbcebca612d7b63d1b7743dc828e7
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -210,6 +210,15 @@ And testing gems like:
|
|
210
210
|
RSpec matchers
|
211
211
|
* [Timecop](https://github.com/ferndopolis/timecop-console) for testing time
|
212
212
|
|
213
|
+
## ENV Variables
|
214
|
+
|
215
|
+
All variables are stored in `.env` file and calls with project name prefix. It
|
216
|
+
made for avoid name space problems with placing more than 1 of Onotole created
|
217
|
+
app on 1 server. Onotole prefix all `env` variables with `#{app_name}` and now
|
218
|
+
you will not have any problems with export variables in production. With this
|
219
|
+
thick you can easy use ENV export tool or just put ENV variables in `.bashrc`
|
220
|
+
without name space conflicts.
|
221
|
+
|
213
222
|
## Other goodies
|
214
223
|
|
215
224
|
Onotole also comes with:
|
@@ -221,8 +230,8 @@ Onotole also comes with:
|
|
221
230
|
* A [low database connection pool limit][pool]
|
222
231
|
* [Safe binstubs][binstub]
|
223
232
|
* [t() and l() in specs without prefixing with I18n][i18n]
|
224
|
-
* An automatically-created `
|
225
|
-
|
233
|
+
* An automatically-created `#{APP_NAME}_SECRET_KEY_BASE` environment variable in
|
234
|
+
all environments
|
226
235
|
* The analytics adapter [Segment][segment] (and therefore config for Google
|
227
236
|
Analytics, Intercom, Facebook Ads, Twitter Ads, etc.)
|
228
237
|
* Check existing of app DB and ask about continuation if base persisted
|
@@ -42,7 +42,7 @@ module Onotole
|
|
42
42
|
def set_heroku_rails_secrets
|
43
43
|
%w(staging production).each do |environment|
|
44
44
|
run_toolbelt_command(
|
45
|
-
"config:add
|
45
|
+
"config:add #{app_builder.app_name.dasherize.upcase}_SECRET_KEY_BASE=#{generate_secret}",
|
46
46
|
environment
|
47
47
|
)
|
48
48
|
end
|
data/lib/onotole/app_builder.rb
CHANGED
@@ -9,11 +9,12 @@ module Onotole
|
|
9
9
|
def setup_asset_host
|
10
10
|
replace_in_file 'config/environments/production.rb',
|
11
11
|
"# config.action_controller.asset_host = 'http://assets.example.com'",
|
12
|
-
|
12
|
+
"config.action_controller.asset_host = ENV.fetch('#{app_name.upcase}_ASSET_HOST',"\
|
13
|
+
" ENV.fetch('#{app_name.upcase}_APPLICATION_HOST'))"
|
13
14
|
|
14
15
|
replace_in_file 'config/initializers/assets.rb',
|
15
16
|
"config.assets.version = '1.0'",
|
16
|
-
|
17
|
+
"config.assets.version = (ENV['#{app_name.upcase}_ASSETS_VERSION'] || '1.0')"
|
17
18
|
|
18
19
|
inject_into_file(
|
19
20
|
'config/environments/production.rb',
|
@@ -30,7 +30,7 @@ module Onotole
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def set_up_forego
|
33
|
-
|
33
|
+
template 'Procfile.erb', 'Procfile', force: true
|
34
34
|
end
|
35
35
|
|
36
36
|
def setup_staging_environment
|
@@ -48,7 +48,11 @@ end
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def setup_secret_token
|
51
|
-
|
51
|
+
copy_file 'secrets.yml', 'config/secrets.yml', force: true
|
52
|
+
# strange bug with ERB in ERB. solved this way
|
53
|
+
replace_in_file 'config/secrets.yml',
|
54
|
+
"<%= ENV['SECRET_KEY_BASE'] %>",
|
55
|
+
"<%= ENV['#{app_name.upcase}_SECRET_KEY_BASE'] %>"
|
52
56
|
end
|
53
57
|
|
54
58
|
def disallow_wrapping_parameters
|
@@ -103,6 +107,7 @@ end
|
|
103
107
|
|
104
108
|
def copy_dotfiles
|
105
109
|
directory 'dotfiles', '.', force: true
|
110
|
+
template 'dotenv.erb', '.env'
|
106
111
|
end
|
107
112
|
|
108
113
|
def setup_spring
|
@@ -161,11 +166,11 @@ end
|
|
161
166
|
config = <<-RUBY
|
162
167
|
|
163
168
|
if ENV.fetch("HEROKU_APP_NAME", "").include?("staging-pr-")
|
164
|
-
ENV["
|
169
|
+
ENV["#{app_name.upcase}_APPLICATION_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
|
165
170
|
end
|
166
171
|
|
167
172
|
# Ensure requests are only served from one, canonical host name
|
168
|
-
config.middleware.use Rack::CanonicalHost, ENV.fetch("
|
173
|
+
config.middleware.use Rack::CanonicalHost, ENV.fetch("#{app_name.upcase}_APPLICATION_HOST")
|
169
174
|
RUBY
|
170
175
|
|
171
176
|
inject_into_file(
|
data/lib/onotole/mail.rb
CHANGED
@@ -4,7 +4,7 @@ module Onotole
|
|
4
4
|
def configure_action_mailer
|
5
5
|
action_mailer_host 'development', %("localhost:3000")
|
6
6
|
action_mailer_host 'test', %("www.example.com")
|
7
|
-
action_mailer_host 'production', %{ENV.fetch("
|
7
|
+
action_mailer_host 'production', %{ENV.fetch("#{app_name.upcase}_APPLICATION_HOST")}
|
8
8
|
end
|
9
9
|
|
10
10
|
def configure_action_mailer_in_specs
|
@@ -12,7 +12,7 @@ module Onotole
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def configure_smtp
|
15
|
-
|
15
|
+
template 'smtp.rb.erb', 'config/smtp.rb', force: true
|
16
16
|
|
17
17
|
prepend_file 'config/environments/production.rb',
|
18
18
|
%{require Rails.root.join("config/smtp")\n}
|
data/lib/onotole/version.rb
CHANGED
@@ -34,17 +34,13 @@ module Onotole
|
|
34
34
|
Heroku.new(app_builder).set_heroku_rails_secrets
|
35
35
|
|
36
36
|
expect(app_builder).to(
|
37
|
-
have_configured_var('staging',
|
37
|
+
have_configured_var('staging', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
|
38
38
|
)
|
39
39
|
expect(app_builder).to(
|
40
|
-
have_configured_var('production',
|
40
|
+
have_configured_var('production', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|
44
|
-
def app_name
|
45
|
-
OnotoleTestHelpers::APP_NAME
|
46
|
-
end
|
47
|
-
|
48
44
|
def have_configured_var(remote_name, var)
|
49
45
|
have_received(:run).with(/config:add #{var}=.+ --remote #{remote_name}/)
|
50
46
|
end
|
@@ -17,11 +17,8 @@ RSpec.describe 'Heroku' do
|
|
17
17
|
)
|
18
18
|
expect(FakeHeroku).to have_created_app_for('staging')
|
19
19
|
expect(FakeHeroku).to have_created_app_for('production')
|
20
|
-
expect(FakeHeroku).to have_configured_vars('staging',
|
21
|
-
expect(FakeHeroku).to have_configured_vars(
|
22
|
-
'production',
|
23
|
-
'SECRET_KEY_BASE'
|
24
|
-
)
|
20
|
+
expect(FakeHeroku).to have_configured_vars('staging', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
|
21
|
+
expect(FakeHeroku).to have_configured_vars('production', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
|
25
22
|
expect(FakeHeroku).to have_setup_pipeline_for(app_name)
|
26
23
|
|
27
24
|
bin_setup_path = "#{project_path}/bin/setup"
|
@@ -46,7 +46,7 @@ RSpec.describe 'Suspend a new project with default configuration' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'loads secret_key_base from env' do
|
49
|
-
expect(secrets_file).to match
|
49
|
+
expect(secrets_file).to match /secret_key_base: <%= ENV\[('|")#{app_name.upcase}_SECRET_KEY_BASE('|")\] %>/
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'adds bin/setup file' do
|
@@ -119,7 +119,7 @@ RSpec.describe 'Suspend a new project with default configuration' do
|
|
119
119
|
|
120
120
|
it 'uses APPLICATION_HOST, not HOST in the production config' do
|
121
121
|
prod_env_file = IO.read("#{project_path}/config/environments/production.rb")
|
122
|
-
expect(prod_env_file).to match
|
122
|
+
expect(prod_env_file).to match /("|')#{app_name.upcase}_APPLICATION_HOST("|')/
|
123
123
|
expect(prod_env_file).not_to match(/("|')HOST("|')/)
|
124
124
|
end
|
125
125
|
|
data/spec/support/onotole.rb
CHANGED
data/templates/app.json.erb
CHANGED
@@ -14,22 +14,22 @@
|
|
14
14
|
"RAILS_ENV":{
|
15
15
|
"required":true
|
16
16
|
},
|
17
|
-
"
|
17
|
+
"<%= "#{app_name.upcase}_SECRET_KEY_BASE" %>":{
|
18
18
|
"generator":"secret"
|
19
19
|
},
|
20
|
-
"
|
20
|
+
"<%= "#{app_name.upcase}_SMTP_ADDRESS" %>":{
|
21
21
|
"required":true
|
22
22
|
},
|
23
|
-
"
|
23
|
+
"<%= "#{app_name.upcase}_SMTP_DOMAIN" %>":{
|
24
24
|
"required":true
|
25
25
|
},
|
26
|
-
"
|
26
|
+
"<%= "#{app_name.upcase}_SMTP_PASSWORD" %>":{
|
27
27
|
"required":true
|
28
28
|
},
|
29
|
-
"
|
29
|
+
"<%= "#{app_name.upcase}_SMTP_USERNAME" %>":{
|
30
30
|
"required":true
|
31
31
|
},
|
32
|
-
"
|
32
|
+
"<%= "#{app_name.upcase}_WEB_CONCURRENCY" %>":{
|
33
33
|
"required":true
|
34
34
|
}
|
35
35
|
},
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# https://github.com/ddollar/forego
|
2
|
+
<%= "#{app_name.upcase}_ASSET_HOST=localhost:3000" %>
|
3
|
+
<%= "#{app_name.upcase}_APPLICATION_HOST=localhost:3000" %>
|
4
|
+
<%= "#{app_name.upcase}_PORT=3000" %>
|
5
|
+
RACK_ENV=development
|
6
|
+
<%= "#{app_name.upcase}_SECRET_KEY_BASE=development_secret" %>
|
7
|
+
EXECJS_RUNTIME=Node
|
8
|
+
<%= "#{app_name.upcase}_SMTP_ADDRESS=smtp.example.com" %>
|
9
|
+
<%= "#{app_name.upcase}_SMTP_DOMAIN=example.com" %>
|
10
|
+
<%= "#{app_name.upcase}_SMTP_PASSWORD=password" %>
|
11
|
+
<%= "#{app_name.upcase}_SMTP_USERNAME=username" %>
|
12
|
+
<%= "#{app_name.upcase}_WEB_CONCURRENCY=1" %>
|
13
|
+
<%= "#{app_name.upcase}_MAX_THREADS=16" %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# The environment variable WEB_CONCURRENCY may be set to a default value based
|
5
5
|
# on dyno size. To manually configure this value use heroku config:set
|
6
|
-
#
|
6
|
+
# #{app_name}_WEB_CONCURRENCY.
|
7
7
|
#
|
8
8
|
# Increasing the number of workers will increase the amount of resting memory
|
9
9
|
# your dynos use. Increasing the number of threads will increase the amount of
|
@@ -13,8 +13,8 @@
|
|
13
13
|
# Starting with a low number of workers and threads provides adequate
|
14
14
|
# performance for most applications, even under load, while maintaining a low
|
15
15
|
# risk of overusing memory.
|
16
|
-
workers Integer(ENV.fetch('
|
17
|
-
threads_count = Integer(ENV.fetch('
|
16
|
+
workers Integer(ENV.fetch('<%= "#{app_name.upcase}_WEB_CONCURRENCY" %>', 2))
|
17
|
+
threads_count = Integer(ENV.fetch('<%= "#{app_name.upcase}_MAX_THREADS" %>', 2))
|
18
18
|
threads(2, threads_count)
|
19
19
|
|
20
20
|
preload_app!
|
data/templates/secrets.yml
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
SMTP_SETTINGS = {
|
3
|
+
address: ENV.fetch(<%= "#{app_name.upcase}_SMTP_ADDRESS" %>), # example: "smtp.sendgrid.net"
|
4
|
+
authentication: :plain,
|
5
|
+
domain: ENV.fetch(<%= "#{app_name.upcase}_SMTP_DOMAIN" %>), # example: "heroku.com"
|
6
|
+
enable_starttls_auto: true,
|
7
|
+
password: ENV.fetch(<%= "#{app_name.upcase}_SMTP_PASSWORD" %>),
|
8
|
+
port: '587',
|
9
|
+
user_name: ENV.fetch(<%= "#{app_name.upcase}_SMTP_USERNAME" %>)
|
10
|
+
}.freeze
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onotole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kvokka
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -111,7 +111,7 @@ files:
|
|
111
111
|
- spec/support/fake_heroku.rb
|
112
112
|
- spec/support/onotole.rb
|
113
113
|
- templates/Gemfile.erb
|
114
|
-
- templates/Procfile
|
114
|
+
- templates/Procfile.erb
|
115
115
|
- templates/README.md.erb
|
116
116
|
- templates/_analytics.html.erb
|
117
117
|
- templates/_flashes.html.erb
|
@@ -139,8 +139,8 @@ files:
|
|
139
139
|
- templates/devise.ru.yml
|
140
140
|
- templates/devise_rspec.rb
|
141
141
|
- templates/disable_xml_params.rb
|
142
|
+
- templates/dotenv.erb
|
142
143
|
- templates/dotfiles/.ctags
|
143
|
-
- templates/dotfiles/.env
|
144
144
|
- templates/dotfiles/.rspec
|
145
145
|
- templates/errors.rb
|
146
146
|
- templates/factories.rb
|
@@ -156,12 +156,12 @@ files:
|
|
156
156
|
- templates/onotole_layout.html.erb.erb
|
157
157
|
- templates/onotole_overcommit.yml
|
158
158
|
- templates/postgresql_database.yml.erb
|
159
|
-
- templates/puma.rb
|
159
|
+
- templates/puma.rb.erb
|
160
160
|
- templates/rails_helper.rb
|
161
161
|
- templates/rubocop.yml
|
162
162
|
- templates/secrets.yml
|
163
163
|
- templates/shoulda_matchers_config_rspec.rb
|
164
|
-
- templates/smtp.rb
|
164
|
+
- templates/smtp.rb.erb
|
165
165
|
- templates/spec_helper.rb
|
166
166
|
- templates/staging.rb
|
167
167
|
- templates/tinymce.yml
|
data/templates/Procfile
DELETED
data/templates/dotfiles/.env
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# https://github.com/ddollar/forego
|
2
|
-
ASSET_HOST=localhost:3000
|
3
|
-
APPLICATION_HOST=localhost:3000
|
4
|
-
PORT=3000
|
5
|
-
RACK_ENV=development
|
6
|
-
SECRET_KEY_BASE=development_secret
|
7
|
-
EXECJS_RUNTIME=Node
|
8
|
-
SMTP_ADDRESS=smtp.example.com
|
9
|
-
SMTP_DOMAIN=example.com
|
10
|
-
SMTP_PASSWORD=password
|
11
|
-
SMTP_USERNAME=username
|
12
|
-
WEB_CONCURRENCY=1
|
13
|
-
MAX_THREADS=16
|
data/templates/smtp.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
SMTP_SETTINGS = {
|
3
|
-
address: ENV.fetch('SMTP_ADDRESS'), # example: "smtp.sendgrid.net"
|
4
|
-
authentication: :plain,
|
5
|
-
domain: ENV.fetch('SMTP_DOMAIN'), # example: "heroku.com"
|
6
|
-
enable_starttls_auto: true,
|
7
|
-
password: ENV.fetch('SMTP_PASSWORD'),
|
8
|
-
port: '587',
|
9
|
-
user_name: ENV.fetch('SMTP_USERNAME')
|
10
|
-
}.freeze
|