rails_app_generator 0.0.4 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.vscode/settings.json +3 -0
- data/CHANGELOG.md +23 -0
- data/README.md +9 -1
- data/after_templates/README.md +0 -0
- data/after_templates/test.rb +12 -0
- data/exe/rag +41 -0
- data/lib/rails_app_generator/add_on.rb +73 -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 +7 -5
- data/lib/rails_app_generator/app_generator.rb +160 -99
- 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 +86 -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/map_option_string.rb +2 -0
- data/lib/rails_app_generator/options/rails_options.rb +55 -32
- data/lib/rails_app_generator/starter.rb +55 -39
- data/lib/rails_app_generator/version.rb +1 -1
- data/lib/rails_app_generator.rb +5 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/rag-add-some-pages.json +11 -0
- data/profiles/rag-bootstrap.json +10 -0
- data/profiles/rag-simple.json +10 -0
- data/templates/README.md.erb +43 -0
- 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 +176 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7729b3a10ff4b9d4608b9c5cbd2e3fefe036a43b90066b447f4048b252a893b
|
4
|
+
data.tar.gz: 02c9a488f5a9296402f5923935fdcd88b69346d8f2337b34dc335640b532cd45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dae7db0f0f6c5656253178dc635e141cd84289fab9d5c7bd621e337732d14f752969902df3e8458fbf43c8ff6239e79fb2d8f077a023ba1e6cb8ae539a5f6070
|
7
|
+
data.tar.gz: d14b704ed3d27d52f85bfd36e07be35490fb0c42f05a182504073c0fbcc59a5d27511a2ce59dfa54209438d449472ac3d71e28687c2e04d8cd7e3f3d9dc25c7d
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
## [0.0.6](https://github.com/klueless-io/rails_app_generator/compare/v0.0.5...v0.0.6) (2022-07-21)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add a bunch of addons ([b781af6](https://github.com/klueless-io/rails_app_generator/commit/b781af66d7fe7d7dcd2550577166213deefc06c6))
|
7
|
+
* add a bunch of addons ([d9a85b7](https://github.com/klueless-io/rails_app_generator/commit/d9a85b7b32c2c25577d98b4b3be9aab7947ff6e9))
|
8
|
+
* update template paths in app_generator ([9b28a5e](https://github.com/klueless-io/rails_app_generator/commit/9b28a5ee58535a761581e619eb01dc3059a79948))
|
9
|
+
|
10
|
+
## [0.0.5](https://github.com/klueless-io/rails_app_generator/compare/v0.0.4...v0.0.5) (2022-07-19)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* add console output capture ([0d66a3b](https://github.com/klueless-io/rails_app_generator/commit/0d66a3ba19c2adbd0f2c0747b8212e7e628c22ba))
|
16
|
+
|
17
|
+
## [0.0.4](https://github.com/klueless-io/rails_app_generator/compare/v0.0.3...v0.0.4) (2022-07-19)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* add map string options ([50a22ba](https://github.com/klueless-io/rails_app_generator/commit/50a22ba1bdefc7726e687d072009d73bbfd21b83))
|
23
|
+
|
1
24
|
## [0.0.3](https://github.com/klueless-io/rails_app_generator/compare/v0.0.2...v0.0.3) (2022-07-19)
|
2
25
|
|
3
26
|
|
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
|
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
# after_bundle do
|
6
|
+
# setup_rails.after_bundle
|
7
|
+
# end
|
8
|
+
|
9
|
+
add_scaffold('post', 'title', 'content:text')
|
10
|
+
add_scaffold('book', 'title', 'content:text')
|
11
|
+
# add_resource("comment", "post:references", 'content:text')
|
12
|
+
# add_mailer("posts", "submitted", "broken")
|
data/exe/rag
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
source_path = File.expand_path("#{Pathname.new(__FILE__).dirname}/../lib")
|
8
|
+
$LOAD_PATH << source_path
|
9
|
+
|
10
|
+
require 'rails_app_generator'
|
11
|
+
|
12
|
+
if ARGV.empty?
|
13
|
+
puts 'Please provide a profile for the new application'
|
14
|
+
puts
|
15
|
+
puts 'See --help for more info'
|
16
|
+
exit 0
|
17
|
+
elsif %w[-v --version].include? ARGV[0]
|
18
|
+
puts RailsAppGenerator::VERSION
|
19
|
+
exit 0
|
20
|
+
end
|
21
|
+
|
22
|
+
profile_path = File.expand_path("#{Pathname.new(__FILE__).dirname}/../profiles")
|
23
|
+
profile_name = ARGV[0]
|
24
|
+
profile_name += '.json' unless profile_name.end_with?('.json')
|
25
|
+
profile_file = File.join(profile_path, profile_name)
|
26
|
+
|
27
|
+
if File.exist?(profile_file)
|
28
|
+
puts "Using profile #{profile_file}"
|
29
|
+
|
30
|
+
profile = JSON.parse(File.read(profile_file), symbolize_names: true)
|
31
|
+
args = profile[:args]
|
32
|
+
opts = profile[:opts]
|
33
|
+
rails_options = RailsAppGenerator::RailsOptions.new(opts)
|
34
|
+
|
35
|
+
instance = RailsAppGenerator::Starter.new(args)
|
36
|
+
FileUtils.rm_rf(instance.target_path)
|
37
|
+
instance.start(rails_options)
|
38
|
+
else
|
39
|
+
puts "Profile #{profile_file} not found"
|
40
|
+
exit 1
|
41
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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
|
+
@dependencies = addon.map(&:to_sym)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
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
|