modulorails 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +14 -0
- data/.gitignore +3 -0
- data/.travis.yml +23 -4
- data/Appraisals +18 -0
- data/CHANGELOG.md +37 -0
- data/Dockerfile.ruby25 +34 -0
- data/Dockerfile.ruby26 +28 -0
- data/Dockerfile.ruby27 +25 -0
- data/Dockerfile.ruby30 +25 -0
- data/Dockerfile.ruby31 +25 -0
- data/Gemfile.lock +61 -54
- data/README.md +16 -4
- data/Rakefile +1 -1
- data/docker-compose.yml +37 -0
- data/entrypoints/appraisal_test.sh +7 -0
- data/gemfiles/rails_52.gemfile +9 -0
- data/gemfiles/rails_60.gemfile +9 -0
- data/gemfiles/rails_61.gemfile +9 -0
- data/gemfiles/rails_70.gemfile +9 -0
- data/lib/generators/modulorails/docker/docker_generator.rb +19 -0
- data/lib/generators/modulorails/docker/templates/Dockerfile.prod.tt +57 -0
- data/lib/generators/modulorails/docker/templates/Dockerfile.tt +26 -0
- data/lib/generators/modulorails/docker/templates/config/database.yml.tt +32 -0
- data/lib/generators/modulorails/docker/templates/docker-compose.prod.yml.tt +50 -0
- data/lib/generators/modulorails/docker/templates/docker-compose.yml.tt +71 -0
- data/lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt +20 -0
- data/lib/generators/modulorails/docker/templates/entrypoints/webpack-entrypoint.sh.tt +7 -0
- data/lib/generators/modulorails/gitlabci/gitlabci_generator.rb +34 -0
- data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +118 -0
- data/lib/generators/modulorails/gitlabci/templates/.modulorails-gitlab-ci +6 -0
- data/lib/generators/modulorails/gitlabci/templates/config/database-ci.yml.tt +8 -0
- data/lib/generators/modulorails/healthcheck/health_check_generator.rb +41 -0
- data/lib/generators/modulorails/healthcheck/templates/.modulorails-health_check +6 -0
- data/lib/generators/modulorails/healthcheck/templates/config/initializers/health_check.rb.tt +100 -0
- data/lib/generators/modulorails/self_update/self_update_generator.rb +32 -0
- data/lib/modulorails/configuration.rb +8 -2
- data/lib/modulorails/data.rb +23 -3
- data/lib/modulorails/railtie.rb +18 -3
- data/lib/modulorails/validators/database_configuration.rb +1 -1
- data/lib/modulorails/version.rb +1 -1
- data/lib/modulorails.rb +34 -21
- data/modulorails.gemspec +2 -0
- metadata +69 -17
- data/lib/generators/gitlabci_generator.rb +0 -132
- data/lib/generators/templates/.gitlab-ci.yml +0 -72
- data/lib/generators/templates/.modulorails-gitlab-ci +0 -3
- data/lib/generators/templates/config/database-ci.yml +0 -7
- data/lib/modulorails/updater.rb +0 -42
data/lib/modulorails.rb
CHANGED
@@ -2,9 +2,10 @@ require 'modulorails/version'
|
|
2
2
|
require 'modulorails/configuration'
|
3
3
|
require 'modulorails/data'
|
4
4
|
require 'modulorails/validators/database_configuration'
|
5
|
-
require 'modulorails/updater'
|
6
5
|
require 'modulorails/railtie' if defined?(Rails::Railtie)
|
7
|
-
require 'generators/gitlabci_generator'
|
6
|
+
require 'generators/modulorails/gitlabci/gitlabci_generator'
|
7
|
+
require 'generators/modulorails/healthcheck/health_check_generator'
|
8
|
+
require 'generators/modulorails/self_update/self_update_generator'
|
8
9
|
require 'httparty'
|
9
10
|
|
10
11
|
# Author: Matthieu 'ciappa_m' Ciappara
|
@@ -77,17 +78,25 @@ module Modulorails
|
|
77
78
|
# Define the JSON body of the request
|
78
79
|
body = data.to_params.to_json
|
79
80
|
|
80
|
-
#
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
81
|
+
# Prevent HTTParty to raise error and crash the server in dev
|
82
|
+
begin
|
83
|
+
# Post to the configured endpoint on the Intranet
|
84
|
+
response = HTTParty.post(configuration.endpoint, headers: headers, body: body)
|
85
|
+
|
86
|
+
# According to the API specification, on a "Bad request" response, the server explicits what
|
87
|
+
# went wrong with an `errors` field. We do not want to raise since the gem's user is not
|
88
|
+
# (necessarily) responsible for the error but we still need to display it somewhere to warn
|
89
|
+
# the user something went wrong.
|
90
|
+
puts("[Modulorails] Error: #{response['errors'].join(', ')}") if response.code == 400
|
91
|
+
|
92
|
+
# Return the response to allow users to do some more
|
93
|
+
response
|
94
|
+
rescue StandardError => e
|
95
|
+
# Still need to notify the user
|
96
|
+
puts("[Modulorails] Error: Could not post to #{configuration.endpoint}")
|
97
|
+
puts e.message
|
98
|
+
nil
|
99
|
+
end
|
91
100
|
else
|
92
101
|
raise Error.new('No endpoint or api key')
|
93
102
|
end
|
@@ -100,13 +109,7 @@ module Modulorails
|
|
100
109
|
def generate_ci_template
|
101
110
|
return if File.exists?(Rails.root.join('.modulorails-gitlab-ci'))
|
102
111
|
|
103
|
-
|
104
|
-
'--app', data.rails_name.parameterize,
|
105
|
-
'--database', data.adapter,
|
106
|
-
'--bundler', data.bundler_version,
|
107
|
-
'--ruby_version', data.ruby_version
|
108
|
-
]
|
109
|
-
GitlabciGenerator.new([], generator_options, {}).invoke_all
|
112
|
+
Modulorails::GitlabciGenerator.new([], {}, {}).invoke_all
|
110
113
|
end
|
111
114
|
|
112
115
|
# @author Matthieu 'ciappa_m' Ciappara
|
@@ -130,9 +133,19 @@ module Modulorails
|
|
130
133
|
# Check the last version of Modulorails available on rubygems and update if there was a
|
131
134
|
# publication
|
132
135
|
def self_update
|
133
|
-
Modulorails::
|
136
|
+
Modulorails::SelfUpdateGenerator.new([], {}, {}).invoke_all unless configuration.no_auto_update
|
134
137
|
rescue StandardError => e
|
135
138
|
puts("[Modulorails] An error occured: #{e.class} - #{e.message}")
|
136
139
|
end
|
140
|
+
|
141
|
+
# @author Matthieu 'ciappa_m' Ciappara
|
142
|
+
#
|
143
|
+
# Generate a health_check configuration unless it was already done.
|
144
|
+
# The check is done using a 'keepfile'.
|
145
|
+
def generate_healthcheck_template
|
146
|
+
return if File.exists?(Rails.root.join('.modulorails-health_check'))
|
147
|
+
|
148
|
+
Modulorails::HealthCheckGenerator.new([], {}, {}).invoke_all
|
149
|
+
end
|
137
150
|
end
|
138
151
|
end
|
data/modulorails.gemspec
CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_runtime_dependency 'git', '~> 1.7', '>= 1.7.0'
|
34
34
|
spec.add_runtime_dependency 'httparty'
|
35
35
|
spec.add_runtime_dependency 'i18n'
|
36
|
+
spec.add_runtime_dependency 'health_check', '~> 3.1'
|
36
37
|
|
37
38
|
spec.add_development_dependency 'activerecord', '>= 4.2.0'
|
39
|
+
spec.add_development_dependency "appraisal"
|
38
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modulorails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthieu Ciappara
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -28,22 +28,22 @@ dependencies:
|
|
28
28
|
name: git
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.7'
|
34
31
|
- - ">="
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: 1.7.0
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '1.7'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '1.7'
|
44
41
|
- - ">="
|
45
42
|
- !ruby/object:Gem::Version
|
46
43
|
version: 1.7.0
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.7'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: httparty
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: health_check
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.1'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.1'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: activerecord
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +100,20 @@ dependencies:
|
|
86
100
|
- - ">="
|
87
101
|
- !ruby/object:Gem::Version
|
88
102
|
version: 4.2.0
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: appraisal
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
89
117
|
description: |
|
90
118
|
Modulorails is the common base for the Ruby on Rails project at Modulotech
|
91
119
|
(https://www.modulotech.fr/).
|
@@ -98,11 +126,18 @@ executables: []
|
|
98
126
|
extensions: []
|
99
127
|
extra_rdoc_files: []
|
100
128
|
files:
|
129
|
+
- ".dockerignore"
|
101
130
|
- ".gitignore"
|
102
131
|
- ".rspec"
|
103
132
|
- ".travis.yml"
|
133
|
+
- Appraisals
|
104
134
|
- CHANGELOG.md
|
105
135
|
- CODE_OF_CONDUCT.md
|
136
|
+
- Dockerfile.ruby25
|
137
|
+
- Dockerfile.ruby26
|
138
|
+
- Dockerfile.ruby27
|
139
|
+
- Dockerfile.ruby30
|
140
|
+
- Dockerfile.ruby31
|
106
141
|
- Gemfile
|
107
142
|
- Gemfile.lock
|
108
143
|
- LICENSE.txt
|
@@ -111,15 +146,32 @@ files:
|
|
111
146
|
- bin/console
|
112
147
|
- bin/setup
|
113
148
|
- config/locales/en.yml
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
149
|
+
- docker-compose.yml
|
150
|
+
- entrypoints/appraisal_test.sh
|
151
|
+
- gemfiles/rails_52.gemfile
|
152
|
+
- gemfiles/rails_60.gemfile
|
153
|
+
- gemfiles/rails_61.gemfile
|
154
|
+
- gemfiles/rails_70.gemfile
|
155
|
+
- lib/generators/modulorails/docker/docker_generator.rb
|
156
|
+
- lib/generators/modulorails/docker/templates/Dockerfile.prod.tt
|
157
|
+
- lib/generators/modulorails/docker/templates/Dockerfile.tt
|
158
|
+
- lib/generators/modulorails/docker/templates/config/database.yml.tt
|
159
|
+
- lib/generators/modulorails/docker/templates/docker-compose.prod.yml.tt
|
160
|
+
- lib/generators/modulorails/docker/templates/docker-compose.yml.tt
|
161
|
+
- lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt
|
162
|
+
- lib/generators/modulorails/docker/templates/entrypoints/webpack-entrypoint.sh.tt
|
163
|
+
- lib/generators/modulorails/gitlabci/gitlabci_generator.rb
|
164
|
+
- lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt
|
165
|
+
- lib/generators/modulorails/gitlabci/templates/.modulorails-gitlab-ci
|
166
|
+
- lib/generators/modulorails/gitlabci/templates/config/database-ci.yml.tt
|
167
|
+
- lib/generators/modulorails/healthcheck/health_check_generator.rb
|
168
|
+
- lib/generators/modulorails/healthcheck/templates/.modulorails-health_check
|
169
|
+
- lib/generators/modulorails/healthcheck/templates/config/initializers/health_check.rb.tt
|
170
|
+
- lib/generators/modulorails/self_update/self_update_generator.rb
|
118
171
|
- lib/modulorails.rb
|
119
172
|
- lib/modulorails/configuration.rb
|
120
173
|
- lib/modulorails/data.rb
|
121
174
|
- lib/modulorails/railtie.rb
|
122
|
-
- lib/modulorails/updater.rb
|
123
175
|
- lib/modulorails/validators/database_configuration.rb
|
124
176
|
- lib/modulorails/version.rb
|
125
177
|
- modulorails.gemspec
|
@@ -130,7 +182,7 @@ metadata:
|
|
130
182
|
homepage_uri: https://github.com/moduloTech/modulorails
|
131
183
|
source_code_uri: https://github.com/moduloTech/modulorails
|
132
184
|
changelog_uri: https://github.com/moduloTech/modulorails/blob/master/CHANGELOG.md
|
133
|
-
post_install_message:
|
185
|
+
post_install_message:
|
134
186
|
rdoc_options: []
|
135
187
|
require_paths:
|
136
188
|
- lib
|
@@ -145,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
197
|
- !ruby/object:Gem::Version
|
146
198
|
version: '0'
|
147
199
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
149
|
-
signing_key:
|
200
|
+
rubygems_version: 3.0.3
|
201
|
+
signing_key:
|
150
202
|
specification_version: 4
|
151
203
|
summary: Common base for Ruby on Rails projects at Modulotech
|
152
204
|
test_files: []
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators'
|
4
|
-
|
5
|
-
class GitlabciGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path('templates', __dir__)
|
7
|
-
class_option(:app,
|
8
|
-
required: true, type: :string,
|
9
|
-
desc: 'Specify the application name.')
|
10
|
-
class_option(:database,
|
11
|
-
required: true, type: :string,
|
12
|
-
desc: 'Specify the database to use (either mysql or postgres).')
|
13
|
-
class_option(:bundler,
|
14
|
-
required: true, type: :string,
|
15
|
-
desc: 'Specify the Bundler version.')
|
16
|
-
class_option(:ruby_version,
|
17
|
-
required: true, type: :string,
|
18
|
-
desc: 'Specify the Ruby version.')
|
19
|
-
desc 'This generator creates a template for a .gitlab-ci.yml file at root'
|
20
|
-
|
21
|
-
# Configurations for MySQL/Postgres dockers
|
22
|
-
MYSQL_DOCKER_DB = <<~EOS
|
23
|
-
# Install a MySQL 5.7 database and configure mandatory environment variables
|
24
|
-
# (https://hub.docker.com/_/mysql/)
|
25
|
-
services:
|
26
|
-
- mysql:5.7
|
27
|
-
variables:
|
28
|
-
MYSQL_DATABASE: test
|
29
|
-
MYSQL_ROOT_PASSWORD: password
|
30
|
-
EOS
|
31
|
-
POSTGRES_DOCKER_DB = <<~EOS
|
32
|
-
# Install a Postgres 11 database and configure mandatory environment variables
|
33
|
-
# (https://hub.docker.com/_/postgres/)
|
34
|
-
services:
|
35
|
-
- postgresql:11
|
36
|
-
variables:
|
37
|
-
POSTGRES_DB: test
|
38
|
-
POSTGRES_PASSWORD: password
|
39
|
-
EOS
|
40
|
-
|
41
|
-
def create_config_file
|
42
|
-
# Get the configuration for the database engine
|
43
|
-
db_conf = database_config(options[:database])
|
44
|
-
|
45
|
-
# Update the gitlab-ci template
|
46
|
-
update_gitlab_ci(options, db_conf)
|
47
|
-
|
48
|
-
# Update the database-ci template
|
49
|
-
update_database_ci(db_conf)
|
50
|
-
|
51
|
-
# Create file to avoid this generator on next modulorails launch
|
52
|
-
create_keep_file
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def update_gitlab_ci(options, db_conf)
|
58
|
-
file = '.gitlab-ci.yml'
|
59
|
-
exists = File.exists?(file)
|
60
|
-
|
61
|
-
# Remove original file if there is one
|
62
|
-
remove_file file if exists
|
63
|
-
|
64
|
-
# Copy file
|
65
|
-
copy_file file, file
|
66
|
-
|
67
|
-
# Add the correct database docker
|
68
|
-
prepend_file file, db_conf[:header]
|
69
|
-
|
70
|
-
# Replace key for CI/CD cache
|
71
|
-
gsub_file file, 'CI_CD_CACHE_KEY', "#{options[:app]}-ci_cd"
|
72
|
-
|
73
|
-
# Replace key for bundler version
|
74
|
-
gsub_file file, 'BUNDLER_VERSION', options[:bundler]
|
75
|
-
|
76
|
-
# Replace ruby version
|
77
|
-
gsub_file file, 'RUBY_VERSION', '2.5.0'
|
78
|
-
|
79
|
-
# Warn the user about file overwrite/creation
|
80
|
-
warn_file_update(file, exists)
|
81
|
-
end
|
82
|
-
|
83
|
-
def update_database_ci(db_conf)
|
84
|
-
file = 'config/database-ci.yml'
|
85
|
-
exists = File.exists?(file)
|
86
|
-
|
87
|
-
# Remove original file if there is one
|
88
|
-
remove_file file if exists
|
89
|
-
|
90
|
-
# Copy file
|
91
|
-
copy_file file, file
|
92
|
-
|
93
|
-
# Replace configuration
|
94
|
-
gsub_file file, 'HOST', db_conf[:host]
|
95
|
-
gsub_file file, 'ADAPTER', db_conf[:adapter]
|
96
|
-
gsub_file file, 'DATABASE', 'test'
|
97
|
-
|
98
|
-
# Warn the user about file overwrite/creation
|
99
|
-
warn_file_update(file, exists)
|
100
|
-
end
|
101
|
-
|
102
|
-
def database_config(database)
|
103
|
-
case database
|
104
|
-
when 'mysql', 'mysql2'
|
105
|
-
{ header: MYSQL_DOCKER_DB, host: 'mysql', adapter: 'mysql2' }
|
106
|
-
when 'postgres', 'postgresql'
|
107
|
-
{ header: POSTGRES_DOCKER_DB, host: 'postgres', adapter: 'postgresql' }
|
108
|
-
else
|
109
|
-
raise 'Unknown database: either mysql or postgres'
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def warn_file_update(file, exists)
|
114
|
-
intro = if exists
|
115
|
-
"/!\\ Watch out! Your #{file} was overwritten"
|
116
|
-
else
|
117
|
-
"A new file #{file} was added"
|
118
|
-
end
|
119
|
-
|
120
|
-
say "#{intro} by Modulorails. Ensure everything is correct!"
|
121
|
-
end
|
122
|
-
|
123
|
-
def create_keep_file
|
124
|
-
file = '.modulorails-gitlab-ci'
|
125
|
-
|
126
|
-
# Create file to avoid this generator on next modulorails launch
|
127
|
-
copy_file(file, file)
|
128
|
-
|
129
|
-
say "Add #{file} to git"
|
130
|
-
%x(git add #{file})
|
131
|
-
end
|
132
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
image: ruby:RUBY_VERSION
|
2
|
-
stages:
|
3
|
-
- lint
|
4
|
-
- test
|
5
|
-
- deploy
|
6
|
-
cache:
|
7
|
-
key: CI_CD_CACHE_KEY
|
8
|
-
paths:
|
9
|
-
- vendor/ruby
|
10
|
-
|
11
|
-
before_script:
|
12
|
-
- apt-get update -qy
|
13
|
-
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
|
14
|
-
- eval $(ssh-agent -s)
|
15
|
-
- ssh-add <(echo "$SSH_PRIVATE_KEY")
|
16
|
-
- mkdir -p ~/.ssh
|
17
|
-
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
|
18
|
-
- apt-get install -y ruby-dev
|
19
|
-
- gem install bundler -v BUNDLER_VERSION --no-document
|
20
|
-
# You might need DPL if you're deploying using Heroku
|
21
|
-
#- gem install dpl -v 1.10.15 --no-document
|
22
|
-
# You might need to add some configurations here like a key for a theme
|
23
|
-
#- bundle config gems.rapidrailsthemes.com "$RRT_CFG"
|
24
|
-
- bundle install -j $(nproc) --path vendor
|
25
|
-
|
26
|
-
rubocop:
|
27
|
-
stage: lint
|
28
|
-
script:
|
29
|
-
- bundle exec rubocop -D
|
30
|
-
tags:
|
31
|
-
- rails
|
32
|
-
except:
|
33
|
-
- master
|
34
|
-
- staging
|
35
|
-
|
36
|
-
test:
|
37
|
-
stage: test
|
38
|
-
script:
|
39
|
-
- cp config/database-ci.yml config/database.yml
|
40
|
-
- "bundle exec rake db:create RAILS_ENV=test"
|
41
|
-
- "RAILS_ENV=test bundle exec rake db:migrate:reset"
|
42
|
-
- bundle exec rspec
|
43
|
-
tags:
|
44
|
-
- rails
|
45
|
-
except:
|
46
|
-
- master
|
47
|
-
|
48
|
-
staging:
|
49
|
-
stage: deploy
|
50
|
-
script:
|
51
|
-
# Uncomment the next line and update the application name if you're using DPL to deploy on
|
52
|
-
# Heroku
|
53
|
-
#- dpl --provider=heroku --app=APP_NAME --api-key=$HEROKU_API_KEY
|
54
|
-
# Remove the next line if you're not using Capistrano
|
55
|
-
- bundle exec cap staging deploy
|
56
|
-
only:
|
57
|
-
- staging
|
58
|
-
tags:
|
59
|
-
- rails
|
60
|
-
|
61
|
-
production:
|
62
|
-
stage: deploy
|
63
|
-
script:
|
64
|
-
# Uncomment the next line and update the application name if you're using DPL to deploy on
|
65
|
-
# Heroku
|
66
|
-
#- dpl --provider=heroku --app=APP_NAME --api-key=$HEROKU_API_KEY
|
67
|
-
# Remove the next line if you're not using Capistrano
|
68
|
-
- bundle exec cap production deploy
|
69
|
-
only:
|
70
|
-
- master
|
71
|
-
tags:
|
72
|
-
- rails
|
data/lib/modulorails/updater.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module Modulorails
|
2
|
-
# Author: Matthieu 'ciappa_m' Ciappara
|
3
|
-
# This updates modulorails by editing the gemfile and running a bundle update
|
4
|
-
class Updater
|
5
|
-
LATEST_VERSION_URL = 'https://rubygems.org/api/v1/versions/modulorails/latest.json'.freeze
|
6
|
-
|
7
|
-
def self.call(*args)
|
8
|
-
new(*args).call
|
9
|
-
end
|
10
|
-
|
11
|
-
def call
|
12
|
-
# Get the last published version
|
13
|
-
@last_published_version = HTTParty.get(LATEST_VERSION_URL).parsed_response['version']
|
14
|
-
|
15
|
-
# Do nothing if we could not fetch the last published version (whatever the reason)
|
16
|
-
# Or if the current version is the same as the last published version
|
17
|
-
return if @last_published_version.nil? || @last_published_version == Modulorails::VERSION
|
18
|
-
|
19
|
-
# If the last published version is different from the current version, we update the gem
|
20
|
-
edit_gemfile
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def edit_gemfile
|
26
|
-
# Read the lines of the Gemfile
|
27
|
-
gemfile_location = Rails.root.join('Gemfile')
|
28
|
-
lines = File.readlines gemfile_location
|
29
|
-
|
30
|
-
# Search and replace the modulorails line
|
31
|
-
index = lines.index { |l| l =~ /gem\s['"]modulorails['"]/ }
|
32
|
-
lines[index].gsub!(/(\s*)gem\s['"]modulorails['"].*/,
|
33
|
-
"#{$1}gem 'modulorails', '= #{@last_published_version}'")
|
34
|
-
|
35
|
-
# Update the Gemfile
|
36
|
-
File.open(gemfile_location, 'w') { |f| f.puts(lines) }
|
37
|
-
|
38
|
-
# Update the gem
|
39
|
-
`bundle install || bundle update modulorails`
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|