modulorails 1.0.0 → 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/.gitignore +1 -0
- data/.rubocop.yml +239 -17
- data/Appraisals +6 -6
- data/CHANGELOG.md +19 -0
- data/app/helpers/modulorails/application_helper.rb +4 -2
- data/gemfiles/rails_52.gemfile +5 -5
- data/gemfiles/rails_60.gemfile +5 -5
- data/gemfiles/rails_61.gemfile +5 -5
- data/gemfiles/rails_70.gemfile +5 -5
- data/lib/generators/modulorails/docker/docker_generator.rb +10 -1
- data/lib/generators/modulorails/docker/templates/Dockerfile.prod.tt +4 -0
- data/lib/generators/modulorails/docker/templates/Dockerfile.tt +3 -0
- data/lib/generators/modulorails/docker/templates/config/database.yml.tt +1 -1
- data/lib/generators/modulorails/docker/templates/docker-compose.yml.tt +6 -1
- data/lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt +2 -2
- data/lib/generators/modulorails/gitlabci/gitlabci_generator.rb +4 -2
- data/lib/generators/modulorails/healthcheck/health_check_generator.rb +8 -5
- data/lib/generators/modulorails/rubocop/rubocop_generator.rb +8 -6
- data/lib/generators/modulorails/self_update/self_update_generator.rb +6 -3
- data/lib/generators/modulorails/service/service_generator.rb +3 -1
- data/lib/modulorails/configuration.rb +4 -0
- data/lib/modulorails/data.rb +113 -62
- data/lib/modulorails/error_data.rb +2 -0
- data/lib/modulorails/errors/invalid_format_error.rb +2 -0
- data/lib/modulorails/errors/invalid_value_error.rb +2 -0
- data/lib/modulorails/railtie.rb +5 -1
- data/lib/modulorails/services/base_service.rb +20 -18
- data/lib/modulorails/services/logs_for_method_service.rb +1 -0
- data/lib/modulorails/success_data.rb +2 -0
- data/lib/modulorails/validators/database_configuration.rb +19 -9
- data/lib/modulorails/version.rb +3 -1
- data/lib/modulorails.rb +40 -33
- data/modulorails.gemspec +8 -7
- metadata +32 -33
- data/lib/generators/modulorails/gitlabci/templates/config/database-ci.yml.tt +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eea438f121d0e403eee3f6c137338eb030fd7dd5dae376dcd4031a84d4a7fb5
|
4
|
+
data.tar.gz: 7b89b7e8ccb4662fea9be88c200681dacac7a90d2b83ae625e29924c0920910d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e558f3457c6bb1689e27c9f65df05dd6cc21b75c4ce21e0d455dd65485143be8ccd48ca82f22785576415cc3527f21bfa8c0c70d67c453151c445dc504d88f8a
|
7
|
+
data.tar.gz: 81232ed88216f39e467cb4a50038d88b8b89924ebcabb8b4a818d97002c3e4b9ff958be097c17836192e42241247554097b686946c1273354cf8bdb0e31cc9d6
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -12,29 +12,33 @@
|
|
12
12
|
# Enabling Rails-specific cops.
|
13
13
|
require: rubocop-rails
|
14
14
|
|
15
|
+
inherit_mode:
|
16
|
+
merge:
|
17
|
+
- Exclude
|
18
|
+
- Include
|
19
|
+
|
15
20
|
AllCops:
|
16
|
-
# Disable all cops by default to ease the migration. This will probably be removed one day.
|
17
|
-
DisabledByDefault: true
|
18
21
|
# No suggestions since the gem is the sole truth for rubocop configuration.
|
19
22
|
SuggestExtensions: false
|
20
23
|
|
24
|
+
# Enable new cops by default
|
25
|
+
NewCops: enable
|
26
|
+
|
21
27
|
# Excluding most directories with generated files and directories with configuration files.
|
22
28
|
Exclude:
|
23
|
-
- 'vendor/**/*'
|
24
|
-
- 'db/**/*'
|
25
|
-
- 'tmp/**/*'
|
26
|
-
- 'bin/**/*'
|
27
|
-
- 'builds/**/*'
|
28
|
-
- 'Gemfile'
|
29
|
-
- '
|
30
|
-
- '
|
31
|
-
- '
|
32
|
-
- '
|
33
|
-
- 'test
|
34
|
-
- '
|
35
|
-
- 'spec
|
36
|
-
- 'node_modules/**/*'
|
37
|
-
- 'spec/**/*'
|
29
|
+
- '/**/vendor/**/*'
|
30
|
+
- '/**/db/**/*'
|
31
|
+
- '/**/tmp/**/*'
|
32
|
+
- '/**/bin/**/*'
|
33
|
+
- '/**/builds/**/*'
|
34
|
+
- '/**/Gemfile'
|
35
|
+
- '/**/Guardfile'
|
36
|
+
- '/**/Capfile'
|
37
|
+
- '/**/Rakefile'
|
38
|
+
- '/**/config/**/*'
|
39
|
+
- '/**/test/**/*'
|
40
|
+
- '/**/node_modules/**/*'
|
41
|
+
- '/**/spec/**/*'
|
38
42
|
|
39
43
|
# Instructing rubocop about all standard Modulotech environments.
|
40
44
|
Rails/UnknownEnv:
|
@@ -43,3 +47,221 @@ Rails/UnknownEnv:
|
|
43
47
|
- development
|
44
48
|
- test
|
45
49
|
- staging
|
50
|
+
- preprod
|
51
|
+
|
52
|
+
# Checks if String literals are using single quotes when no interpolation is required
|
53
|
+
Style/StringLiterals:
|
54
|
+
Enabled: true
|
55
|
+
EnforcedStyle: single_quotes
|
56
|
+
ConsistentQuotesInMultiline: false
|
57
|
+
|
58
|
+
# Checks if the quotes used for quoted symbols are single quotes when no interpolation is required
|
59
|
+
Style/QuotedSymbols:
|
60
|
+
Enabled: true
|
61
|
+
EnforcedStyle: same_as_string_literals
|
62
|
+
|
63
|
+
# This cop checks for uses of literal strings converted to a symbol where a literal symbol could be used instead.
|
64
|
+
Lint/SymbolConversion:
|
65
|
+
Enabled: true
|
66
|
+
EnforcedStyle: strict
|
67
|
+
|
68
|
+
# Useless cop. It checks for unnecessary safe navigations.
|
69
|
+
# Example:
|
70
|
+
# obj&.a && obj.b
|
71
|
+
# Triggers rubocop error: it requires to add safe navigation for "obj.b" call => "obj&.b".
|
72
|
+
# but it is not necessary. obj&.a will return nil if obj is nil, and it will stop
|
73
|
+
# execution of the operation because `&&` right part executes only when left part is truthy.
|
74
|
+
Lint/SafeNavigationConsistency:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
# Checks for places where keyword arguments can be used instead of boolean arguments when defining methods.
|
78
|
+
# Disabled because moving from default arguments to keywords is not that easy.
|
79
|
+
Style/OptionalBooleanParameter:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
# Checks for use of the lambda.(args) syntax.
|
83
|
+
# Disabled while the Ruby team has not voted on this.
|
84
|
+
Style/LambdaCall:
|
85
|
+
Enabled: false
|
86
|
+
EnforcedStyle: braces
|
87
|
+
|
88
|
+
# Checks for presence or absence of braces around hash literal as a last array item depending on configuration.
|
89
|
+
# Disabled because it would break a lot of permitted_params definitions
|
90
|
+
Style/HashAsLastArrayItem:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
# Checks for grouping of accessors in class and module bodies.
|
94
|
+
# Useless.
|
95
|
+
Style/AccessorGrouping:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
# Makes our lives happier: we don't need to disable it in each case/when method
|
99
|
+
# with more than 5 "when"s.
|
100
|
+
Metrics/CyclomaticComplexity:
|
101
|
+
Max: 10
|
102
|
+
|
103
|
+
# Commonly used screens these days easily fit more than 80 characters.
|
104
|
+
Layout/LineLength:
|
105
|
+
Max: 100
|
106
|
+
|
107
|
+
# Too short methods lead to extraction of single-use methods, which can make
|
108
|
+
# the code easier to read (by naming things), but can also clutter the class
|
109
|
+
Metrics/MethodLength:
|
110
|
+
Max: 20
|
111
|
+
|
112
|
+
# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
|
113
|
+
Metrics/ClassLength:
|
114
|
+
Max: 1500
|
115
|
+
|
116
|
+
# No space makes the method definition shorter and differentiates
|
117
|
+
# from a regular assignment.
|
118
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
119
|
+
EnforcedStyle: no_space
|
120
|
+
|
121
|
+
# We do not need to support Ruby 1.9, so this is good to use.
|
122
|
+
Style/SymbolArray:
|
123
|
+
Enabled: true
|
124
|
+
|
125
|
+
# Most readable form.
|
126
|
+
Layout/HashAlignment:
|
127
|
+
EnforcedHashRocketStyle: table
|
128
|
+
EnforcedColonStyle: table
|
129
|
+
|
130
|
+
# Mixing the styles looks just silly.
|
131
|
+
Style/HashSyntax:
|
132
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
133
|
+
|
134
|
+
# has_key? and has_value? are far more readable than key? and value?
|
135
|
+
Style/PreferredHashMethods:
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
# String#% is by far the least verbose and only object oriented variant.
|
139
|
+
Style/FormatString:
|
140
|
+
EnforcedStyle: percent
|
141
|
+
|
142
|
+
# Annotated or template are too verbose and rarely needed.
|
143
|
+
Style/FormatStringToken:
|
144
|
+
EnforcedStyle: unannotated
|
145
|
+
|
146
|
+
Style/CollectionMethods:
|
147
|
+
Enabled: true
|
148
|
+
PreferredMethods:
|
149
|
+
# inject seems more common in the community.
|
150
|
+
reduce: "inject"
|
151
|
+
|
152
|
+
# Either allow this style or don't. Marking it as safe with parenthesis
|
153
|
+
# is silly. Let's try to live without them for now.
|
154
|
+
Style/ParenthesesAroundCondition:
|
155
|
+
AllowSafeAssignment: false
|
156
|
+
Lint/AssignmentInCondition:
|
157
|
+
AllowSafeAssignment: false
|
158
|
+
|
159
|
+
# A specialized exception class will take one or more arguments and construct the message from it.
|
160
|
+
# So both variants make sense.
|
161
|
+
Style/RaiseArgs:
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
# Indenting the chained dots beneath each other is not supported by this cop,
|
165
|
+
# see https://github.com/bbatsov/rubocop/issues/1633
|
166
|
+
Layout/MultilineOperationIndentation:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
# Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
|
170
|
+
# The argument that fail should be used to abort the program is wrong too,
|
171
|
+
# there's Kernel#abort for that.
|
172
|
+
Style/SignalException:
|
173
|
+
EnforcedStyle: only_raise
|
174
|
+
|
175
|
+
# Suppressing exceptions can be perfectly fine, and be it to avoid to
|
176
|
+
# explicitly type nil into the rescue since that's what you want to return,
|
177
|
+
# or suppressing LoadError for optional dependencies
|
178
|
+
Lint/SuppressedException:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
# { ... } for multi-line blocks is okay, follow Weirichs rule instead:
|
182
|
+
# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
|
183
|
+
Style/BlockDelimiters:
|
184
|
+
Enabled: false
|
185
|
+
|
186
|
+
# do / end blocks should be used for side effects,
|
187
|
+
# methods that run a block for side effects and have
|
188
|
+
# a useful return value are rare, assign the return
|
189
|
+
# value to a local variable for those cases.
|
190
|
+
Style/MethodCalledOnDoEndBlock:
|
191
|
+
Enabled: true
|
192
|
+
|
193
|
+
# Enforcing the names of variables? To single letter ones? Just no.
|
194
|
+
Style/SingleLineBlockParams:
|
195
|
+
Enabled: false
|
196
|
+
|
197
|
+
# Shadowing outer local variables with block parameters is often useful
|
198
|
+
# to not reinvent a new name for the same thing, it highlights the relation
|
199
|
+
# between the outer variable and the parameter. The cases where it's actually
|
200
|
+
# confusing are rare, and usually bad for other reasons already, for example
|
201
|
+
# because the method is too long.
|
202
|
+
Lint/ShadowingOuterLocalVariable:
|
203
|
+
Enabled: false
|
204
|
+
|
205
|
+
# Check with yard instead.
|
206
|
+
Style/Documentation:
|
207
|
+
Enabled: false
|
208
|
+
|
209
|
+
# This is just silly. Calling the argument `other` in all cases makes no sense.
|
210
|
+
Naming/BinaryOperatorParameterName:
|
211
|
+
Enabled: false
|
212
|
+
|
213
|
+
# Disable frozen string
|
214
|
+
Style/FrozenStringLiteralComment:
|
215
|
+
Enabled: false
|
216
|
+
|
217
|
+
# Disable No ASCII char in comments
|
218
|
+
Style/AsciiComments:
|
219
|
+
Enabled: false
|
220
|
+
|
221
|
+
# Disable ordered Gems By ascii
|
222
|
+
Bundler/OrderedGems:
|
223
|
+
Enabled: false
|
224
|
+
|
225
|
+
# Change ABC max value
|
226
|
+
Metrics/AbcSize:
|
227
|
+
Max: 35
|
228
|
+
|
229
|
+
# Disable empty method in one line
|
230
|
+
Style/EmptyMethod:
|
231
|
+
EnforcedStyle: expanded
|
232
|
+
|
233
|
+
# Disable max height block
|
234
|
+
Metrics/BlockLength:
|
235
|
+
Enabled: true
|
236
|
+
Exclude:
|
237
|
+
- '/**/app/admin/**/*'
|
238
|
+
|
239
|
+
# Checks if empty lines around the bodies of classes match the configuration.
|
240
|
+
Layout/EmptyLinesAroundClassBody:
|
241
|
+
EnforcedStyle: empty_lines
|
242
|
+
# Checks if empty lines around the bodies of modules match the configuration.
|
243
|
+
Layout/EmptyLinesAroundModuleBody:
|
244
|
+
EnforcedStyle: empty_lines
|
245
|
+
|
246
|
+
# Enforces the consistent usage of %-literal delimiters.
|
247
|
+
Style/PercentLiteralDelimiters:
|
248
|
+
PreferredDelimiters:
|
249
|
+
default: '()'
|
250
|
+
'%i': '[]'
|
251
|
+
'%I': '[]'
|
252
|
+
'%r': '{}'
|
253
|
+
'%w': '[]'
|
254
|
+
'%W': '[]'
|
255
|
+
|
256
|
+
# Unnecessary cop. In what universe "A || B && C" or "A && B || C && D" is ambiguous? looks
|
257
|
+
# like a cop for those who can't in boolean.
|
258
|
+
Lint/AmbiguousOperatorPrecedence:
|
259
|
+
Enabled: false
|
260
|
+
|
261
|
+
# Checks for simple usages of parallel assignment.
|
262
|
+
Style/ParallelAssignment:
|
263
|
+
Enabled: false
|
264
|
+
|
265
|
+
# Checks the style of children definitions at classes and modules.
|
266
|
+
Style/ClassAndModuleChildren:
|
267
|
+
Enabled: false
|
data/Appraisals
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
appraise
|
1
|
+
appraise 'rails-52' do
|
2
2
|
gem 'rails', '~> 5.2', '>= 5.2.6'
|
3
3
|
end
|
4
4
|
|
5
|
-
appraise
|
5
|
+
appraise 'rails-60' do
|
6
6
|
gem 'rails', '~> 6.0', '>= 6.0.4.4'
|
7
7
|
end
|
8
8
|
|
9
|
-
appraise
|
9
|
+
appraise 'rails-61' do
|
10
10
|
gem 'rails', '~> 6.1', '>= 6.1.4.4'
|
11
11
|
end
|
12
12
|
|
13
13
|
# Rails 7 requires at least Ruby 2.7
|
14
14
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
appraise 'rails-70' do
|
16
|
+
gem 'rails', '~> 7.0'
|
17
|
+
end
|
18
18
|
end
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,25 @@
|
|
2
2
|
|
3
3
|
This file is used to list changes made in each version of the gem.
|
4
4
|
|
5
|
+
# 1.1.0
|
6
|
+
|
7
|
+
The 'new project' release.
|
8
|
+
|
9
|
+
- Add lot of Rubocop rules.
|
10
|
+
- Fix rubocop offenses for the gem.
|
11
|
+
- Ensure Modulorails will work with Moduloproject.
|
12
|
+
- Add `webpacker`, `importmap` and `jsbundling` versions to `Modulorails::Data`.
|
13
|
+
|
14
|
+
# 1.0.2
|
15
|
+
|
16
|
+
Fix error in with_transaction: `uninitialized constant Modulorails::BaseService::ErrorData`.
|
17
|
+
|
18
|
+
# 1.0.1
|
19
|
+
|
20
|
+
First Rubocop rules.
|
21
|
+
|
22
|
+
- Add Style/StringLiterals, Style/QuotedSymbols and Lint/SymbolConversion.
|
23
|
+
|
5
24
|
# 1.0.0
|
6
25
|
|
7
26
|
The Rubocop release.
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# @author Matthieu CIAPPARA <ciappa_m@modulotech.fr>
|
2
2
|
module Modulorails::ApplicationHelper
|
3
|
+
|
3
4
|
def powered_by
|
4
|
-
link_to('https://www.modulotech.fr/', target: '_blank', class: 'modulolink') do
|
5
|
-
|
5
|
+
link_to('https://www.modulotech.fr/', target: '_blank', class: 'modulolink', rel: 'noopener') do
|
6
|
+
safe_join(['Powered by modulo', content_tag(:span, 'Tech')])
|
6
7
|
end
|
7
8
|
end
|
9
|
+
|
8
10
|
end
|
data/gemfiles/rails_52.gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
5
|
+
gem 'rake', '~> 12.0'
|
6
|
+
gem 'rspec', '~> 3.0'
|
7
|
+
gem 'rails', '~> 5.2', '>= 5.2.6'
|
8
8
|
|
9
|
-
gemspec path:
|
9
|
+
gemspec path: '../'
|
data/gemfiles/rails_60.gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
5
|
+
gem 'rake', '~> 12.0'
|
6
|
+
gem 'rspec', '~> 3.0'
|
7
|
+
gem 'rails', '~> 6.0', '>= 6.0.4.4'
|
8
8
|
|
9
|
-
gemspec path:
|
9
|
+
gemspec path: '../'
|
data/gemfiles/rails_61.gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
5
|
+
gem 'rake', '~> 12.0'
|
6
|
+
gem 'rspec', '~> 3.0'
|
7
|
+
gem 'rails', '~> 6.1', '>= 6.1.4.4'
|
8
8
|
|
9
|
-
gemspec path:
|
9
|
+
gemspec path: '../'
|
data/gemfiles/rails_70.gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
5
|
+
gem 'rake', '~> 12.0'
|
6
|
+
gem 'rspec', '~> 3.0'
|
7
|
+
gem 'rails', '~> 7.0'
|
8
8
|
|
9
|
-
gemspec path:
|
9
|
+
gemspec path: '../'
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'rails/generators'
|
4
4
|
|
5
5
|
class Modulorails::DockerGenerator < Rails::Generators::Base
|
6
|
+
|
6
7
|
source_root File.expand_path('templates', __dir__)
|
7
8
|
desc 'This generator creates Dockerfiles for an app'
|
8
9
|
|
@@ -12,8 +13,16 @@ class Modulorails::DockerGenerator < Rails::Generators::Base
|
|
12
13
|
template 'docker-compose.yml'
|
13
14
|
template 'docker-compose.prod.yml'
|
14
15
|
template 'entrypoints/docker-entrypoint.sh'
|
16
|
+
chmod 'entrypoints/docker-entrypoint.sh', 0755
|
15
17
|
template 'config/database.yml'
|
18
|
+
|
19
|
+
# Useless unless project is using Webpacker
|
20
|
+
if Modulorails.data.webpacker_version.present?
|
21
|
+
template 'entrypoints/webpack-entrypoint.sh'
|
22
|
+
chmod 'entrypoints/webpack-entrypoint.sh', 0755
|
23
|
+
end
|
16
24
|
rescue StandardError => e
|
17
|
-
|
25
|
+
warn("[Modulorails] Error: cannot generate Docker configuration: #{e.message}")
|
18
26
|
end
|
27
|
+
|
19
28
|
end
|
@@ -10,6 +10,7 @@ RUN apk add --update --no-cache \
|
|
10
10
|
tzdata \
|
11
11
|
yarn \
|
12
12
|
shared-mime-info \
|
13
|
+
gcompat \
|
13
14
|
<%- adapter = Modulorails.data.adapter -%>
|
14
15
|
<%- if adapter =~ /mysql/ -%>
|
15
16
|
mysql-dev
|
@@ -31,6 +32,8 @@ RUN bundle exec rake assets:precompile
|
|
31
32
|
# FINAL IMAGE
|
32
33
|
FROM ruby:<%= Modulorails.data.ruby_version %>-alpine
|
33
34
|
|
35
|
+
ENV RAILS_ENV=development
|
36
|
+
ENV EDITOR=vim
|
34
37
|
WORKDIR /app
|
35
38
|
|
36
39
|
RUN apk add --update --no-cache \
|
@@ -39,6 +42,7 @@ RUN apk add --update --no-cache \
|
|
39
42
|
nodejs \
|
40
43
|
tzdata \
|
41
44
|
shared-mime-info \
|
45
|
+
vim \
|
42
46
|
<%- adapter = Modulorails.data.adapter -%>
|
43
47
|
<%- if adapter =~ /mysql/ -%>
|
44
48
|
mysql-dev \
|
@@ -1,6 +1,7 @@
|
|
1
1
|
FROM ruby:<%= Modulorails.data.ruby_version %>-alpine
|
2
2
|
|
3
3
|
ENV RAILS_ENV=development
|
4
|
+
ENV EDITOR=vim
|
4
5
|
WORKDIR /app
|
5
6
|
|
6
7
|
RUN apk add --update --no-cache \
|
@@ -8,6 +9,8 @@ RUN apk add --update --no-cache \
|
|
8
9
|
nodejs \
|
9
10
|
yarn \
|
10
11
|
tzdata \
|
12
|
+
gcompat \
|
13
|
+
vim \
|
11
14
|
<%- adapter = Modulorails.data.adapter -%>
|
12
15
|
<%- if adapter =~ /mysql/ -%>
|
13
16
|
mysql-dev
|
@@ -13,7 +13,7 @@ development: &default
|
|
13
13
|
port: <%%= ENV.fetch('<%= upper_image_name %>_DATABASE_PORT', 3306) %>
|
14
14
|
<%- else -%>
|
15
15
|
development: &default
|
16
|
-
adapter:
|
16
|
+
adapter: postgresql
|
17
17
|
database: <%%= ENV.fetch('<%= upper_image_name %>_DATABASE_NAME', '<%= image_name %>') %>
|
18
18
|
username: <%%= ENV.fetch('<%= upper_image_name %>_DATABASE_USERNAME', 'postgres') %>
|
19
19
|
password: <%%= ENV.fetch('<%= upper_image_name %>_DATABASE_PASSWORD', 'postgres') %>
|
@@ -20,6 +20,8 @@ services:
|
|
20
20
|
<%= image_name.upcase %>_DATABASE_HOST: database
|
21
21
|
<%= image_name.upcase %>_DATABASE_NAME: <%= image_name %>
|
22
22
|
entrypoint: ./entrypoints/docker-entrypoint.sh
|
23
|
+
stdin_open: true
|
24
|
+
tty: true
|
23
25
|
|
24
26
|
<%- adapter = Modulorails.data.adapter -%>
|
25
27
|
<%- if adapter =~ /mysql/ -%>
|
@@ -52,7 +54,9 @@ services:
|
|
52
54
|
ports:
|
53
55
|
- 1080:80
|
54
56
|
|
55
|
-
|
57
|
+
<%- webpack_container_needed = Modulorails.data.webpacker_version.present? -%>
|
58
|
+
<%- if webpack_container_needed -%>
|
59
|
+
webpack:
|
56
60
|
image: modulotechgroup/<%= image_name %>:dev
|
57
61
|
build:
|
58
62
|
context: .
|
@@ -66,6 +70,7 @@ services:
|
|
66
70
|
NODE_ENV: development
|
67
71
|
RAILS_ENV: development
|
68
72
|
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
|
73
|
+
<%- end-%>
|
69
74
|
|
70
75
|
volumes:
|
71
76
|
db_data:
|
@@ -4,8 +4,8 @@
|
|
4
4
|
set -e
|
5
5
|
|
6
6
|
# No `node_modules` directory means `yarn install` was never launched.
|
7
|
-
# It is mandatory to install yarn dependencies.
|
8
|
-
if [ ! -d node_modules ]
|
7
|
+
# It is mandatory to install yarn dependencies IF there is a `package.json` file.
|
8
|
+
if [ -f package.json ] && [ ! -d node_modules ]
|
9
9
|
then
|
10
10
|
yarn install
|
11
11
|
fi
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'rails/generators'
|
4
4
|
|
5
5
|
class Modulorails::GitlabciGenerator < Rails::Generators::Base
|
6
|
+
|
6
7
|
source_root File.expand_path('templates', __dir__)
|
7
8
|
desc 'This generator creates a template for a .gitlab-ci.yml file at root'
|
8
9
|
|
@@ -17,7 +18,7 @@ class Modulorails::GitlabciGenerator < Rails::Generators::Base
|
|
17
18
|
# Create file to avoid this generator on next modulorails launch
|
18
19
|
create_keep_file
|
19
20
|
rescue StandardError => e
|
20
|
-
|
21
|
+
warn("[Modulorails] Error: cannot generate CI configuration: #{e.message}")
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
@@ -29,6 +30,7 @@ class Modulorails::GitlabciGenerator < Rails::Generators::Base
|
|
29
30
|
copy_file(file, file)
|
30
31
|
|
31
32
|
say "Add #{file} to git"
|
32
|
-
|
33
|
+
`git add #{file}`
|
33
34
|
end
|
35
|
+
|
34
36
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'rails/generators'
|
4
4
|
|
5
5
|
class Modulorails::HealthCheckGenerator < Rails::Generators::Base
|
6
|
+
|
6
7
|
source_root File.expand_path('templates', __dir__)
|
7
8
|
desc 'This generator creates a configuration for the health_check gem'
|
8
9
|
|
@@ -12,9 +13,10 @@ class Modulorails::HealthCheckGenerator < Rails::Generators::Base
|
|
12
13
|
|
13
14
|
# Add the route
|
14
15
|
unless File.read(Rails.root.join('config/routes.rb')).match?('health_check_routes')
|
15
|
-
inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do
|
16
|
-
|
17
|
-
|
16
|
+
inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do
|
17
|
+
<<~'RUBY'
|
18
|
+
health_check_routes
|
19
|
+
RUBY
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -24,7 +26,7 @@ class Modulorails::HealthCheckGenerator < Rails::Generators::Base
|
|
24
26
|
# Create file to avoid this generator on next modulorails launch
|
25
27
|
create_keep_file
|
26
28
|
rescue StandardError => e
|
27
|
-
|
29
|
+
warn("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
|
28
30
|
end
|
29
31
|
|
30
32
|
private
|
@@ -36,6 +38,7 @@ class Modulorails::HealthCheckGenerator < Rails::Generators::Base
|
|
36
38
|
copy_file(file, file)
|
37
39
|
|
38
40
|
say "Add #{file} to git"
|
39
|
-
|
41
|
+
`git add #{file}`
|
40
42
|
end
|
43
|
+
|
41
44
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'rails/generators'
|
4
4
|
|
5
5
|
class Modulorails::RubocopGenerator < Rails::Generators::Base
|
6
|
+
|
6
7
|
source_root File.expand_path('templates', __dir__)
|
7
8
|
desc 'This generator creates a configuration for Rubocop'
|
8
9
|
|
@@ -10,15 +11,16 @@ class Modulorails::RubocopGenerator < Rails::Generators::Base
|
|
10
11
|
rubocop_config_path = Rails.root.join('.rubocop.yml')
|
11
12
|
gitlab_config_path = Rails.root.join('.gitlab-ci.yml')
|
12
13
|
|
13
|
-
template
|
14
|
+
template 'rubocop.yml', rubocop_config_path, force: true
|
15
|
+
|
16
|
+
return if File.read(gitlab_config_path).match?(/\s+extends:\s+.lint\s*$/)
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
<<~YAML
|
18
|
+
append_file gitlab_config_path do
|
19
|
+
<<~YAML
|
18
20
|
rubocop:
|
19
21
|
extends: .lint
|
20
|
-
|
21
|
-
end
|
22
|
+
YAML
|
22
23
|
end
|
23
24
|
end
|
25
|
+
|
24
26
|
end
|
@@ -5,10 +5,11 @@ require 'rails/generators'
|
|
5
5
|
# Author: Matthieu 'ciappa_m' Ciappara
|
6
6
|
# This updates modulorails by editing the gemfile and running a bundle update
|
7
7
|
class Modulorails::SelfUpdateGenerator < Rails::Generators::Base
|
8
|
+
|
8
9
|
source_root File.expand_path('templates', __dir__)
|
9
10
|
desc 'This generator updates Modulorails if required'
|
10
11
|
|
11
|
-
LATEST_VERSION_URL = 'https://rubygems.org/api/v1/versions/modulorails/latest.json'
|
12
|
+
LATEST_VERSION_URL = 'https://rubygems.org/api/v1/versions/modulorails/latest.json'
|
12
13
|
|
13
14
|
def create_config_file
|
14
15
|
modulorails_version = Gem::Version.new(Modulorails::VERSION)
|
@@ -22,11 +23,13 @@ class Modulorails::SelfUpdateGenerator < Rails::Generators::Base
|
|
22
23
|
return if last_published_version <= modulorails_version
|
23
24
|
|
24
25
|
# Add gem to Gemfile
|
25
|
-
gsub_file 'Gemfile', /^\s*gem\s['"]modulorails['"].*$/,
|
26
|
+
gsub_file 'Gemfile', /^\s*gem\s['"]modulorails['"].*$/,
|
27
|
+
"gem 'modulorails', '= #{last_published_version}'"
|
26
28
|
|
27
29
|
# Update the gem and the Gemfile.lock
|
28
30
|
system('bundle install')
|
29
31
|
rescue StandardError => e
|
30
|
-
|
32
|
+
warn("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
|
31
33
|
end
|
34
|
+
|
32
35
|
end
|