rails_app_generator 0.0.3 → 0.0.6
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/.rubocop.yml +1 -0
- data/.vscode/settings.json +3 -0
- data/CHANGELOG.md +21 -0
- data/README.md +9 -1
- data/exe/rails_app_generator +51 -0
- data/lib/rails_app_generator/add_on.rb +74 -0
- data/lib/rails_app_generator/addons/annotate.rb +15 -0
- data/lib/rails_app_generator/addons/continuous_integration.rb +14 -0
- data/lib/rails_app_generator/addons/devise.rb +50 -0
- data/lib/rails_app_generator/addons/docker.rb +14 -0
- data/lib/rails_app_generator/addons/docker_compose.rb +13 -0
- data/lib/rails_app_generator/addons/dotenv.rb +13 -0
- data/lib/rails_app_generator/addons/factory_bot.rb +19 -0
- data/lib/rails_app_generator/addons/foreman.rb +15 -0
- data/lib/rails_app_generator/addons/generators.rb +31 -0
- data/lib/rails_app_generator/addons/high_voltage.rb +15 -0
- data/lib/rails_app_generator/addons/inline_svg.rb +11 -0
- data/lib/rails_app_generator/addons/irbrc.rb +13 -0
- data/lib/rails_app_generator/addons/lograge.rb +13 -0
- data/lib/rails_app_generator/addons/pundit.rb +16 -0
- data/lib/rails_app_generator/addons/rspec.rb +17 -0
- data/lib/rails_app_generator/addons/rubocop.rb +13 -0
- data/lib/rails_app_generator/addons/scaffold.rb +15 -0
- data/lib/rails_app_generator/addons/services.rb +13 -0
- data/lib/rails_app_generator/addons/sidekiq.rb +18 -0
- data/lib/rails_app_generator/addons/stimulus.rb +15 -0
- data/lib/rails_app_generator/addons/stimulus_components.rb +33 -0
- data/lib/rails_app_generator/addons/tailwind.rb +22 -0
- data/lib/rails_app_generator/addons/views.rb +21 -0
- data/lib/rails_app_generator/app_builder.rb +2 -2
- data/lib/rails_app_generator/app_generator.rb +147 -103
- data/lib/rails_app_generator/context.rb +75 -0
- data/lib/rails_app_generator/dependencies.rb +34 -0
- data/lib/rails_app_generator/notes/a1.txt +86 -0
- data/lib/rails_app_generator/notes/a2.txt +87 -0
- data/lib/rails_app_generator/notes/kw01-b.txt +86 -0
- data/lib/rails_app_generator/notes/kw01.txt +91 -0
- data/lib/rails_app_generator/options/base_map_option.rb +10 -0
- data/lib/rails_app_generator/options/build_option.rb +4 -2
- data/lib/rails_app_generator/options/map_option_boolean_flag.rb +3 -3
- data/lib/rails_app_generator/options/{map_option_pass_through.rb → map_option_ignore.rb} +3 -3
- data/lib/rails_app_generator/options/map_option_string.rb +14 -0
- data/lib/rails_app_generator/options/{build_options.rb → options_builder.rb} +13 -2
- data/lib/rails_app_generator/options/rails_options.rb +77 -0
- data/lib/rails_app_generator/starter.rb +55 -39
- data/lib/rails_app_generator/version.rb +1 -1
- data/lib/rails_app_generator.rb +10 -3
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/templates/addons/annotate/auto_annotate_models.rake +60 -0
- data/templates/addons/continuous_integration/.github/workflows/build.yml.erb +49 -0
- data/templates/addons/devise/app/views/devise/confirmations/new.html.erb +24 -0
- data/templates/addons/devise/app/views/devise/passwords/edit.html.erb +34 -0
- data/templates/addons/devise/app/views/devise/passwords/new.html.erb +23 -0
- data/templates/addons/devise/app/views/devise/registrations/edit.html.erb +62 -0
- data/templates/addons/devise/app/views/devise/registrations/new.html.erb +45 -0
- data/templates/addons/devise/app/views/devise/sessions/new.html.erb +33 -0
- data/templates/addons/devise/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/templates/addons/devise/app/views/devise/shared/_form_wrap.html.erb +5 -0
- data/templates/addons/devise/app/views/devise/shared/_links.html.erb +25 -0
- data/templates/addons/devise/app/views/devise/unlocks/new.html.erb +22 -0
- data/templates/addons/docker/.dockerignore.erb +51 -0
- data/templates/addons/docker/Dockerfile.erb +45 -0
- data/templates/addons/docker_compose/docker-compose.yml.erb +21 -0
- data/templates/addons/dotenv/.env.development.erb +3 -0
- data/templates/addons/foreman/.foreman.erb +1 -0
- data/templates/addons/foreman/Procfile.dev.erb +7 -0
- data/templates/addons/foreman/Procfile.erb +4 -0
- data/templates/addons/generators/lib/generators/rails/navigation/USAGE +6 -0
- data/templates/addons/generators/lib/generators/rails/navigation/navigation_generator.rb +16 -0
- data/templates/addons/generators/lib/generators/rails/scaffold_controller_generator.rb +12 -0
- data/templates/addons/high_voltage/config/initializers/high_voltage.rb +6 -0
- data/templates/addons/irbrc/.irbrc.erb +13 -0
- data/templates/addons/lograge/config/initializers/lograge.rb +5 -0
- data/templates/addons/pundit/app/controllers/authorized_controller.rb.erb +10 -0
- data/templates/addons/pundit/app/policies/application_policy.rb +57 -0
- data/templates/addons/rspec/spec/rails_helper.rb +26 -0
- data/templates/addons/rspec/spec/spec_helper.rb +61 -0
- data/templates/addons/rubocop/.rubocop.yml.erb +37 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/_form.html.erb +39 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/edit.html.erb +7 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/index.html.erb +34 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/new.html.erb +7 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/show.html.erb +18 -0
- data/templates/addons/services/app/services/application_service.rb +15 -0
- data/templates/app_x/controllers/authorized_controller.rb.erb +10 -0
- data/templates/app_x/controllers/errors_controller.rb.erb +24 -0
- data/templates/app_x/javascript/images/checkmark.svg +1 -0
- data/templates/app_x/javascript/images/logo.svg +1 -0
- data/templates/app_x/javascript/stylesheets/components.scss +206 -0
- data/templates/app_x/views/errors/internal_error.html.erb +14 -0
- data/templates/app_x/views/errors/not_found.html.erb +14 -0
- data/templates/app_x/views/errors/unacceptable.html.erb +14 -0
- data/templates/app_x/views/layouts/application.html.erb.tt +30 -0
- data/templates/app_x/views/pages/home.html.erb.tt +20 -0
- data/templates/app_x/views/shared/_flashes.html.erb.tt +12 -0
- data/templates/app_x/views/shared/_footer.html.erb.tt +21 -0
- data/templates/app_x/views/shared/_navbar.html.erb.tt +55 -0
- data/templates/app_x/workers/application_worker.rb +5 -0
- metadata +175 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9db638d5387a342cec3c8ad01cf7aa69298a2e592f005608a603c17ec336b20
|
4
|
+
data.tar.gz: 192fd7e39c98346954ddb9752fba2c7cd5380e306d07e32b638d8d5c0201a637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3d1733fb92b31e44eaaa31cf062038e7f8715cca8adf2e29351e7363e74c24a5ba488186143c803be5d814d17bfcc80b8fa5b945b9bd06cd0e2da966244c065
|
7
|
+
data.tar.gz: 1f2955850cf06ad10529dc86355f9db15af680bc017284ec01524f3c83c7314cb903b6deff6beefb7673ab78fc2d57152fef36a015d7a7b282df03310509dc24
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## [0.0.5](https://github.com/klueless-io/rails_app_generator/compare/v0.0.4...v0.0.5) (2022-07-19)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add console output capture ([0d66a3b](https://github.com/klueless-io/rails_app_generator/commit/0d66a3ba19c2adbd0f2c0747b8212e7e628c22ba))
|
7
|
+
|
8
|
+
## [0.0.4](https://github.com/klueless-io/rails_app_generator/compare/v0.0.3...v0.0.4) (2022-07-19)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* add map string options ([50a22ba](https://github.com/klueless-io/rails_app_generator/commit/50a22ba1bdefc7726e687d072009d73bbfd21b83))
|
14
|
+
|
15
|
+
## [0.0.3](https://github.com/klueless-io/rails_app_generator/compare/v0.0.2...v0.0.3) (2022-07-19)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* add builder option command line mapping ([5cc16b5](https://github.com/klueless-io/rails_app_generator/commit/5cc16b53f3ea2821e226a51dedfa10513307860f))
|
21
|
+
|
1
22
|
## [0.0.2](https://github.com/klueless-io/rails_app_generator/compare/v0.0.1...v0.0.2) (2022-07-19)
|
2
23
|
|
3
24
|
|
data/README.md
CHANGED
@@ -22,6 +22,15 @@ Or install it yourself as:
|
|
22
22
|
gem install rails_app_generator
|
23
23
|
```
|
24
24
|
|
25
|
+
## Notes
|
26
|
+
|
27
|
+
You can use rails_app_generator to create Rails 7 applications
|
28
|
+
You can use rails_app_generator with ruby 2.7 or 3.1
|
29
|
+
|
30
|
+
Rails new uses a batteries included approach, this means that you get everything and if you don't want a feature you need to turn it off explicitly using --skip-feature
|
31
|
+
I hope to change the focus in this project so that you get very minimal installation and then you turn on what you want explicitly.
|
32
|
+
Templates for rails are separated from templates for addons
|
33
|
+
|
25
34
|
## Stories
|
26
35
|
|
27
36
|
### Main Story
|
@@ -32,7 +41,6 @@ See all [stories](./STORIES.md)
|
|
32
41
|
|
33
42
|
|
34
43
|
## Usage
|
35
|
-
xxxxxxxxxxxxxxxx <help name="blah blah" />
|
36
44
|
See all [usage examples](./USAGE.md)
|
37
45
|
|
38
46
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
source_path = File.expand_path("#{Pathname.new(__FILE__).dirname}/../lib")
|
7
|
+
$LOAD_PATH << source_path
|
8
|
+
|
9
|
+
require 'rails_app_generator'
|
10
|
+
|
11
|
+
# if ARGV.empty?
|
12
|
+
# puts 'Please provide a path for the new application'
|
13
|
+
# puts
|
14
|
+
# puts 'See --help for more info'
|
15
|
+
# exit 0
|
16
|
+
# elsif %w[-v --version].include? ARGV[0]
|
17
|
+
# puts RailsAppGenerator::VERSION
|
18
|
+
# exit 0
|
19
|
+
# end
|
20
|
+
|
21
|
+
# templates_root = File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__))
|
22
|
+
# RailsAppGenerator::AppGenerator.source_root templates_root
|
23
|
+
# RailsAppGenerator::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
24
|
+
|
25
|
+
# RailsAppGenerator::AppGenerator.start
|
26
|
+
require 'pry'
|
27
|
+
|
28
|
+
args = {
|
29
|
+
app_path: 'kw01_bootstrap',
|
30
|
+
destination_root: '/Users/davidcruwys/dev/kweb'
|
31
|
+
}
|
32
|
+
opts = {
|
33
|
+
skip_git: true,
|
34
|
+
skip_bundle: false
|
35
|
+
# css: 'bootstrap'
|
36
|
+
}
|
37
|
+
|
38
|
+
# RailsAppGenerator::AppGenerator.override_template_path = '/Users/davidcruwys/dev/kgems/rails_app_generator/templates'
|
39
|
+
# RailsAppGenerator::AppGenerator.addon_template_path = '/Users/davidcruwys/dev/kgems/rails_app_generator/templates/addons/%<addon>'
|
40
|
+
|
41
|
+
instance = RailsAppGenerator::Starter.new(args)
|
42
|
+
FileUtils.rm_rf(instance.target_path)
|
43
|
+
|
44
|
+
rails_options = RailsAppGenerator::RailsOptions.new(opts)
|
45
|
+
instance.start(rails_options)
|
46
|
+
|
47
|
+
# system 'gem env'
|
48
|
+
|
49
|
+
# console_output_file = File.expand_path('../../../lib/rails_app_generator/notes/kw01.txt', File.join(File.dirname(__FILE__)))
|
50
|
+
|
51
|
+
# File.write(console_output_file, instance.console_output.split("\n").compact.collect(&:strip).join("\n"))
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# XXXX
|
5
|
+
class AddOn < Rails::Generators::Base
|
6
|
+
include Thor::Actions
|
7
|
+
include Rails::Generators::Actions
|
8
|
+
include Rails::Generators::AppName
|
9
|
+
|
10
|
+
attr_reader :dependencies, :context
|
11
|
+
|
12
|
+
def initialize(context)
|
13
|
+
super
|
14
|
+
@context = context
|
15
|
+
@dependencies = self.class.dependencies || []
|
16
|
+
end
|
17
|
+
|
18
|
+
def apply; end
|
19
|
+
|
20
|
+
# list any methods that you want access to, but not to be exposed as a thor command
|
21
|
+
no_commands do
|
22
|
+
def source_paths
|
23
|
+
[
|
24
|
+
format(context.addon_template_path, addon: self.class.addon_name),
|
25
|
+
context.rails_override_template_path,
|
26
|
+
context.rails_template_path
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
def options
|
31
|
+
context.options
|
32
|
+
end
|
33
|
+
|
34
|
+
def uses?(addon_name = nil)
|
35
|
+
addon_name ||= self.class.addon_name
|
36
|
+
|
37
|
+
return false if options["skip_#{addon_name}".to_sym]
|
38
|
+
return true if context.default_addons.include?(addon_name)
|
39
|
+
|
40
|
+
klass = addon_name.nil? ? self.class : self.class.get(addon_name)
|
41
|
+
Dependencies.new(klass, context).satisfied?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class << self
|
46
|
+
def apply(context = Context.new({}))
|
47
|
+
instance = new(context)
|
48
|
+
return unless instance.uses?
|
49
|
+
|
50
|
+
instance.apply
|
51
|
+
end
|
52
|
+
|
53
|
+
def get(addon)
|
54
|
+
addon = addon.to_s.capitalize.camelize
|
55
|
+
"RailsAppGenerator::AddOns::#{addon}".constantize
|
56
|
+
end
|
57
|
+
|
58
|
+
def addon_name
|
59
|
+
name.demodulize.underscore.to_sym
|
60
|
+
end
|
61
|
+
|
62
|
+
def dependencies
|
63
|
+
@dependencies ||= []
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
def depends_on(*addon)
|
69
|
+
puts addon
|
70
|
+
@dependencies = addon.map(&:to_sym)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Annotate for ActiveRecord models to rails application
|
7
|
+
class Annotate < AddOn
|
8
|
+
depends_on :active_record
|
9
|
+
|
10
|
+
def apply
|
11
|
+
template('auto_annotate_models.rake', 'lib/tasks/auto_annotate_models.rake', force: true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add GitHub Actions continuous integration
|
7
|
+
class ContinuousIntegration < AddOn
|
8
|
+
def apply
|
9
|
+
say 'continuous integration - Setup GitHub Actions'
|
10
|
+
template('github/workflows/build.yml.erb', '.github/workflows/build.yml')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Devise authentication to rails application
|
7
|
+
class Devise < AddOn
|
8
|
+
depends_on :active_record
|
9
|
+
|
10
|
+
def apply
|
11
|
+
generate('devise:install', capture: true)
|
12
|
+
generate(:devise, 'User', 'name', 'admin:boolean', capture: true)
|
13
|
+
|
14
|
+
directory('app/views/devise', 'app/views/devise') if uses?(:views)
|
15
|
+
|
16
|
+
inject_into_file 'config/environments/development.rb', before: /^end/ do
|
17
|
+
<<-RUBY
|
18
|
+
|
19
|
+
# Enable devise mailer
|
20
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
21
|
+
RUBY
|
22
|
+
end
|
23
|
+
|
24
|
+
gsub_file 'config/initializers/devise.rb', /# config.pepper = .+/, " # config.pepper = 'pepper'"
|
25
|
+
gsub_file 'config/initializers/devise.rb', /# config.secret_key = .+/, " # config.secret_key = 'secret_key'"
|
26
|
+
|
27
|
+
db_changes
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def db_changes
|
33
|
+
in_root do
|
34
|
+
migration = Dir.glob('db/migrate/*').max_by { |f| File.mtime(f) }
|
35
|
+
gsub_file migration, /:admin/, ':admin, default: false'
|
36
|
+
end
|
37
|
+
insert_into_file 'db/seeds.rb' do
|
38
|
+
<<~RUBY
|
39
|
+
# Create an initial admin user for development
|
40
|
+
User.find_or_create_by(email: "admin@admin.com") do |user|
|
41
|
+
user.name = 'Admin'
|
42
|
+
user.password = 'password'
|
43
|
+
user.admin = true
|
44
|
+
end
|
45
|
+
RUBY
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Docker to rails application
|
7
|
+
class Docker < AddOn
|
8
|
+
def apply
|
9
|
+
template 'Dockerfile.erb', 'Dockerfile'
|
10
|
+
template '.dockerignore.erb', '.dockerignore'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Docker Compose to rails application
|
7
|
+
class DockerCompose < AddOn
|
8
|
+
def apply
|
9
|
+
template 'docker-compose.yml.erb', 'docker-compose.yml'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add DotEnv to rails application
|
7
|
+
class Dotenv < AddOn
|
8
|
+
def apply
|
9
|
+
template '.env.development.erb', '.env.development'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add FactoryBot to rails application
|
7
|
+
class FactoryBot < AddOn
|
8
|
+
depends_on :active_record, :test
|
9
|
+
|
10
|
+
def apply
|
11
|
+
# TODO: Make this work for minitest
|
12
|
+
return unless uses?(:factory_bot)
|
13
|
+
|
14
|
+
empty_directory 'spec/factories'
|
15
|
+
template('spec/support/factory_bot.rb')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Foreman process management for applications with multiple components
|
7
|
+
class Foreman < AddOn
|
8
|
+
def apply
|
9
|
+
template '.foreman.erb', '.foreman'
|
10
|
+
template 'Procfile.erb', 'Procfile'
|
11
|
+
template 'Procfile.dev.erb', 'Procfile.dev'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Rails Generator configuration to rails application
|
7
|
+
class Generators < AddOn
|
8
|
+
def apply
|
9
|
+
directory('lib/generators/rails/navigation', 'lib/generators/rails/navigation') if uses?(:views)
|
10
|
+
|
11
|
+
template = 'lib/generators/rails/scaffold_controller_generator.rb'
|
12
|
+
template(template) if uses?(:scaffold)
|
13
|
+
|
14
|
+
generators = <<-RUBY
|
15
|
+
config.generators do |generate|
|
16
|
+
#{"require_relative '../lib/generators/rails/scaffold_controller_generator'" if uses?(:scaffold)}
|
17
|
+
generate.helper false
|
18
|
+
generate.javascripts false
|
19
|
+
generate.request_specs false
|
20
|
+
generate.routing_specs false
|
21
|
+
generate.stylesheets false
|
22
|
+
#{'generate.test_framework :rspec' if uses?(:rspec)}
|
23
|
+
generate.view_specs false
|
24
|
+
#{'generate.factory_bot true' if uses?(:factory_bot)}
|
25
|
+
end
|
26
|
+
RUBY
|
27
|
+
inject_into_file 'config/application.rb', generators, before: /^ {2}end\n/
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add High Voltage rails engine for static pages.
|
7
|
+
class HighVoltage < AddOn
|
8
|
+
depends_on :views
|
9
|
+
|
10
|
+
def apply
|
11
|
+
template('config/initializers/high_voltage.rb')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add IrbRc to rails application
|
7
|
+
class Irbrc < RailsAppGenerator::AddOn
|
8
|
+
def apply
|
9
|
+
template '.irbrc.erb', '.irbrc'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add LogRage - Tame Rails' multi-line logging into a single line per request
|
7
|
+
class Lograge < AddOn
|
8
|
+
def apply
|
9
|
+
template 'config/initializers/lograge.rb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Pundit - Pundit provides a set of helpers which guide you in
|
7
|
+
# leveraging regular Ruby classes and object oriented design patterns
|
8
|
+
# to build a simple, robust and scalable authorization system.
|
9
|
+
class Pundit < AddOn
|
10
|
+
def apply
|
11
|
+
directory 'app/policies', 'app/policies'
|
12
|
+
template 'app/controllers/authorized_controller.rb.erb', 'app/controllers/authorized_controller.rb'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add RSpec unit testing support to rails application
|
7
|
+
class Rspec < AddOn
|
8
|
+
depends_on :test
|
9
|
+
|
10
|
+
def apply
|
11
|
+
create_file('.rspec', '--require spec_helper')
|
12
|
+
template('spec/rails_helper.rb')
|
13
|
+
template('spec/spec_helper.rb')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Rubocop to rails application
|
7
|
+
class Rubocop < AddOn
|
8
|
+
def apply
|
9
|
+
template '.rubocop.yml.erb', '.rubocop.yml'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Tailwind CSS support to rails application
|
7
|
+
class Scaffold < AddOn
|
8
|
+
depends_on :tailwind
|
9
|
+
|
10
|
+
def apply
|
11
|
+
directory 'lib/templates/erb/scaffold', 'lib/templates/erb/scaffold'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add DotEnv to rails application
|
7
|
+
class Services < AddOn
|
8
|
+
def apply
|
9
|
+
directory 'app/services', 'app/services'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Sidekiq to rails application
|
7
|
+
#
|
8
|
+
# Sidekiq is a job server that can be used to process jobs in the background.
|
9
|
+
# `Sidekiq` is a subclass of `AddOn` that adds a `apply` method that says "setup sidekiq" and
|
10
|
+
# copies the `app/workers` directory from the `templates` directory to the `app` directory
|
11
|
+
class Sidekiq < AddOn
|
12
|
+
def apply
|
13
|
+
say 'setup sidekiq'
|
14
|
+
directory('app/workers', 'app/workers')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Stimulus components
|
7
|
+
class Stimulus < AddOn
|
8
|
+
depends_on :javascript
|
9
|
+
|
10
|
+
def apply
|
11
|
+
rails_command('stimulus:install')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Stimulus components
|
7
|
+
class StimulusComponents < AddOn
|
8
|
+
depends_on :stimulus
|
9
|
+
|
10
|
+
def apply
|
11
|
+
run('yarn add tailwindcss-stimulus-components')
|
12
|
+
inject_into_file('app/javascript/packs/application.js') do
|
13
|
+
<<~JS
|
14
|
+
import { Application } from "stimulus"
|
15
|
+
import { definitionsFromContext } from "stimulus/webpack-helpers"
|
16
|
+
|
17
|
+
const application = Application.start();
|
18
|
+
const context = require.context("controllers", true, /.js$/);
|
19
|
+
application.load(definitionsFromContext(context));
|
20
|
+
|
21
|
+
import { Dropdown, Modal, Tabs, Popover, Toggle, Slideover } from "tailwindcss-stimulus-components"
|
22
|
+
application.register('dropdown', Dropdown)
|
23
|
+
application.register('modal', Modal)
|
24
|
+
application.register('tabs', Tabs)
|
25
|
+
application.register('popover', Popover)
|
26
|
+
application.register('toggle', Toggle)
|
27
|
+
application.register('slideover', Slideover)
|
28
|
+
JS
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Tailwind CSS support to rails application
|
7
|
+
class Tailwind < AddOn
|
8
|
+
depends_on :javascript
|
9
|
+
|
10
|
+
def apply
|
11
|
+
rails_command('tailwindcss:install')
|
12
|
+
template('app/javascript/stylesheets/components.scss')
|
13
|
+
insert_into_file 'app/javascript/stylesheets/application.scss' do
|
14
|
+
<<~CSS
|
15
|
+
|
16
|
+
@import "components";
|
17
|
+
CSS
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add default rails views
|
7
|
+
class Views < AddOn
|
8
|
+
depends_on :tailwind
|
9
|
+
|
10
|
+
def apply
|
11
|
+
say 'Setting up custom landing page'
|
12
|
+
directory 'app/views/layouts', 'app/views/layouts', force: true
|
13
|
+
directory 'app/views/shared', 'app/views/shared'
|
14
|
+
directory 'app/views/pages', 'app/views/pages' if uses?(:high_voltage)
|
15
|
+
# Make sure we can access any images put into the images folder
|
16
|
+
inject_into_file('app/javascript/packs/application.js', "require.context('../images', true)")
|
17
|
+
directory 'app/javascript/images', 'app/javascript/images'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -10,7 +10,7 @@ module RailsAppGenerator
|
|
10
10
|
# def credentials
|
11
11
|
# super
|
12
12
|
# # This sets up credentials using a custom template for both development and production use
|
13
|
-
#
|
13
|
+
# RailsAppGenerator::AddOns::Credentials.apply
|
14
14
|
# end
|
15
15
|
|
16
16
|
# def readme
|
@@ -18,7 +18,7 @@ module RailsAppGenerator
|
|
18
18
|
# end
|
19
19
|
|
20
20
|
# def ruby_version
|
21
|
-
#
|
21
|
+
# RailsAppGenerator::AddOns::RubyVersion.new(Context.new(options)).apply
|
22
22
|
# end
|
23
23
|
|
24
24
|
# def gemfile
|