mogu 0.5.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2db47b44f542a88efc8a2bf123276264957d905fc299bc0fc87662090d139464
4
- data.tar.gz: 39e544f5a42fcec266d1c410b415382679b1e7d92bafc8fbf8a717b7a80446f2
3
+ metadata.gz: ff62aaa44ea6ba8a4fa79cc8453cf5ac54bfe142b06d95d5512d80ea6e644540
4
+ data.tar.gz: 7ce4af13262e1cad5baf01e1c258a9d8d46918c8dc6f7b222f090d249c92d11e
5
5
  SHA512:
6
- metadata.gz: ec71aa0276b7f96d7df1720c662cbf704f40c68e11351eb7fda301843be180772be15d48bc454f7002d0a93c4cd61dbfa429b449463017c03afde7f0dc41027c
7
- data.tar.gz: 8fd8fc23a60b048820dc65a30b1d5da88d87ab47f4a0e40f3f15231f316df835d228582472b2cacfacabfcf83518a9620f06f6b67e71a194286383cf330dfbaf
6
+ metadata.gz: 7f7552ae5a1531d8bc61d7b0df6dfaaa867ee26d6e9a091a12c650b63aa5afb04725a9cebca260f8f9b4aa20fe52541db02c10e710a333b1e22b883af29f922b
7
+ data.tar.gz: f9cf99602a0ad431399e55dcf76f84a29f6e5f7adc3ce8a2fe26bee759c4de62dfbfc11cd5654fdc637dc4faceeb0af75def7f165a11a57b305ccfbbd9cdcfa3
@@ -0,0 +1,39 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.231.2/containers/docker-existing-docker-compose
3
+ // If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
4
+ {
5
+ "name": "Existing Docker Compose (Extend)",
6
+
7
+ // Update the 'dockerComposeFile' list if you have more compose files or use different names.
8
+ // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
9
+ "dockerComposeFile": ["../compose.yaml", "docker-compose.yml"],
10
+
11
+ // The 'service' property is the name of the service for the container that VS Code should
12
+ // use. Update this value and .devcontainer/docker-compose.yml to the real service name.
13
+ "service": "ruby",
14
+
15
+ // The optional 'workspaceFolder' property is the path VS Code should open by default when
16
+ // connected. This is typically a file mount in .devcontainer/docker-compose.yml
17
+ "workspaceFolder": "/workspace",
18
+
19
+ // Set *default* container specific settings.json values on container create.
20
+ "settings": {},
21
+
22
+ // Add the IDs of extensions you want installed when the container is created.
23
+ "extensions": ["castwide.solargraph"]
24
+
25
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
26
+ // "forwardPorts": [],
27
+
28
+ // Uncomment the next line if you want start specific services in your Docker Compose config.
29
+ // "runServices": [],
30
+
31
+ // Uncomment the next line if you want to keep your containers running after VS Code shuts down.
32
+ // "shutdownAction": "none",
33
+
34
+ // Uncomment the next line to run commands after the container is created - for example installing curl.
35
+ // "postCreateCommand": "apt-get update && apt-get install -y curl",
36
+
37
+ // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
38
+ // "remoteUser": "vscode"
39
+ }
@@ -0,0 +1,38 @@
1
+ version: '3.8'
2
+ services:
3
+ # Update this to the name of the service you want to work with in your docker-compose.yml file
4
+ ruby:
5
+ # If you want add a non-root user to your Dockerfile, you can use the "remoteUser"
6
+ # property in devcontainer.json to cause VS Code its sub-processes (terminals, tasks,
7
+ # debugging) to execute as the user. Uncomment the next line if you want the entire
8
+ # container to run as this user instead. Note that, on Linux, you may need to
9
+ # ensure the UID and GID of the container user you create matches your local user.
10
+ # See https://aka.ms/vscode-remote/containers/non-root for details.
11
+ #
12
+ # user: vscode
13
+
14
+ # Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
15
+ # folder. Note that the path of the Dockerfile and context is relative to the *primary*
16
+ # docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
17
+ # array). The sample below assumes your primary file is in the root of your project.
18
+ #
19
+ # build:
20
+ # context: .
21
+ # dockerfile: .devcontainer/Dockerfile
22
+
23
+ volumes:
24
+ # Update this to wherever you want VS Code to mount the folder of your project
25
+ - .:/workspace:cached
26
+
27
+ # Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details.
28
+ # - /var/run/docker.sock:/var/run/docker.sock
29
+
30
+ # Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
31
+ # cap_add:
32
+ # - SYS_PTRACE
33
+ # security_opt:
34
+ # - seccomp:unconfined
35
+
36
+ # Overrides default command so things don't shut down after the process ends.
37
+ command: /bin/sh -c "while sleep 1000; do :; done"
38
+
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
 
13
13
  /Gemfile.lock
14
14
  /*.gem
15
+
16
+ /compose.override.yaml
data/README.md CHANGED
@@ -12,6 +12,7 @@ CLI to create rails projects interactively.
12
12
  - database
13
13
  - javascript
14
14
  - css
15
+ - skips
15
16
  - Support in adding gems
16
17
 
17
18
  ## Installation
@@ -22,43 +23,75 @@ gem install mogu
22
23
 
23
24
  ## Usage
24
25
 
26
+ ### help
27
+
28
+ ```bash
29
+ mogu help
30
+ ```
31
+
32
+ ### new
33
+
34
+ Create rails projects interactively.
35
+
25
36
  ```bash
26
- mogu
37
+ mogu new
27
38
  ```
28
39
 
29
40
  ```bash
30
- Please input app path
31
-
32
- Choose customizes
33
- > database (Default: sqlite3)
34
- javascript (Default: importmap)
35
- css
36
- ⬡ gems
37
-
38
- Choose database
39
- > sqlite3
40
- mysql
41
- postgresql
41
+ ? Please input app path
42
+ >
43
+
44
+ ? Do you want api mode? (Choose with ↑ ↓ ⏎)
45
+ > 1. no
46
+ 2. yes
47
+
48
+ ? Choose customizes (Toggle options. Choose with ↑ ↓ ⏎, filter with 'f')
49
+ > 1. ☐ database (Default: sqlite3)
50
+ 2. ☐ javascript (Default: importmap)
51
+ 3. ☐ css
52
+ 4. ☐ skips
53
+ 0. Done
54
+
55
+ ? Choose database (Choose with ↑ ↓ ⏎, filter with 'f')
56
+ > 1. sqlite3
57
+ 2. mysql
58
+ 3. postgresql
42
59
  ...
43
60
 
44
- Choose javascript
45
- > importmap
46
- webpack
47
- esbuild
48
- rollup
49
-
50
- Choose css
51
- > tailwind
52
- bootstrap
53
- bulma
54
- postcss
55
- sass
56
-
57
- Choose gems
58
- > brakeman
59
- solargraph
60
- ⬡ rspec
61
- ⬡ rubocop
61
+ ? Choose javascript (Choose with ↑ ↓ ⏎, filter with 'f')
62
+ > 1. importmap
63
+ 2. webpack
64
+ 3. esbuild
65
+ 4. rollup
66
+
67
+ ? Choose css (Choose with ↑ ↓ ⏎, filter with 'f')
68
+ > 1. tailwind
69
+ 2. bootstrap
70
+ 3. bulma
71
+ 4. postcss
72
+ 5. sass
73
+
74
+ ? Choose skips (Toggle options. Choose with ↑ ↓ ⏎, filter with 'f')
75
+ > 1. ☐ test
76
+ 0. Done
77
+ ```
78
+
79
+ ### gem
80
+
81
+ Add gems to rails projects.
82
+
83
+ ```bash
84
+ mogu gem
85
+ ```
86
+
87
+ ```bash
88
+ ? Choose gems (Toggle options. Choose with ↑ ↓ ⏎, filter with 'f')
89
+ > 1. ☐ brakeman
90
+ 2. ☐ solargraph
91
+ 3. ☐ rspec
92
+ 4. ☐ rubocop
93
+ 0. Done
94
+
62
95
  ```
63
96
 
64
97
  ## Development
@@ -1,14 +1,10 @@
1
- version: "3.9"
2
-
3
1
  services:
4
2
  ruby:
5
3
  image: ruby
6
4
  volumes:
7
5
  - .:/workspace
8
- - gem-credentials-data:/root/.local/share/gem
9
6
  - gem-data:/usr/local/bundle
10
7
  working_dir: /workspace
11
8
 
12
9
  volumes:
13
- gem-credentials-data:
14
10
  gem-data:
data/lib/mogu/cli.rb CHANGED
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'optparse'
4
- require 'rails/command'
3
+ require 'thor'
5
4
 
6
5
  module Mogu
7
- class CLI
8
- class << self
9
- def start
10
- params = OptionParser.getopts(ARGV, 'v')
6
+ class CLI < Thor
7
+ desc 'gem', 'Add gems to rails projects'
8
+ def gem
9
+ Mogu::GemCommand.new.run
10
+ end
11
11
 
12
- if params['v']
13
- puts "mogu #{Mogu::VERSION}"
14
- else
15
- prompt = Mogu::Prompt.new
16
- prompt.run
12
+ desc 'new', 'Create rails projects interactively'
13
+ def new
14
+ Mogu::NewCommand.new.run
15
+ end
17
16
 
18
- Rails::Command.invoke :application, ['new', *prompt.to_opt]
19
- end
20
- end
17
+ desc 'version', 'Display mogu version'
18
+ def version
19
+ puts Mogu::VERSION
21
20
  end
22
21
  end
23
22
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cli/ui'
4
+ require 'erb'
5
+ require 'rails/command'
6
+ require 'tempfile'
7
+
8
+ module Mogu
9
+ class GemCommand
10
+ def run
11
+ erb = ERB.new File.read(File.expand_path('templates/gem.erb', __dir__))
12
+ template = Tempfile.new
13
+
14
+ gems = ask_gems
15
+ template.write erb.result_with_hash(gems: gems)
16
+ template.rewind
17
+
18
+ ENV.store 'LOCATION', template.path
19
+
20
+ Rails::Command.invoke 'app:template'
21
+ end
22
+
23
+ private
24
+
25
+ def ask_gems
26
+ options = %w[brakeman solargraph rspec rubocop]
27
+
28
+ ::CLI::UI::Prompt.ask 'Choose gems', multiple: true, options: options
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cli/ui'
4
+ require 'rails/command'
5
+
6
+ module Mogu
7
+ class NewCommand
8
+ def run
9
+ @app_path = ask_app_path
10
+ @is_api = confirm_is_api
11
+ customizes = ask_customizes
12
+
13
+ @database = customizes.include?('database') ? ask_database : []
14
+ @javascript = customizes.include?('javascript') ? ask_javascript : []
15
+ @css = customizes.include?('css') ? ask_css : []
16
+ @skips = customizes.include?('skips') ? ask_skips : []
17
+
18
+ Rails::Command.invoke :application, ['new', *to_opt]
19
+ end
20
+
21
+ private
22
+
23
+ def ask_app_path
24
+ ::CLI::UI::Prompt.ask 'Please input app path', allow_empty: false
25
+ end
26
+
27
+ def confirm_is_api
28
+ ::CLI::UI::Prompt.confirm 'Do you want api mode?', default: false
29
+ end
30
+
31
+ def ask_customizes
32
+ ::CLI::UI::Prompt.ask 'Choose customizes', multiple: true do |handler|
33
+ handler.option('database (Default: sqlite3)') { 'database' }
34
+
35
+ unless @is_api
36
+ handler.option('javascript (Default: importmap)') { 'javascript' }
37
+ handler.option('css') { 'css' }
38
+ end
39
+
40
+ handler.option('skips') { 'skips' }
41
+ end
42
+ end
43
+
44
+ def ask_database
45
+ options = %w[sqlite3 mysql postgresql oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc]
46
+
47
+ ::CLI::UI::Prompt.ask 'Choose database' do |handler|
48
+ options.each do |option|
49
+ handler.option(option) { |s| ['-d', s] }
50
+ end
51
+ end
52
+ end
53
+
54
+ def ask_javascript
55
+ options = %w[importmap webpack esbuild rollup]
56
+
57
+ ::CLI::UI::Prompt.ask 'Choose javascript' do |handler|
58
+ options.each do |option|
59
+ handler.option(option) { |s| ['-j', s] }
60
+ end
61
+ end
62
+ end
63
+
64
+ def ask_css
65
+ options = %w[tailwind bootstrap bulma postcss sass]
66
+
67
+ ::CLI::UI::Prompt.ask 'Choose css' do |handler|
68
+ options.each do |option|
69
+ handler.option(option) { |s| ['-c', s] }
70
+ end
71
+ end
72
+ end
73
+
74
+ def ask_skips
75
+ ::CLI::UI::Prompt.ask 'Choose skips', multiple: true do |handler|
76
+ handler.option('test') { '--skip-test' }
77
+ end
78
+ end
79
+
80
+ def to_opt
81
+ [
82
+ @app_path,
83
+ @is_api ? '--api' : [],
84
+ @database,
85
+ @javascript,
86
+ @css,
87
+ *@skips
88
+ ].flatten
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,39 @@
1
+ <% if gems.include? 'brakeman' %>
2
+ gem 'brakeman', group: :development
3
+ <% end %>
4
+
5
+ <% if gems.include? 'rspec' %>
6
+ gem 'factory_bot_rails', group: %i[development test]
7
+ gem 'rspec-rails', group: %i[development test]
8
+ <% end %>
9
+
10
+ <% if gems.include? 'rubocop' %>
11
+ gem 'rubocop-rails', group: :development, require: false
12
+ <% end %>
13
+
14
+ <% if gems.include? 'solargraph' %>
15
+ gem 'solargraph', group: :development
16
+ <% end %>
17
+
18
+ <% if gems.include? 'rubocop' %>
19
+ create_file '.rubocop.yml', <<~YML
20
+ require:
21
+ - rubocop-rails
22
+
23
+ AllCops:
24
+ NewCops: enable
25
+
26
+ Rails:
27
+ Enabled: true
28
+ YML
29
+ <% end %>
30
+
31
+ run 'bundle install'
32
+
33
+ <% if gems.include? 'rspec' %>
34
+ generate 'rspec:install'
35
+ <% end %>
36
+
37
+ <% if gems.include? 'rubocop' %>
38
+ run 'rubocop --auto-gen-config'
39
+ <% end %>
data/lib/mogu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mogu
4
- VERSION = '0.5.0'
4
+ VERSION = '0.8.0'
5
5
  end
data/lib/mogu.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'mogu/cli'
4
- require_relative 'mogu/prompt'
5
- require_relative 'mogu/template'
4
+ require_relative 'mogu/gem_command'
5
+ require_relative 'mogu/new_command'
6
6
  require_relative 'mogu/version'
7
7
 
8
8
  module Mogu; end
data/mogu.gemspec CHANGED
@@ -32,8 +32,9 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ['lib']
33
33
 
34
34
  # Uncomment to register a new dependency of your gem
35
+ spec.add_dependency 'cli-ui', '~> 1.0'
35
36
  spec.add_dependency 'railties', '~> 7.0'
36
- spec.add_dependency 'tty-prompt', '~> 0.23'
37
+ spec.add_dependency 'thor', '~> 1.0'
37
38
 
38
39
  # For more information and examples about making a new gem, checkout our
39
40
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mogu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MoguraStore
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-24 00:00:00.000000000 Z
11
+ date: 2022-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cli-ui
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: railties
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,19 +39,19 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '7.0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: tty-prompt
42
+ name: thor
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0.23'
47
+ version: '1.0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0.23'
54
+ version: '1.0'
41
55
  description: CLI to create rails projects interactively.
42
56
  email:
43
57
  - 368034+lisp719@users.noreply.github.com
@@ -46,6 +60,8 @@ executables:
46
60
  extensions: []
47
61
  extra_rdoc_files: []
48
62
  files:
63
+ - ".devcontainer/devcontainer.json"
64
+ - ".devcontainer/docker-compose.yml"
49
65
  - ".github/workflows/ci.yml"
50
66
  - ".gitignore"
51
67
  - ".rspec"
@@ -57,12 +73,13 @@ files:
57
73
  - Rakefile
58
74
  - bin/console
59
75
  - bin/setup
60
- - docker-compose.yml
76
+ - compose.yaml
61
77
  - exe/mogu
62
78
  - lib/mogu.rb
63
79
  - lib/mogu/cli.rb
64
- - lib/mogu/prompt.rb
65
- - lib/mogu/template.rb
80
+ - lib/mogu/gem_command.rb
81
+ - lib/mogu/new_command.rb
82
+ - lib/mogu/templates/gem.erb
66
83
  - lib/mogu/version.rb
67
84
  - mogu.gemspec
68
85
  homepage: https://github.com/mogurastore/mogu
@@ -87,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
104
  - !ruby/object:Gem::Version
88
105
  version: '0'
89
106
  requirements: []
90
- rubygems_version: 3.2.22
107
+ rubygems_version: 3.3.7
91
108
  signing_key:
92
109
  specification_version: 4
93
110
  summary: CLI to create rails projects interactively.
data/lib/mogu/prompt.rb DELETED
@@ -1,127 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'tty-prompt'
4
-
5
- module Mogu
6
- class Prompt
7
- Result = Struct.new(
8
- :app_path,
9
- :is_api,
10
- :customizes,
11
- :database,
12
- :javascript,
13
- :css,
14
- :gems,
15
- :template,
16
- keyword_init: true
17
- )
18
-
19
- def initialize
20
- @prompt = TTY::Prompt.new
21
-
22
- @result = Result.new(
23
- app_path: '',
24
- is_api: false,
25
- customizes: [],
26
- database: '',
27
- javascript: '',
28
- css: '',
29
- gems: [],
30
- template: nil
31
- )
32
- end
33
-
34
- def run
35
- @result.app_path = @prompt.ask 'Please input app path', required: true
36
- @result.is_api = @prompt.yes? 'Do you want api mode?', default: false
37
- @result.customizes = customizes
38
-
39
- @result.database = database if database?
40
- @result.javascript = javascript if javascript?
41
- @result.css = css if css?
42
- @result.gems = gems if gems?
43
- @result.template = Mogu::Template.create @result.gems if template?
44
- end
45
-
46
- def to_opt
47
- [
48
- @result.app_path,
49
- @result.is_api ? ['--api'] : [],
50
- database? ? ['-d', @result.database] : [],
51
- javascript? ? ['-j', @result.javascript] : [],
52
- css? ? ['-c', @result.css] : [],
53
- rspec? ? %w[-T] : [],
54
- template? ? ['-m', @result.template.path] : []
55
- ].flatten
56
- end
57
-
58
- private
59
-
60
- def database?
61
- @result.customizes.include? 'database'
62
- end
63
-
64
- def javascript?
65
- @result.customizes.include? 'javascript'
66
- end
67
-
68
- def css?
69
- @result.customizes.include? 'css'
70
- end
71
-
72
- def gems?
73
- @result.customizes.include? 'gems'
74
- end
75
-
76
- def rspec?
77
- @result.gems.include? 'rspec'
78
- end
79
-
80
- def template?
81
- @result.gems.any?
82
- end
83
-
84
- def css
85
- choices = %w[tailwind bootstrap bulma postcss sass]
86
-
87
- @prompt.select 'Choose css', choices
88
- end
89
-
90
- def customizes
91
- choices =
92
- if @result.is_api
93
- [
94
- { name: 'database (Default: sqlite3)', value: 'database' },
95
- { name: 'gems', value: 'gems' }
96
- ]
97
- else
98
- [
99
- { name: 'database (Default: sqlite3)', value: 'database' },
100
- { name: 'javascript (Default: importmap)', value: 'javascript' },
101
- { name: 'css', value: 'css' },
102
- { name: 'gems', value: 'gems' }
103
- ]
104
- end
105
-
106
- @prompt.multi_select 'Choose customizes', choices
107
- end
108
-
109
- def database
110
- choices = %w[sqlite3 mysql postgresql oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc]
111
-
112
- @prompt.select 'Choose database', choices
113
- end
114
-
115
- def gems
116
- choices = %w[brakeman solargraph rspec rubocop]
117
-
118
- @prompt.multi_select 'Choose gems', choices
119
- end
120
-
121
- def javascript
122
- choices = %w[importmap webpack esbuild rollup]
123
-
124
- @prompt.select 'Choose javascript', choices
125
- end
126
- end
127
- end
data/lib/mogu/template.rb DELETED
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'tempfile'
4
-
5
- module Mogu
6
- class Template
7
- class << self
8
- def create(gems)
9
- template = new
10
- template.write gems
11
-
12
- template
13
- end
14
- end
15
-
16
- def initialize
17
- @file = Tempfile.new
18
- end
19
-
20
- def path
21
- @file.path
22
- end
23
-
24
- def write(gems)
25
- @file.write brakeman_code if gems.include? 'brakeman'
26
- @file.write solargraph_code if gems.include? 'solargraph'
27
- @file.write rspec_code if gems.include? 'rspec'
28
- @file.write rubocop_code if gems.include? 'rubocop'
29
-
30
- @file.rewind
31
- end
32
-
33
- private
34
-
35
- def brakeman_code
36
- <<~CODE
37
- gem 'brakeman', group: :development
38
- CODE
39
- end
40
-
41
- def solargraph_code
42
- <<~CODE
43
- gem 'solargraph', group: :development
44
- CODE
45
- end
46
-
47
- def rspec_code
48
- <<~CODE
49
- gem 'factory_bot_rails', group: %i[development test]
50
- gem 'rspec-rails', group: %i[development test]
51
-
52
- after_bundle do
53
- generate 'rspec:install'
54
- end
55
- CODE
56
- end
57
-
58
- def rubocop_code
59
- <<~CODE
60
- gem 'rubocop-rails', group: :development, require: false
61
-
62
- create_file '.rubocop.yml', <<~YML
63
- require:
64
- - rubocop-rails
65
-
66
- AllCops:
67
- NewCops: enable
68
-
69
- Rails:
70
- Enabled: true
71
- YML
72
-
73
- after_bundle do
74
- run 'rubocop --auto-gen-config'
75
- end
76
- CODE
77
- end
78
- end
79
- end