modulorails 1.4.0.1 → 1.5.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/Gemfile +3 -0
- data/lib/generators/modulorails/bundleraudit/bundleraudit_generator.rb +13 -8
- data/lib/generators/modulorails/docker/docker_generator.rb +58 -15
- data/lib/generators/modulorails/docker/templates/config/cable.yml.tt +6 -6
- data/lib/generators/modulorails/docker/templates/config/database.yml.tt +3 -15
- data/lib/generators/modulorails/docker/templates/config/initializers/0_redis.rb +2 -0
- data/lib/generators/modulorails/docker/templates/config/puma.rb +41 -0
- data/lib/generators/modulorails/docker/templates/docker-compose.yml.tt +14 -7
- data/lib/generators/modulorails/docker/templates/{Dockerfile.prod.tt → dockerfiles/modulotech/Dockerfile.prod.tt} +9 -7
- data/lib/generators/modulorails/docker/templates/{Dockerfile.tt → dockerfiles/modulotech/Dockerfile.tt} +3 -1
- data/lib/generators/modulorails/docker/templates/dockerfiles/rails/Dockerfile.prod.tt +87 -0
- data/lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt +13 -9
- data/lib/generators/modulorails/githooks/githooks_generator.rb +57 -0
- data/lib/generators/modulorails/githooks/templates/dockeruby.sh +112 -0
- data/lib/generators/modulorails/githooks/templates/post-rewrite.sh +5 -0
- data/lib/generators/modulorails/githooks/templates/pre-merge-commit.sh +2 -0
- data/lib/generators/modulorails/githooks/templates/refresh_generations.sh +25 -0
- data/lib/generators/modulorails/gitlabci/gitlabci_generator.rb +5 -19
- data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +15 -3
- data/lib/generators/modulorails/gitlabci/templates/config/deploy/production.yaml.tt +15 -0
- data/lib/generators/modulorails/gitlabci/templates/config/deploy/review.yaml.tt +15 -0
- data/lib/generators/modulorails/gitlabci/templates/config/deploy/staging.yaml.tt +15 -0
- data/lib/generators/modulorails/health_check/health_check_generator.rb +29 -0
- data/lib/generators/modulorails/{healthcheck → health_check}/templates/.modulorails-health_check +2 -0
- data/lib/generators/modulorails/moduloproject/moduloproject_generator.rb +42 -0
- data/lib/generators/modulorails/moduloproject/templates/config/environments/production.rb.tt +109 -0
- data/lib/generators/modulorails/rubocop/rubocop_generator.rb +1 -0
- data/lib/generators/modulorails/self_update/self_update_generator.rb +3 -2
- data/lib/generators/modulorails/service/service_generator.rb +2 -2
- data/lib/generators/modulorails/service/templates/service.rb.tt +4 -11
- data/lib/generators/modulorails/sidekiq/sidekiq_generator.rb +41 -45
- data/lib/modulorails/data.rb +10 -6
- data/lib/modulorails/generators/base.rb +79 -0
- data/lib/modulorails/railtie.rb +6 -0
- data/lib/modulorails/services/base_service.rb +22 -12
- data/lib/modulorails/services/logs_for_method_service.rb +5 -0
- data/lib/modulorails/version.rb +1 -1
- data/lib/modulorails.rb +23 -12
- data/modulorails.gemspec +9 -10
- metadata +37 -54
- data/lib/generators/modulorails/docker/templates/docker-compose.prod.yml.tt +0 -49
- data/lib/generators/modulorails/healthcheck/health_check_generator.rb +0 -40
- /data/lib/generators/modulorails/{healthcheck → health_check}/templates/config/initializers/health_check.rb.tt +0 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
set -e
|
3
|
+
|
4
|
+
# shellcheck disable=SC2016
|
5
|
+
VALID_LAST_INSTRUCTION='exec "${@}"'
|
6
|
+
|
7
|
+
# Check if the Dockerfile exists
|
8
|
+
check_dockerfile() {
|
9
|
+
if [ -f "Dockerfile" ]; then
|
10
|
+
return 0
|
11
|
+
else
|
12
|
+
echo "No Dockerfile"
|
13
|
+
return 1
|
14
|
+
fi
|
15
|
+
}
|
16
|
+
|
17
|
+
# Get the entrypoint location from the Dockerfile
|
18
|
+
entrypoint_location() {
|
19
|
+
entrypoint_line=$(grep '^ENTRYPOINT' Dockerfile || true)
|
20
|
+
|
21
|
+
if [ -z "$entrypoint_line" ]; then
|
22
|
+
echo ""
|
23
|
+
else
|
24
|
+
echo "$entrypoint_line" | sed -n 's/.*\[\(.*\)\].*/\1/p' | tr -d '"'
|
25
|
+
fi
|
26
|
+
}
|
27
|
+
|
28
|
+
# Check if the entrypoint is valid
|
29
|
+
check_entrypoint() {
|
30
|
+
el=$(entrypoint_location)
|
31
|
+
if [ -z "$el" ]; then
|
32
|
+
return 0
|
33
|
+
fi
|
34
|
+
|
35
|
+
if [ ! -f "$el" ]; then
|
36
|
+
echo "Entrypoint not found at location: $el"
|
37
|
+
return 1
|
38
|
+
fi
|
39
|
+
|
40
|
+
last_line=$(tail -n 1 "$el" | xargs)
|
41
|
+
|
42
|
+
if [ "$last_line" != "$VALID_LAST_INSTRUCTION" ]; then
|
43
|
+
echo "Invalid entrypoint: Last instruction should be '$VALID_LAST_INSTRUCTION' instead of '$last_line'"
|
44
|
+
return 1
|
45
|
+
fi
|
46
|
+
|
47
|
+
return 0
|
48
|
+
}
|
49
|
+
|
50
|
+
# Run docker with the necessary options
|
51
|
+
executer_docker_run() {
|
52
|
+
pwd=$(pwd)
|
53
|
+
working_directory=$(basename "$pwd")
|
54
|
+
|
55
|
+
tty_option=""
|
56
|
+
if [ -t 1 ]; then
|
57
|
+
tty_option="-ti"
|
58
|
+
fi
|
59
|
+
|
60
|
+
command="docker run --rm -v '$pwd:/app/$working_directory' -w '/app/$working_directory' $tty_option $git_environment ezveus/ruby:latest $docker_args"
|
61
|
+
echo "$command"
|
62
|
+
exec "$command"
|
63
|
+
}
|
64
|
+
|
65
|
+
executer_dockerfile_run() {
|
66
|
+
if check_entrypoint; then
|
67
|
+
entrypoint_option=""
|
68
|
+
else
|
69
|
+
entrypoint_option="--entrypoint \"sh -c\""
|
70
|
+
fi
|
71
|
+
|
72
|
+
command="docker compose build && docker compose run --rm $tty_option $git_environment $entrypoint_option app $docker_args"
|
73
|
+
echo "$command"
|
74
|
+
exec "$command"
|
75
|
+
}
|
76
|
+
|
77
|
+
# Main function
|
78
|
+
main() {
|
79
|
+
args="$*"
|
80
|
+
docker_args=""
|
81
|
+
contains_command=false
|
82
|
+
git_name=$(git config --get user.name || whoami)
|
83
|
+
git_email=$(git config --get user.email || echo "$git_name@local")
|
84
|
+
git_environment="-e \"GIT_AUTHOR_EMAIL=$git_email\" -e \"GIT_AUTHOR_NAME=$git_name\" -e \"GIT_COMMITTER_EMAIL=$git_email\" -e \"GIT_COMMITTER_NAME=$git_name\""
|
85
|
+
|
86
|
+
tty_option=""
|
87
|
+
if [ -t 1 ]; then
|
88
|
+
tty_option="-ti"
|
89
|
+
fi
|
90
|
+
|
91
|
+
for arg in "$@"; do
|
92
|
+
# Check if any argument is not an option (doesn't start with '-')
|
93
|
+
if [ "${arg#-}" = "$arg" ]; then
|
94
|
+
contains_command=true
|
95
|
+
break
|
96
|
+
fi
|
97
|
+
done
|
98
|
+
|
99
|
+
if [ "$contains_command" = false ]; then
|
100
|
+
docker_args="ruby $args"
|
101
|
+
else
|
102
|
+
docker_args="$args"
|
103
|
+
fi
|
104
|
+
|
105
|
+
if check_dockerfile; then
|
106
|
+
executer_dockerfile_run
|
107
|
+
else
|
108
|
+
executer_docker_run "$docker_args"
|
109
|
+
fi
|
110
|
+
}
|
111
|
+
|
112
|
+
main "$@"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
echo 'Regenerate Gemfile.lock'
|
4
|
+
bundle install
|
5
|
+
git add Gemfile.lock
|
6
|
+
|
7
|
+
if [ $(cat Gemfile.lock | grep i18n-js | wc -l) -gt 0 ]
|
8
|
+
then
|
9
|
+
echo 'Regenerate JS translations'
|
10
|
+
rake i18n:js:export
|
11
|
+
git add app/assets/javascripts/i18n/translations.js
|
12
|
+
fi
|
13
|
+
|
14
|
+
echo 'Regenerate DB schema'
|
15
|
+
export RAILS_ENV=test
|
16
|
+
bundle exec rake db:drop db:create db:schema:load db:migrate
|
17
|
+
git add db/schema.rb
|
18
|
+
export RAILS_ENV=development
|
19
|
+
|
20
|
+
if [ "$(git diff --cached --name-only | wc -l)" -ne 0 ]; then
|
21
|
+
echo "Commit regenerated files by $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
|
22
|
+
git commit -m 'hook: Update generated files'
|
23
|
+
else
|
24
|
+
echo 'Nothing to commit'
|
25
|
+
fi
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'modulorails/generators/base'
|
4
4
|
|
5
|
-
class Modulorails::GitlabciGenerator <
|
5
|
+
class Modulorails::GitlabciGenerator < Modulorails::Generators::Base
|
6
6
|
|
7
|
-
source_root File.expand_path('templates', __dir__)
|
8
7
|
desc 'This generator creates a template for a .gitlab-ci.yml file at root'
|
9
8
|
|
10
|
-
|
9
|
+
protected
|
10
|
+
|
11
|
+
def create_config
|
11
12
|
@data = Modulorails.data
|
12
13
|
@image_name = @data.name.parameterize
|
13
14
|
@environment_name = @data.environment_name
|
@@ -25,23 +26,8 @@ class Modulorails::GitlabciGenerator < Rails::Generators::Base
|
|
25
26
|
# Remove the database-ci template if it exists.
|
26
27
|
# It used to be referenced by the gitlab-ci template.
|
27
28
|
remove_file 'config/database-ci.yml'
|
28
|
-
|
29
|
-
# Create file to avoid this generator on next modulorails launch
|
30
|
-
create_keep_file
|
31
29
|
rescue StandardError => e
|
32
30
|
warn("[Modulorails] Error: cannot generate CI configuration: #{e.message}")
|
33
31
|
end
|
34
32
|
|
35
|
-
private
|
36
|
-
|
37
|
-
def create_keep_file
|
38
|
-
file = '.modulorails-gitlab-ci'
|
39
|
-
|
40
|
-
# Create file to avoid this generator on next modulorails launch
|
41
|
-
copy_file(file, file)
|
42
|
-
|
43
|
-
say "Add #{file} to git"
|
44
|
-
`git add #{file}`
|
45
|
-
end
|
46
|
-
|
47
33
|
end
|
@@ -55,7 +55,7 @@ deploy_review:
|
|
55
55
|
variables:
|
56
56
|
NAMESPACE: <%= @image_name %>-$CI_ENVIRONMENT_SLUG
|
57
57
|
NAME: <%= @image_name %>
|
58
|
-
CHART_NAME:
|
58
|
+
CHART_NAME: rails
|
59
59
|
CONFIG_FILE: config/deploy/review.yaml
|
60
60
|
EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set ingress.hosts[0].host=${CI_ENVIRONMENT_SLUG}.<%= @review_base_url %> --set ingress.tls[0].hosts[0]=${CI_ENVIRONMENT_SLUG}.<%= @review_base_url %> --set env.url=${CI_ENVIRONMENT_SLUG}.<%= @review_base_url %> --set database.url=$DATABASE_URL --set master_key.key=$MASTER_KEY
|
61
61
|
environment:
|
@@ -81,14 +81,26 @@ deploy_staging:
|
|
81
81
|
variables:
|
82
82
|
NAMESPACE: <%= @image_name %>
|
83
83
|
NAME: <%= @image_name %>
|
84
|
-
CHART_NAME:
|
84
|
+
CHART_NAME: rails
|
85
85
|
CONFIG_FILE: config/deploy/staging.yaml
|
86
86
|
EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set database.url=$DATABASE_URL --set master_key.key=$MASTER_KEY
|
87
87
|
environment:
|
88
88
|
name: staging
|
89
89
|
url: https://<%= @staging_url %>
|
90
|
+
on_stop: stop_staging
|
91
|
+
auto_stop_in: 7 days
|
90
92
|
only:
|
91
93
|
- staging
|
94
|
+
|
95
|
+
stop_staging:
|
96
|
+
extends: .stop_staging
|
97
|
+
variables:
|
98
|
+
NAMESPACE: <%= @image_name %>
|
99
|
+
NAME: <%= @image_name %>
|
100
|
+
only:
|
101
|
+
- staging
|
102
|
+
needs:
|
103
|
+
- docker_build
|
92
104
|
<%- end -%>
|
93
105
|
|
94
106
|
<%- if @production_url.present? -%>
|
@@ -97,7 +109,7 @@ deploy_production:
|
|
97
109
|
variables:
|
98
110
|
NAMESPACE: <%= @image_name %>
|
99
111
|
NAME: <%= @image_name %>
|
100
|
-
CHART_NAME:
|
112
|
+
CHART_NAME: rails
|
101
113
|
CONFIG_FILE: config/deploy/production.yaml
|
102
114
|
EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA
|
103
115
|
environment:
|
@@ -41,3 +41,18 @@ env:
|
|
41
41
|
redis:
|
42
42
|
enabled: false
|
43
43
|
existingSecret: 'redis-credential'
|
44
|
+
|
45
|
+
sidekiq:
|
46
|
+
enabled: false
|
47
|
+
# resources:
|
48
|
+
# requests:
|
49
|
+
# cpu: 100m
|
50
|
+
# memory: 512Mi
|
51
|
+
# limits:
|
52
|
+
# cpu: 100m
|
53
|
+
# memory: 512Mi
|
54
|
+
# autoscaling:
|
55
|
+
# enabled: true
|
56
|
+
# minReplicas: 1
|
57
|
+
# maxReplicas: 10
|
58
|
+
# targetCPUUtilizationPercentage: 80
|
@@ -40,3 +40,18 @@ env:
|
|
40
40
|
|
41
41
|
redis:
|
42
42
|
enabled: true
|
43
|
+
|
44
|
+
sidekiq:
|
45
|
+
enabled: true
|
46
|
+
# resources:
|
47
|
+
# requests:
|
48
|
+
# cpu: 100m
|
49
|
+
# memory: 512Mi
|
50
|
+
# limits:
|
51
|
+
# cpu: 100m
|
52
|
+
# memory: 512Mi
|
53
|
+
# autoscaling:
|
54
|
+
# enabled: true
|
55
|
+
# minReplicas: 1
|
56
|
+
# maxReplicas: 10
|
57
|
+
# targetCPUUtilizationPercentage: 80
|
@@ -40,3 +40,18 @@ env:
|
|
40
40
|
|
41
41
|
redis:
|
42
42
|
enabled: true
|
43
|
+
|
44
|
+
sidekiq:
|
45
|
+
enabled: true
|
46
|
+
# resources:
|
47
|
+
# requests:
|
48
|
+
# cpu: 100m
|
49
|
+
# memory: 512Mi
|
50
|
+
# limits:
|
51
|
+
# cpu: 100m
|
52
|
+
# memory: 512Mi
|
53
|
+
# autoscaling:
|
54
|
+
# enabled: true
|
55
|
+
# minReplicas: 1
|
56
|
+
# maxReplicas: 10
|
57
|
+
# targetCPUUtilizationPercentage: 80
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'modulorails/generators/base'
|
4
|
+
|
5
|
+
class Modulorails::HealthCheckGenerator < Modulorails::Generators::Base
|
6
|
+
|
7
|
+
VERSION = 1
|
8
|
+
|
9
|
+
desc 'This generator creates a configuration for the health_check gem'
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def create_config
|
14
|
+
# Update the template
|
15
|
+
template 'config/initializers/health_check.rb'
|
16
|
+
|
17
|
+
# Add the route
|
18
|
+
return if Rails.root.join('config/routes.rb').read.match?('health_check_routes')
|
19
|
+
|
20
|
+
inject_into_file 'config/routes.rb', " health_check_routes\n\n", after: "Rails.application.routes.draw do\n"
|
21
|
+
rescue StandardError => e
|
22
|
+
warn("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def keep_file_name
|
26
|
+
'.modulorails-health_check'
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
class Modulorails::ModuloprojectGenerator < Modulorails::Generators::Base
|
6
|
+
|
7
|
+
desc 'This generator creates templates for Moduloproject'
|
8
|
+
|
9
|
+
def create_config
|
10
|
+
template 'config/environments/production.rb'
|
11
|
+
copy_file('config/environments/production.rb', 'config/environments/staging.rb')
|
12
|
+
update_application_rb
|
13
|
+
create_file('config/locales/fr.yml', "--\nfr: {}\n")
|
14
|
+
rescue StandardError => e
|
15
|
+
warn("[Modulorails] Error: cannot generate Moduloproject configuration: #{e.message}")
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def update_application_rb
|
21
|
+
file = 'config/application.rb'
|
22
|
+
pattern = /^(?>\s*)(?>#\s*)?config.time_zone = .+$/
|
23
|
+
|
24
|
+
config = <<-RUBY
|
25
|
+
|
26
|
+
config.time_zone = 'Europe/Paris'
|
27
|
+
I18n.available_locales = %i[fr en]
|
28
|
+
I18n.default_locale = 'fr'
|
29
|
+
|
30
|
+
uri = URI.parse(ENV.fetch('URL', 'http://localhost:3000'))
|
31
|
+
config.url = uri
|
32
|
+
Rails.application.routes.default_url_options = { protocol: uri.scheme, host: uri.host, port: uri.port }
|
33
|
+
RUBY
|
34
|
+
|
35
|
+
if File.read(file).match?(pattern)
|
36
|
+
gsub_file(file, pattern, config)
|
37
|
+
else
|
38
|
+
append_file(file, "\n#{config.chomp}", after: /^(?>\s*)(?>#\s*)?config.load_defaults.+$/)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# Code is not reloaded between requests.
|
7
|
+
config.enable_reloading = false
|
8
|
+
|
9
|
+
# Eager load code on boot. This eager loads most of Rails and
|
10
|
+
# your application in memory, allowing both threaded web servers
|
11
|
+
# and those relying on copy on write to perform better.
|
12
|
+
# Rake tasks automatically ignore this option for performance.
|
13
|
+
config.eager_load = true
|
14
|
+
|
15
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
16
|
+
# config.eager_load_paths += %W[
|
17
|
+
# #{config.root}/lib/constraints
|
18
|
+
# ]
|
19
|
+
|
20
|
+
# Full error reports are disabled and caching is turned on.
|
21
|
+
config.consider_all_requests_local = false
|
22
|
+
config.action_controller.perform_caching = true
|
23
|
+
|
24
|
+
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
|
25
|
+
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
|
26
|
+
# config.require_master_key = true
|
27
|
+
|
28
|
+
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
|
29
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
30
|
+
|
31
|
+
# Compress CSS using a preprocessor.
|
32
|
+
# config.assets.css_compressor = :sass
|
33
|
+
|
34
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
35
|
+
config.assets.compile = false
|
36
|
+
|
37
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
38
|
+
# config.asset_host = "http://assets.example.com"
|
39
|
+
|
40
|
+
# Specifies the header that your server uses for sending files.
|
41
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
|
42
|
+
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
|
43
|
+
|
44
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
45
|
+
config.active_storage.service = :local
|
46
|
+
|
47
|
+
# Mount Action Cable outside main process or domain.
|
48
|
+
# config.action_cable.mount_path = nil
|
49
|
+
# host = URI(ENV.fetch('URL', 'http://localhost:3000/')).host
|
50
|
+
# config.action_cable.url = "wss://#{host}/cable"
|
51
|
+
# config.action_cable.disable_request_forgery_protection = true
|
52
|
+
# config.action_cable.allowed_request_origins = [
|
53
|
+
# %r{(https|wss)://host}
|
54
|
+
# ]
|
55
|
+
|
56
|
+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
57
|
+
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
|
58
|
+
config.assume_ssl = true
|
59
|
+
|
60
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
61
|
+
config.force_ssl = false
|
62
|
+
|
63
|
+
# Skip http-to-https redirect for the default health check endpoint.
|
64
|
+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
|
65
|
+
|
66
|
+
# Log to STDOUT by default
|
67
|
+
config.logger = ActiveSupport::Logger.new(STDOUT)
|
68
|
+
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
|
69
|
+
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
70
|
+
|
71
|
+
# Prepend all log lines with the following tags.
|
72
|
+
config.log_tags = [:request_id]
|
73
|
+
|
74
|
+
# Info include generic and useful information about system operation, but avoids logging too much
|
75
|
+
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
76
|
+
# want to log everything, set the level to "debug".
|
77
|
+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
|
78
|
+
|
79
|
+
# Use a different cache store in production.
|
80
|
+
config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'], expires_in: 6.hours }
|
81
|
+
|
82
|
+
# Use a real queuing backend for Active Job (and separate queues per environment).
|
83
|
+
# config.active_job.queue_adapter = :sidekiq
|
84
|
+
# config.active_job.queue_name_prefix = "<%= Modulorails.data.rails_name.underscore %>_production"
|
85
|
+
|
86
|
+
config.action_mailer.perform_caching = false
|
87
|
+
|
88
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
89
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
90
|
+
# config.action_mailer.raise_delivery_errors = false
|
91
|
+
|
92
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
93
|
+
# the I18n.default_locale when a translation cannot be found).
|
94
|
+
config.i18n.fallbacks = true
|
95
|
+
|
96
|
+
# Don't log any deprecations.
|
97
|
+
config.active_support.report_deprecations = false
|
98
|
+
|
99
|
+
# Do not dump schema after migrations.
|
100
|
+
config.active_record.dump_schema_after_migration = false
|
101
|
+
|
102
|
+
# Enable DNS rebinding protection and other `Host` header attacks.
|
103
|
+
# config.hosts = [
|
104
|
+
# "example.com", # Allow requests from example.com
|
105
|
+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
106
|
+
# ]
|
107
|
+
# Skip DNS rebinding protection for the default health check endpoint.
|
108
|
+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
109
|
+
end
|
@@ -13,7 +13,8 @@ class Modulorails::SelfUpdateGenerator < Rails::Generators::Base
|
|
13
13
|
|
14
14
|
def create_config_file
|
15
15
|
# Get the last published version
|
16
|
-
|
16
|
+
versions = HTTParty.get(LATEST_VERSION_URL).parsed_response
|
17
|
+
last_published_version = versions&.reject { |version| Gem::Version.new(version['number']).prerelease? }&.first
|
17
18
|
|
18
19
|
# Do nothing if we could not fetch the last published version (whatever the reason)
|
19
20
|
return if last_published_version.nil?
|
@@ -35,7 +36,7 @@ class Modulorails::SelfUpdateGenerator < Rails::Generators::Base
|
|
35
36
|
"gem 'modulorails', '= #{version}'"
|
36
37
|
|
37
38
|
# Update the gem and the Gemfile.lock
|
38
|
-
|
39
|
+
run('bundle install -q')
|
39
40
|
rescue StandardError => e
|
40
41
|
warn("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
|
41
42
|
end
|
@@ -8,7 +8,7 @@ class Modulorails::ServiceGenerator < Rails::Generators::NamedBase
|
|
8
8
|
desc 'This generator creates a service inheriting Modulorails::BaseService'
|
9
9
|
argument :arguments, type: :array, default: [], banner: 'argument argument'
|
10
10
|
|
11
|
-
check_class_collision suffix:
|
11
|
+
check_class_collision suffix: 'Service'
|
12
12
|
|
13
13
|
def create_service_files
|
14
14
|
template 'service.rb', File.join('app/services', class_path, "#{file_name}_service.rb")
|
@@ -17,7 +17,7 @@ class Modulorails::ServiceGenerator < Rails::Generators::NamedBase
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def file_name
|
20
|
-
@
|
20
|
+
@file_name ||= remove_possible_suffix(super)
|
21
21
|
end
|
22
22
|
|
23
23
|
def remove_possible_suffix(name)
|
@@ -1,17 +1,10 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
|
-
|
3
|
-
# <DESCRIBE YOUR CLASS HERE>
|
4
|
-
<%- if arguments.size >= 1 -%>
|
5
|
-
#
|
6
|
-
<%- arguments.each do |argument| -%>
|
7
|
-
# @!attribute <%= argument %>
|
8
|
-
# @return <DESCRIBE YOUR ARGUMENT HERE>
|
9
|
-
<%- end -%>
|
10
|
-
<%- end -%>
|
11
|
-
class <%= class_name %>Service < ::ApplicationService
|
2
|
+
class <%= class_name %>Service < ApplicationService
|
12
3
|
<%- if arguments.size >= 1 -%>
|
13
4
|
|
14
|
-
|
5
|
+
attr_reader <%= arguments.map { |arg| ":#{arg}" }.join(', ') %>
|
6
|
+
|
7
|
+
def initialize(<%= arguments.map { |arg| "#{arg}:" }.join(', ') %>)
|
15
8
|
super()
|
16
9
|
|
17
10
|
<%- arguments.each do |argument| -%>
|