launch_base 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f884d46fd72417fcda19ba1790afbf3cbe0ea79e61f402fcc279ad086e9b4d0
4
- data.tar.gz: a464b1631d7e8e0b79464d17613d90981378820a347d249ff4db912213d2408b
3
+ metadata.gz: 70ef923d0623037c82adc26d13c28dc7f9bb4f3ce35061f0f803a3ac3d1aa253
4
+ data.tar.gz: 7e121c6715817126a207a737d351010889dbf82768837566715e4a69a7a1703f
5
5
  SHA512:
6
- metadata.gz: 8b8e81ce0905a2e9ac5b5808b4c964855743a1c45631587da73ef2b02b756e737644544ddbff1c0a90a52670d88f584af6bb253b3728ac3f44156ee44d4e1743
7
- data.tar.gz: d09a32627efba676541340c9beed8184162c2ab6fba83b97de4b34af2b10b8ac3a732daba645c6de34be5a610e5518763f22ae6e4a7b980f36fb50a27ee5822a
6
+ metadata.gz: da567056d8ef15e33b0719728246a1dd2c94961c694aab66679d17d9768b05da3bfa361e6b2cd2f127119d1401998af05d10e012ccb44d5ab9940a196518ed39
7
+ data.tar.gz: 2e028aba182253fe5ef863ec526f4aa067892a5433fa195f3f53ecdbe343e6a51372cc867e0f3e5f42868ab2a08d74eb56b2ce953d0e16187b87fd6e9f148cad
data/README.md CHANGED
@@ -29,8 +29,10 @@ Or install it yourself as:
29
29
  ## Usage
30
30
 
31
31
  ```
32
+ launch_base add sidekiq # Add Sidekiq gem and configuration to your app
32
33
  launch_base help [COMMAND] # Describe available commands or one specific command
33
34
  launch_base new # Create a new LaunchBase project (Rails 5.1 or higher is required)
35
+ launch_base new --with-sidekiq # Create a new LaunchBase project including Sidekiq support
34
36
  launch_base update # update LaunchBase
35
37
  launch_base lint install # install lint configuration files
36
38
  launch_base lint update # update gem and reinstall lint configuration files
@@ -88,8 +90,8 @@ You can also run `bin/console` for an interactive prompt that will allow you to
88
90
 
89
91
  To install this gem onto your local machine, run `bundle exec rake install`.
90
92
  To release a new version, update the version number in `version.rb`,
91
- and then run `bundle exec rake release`, which will create a git tag for the version,
92
- push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
93
+ and then run `bundle exec gem tag --push`, which will create and ush a git tag for the version.
94
+ Travis CI will automatically build and publish the gem.
93
95
 
94
96
  ## Contributing
95
97
 
data/bin/launch_base CHANGED
@@ -6,4 +6,4 @@ $LOAD_PATH << source_path
6
6
 
7
7
  require 'launch_base'
8
8
 
9
- LaunchBase::CLI.start
9
+ LaunchBase::CLI::Base.start
data/launch_base.gemspec CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency 'redcarpet', '~> 3.4'
41
41
 
42
42
  spec.add_dependency 'thor', '~> 0.20'
43
+ spec.add_dependency 'redcarpet', '~> 3.4'
43
44
 
44
45
  spec.add_development_dependency 'gem-release', '~> 1.0'
45
46
  end
data/lib/launch_base.rb CHANGED
@@ -1,2 +1,2 @@
1
- require 'launch_base/cli'
1
+ require 'launch_base/cli/base'
2
2
  require 'launch_base/version'
@@ -0,0 +1,17 @@
1
+ require 'launch_base/plugin'
2
+ require 'launch_base/plugins/all'
3
+
4
+ module LaunchBase
5
+ module CLI
6
+ class Add < Thor
7
+ Plugin.each_plugin do |plugin_name, plugin|
8
+ desc plugin_name, "Adds #{plugin.description} to the Rails app"
9
+ long_desc "#{@package_name} add #{plugin_name} adds #{plugin.description} to the Rails app"
10
+
11
+ define_method(plugin_name) do
12
+ plugin.new.install
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'add'
2
+ require_relative 'lint'
@@ -0,0 +1,72 @@
1
+ require 'thor'
2
+ require 'launch_base/cli/all'
3
+ require 'launch_base/utilities'
4
+ require 'launch_base/plugin'
5
+ require 'launch_base/plugins/all'
6
+
7
+ module LaunchBase
8
+ module CLI
9
+ class Base < Thor
10
+ include Thor::Actions
11
+
12
+ package_name 'launch_base'
13
+ register(CLI::Lint, 'lint', 'lint', 'Lint commands')
14
+ register(CLI::Add, 'add', 'add', 'Add additional modules')
15
+
16
+ desc 'update', "update #{LaunchBase}"
17
+
18
+ long_desc <<-LONGDESC
19
+ `#{@package_name} update` triggers Bundler to update the #{LaunchBase} gem
20
+ LONGDESC
21
+
22
+ def update
23
+ run 'bundle update launch_base --conservative'
24
+ end
25
+
26
+ desc 'new', "Create a new #{LaunchBase} project"
27
+
28
+ long_desc <<-LONGDESC
29
+ `#{@package_name} new [project-path]` creates a new rails project with Kabisa preferences.
30
+ LONGDESC
31
+
32
+ Plugin.each_plugin do |_plugin_name, plugin|
33
+ option plugin.command_line_flag, type: :boolean, default: false
34
+ end
35
+
36
+ def new(project_path)
37
+ installed_rails_version = Utilities.get_rails_version
38
+
39
+ if installed_rails_version
40
+ if Utilities.rails_up_to_date?(installed_rails_version)
41
+ run "rails new #{project_path} -m #{Utilities.gem_home}/templates/launch_base_default_template.rb"
42
+ Base.install_modules(project_path, options)
43
+ else
44
+ say "Your current installation of Rails is outdated (#{installed_rails_version}). "\
45
+ "Please upgrade to Rails #{RAILS_VERSION}"
46
+ end
47
+ else
48
+ say "No installation of Rails found. Please install Rails #{RAILS_VERSION}"
49
+ end
50
+ end
51
+
52
+ def help
53
+ show_banner
54
+ super
55
+ end
56
+
57
+ def self.install_modules(project_path, options)
58
+ Plugin.each_plugin do |_plugin_name, plugin|
59
+ if options[plugin.command_line_flag]
60
+ plugin.install(destination_root: project_path)
61
+ end
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ def show_banner
68
+ say "\u{1f680} Kabisa #{LaunchBase}\n\n"
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,30 @@
1
+ require 'thor'
2
+
3
+ module LaunchBase
4
+ module CLI
5
+ class Lint < Thor
6
+ include Thor::Actions
7
+
8
+ desc 'install', 'install lint configuration files'
9
+ long_desc <<-LONGDESC
10
+ `#{@package_name} lint install` installs the lint configuration files into the current directory
11
+ LONGDESC
12
+ def install
13
+ ['.codeclimate.yml', '.eslintrc.json', '.mdlrc', '.rubocop.yml', 'config.reek'].each do |config_file_name|
14
+ create_file(config_file_name) do
15
+ Utilities.gem_home.join('templates', config_file_name).read
16
+ end
17
+ end
18
+ end
19
+
20
+ desc 'update', 'update gem and reinstall lint configuration files'
21
+ long_desc <<-LONGDESC
22
+ `#{@package_name} lint update` updates the gem and reinstalls the lint configuration files
23
+ LONGDESC
24
+ def update
25
+ invoke Base, 'update'
26
+ invoke :install
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,70 @@
1
+ require 'fileutils'
2
+
3
+ module LaunchBase
4
+ class Plugin < Thor
5
+ include Thor::Actions
6
+
7
+ def self.method_added(method_sym)
8
+ super unless method_sym == :install
9
+ end
10
+
11
+ def touch(file_path)
12
+ full_path = File.join(destination_root, file_path)
13
+ FileUtils.touch(full_path)
14
+ end
15
+
16
+ def run_install
17
+ say "Install #{class_name} module"
18
+ install
19
+ say "Successfully installed #{class_name} module"
20
+ end
21
+
22
+ def self.install(destination_root:)
23
+ new([], {}, destination_root: destination_root).run_install
24
+ end
25
+
26
+ def self.description
27
+ to_s
28
+ end
29
+
30
+ def self.inherited(child_class)
31
+ plugin_name = child_class.plugin_name
32
+ register(plugin_name, child_class)
33
+ end
34
+
35
+ def self.register(name, plugin)
36
+ @plugins ||= {}
37
+ @plugins[name] = plugin
38
+ end
39
+
40
+ def self.each_plugin(&block)
41
+ @plugins.each(&block)
42
+ end
43
+
44
+ def self.plugin_name
45
+ to_snake_case(class_name)
46
+ end
47
+
48
+ def self.command_line_flag
49
+ "with-#{plugin_name.tr('_', '-')}"
50
+ end
51
+
52
+ def class_name
53
+ self.class.class_name
54
+ end
55
+
56
+ def self.class_name
57
+ name
58
+ .split('::')
59
+ .last
60
+ end
61
+
62
+ def self.to_snake_case(str)
63
+ str
64
+ .gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
65
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
66
+ .tr('-', '_')
67
+ .downcase
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ Dir["#{__dir__}/**/*.rb"].each do |file|
2
+ require(file)
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'launch_base/plugin'
2
+
3
+ module LaunchBase
4
+ module Plugins
5
+ class Sidekiq < Plugin
6
+ def install
7
+ append_to_file 'Gemfile', "gem 'sidekiq', '~> 5.1'"
8
+ touch 'Procfile'
9
+ append_to_file 'Procfile', 'bundle exec sidekiq'
10
+ empty_directory 'app/workers'
11
+ run 'bundle install'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -10,5 +10,9 @@ module LaunchBase
10
10
 
11
11
  match_data[1] if match_data
12
12
  end
13
+
14
+ def self.gem_home
15
+ Pathname.new(__dir__).join('..', '..')
16
+ end
13
17
  end
14
18
  end
@@ -1,5 +1,5 @@
1
1
  module LaunchBase
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  RAILS_VERSION = '~> 5.2.0'.freeze
4
4
  RUBY_VERSION = '2.5.1'.freeze
5
5
  end
@@ -82,6 +82,10 @@ Style/MethodCalledOnDoEndBlock:
82
82
  Style/Next:
83
83
  Enabled: false
84
84
 
85
+ # Do not enforce the use of modifiers over conditionals when they would fit on one line
86
+ Style/IfUnlessModifier:
87
+ Enabled: false
88
+
85
89
  # Complex inline ifs need ()
86
90
  Style/TernaryParentheses:
87
91
  EnforcedStyle: require_parentheses_when_complex
@@ -64,3 +64,11 @@ codeclimate analyze
64
64
  More info about CodeClimate: [codeclimate.com](https://codeclimate.com)
65
65
 
66
66
  More info about the CodeClimate CLI: [github.com/codeclimate/codeclimate](https://github.com/codeclimate/codeclimate)
67
+
68
+ ## Before deployment/go live
69
+
70
+ - verify mail can be sent
71
+ - verify monitoring is in place
72
+ - do a stress/load test
73
+ - ensure continuous deployment works
74
+ - ensure enough disk space/correct S3 configuration
@@ -32,6 +32,7 @@ gem_group :development do
32
32
  gem 'web-console', '>= 3.3.0'
33
33
  gem 'spring'
34
34
  gem 'listen'
35
+ gem 'rubocop'
35
36
  end
36
37
 
37
38
  gem_group :test do
@@ -0,0 +1,10 @@
1
+ RSpec.configure do |config|
2
+ config.after :each, js: true do
3
+ errors = page.driver.browser.manage.logs.get(:browser).select { |log| log.level == 'SEVERE' }
4
+
5
+ if errors.any?
6
+ report = errors.map { |error| error.message.gsub('\\n', '\n') }.join("\n\n")
7
+ raise "There were #{errors.count} JavaScript errors:\n\n#{report}"
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launch_base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martijn Versluis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-08 00:00:00.000000000 Z
12
+ date: 2018-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -151,6 +151,20 @@ dependencies:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0.20'
154
+ - !ruby/object:Gem::Dependency
155
+ name: redcarpet
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '3.4'
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '3.4'
154
168
  - !ruby/object:Gem::Dependency
155
169
  name: gem-release
156
170
  requirement: !ruby/object:Gem::Requirement
@@ -181,8 +195,13 @@ files:
181
195
  - bin/launch_base
182
196
  - launch_base.gemspec
183
197
  - lib/launch_base.rb
184
- - lib/launch_base/cli.rb
185
- - lib/launch_base/lint_cli.rb
198
+ - lib/launch_base/cli/add.rb
199
+ - lib/launch_base/cli/all.rb
200
+ - lib/launch_base/cli/base.rb
201
+ - lib/launch_base/cli/lint.rb
202
+ - lib/launch_base/plugin.rb
203
+ - lib/launch_base/plugins/all.rb
204
+ - lib/launch_base/plugins/sidekiq.rb
186
205
  - lib/launch_base/utilities.rb
187
206
  - lib/launch_base/version.rb
188
207
  - templates/.codeclimate.yml
@@ -208,6 +227,7 @@ files:
208
227
  - templates/spec/support/capybara.rb
209
228
  - templates/spec/support/factory_bot.rb
210
229
  - templates/spec/support/feature_spec_helpers.rb
230
+ - templates/spec/support/reraise_javascript_errors.rb
211
231
  - templates/spec/support/spec_helpers.rb
212
232
  homepage: https://github.com/kabisa/launch-base
213
233
  licenses:
@@ -230,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
250
  version: '0'
231
251
  requirements: []
232
252
  rubyforge_project:
233
- rubygems_version: 2.7.7
253
+ rubygems_version: 2.7.8
234
254
  signing_key:
235
255
  specification_version: 4
236
256
  summary: A Rails template with Kabisa defaults
@@ -1,54 +0,0 @@
1
- require 'thor'
2
- require 'launch_base/lint_cli'
3
- require 'launch_base/utilities'
4
-
5
- module LaunchBase
6
- class CLI < Thor
7
- include Thor::Actions
8
-
9
- package_name 'launch_base'
10
- register(LintCLI, 'lint', 'lint', 'Lint commands')
11
-
12
- desc 'update', "update #{LaunchBase}"
13
- long_desc <<-LONGDESC
14
- `#{@package_name} update` triggers Bundler to update the #{LaunchBase} gem
15
- LONGDESC
16
- def update
17
- run 'bundle update launch_base --conservative'
18
- end
19
-
20
- desc 'new', "Create a new #{LaunchBase} project"
21
- long_desc <<-LONGDESC
22
- `#{@package_name} new [project-path]` creates a new rails project with Kabisa preferences.
23
- LONGDESC
24
- def new(project_path)
25
- installed_rails_version = Utilities.get_rails_version
26
-
27
- if installed_rails_version
28
- if Utilities.rails_up_to_date?(installed_rails_version)
29
- run "rails new #{project_path} -m #{gem_home}/templates/launch_base_default_template.rb"
30
- else
31
- say "Your current installation of Rails is outdated (#{installed_rails_version}). "\
32
- "Please upgrade to Rails #{RAILS_VERSION}"
33
- end
34
- else
35
- say "No installation of Rails found. Please install Rails #{RAILS_VERSION}"
36
- end
37
- end
38
-
39
- def help
40
- show_banner
41
- super
42
- end
43
-
44
- private
45
-
46
- def show_banner
47
- say "\u{1f680} Kabisa #{LaunchBase}\n\n"
48
- end
49
-
50
- def gem_home
51
- Pathname.new(__dir__).join('..', '..')
52
- end
53
- end
54
- end
@@ -1,34 +0,0 @@
1
- require 'thor'
2
-
3
- module LaunchBase
4
- class LintCLI < Thor
5
- include Thor::Actions
6
-
7
- desc 'install', 'install lint configuration files'
8
- long_desc <<-LONGDESC
9
- `#{@package_name} lint install` installs the lint configuration files into the current directory
10
- LONGDESC
11
- def install
12
- ['.codeclimate.yml', '.eslintrc.json', '.mdlrc', '.rubocop.yml', 'config.reek'].each do |config_file_name|
13
- create_file(config_file_name) do
14
- gem_home.join('templates', config_file_name).read
15
- end
16
- end
17
- end
18
-
19
- desc 'update', 'update gem and reinstall lint configuration files'
20
- long_desc <<-LONGDESC
21
- `#{@package_name} lint update` updates the gem and reinstalls the lint configuration files
22
- LONGDESC
23
- def update
24
- invoke CLI, 'update'
25
- invoke :install
26
- end
27
-
28
- private
29
-
30
- def gem_home
31
- Pathname.new(__dir__).join('..', '..')
32
- end
33
- end
34
- end