launch_base 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ FROM ruby:2.5.1
2
+
3
+ RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
4
+
5
+ ENV DEBIAN_FRONTEND noninteractive
6
+
7
+ RUN echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main"\
8
+ > /etc/apt/sources.list.d/google-chrome.list
9
+ RUN curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
10
+
11
+ # Install necessary libraries
12
+ RUN apt-get update -qq && apt-get install -y \
13
+ build-essential \
14
+ libpq-dev \
15
+ curl \
16
+ nodejs \
17
+ postgresql \
18
+ postgresql-contrib \
19
+ google-chrome-stable \
20
+ unzip \
21
+ && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
22
+
23
+ RUN wget --no-check-certificate https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip \
24
+ && unzip chromedriver_linux64.zip \
25
+ && rm chromedriver_linux64.zip \
26
+ && mv -f chromedriver /usr/local/share/ \
27
+ && chmod +x /usr/local/share/chromedriver \
28
+ && ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver \
29
+ && chromedriver -v
30
+
31
+ # Setup peer trust for postgresql
32
+ RUN sed -i 's/md5\|peer/trust/' /etc/postgresql/*/main/pg_hba.conf
33
+
34
+ # Configure bundler
35
+ RUN gem install bundler
36
+ RUN bundle config --global path /cache/
37
+
38
+ # Install CodeClimate test reporter
39
+ RUN curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > \
40
+ /usr/local/share/cc-test-reporter \
41
+ && chmod +x /usr/local/share/cc-test-reporter \
42
+ && ln -s /usr/local/share/cc-test-reporter /usr/local/bin/cc-test-reporter
43
+
44
+ # Set the workdir for running ci
45
+ WORKDIR /app
@@ -0,0 +1,149 @@
1
+ require 'redcarpet'
2
+
3
+ @app_id = @app_name.tr('_', '-')
4
+ # Humanize the App Description
5
+ @app_description = @app_name.tr('-', '_').sub(/\A_+/, '').tr('_', ' ').sub(/\A\w/, &:upcase)
6
+
7
+ # Launch Base default template file
8
+ def source_paths
9
+ fixtures_directory = Pathname.new(__dir__).join('..', 'spec', 'fixtures')
10
+ [__dir__, fixtures_directory] + Array(super)
11
+ end
12
+
13
+ say 'Removing and setting up Gemfile for new project'
14
+ remove_file 'Gemfile'
15
+ run 'touch Gemfile'
16
+ add_source 'https://rubygems.org'
17
+
18
+ gem 'rails', '5.2.0'
19
+ gem 'pg'
20
+ gem 'puma', '~> 3.11'
21
+ gem 'sass-rails', '~> 5.0'
22
+ gem 'uglifier', '>= 1.3.0'
23
+ gem 'bootsnap', '>= 1.1.0', require: false
24
+ gem 'turbolinks', '~> 5'
25
+
26
+ gem_group :development, :test do
27
+ gem 'pry'
28
+ gem 'factory_bot_rails'
29
+ end
30
+
31
+ gem_group :development do
32
+ gem 'web-console', '>= 3.3.0'
33
+ gem 'spring'
34
+ gem 'listen'
35
+ end
36
+
37
+ gem_group :test do
38
+ gem 'capybara', '>= 2.15', '< 4.0'
39
+ gem 'capybara-selenium'
40
+ gem 'capybara-screenshot'
41
+ gem 'simplecov'
42
+ gem 'fuubar'
43
+ gem 'selenium-webdriver'
44
+ gem 'chromedriver-helper'
45
+ gem 'rspec-rails', '~> 3.7'
46
+ end
47
+
48
+ say 'Adding .ruby-version and .ruby-gemset file to project'
49
+ remove_file '.ruby-version'
50
+ copy_file '.ruby-version', '.ruby-version'
51
+ copy_file '.ruby-gemset', '.ruby-gemset'
52
+
53
+ copy_file '.codeclimate.yml', '.codeclimate.yml'
54
+ copy_file '.eslintrc.json', '.eslintrc.json'
55
+ copy_file '.mdlrc', '.mdlrc'
56
+ copy_file '.rubocop.yml', '.rubocop.yml'
57
+ copy_file 'config.reek', 'config.reek'
58
+
59
+ say 'Adding README.md.erb file to project'
60
+ remove_file 'README.md'
61
+ template 'README.md.erb', 'README.md'
62
+
63
+ remove_file 'config/database.yml'
64
+ template 'config/database.yml.erb', 'config/database.yml'
65
+
66
+ template 'app.json.erb', 'app.json'
67
+ copy_file 'bin/ci', 'bin/ci'
68
+ run 'chmod +x bin/ci'
69
+ copy_file 'bin/post_deploy', 'bin/post_deploy'
70
+ copy_file 'dockerfiles/ci/Dockerfile', 'dockerfiles/ci/Dockerfile'
71
+ template 'Jenkinsfile.erb', 'Jenkinsfile'
72
+
73
+ uncomment_lines 'config/environments/development.rb', 'config.action_view.raise_on_missing_translations = true'
74
+ uncomment_lines 'config/environments/test.rb', 'config.action_view.raise_on_missing_translations = true'
75
+ gsub_file 'config/environments/production.rb', 'config.log_level = :debug', 'config.log_level = :info'
76
+
77
+ after_bundle do
78
+ run 'spring stop'
79
+ bundle_command 'exec rails g rspec:install'
80
+
81
+ remove_file '.rspec'
82
+ copy_file '.rspec', '.rspec'
83
+
84
+ run 'mkdir -p spec/features \
85
+ spec/models \
86
+ spec/factories \
87
+ spec/requests \
88
+ spec/support \
89
+ spec/fixtures'
90
+
91
+ copy_file 'spec/support/capybara.rb', 'spec/support/capybara.rb'
92
+ copy_file 'spec/support/factory_bot.rb', 'spec/support/factory_bot.rb'
93
+ copy_file 'spec/support/feature_spec_helpers.rb', 'spec/support/feature_spec_helpers.rb'
94
+ copy_file 'spec/support/spec_helpers.rb', 'spec/support/spec_helpers.rb'
95
+
96
+ remove_file 'spec/rails_helper.rb'
97
+ copy_file 'spec/rails_helper.rb', 'spec/rails_helper.rb'
98
+
99
+ run 'rm -rf test'
100
+
101
+ copy_file 'spec/requests/ping_spec.rb', 'spec/requests/ping_spec.rb'
102
+ copy_file 'spec/features/homepage_spec.rb', 'spec/features/homepage_spec.rb'
103
+ copy_file 'app/controllers/homepage_controller.rb', 'app/controllers/homepage_controller.rb'
104
+
105
+ insert_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do
106
+ <<-ROUTES
107
+ get '/ping', to: ->(_env) { [200, {}, ['pong']]}
108
+ root to: 'homepage#show'
109
+ ROUTES
110
+ end
111
+
112
+ create_file 'app/views/homepage/show.html.erb' do
113
+ markdown_renderer = Redcarpet::Markdown.new(
114
+ Redcarpet::Render::HTML.new(link_attributes: { target: '_blank' }),
115
+ autolink: true,
116
+ tables: true
117
+ )
118
+
119
+ markdown = File.read('README.md')
120
+ markdown_renderer.render(markdown)
121
+ end
122
+
123
+ if ENV['INCLUDE_TESTING_FILES'] == '1'
124
+ insert_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do
125
+ <<-ROUTES
126
+ resource :kabisians, only: [:show]
127
+ ROUTES
128
+ end
129
+
130
+ insert_into_file 'bin/ci', before: "\ncc-test-reporter before-build" do
131
+ "\ngit add . && git commit -m 'Dummy commit'"
132
+ end
133
+
134
+ insert_into_file 'bin/ci', after: 'cc-test-reporter after-build' do
135
+ ' || true'
136
+ end
137
+
138
+ copy_file 'controllers/kabisians_controller.rb', 'app/controllers/kabisians_controller.rb'
139
+ copy_file 'models/kabisian.rb', 'app/models/kabisian.rb'
140
+ copy_file 'views/kabisians/show.html.erb', 'app/views/kabisians/show.html.erb'
141
+ copy_file 'spec/factories/kabisians.rb', 'spec/factories/kabisians.rb'
142
+ copy_file 'spec/features/kabisians_spec_.rb', 'spec/features/kabisians_spec.rb'
143
+ bundle_command 'exec rails generate migration CreateKabisians name:string'
144
+ end
145
+
146
+ bundle_command 'exec rake db:drop'
147
+ bundle_command 'exec rake db:create'
148
+ bundle_command 'exec rake db:migrate'
149
+ end
@@ -0,0 +1,7 @@
1
+ describe 'homepage' do
2
+ it 'shows the basic readme info', :js do
3
+ visit '/'
4
+
5
+ expect(page).to have_content 'Rails app generated by Kabisa LaunchBase'
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'simplecov'
2
+ SimpleCov.start 'rails' do
3
+ add_group 'Config', 'config'
4
+ end
5
+
6
+ ENV['RAILS_ENV'] ||= 'test'
7
+ require File.expand_path('../../config/environment', __FILE__)
8
+
9
+ # Prevent database truncation if the environment is production
10
+ abort('The Rails environment is running in production mode!') if Rails.env.production?
11
+
12
+ require 'rspec/rails'
13
+ # Add additional requires below this line. Rails is not loaded until this point!
14
+
15
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
16
+
17
+ ActiveRecord::Migration.maintain_test_schema!
18
+
19
+ RSpec.configure do |config|
20
+ config.use_transactional_fixtures = true
21
+ config.infer_spec_type_from_file_location!
22
+ config.filter_rails_from_backtrace!
23
+ config.include SpecHelpers
24
+ config.include FeatureSpecHelpers, type: :feature
25
+ end
@@ -0,0 +1,8 @@
1
+ describe '/ping' do
2
+ it 'renders "pong"' do
3
+ get '/ping'
4
+
5
+ expect(response).to be_successful
6
+ expect(response.body).to eq 'pong'
7
+ end
8
+ end
@@ -0,0 +1,30 @@
1
+ require 'capybara/rspec'
2
+ require 'selenium/webdriver'
3
+ require 'capybara-screenshot/rspec'
4
+
5
+ RSpec.configure do |config|
6
+ config.before :each do |example|
7
+ Capybara.register_driver :selenium_chrome_headless do |app|
8
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
9
+ chromeOptions: { args: ['headless', 'disable-gpu', 'no-sandbox', 'window-size=1400,1200)'] },
10
+ loggingPrefs: { browser: 'ALL' }
11
+ )
12
+
13
+ Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
14
+ end
15
+
16
+ Capybara.register_driver :selenium_chrome do |app|
17
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
18
+ chromeOptions: { args: ['disable-gpu', 'no-sandbox', 'window-size=1400,1200)'] }
19
+ )
20
+
21
+ Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
22
+ end
23
+
24
+ Capybara.current_driver = if example.metadata[:js]
25
+ (example.metadata[:headless] == false) ? :selenium_chrome : :selenium_chrome_headless
26
+ else
27
+ :rack_test
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryBot::Syntax::Methods
3
+ end
@@ -0,0 +1,2 @@
1
+ module FeatureSpecHelpers
2
+ end
@@ -0,0 +1,2 @@
1
+ module SpecHelpers
2
+ end
metadata ADDED
@@ -0,0 +1,237 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: launch_base
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Martijn Versluis
8
+ - Tjaco Oostdijk
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2018-06-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.16'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.16'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: fuubar
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.3'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.55'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.55'
84
+ - !ruby/object:Gem::Dependency
85
+ name: reek
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '4.8'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '4.8'
98
+ - !ruby/object:Gem::Dependency
99
+ name: pry
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.11'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.11'
112
+ - !ruby/object:Gem::Dependency
113
+ name: simplecov
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '0.16'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.16'
126
+ - !ruby/object:Gem::Dependency
127
+ name: redcarpet
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '3.4'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '3.4'
140
+ - !ruby/object:Gem::Dependency
141
+ name: thor
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '0.20'
147
+ type: :runtime
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '0.20'
154
+ - !ruby/object:Gem::Dependency
155
+ name: gem-release
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '1.0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '1.0'
168
+ description:
169
+ email:
170
+ - martijn@kabisa.nl
171
+ - tjaco@kabisa.nl
172
+ executables:
173
+ - launch_base
174
+ extensions: []
175
+ extra_rdoc_files: []
176
+ files:
177
+ - Gemfile
178
+ - Gemfile.lock
179
+ - LICENSE.txt
180
+ - README.md
181
+ - bin/launch_base
182
+ - launch_base.gemspec
183
+ - lib/launch_base.rb
184
+ - lib/launch_base/cli.rb
185
+ - lib/launch_base/lint_cli.rb
186
+ - lib/launch_base/utilities.rb
187
+ - lib/launch_base/version.rb
188
+ - templates/.codeclimate.yml
189
+ - templates/.eslintrc.json
190
+ - templates/.mdlrc
191
+ - templates/.rspec
192
+ - templates/.rubocop.yml
193
+ - templates/.ruby-gemset
194
+ - templates/.ruby-version
195
+ - templates/Jenkinsfile.erb
196
+ - templates/README.md.erb
197
+ - templates/app.json.erb
198
+ - templates/app/controllers/homepage_controller.rb
199
+ - templates/bin/ci
200
+ - templates/bin/post_deploy
201
+ - templates/config.reek
202
+ - templates/config/database.yml.erb
203
+ - templates/dockerfiles/ci/Dockerfile
204
+ - templates/launch_base_default_template.rb
205
+ - templates/spec/features/homepage_spec.rb
206
+ - templates/spec/rails_helper.rb
207
+ - templates/spec/requests/ping_spec.rb
208
+ - templates/spec/support/capybara.rb
209
+ - templates/spec/support/factory_bot.rb
210
+ - templates/spec/support/feature_spec_helpers.rb
211
+ - templates/spec/support/spec_helpers.rb
212
+ homepage: https://github.com/kabisa/launch-base
213
+ licenses:
214
+ - MIT
215
+ metadata:
216
+ allowed_push_host: https://rubygems.org
217
+ post_install_message:
218
+ rdoc_options: []
219
+ require_paths:
220
+ - lib
221
+ required_ruby_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ requirements: []
232
+ rubyforge_project:
233
+ rubygems_version: 2.7.7
234
+ signing_key:
235
+ specification_version: 4
236
+ summary: A Rails template with Kabisa defaults
237
+ test_files: []