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
@@ -0,0 +1,91 @@
|
|
1
|
+
create
|
2
|
+
create README.md
|
3
|
+
create Rakefile
|
4
|
+
create .ruby-version
|
5
|
+
create config.ru
|
6
|
+
create Gemfile
|
7
|
+
create app
|
8
|
+
create app/assets/config/manifest.js
|
9
|
+
create app/assets/stylesheets/application.css
|
10
|
+
create app/channels/application_cable/channel.rb
|
11
|
+
create app/channels/application_cable/connection.rb
|
12
|
+
create app/controllers/application_controller.rb
|
13
|
+
create app/helpers/application_helper.rb
|
14
|
+
create app/jobs/application_job.rb
|
15
|
+
create app/mailers/application_mailer.rb
|
16
|
+
create app/models/application_record.rb
|
17
|
+
create app/views/layouts/application.html.erb
|
18
|
+
create app/views/layouts/mailer.html.erb
|
19
|
+
create app/views/layouts/mailer.text.erb
|
20
|
+
create app/assets/images
|
21
|
+
create app/assets/images/.keep
|
22
|
+
create app/controllers/concerns/.keep
|
23
|
+
create app/models/concerns/.keep
|
24
|
+
create bin
|
25
|
+
create bin/rails
|
26
|
+
create bin/rake
|
27
|
+
create bin/setup
|
28
|
+
create config
|
29
|
+
create config/routes.rb
|
30
|
+
create config/application.rb
|
31
|
+
create config/environment.rb
|
32
|
+
create config/cable.yml
|
33
|
+
create config/puma.rb
|
34
|
+
create config/storage.yml
|
35
|
+
create config/environments
|
36
|
+
create config/environments/development.rb
|
37
|
+
create config/environments/production.rb
|
38
|
+
create config/environments/test.rb
|
39
|
+
create config/initializers
|
40
|
+
create config/initializers/assets.rb
|
41
|
+
create config/initializers/content_security_policy.rb
|
42
|
+
create config/initializers/cors.rb
|
43
|
+
create config/initializers/filter_parameter_logging.rb
|
44
|
+
create config/initializers/inflections.rb
|
45
|
+
create config/initializers/new_framework_defaults_7_0.rb
|
46
|
+
create config/initializers/permissions_policy.rb
|
47
|
+
create config/locales
|
48
|
+
create config/locales/en.yml
|
49
|
+
create config/master.key
|
50
|
+
create config/boot.rb
|
51
|
+
create config/database.yml
|
52
|
+
create db
|
53
|
+
create db/seeds.rb
|
54
|
+
create lib
|
55
|
+
create lib/tasks
|
56
|
+
create lib/tasks/.keep
|
57
|
+
create lib/assets
|
58
|
+
create lib/assets/.keep
|
59
|
+
create log
|
60
|
+
create log/.keep
|
61
|
+
create public
|
62
|
+
create public/404.html
|
63
|
+
create public/422.html
|
64
|
+
create public/500.html
|
65
|
+
create public/apple-touch-icon-precomposed.png
|
66
|
+
create public/apple-touch-icon.png
|
67
|
+
create public/favicon.ico
|
68
|
+
create public/robots.txt
|
69
|
+
create tmp
|
70
|
+
create tmp/.keep
|
71
|
+
create tmp/pids
|
72
|
+
create tmp/pids/.keep
|
73
|
+
create tmp/cache
|
74
|
+
create tmp/cache/assets
|
75
|
+
create vendor
|
76
|
+
create vendor/.keep
|
77
|
+
create test/system
|
78
|
+
create test/system/.keep
|
79
|
+
create test/application_system_test_case.rb
|
80
|
+
create storage
|
81
|
+
create storage/.keep
|
82
|
+
create tmp/storage
|
83
|
+
create tmp/storage/.keep
|
84
|
+
remove config/initializers/cors.rb
|
85
|
+
remove config/initializers/new_framework_defaults_7_0.rb
|
86
|
+
finish template
|
87
|
+
run bundle install
|
88
|
+
run bundle binstubs bundler
|
89
|
+
rails javascript:install:esbuild
|
90
|
+
rails turbo:install stimulus:install
|
91
|
+
rails css:install:bootstrap
|
@@ -47,9 +47,11 @@ module RailsAppGenerator
|
|
47
47
|
def sane_mapper
|
48
48
|
case type
|
49
49
|
when :boolean
|
50
|
-
RailsAppGenerator::MapOptionBooleanFlag
|
50
|
+
RailsAppGenerator::MapOptionBooleanFlag.new
|
51
|
+
when :string
|
52
|
+
RailsAppGenerator::MapOptionString.new
|
51
53
|
else
|
52
|
-
RailsAppGenerator::
|
54
|
+
RailsAppGenerator::MapOptionIgnore.new
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module RailsAppGenerator
|
4
4
|
# Map a boolean true to a command line flag in the format "--flag-name"
|
5
5
|
# false is ignored
|
6
|
-
class MapOptionBooleanFlag
|
7
|
-
def
|
8
|
-
value == true ?
|
6
|
+
class MapOptionBooleanFlag < BaseMapOption
|
7
|
+
def map(name, value)
|
8
|
+
value == true ? option_name(name) : ''
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module RailsAppGenerator
|
4
4
|
# Simple pass through mapper for options that do not yet have a mapper defined
|
5
|
-
class
|
6
|
-
def
|
7
|
-
|
5
|
+
class MapOptionIgnore < BaseMapOption
|
6
|
+
def map(_name, _value)
|
7
|
+
nil
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Simple pass through mapper for options that do not yet have a mapper defined
|
5
|
+
class MapOptionString < BaseMapOption
|
6
|
+
def map(name, value)
|
7
|
+
return '' if value.nil? || value.empty?
|
8
|
+
|
9
|
+
value = value.to_s
|
10
|
+
value = "\"#{value}\"" if value.include?(' ')
|
11
|
+
"#{option_name(name)}=#{value}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RailsAppGenerator
|
4
|
-
#
|
5
|
-
|
4
|
+
# OptionBuilder can work standalone or as the base class
|
5
|
+
# for application generator options used by RailsAppGenerator::Starter
|
6
|
+
class OptionsBuilder
|
6
7
|
attr_reader :options
|
7
8
|
|
8
9
|
def initialize(opts)
|
@@ -20,6 +21,9 @@ module RailsAppGenerator
|
|
20
21
|
@registered_options_lookup ||= {}
|
21
22
|
end
|
22
23
|
|
24
|
+
# Future options are placeholders for options that are not yet implemented
|
25
|
+
def future_option(name, **args); end
|
26
|
+
|
23
27
|
def register_option(name, **args)
|
24
28
|
return if registered_options_lookup.key?(name)
|
25
29
|
|
@@ -43,6 +47,13 @@ module RailsAppGenerator
|
|
43
47
|
end.reject(&:blank?)
|
44
48
|
end
|
45
49
|
|
50
|
+
def debug
|
51
|
+
puts '[ Options JSON ]----------------------------------------------------'
|
52
|
+
puts JSON.pretty_generate(options)
|
53
|
+
puts '[ Options Command Line ]--------------------------------------------'
|
54
|
+
puts cmd_line_options
|
55
|
+
end
|
56
|
+
|
46
57
|
private
|
47
58
|
|
48
59
|
def default_options
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
class RailsOptions < OptionsBuilder
|
5
|
+
# NOTE: Currently you need to register new options in two places
|
6
|
+
# here and in lib/rails_app_generator/app_generator.rb
|
7
|
+
|
8
|
+
future_option :template , type: :string # , desc: "Path to some #{name} template (can be a filesystem path or URL)"
|
9
|
+
future_option :database , type: :string , default: 'sqlite3' # , desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
10
|
+
register_option :skip_git , type: :boolean, default: false # , desc: "Skip .gitignore file"
|
11
|
+
future_option :skip_keeps , type: :boolean, default: false # , desc: "Skip source control .keep files"
|
12
|
+
future_option :skip_action_mailer , type: :boolean, default: false # , desc: "Skip Action Mailer files"
|
13
|
+
future_option :skip_action_mailbox , type: :boolean, default: false # , desc: "Skip Action Mailbox gem"
|
14
|
+
future_option :skip_action_text , type: :boolean, default: false # , desc: "Skip Action Text gem"
|
15
|
+
future_option :skip_active_record , type: :boolean, default: false # , desc: "Skip Active Record files"
|
16
|
+
future_option :skip_active_job , type: :boolean, default: false # , desc: "Skip Active Job"
|
17
|
+
future_option :skip_active_storage , type: :boolean, default: false # , desc: "Skip Active Storage files"
|
18
|
+
future_option :skip_action_cable , type: :boolean, default: false # , desc: "Skip Action Cable files"
|
19
|
+
future_option :skip_asset_pipeline , type: :boolean, default: false #
|
20
|
+
future_option :asset_pipeline , type: :string , default: 'sprockets' # , desc: "Choose your asset pipeline [options: sprockets (default), propshaft]"
|
21
|
+
future_option :skip_javascript , type: :boolean, default: false # name == 'plugin' # , desc: "Skip JavaScript files"
|
22
|
+
future_option :skip_hotwire , type: :boolean, default: false # , desc: "Skip Hotwire integration"
|
23
|
+
future_option :skip_jbuilder , type: :boolean, default: false # , desc: "Skip jbuilder gem"
|
24
|
+
register_option :skip_test , type: :boolean, default: false # , desc: "Skip test files"
|
25
|
+
register_option :test , type: :string , default: 'rspec' # , desc: "minitest or rspec (default: rspec)"
|
26
|
+
future_option :skip_system_test , type: :boolean, default: false # , desc: "Skip system test files"
|
27
|
+
future_option :skip_bootsnap , type: :boolean, default: false # , desc: "Skip bootsnap gem"
|
28
|
+
future_option :dev , type: :boolean, default: false # , desc: "Set up the #{name} with Gemfile pointing to your Rails checkout"
|
29
|
+
future_option :edge , type: :boolean, default: false # , desc: "Set up the #{name} with Gemfile pointing to Rails repository"
|
30
|
+
future_option :main , type: :boolean, default: false # , desc: "Set up the #{name} with Gemfile pointing to Rails repository main branch"
|
31
|
+
future_option :rc , type: :string , default: nil # , desc: "Path to file containing extra configuration options for rails command"
|
32
|
+
future_option :no_rc , type: :boolean, default: false # , desc: "Skip loading of extra configuration options from .railsrc file"
|
33
|
+
future_option :help , type: :boolean # , group: :rails # , desc: "Show this help message and quit"
|
34
|
+
future_option :version , type: :boolean # , group: :rails, desc: "Show Rails version number and quit"
|
35
|
+
future_option :api , type: :boolean # , desc: "Preconfigure smaller stack for API only apps"
|
36
|
+
future_option :minimal , type: :boolean # , desc: "Preconfigure a minimal rails app"
|
37
|
+
future_option :javascript , type: :string , default: 'importmap' # , desc: "Choose JavaScript approach [options: importmap (default), webpack, esbuild, rollup]"
|
38
|
+
register_option :css , type: :string # , desc: "Choose CSS processor [options: tailwind, bootstrap, bulma, postcss, sass... check https://github.com/rails/cssbundling-rails]"
|
39
|
+
register_option :skip_bundle , type: :boolean, default: false # , desc: "Don't run bundle install"
|
40
|
+
|
41
|
+
register_option :add_irbrc , type: :boolean, default: false
|
42
|
+
register_option :add_foreman , type: :boolean, default: false
|
43
|
+
register_option :add_dotenv , type: :boolean, default: false
|
44
|
+
register_option :add_docker , type: :boolean, default: false
|
45
|
+
register_option :add_docker_compose , type: :boolean, default: false
|
46
|
+
register_option :add_rubocop , type: :boolean, default: false
|
47
|
+
register_option :add_annotate , type: :boolean, default: false
|
48
|
+
register_option :add_continuous_integration , type: :boolean, default: false
|
49
|
+
register_option :add_high_voltage , type: :boolean, default: false
|
50
|
+
register_option :add_generators , type: :boolean, default: false
|
51
|
+
register_option :add_lograge , type: :boolean, default: false
|
52
|
+
register_option :add_pundit , type: :boolean, default: false
|
53
|
+
register_option :add_services , type: :boolean, default: false
|
54
|
+
register_option :add_sidekiq , type: :boolean, default: false
|
55
|
+
register_option :add_views , type: :boolean, default: false
|
56
|
+
register_option :add_errors , type: :boolean, default: false
|
57
|
+
register_option :add_scaffold , type: :boolean, default: false
|
58
|
+
register_option :add_factory_bot , type: :boolean, default: false
|
59
|
+
register_option :add_shoulda , type: :boolean, default: false
|
60
|
+
|
61
|
+
# if options[:minimal]
|
62
|
+
# self.options = options.merge(
|
63
|
+
# skip_action_cable: true,
|
64
|
+
# skip_action_mailer: true,
|
65
|
+
# skip_action_mailbox: true,
|
66
|
+
# skip_action_text: true,
|
67
|
+
# skip_active_job: true,
|
68
|
+
# skip_active_storage: true,
|
69
|
+
# skip_bootsnap: true,
|
70
|
+
# skip_dev_gems: true,
|
71
|
+
# skip_javascript: true,
|
72
|
+
# skip_jbuilder: true,
|
73
|
+
# skip_system_test: true,
|
74
|
+
# skip_hotwire: true).freeze
|
75
|
+
# end
|
76
|
+
end
|
77
|
+
end
|
@@ -29,56 +29,72 @@ module RailsAppGenerator
|
|
29
29
|
|
30
30
|
attr_reader :app_path
|
31
31
|
attr_reader :destination_root
|
32
|
+
|
33
|
+
# points to the original rails templates
|
32
34
|
attr_reader :rails_template_path
|
33
|
-
|
35
|
+
|
36
|
+
# points to the overriding templates related to rails
|
37
|
+
attr_reader :override_template_path
|
38
|
+
|
39
|
+
# points to templates related to rails addons
|
40
|
+
attr_reader :addon_template_path
|
41
|
+
|
42
|
+
attr_reader :console_output
|
34
43
|
|
35
44
|
def initialize(**args)
|
36
|
-
@app_path
|
37
|
-
@destination_root
|
38
|
-
@rails_template_path
|
39
|
-
@
|
45
|
+
@app_path = args[:app_path] || '.'
|
46
|
+
@destination_root = args[:destination_root] || Dir.pwd
|
47
|
+
@rails_template_path = args[:rails_template_path] || AppGenerator.rails_template_path
|
48
|
+
@override_template_path = args[:override_template_path] || AppGenerator.override_template_path
|
49
|
+
@addon_template_path = args[:addon_template_path] || AppGenerator.addon_template_path
|
40
50
|
end
|
41
51
|
|
42
52
|
def target_path
|
43
53
|
File.expand_path(File.join(destination_root, app_path))
|
44
54
|
end
|
45
55
|
|
46
|
-
def start
|
56
|
+
def start(options = [])
|
47
57
|
puts "Target path: #{target_path}"
|
48
58
|
|
49
|
-
RailsAppGenerator::AppGenerator.source_root(rails_template_path)
|
50
|
-
RailsAppGenerator::AppGenerator.source_paths << rails_template_path
|
51
|
-
RailsAppGenerator::AppGenerator.source_paths <<
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
59
|
+
# RailsAppGenerator::AppGenerator.source_root(rails_template_path)
|
60
|
+
# # RailsAppGenerator::AppGenerator.source_paths << rails_template_path
|
61
|
+
# RailsAppGenerator::AppGenerator.source_paths << addon_template_path
|
62
|
+
|
63
|
+
opts = extract_rails_options(app_path, options)
|
64
|
+
|
65
|
+
@console_output = capture_console do
|
66
|
+
RailsAppGenerator::AppGenerator.start(opts, destination_root: destination_root)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def capture_console
|
73
|
+
$stdout = StringIO.new
|
74
|
+
yield
|
75
|
+
output = $stdout.string
|
76
|
+
$stdout.close
|
77
|
+
output
|
78
|
+
ensure
|
79
|
+
$stdout = STDOUT
|
80
|
+
$stdout.puts output
|
81
|
+
end
|
82
|
+
|
83
|
+
# Rails options returns a flat array of options
|
84
|
+
#
|
85
|
+
# It can work accept a flat array of options or a
|
86
|
+
# an object that implements cmd_line_options such as OptionsBuilder
|
87
|
+
#
|
88
|
+
# @param [Array<String>, OptionsBuilder] options
|
89
|
+
# @return [Array<String>]
|
90
|
+
def extract_rails_options(app_path, options)
|
91
|
+
opts = nil
|
92
|
+
opts = options.cmd_line_options if options.respond_to?(:cmd_line_options)
|
93
|
+
opts = options if options.is_a?(Array)
|
94
|
+
|
95
|
+
raise ArgumentError, 'options is required' unless opts
|
96
|
+
|
97
|
+
[app_path] + opts
|
82
98
|
end
|
83
99
|
end
|
84
100
|
end
|
data/lib/rails_app_generator.rb
CHANGED
@@ -10,13 +10,20 @@ require 'rails/generators/rails/app/app_generator'
|
|
10
10
|
require 'bundler'
|
11
11
|
|
12
12
|
require 'rails_app_generator/version'
|
13
|
-
require 'rails_app_generator/options/
|
13
|
+
require 'rails_app_generator/options/base_map_option'
|
14
|
+
require 'rails_app_generator/options/map_option_ignore'
|
15
|
+
require 'rails_app_generator/options/map_option_string'
|
14
16
|
require 'rails_app_generator/options/map_option_boolean_flag'
|
15
17
|
require 'rails_app_generator/options/build_option'
|
16
|
-
require 'rails_app_generator/options/
|
17
|
-
require 'rails_app_generator/
|
18
|
+
require 'rails_app_generator/options/options_builder'
|
19
|
+
require 'rails_app_generator/options/rails_options'
|
20
|
+
require_relative 'rails_app_generator/context'
|
21
|
+
require_relative 'rails_app_generator/dependencies'
|
22
|
+
require_relative 'rails_app_generator/add_on'
|
23
|
+
Dir[File.join(__dir__, 'rails_app_generator', 'addons', '*.rb')].sort.each { |file| require file }
|
18
24
|
require 'rails_app_generator/app_builder'
|
19
25
|
require 'rails_app_generator/app_generator'
|
26
|
+
require 'rails_app_generator/starter'
|
20
27
|
|
21
28
|
# require "rails_app_generator/generators/base"
|
22
29
|
# require "rails_app_generator/generators/foo_generator"
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "rails_app_generator",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.6",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "rails_app_generator",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.6",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.1",
|
data/package.json
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if Rails.env.development?
|
4
|
+
require 'annotate'
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
6
|
+
task set_annotation_options: :environment do
|
7
|
+
# You can override any of these by setting an environment variable of the
|
8
|
+
# same name.
|
9
|
+
Annotate.set_defaults(
|
10
|
+
'active_admin' => 'false',
|
11
|
+
'additional_file_patterns' => [],
|
12
|
+
'routes' => 'false',
|
13
|
+
'models' => 'true',
|
14
|
+
'position_in_routes' => 'before',
|
15
|
+
'position_in_class' => 'before',
|
16
|
+
'position_in_test' => 'before',
|
17
|
+
'position_in_fixture' => 'before',
|
18
|
+
'position_in_factory' => 'before',
|
19
|
+
'position_in_serializer' => 'before',
|
20
|
+
'show_foreign_keys' => 'true',
|
21
|
+
'show_complete_foreign_keys' => 'false',
|
22
|
+
'show_indexes' => 'true',
|
23
|
+
'simple_indexes' => 'false',
|
24
|
+
'model_dir' => 'app/models',
|
25
|
+
'root_dir' => '',
|
26
|
+
'include_version' => 'false',
|
27
|
+
'require' => '',
|
28
|
+
'exclude_tests' => 'true',
|
29
|
+
'exclude_fixtures' => 'true',
|
30
|
+
'exclude_factories' => 'true',
|
31
|
+
'exclude_serializers' => 'true',
|
32
|
+
'exclude_scaffolds' => 'true',
|
33
|
+
'exclude_controllers' => 'true',
|
34
|
+
'exclude_helpers' => 'true',
|
35
|
+
'exclude_sti_subclasses' => 'false',
|
36
|
+
'ignore_model_sub_dir' => 'false',
|
37
|
+
'ignore_columns' => nil,
|
38
|
+
'ignore_routes' => nil,
|
39
|
+
'ignore_unknown_models' => 'false',
|
40
|
+
'hide_limit_column_types' => 'integer,bigint,boolean',
|
41
|
+
'hide_default_column_types' => 'json,jsonb,hstore',
|
42
|
+
'skip_on_db_migrate' => 'false',
|
43
|
+
'format_bare' => 'true',
|
44
|
+
'format_rdoc' => 'false',
|
45
|
+
'format_yard' => 'false',
|
46
|
+
'format_markdown' => 'false',
|
47
|
+
'sort' => 'false',
|
48
|
+
'force' => 'false',
|
49
|
+
'frozen' => 'false',
|
50
|
+
'classified_sort' => 'true',
|
51
|
+
'trace' => 'false',
|
52
|
+
'wrapper_open' => nil,
|
53
|
+
'wrapper_close' => nil,
|
54
|
+
'with_comment' => 'true'
|
55
|
+
)
|
56
|
+
end
|
57
|
+
# rubocop:enable Metrics/BlockLength
|
58
|
+
|
59
|
+
Annotate.load_tasks
|
60
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
name: <%= camelized %> CI 🚀
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
tests:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
env:
|
15
|
+
RAILS_ENV: test
|
16
|
+
DATABASE_HOST: localhost
|
17
|
+
DATABASE_USERNAME: <%= app_name %>
|
18
|
+
DATABASE_PASSWORD: <%= app_name %>
|
19
|
+
services:
|
20
|
+
postgres:
|
21
|
+
image: postgres:13
|
22
|
+
env:
|
23
|
+
POSTGRES_PASSWORD: <%= app_name %>
|
24
|
+
POSTGRES_USER: <%= app_name %>
|
25
|
+
ports:
|
26
|
+
- 5432:5432
|
27
|
+
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v2
|
30
|
+
- name: Set up Ruby
|
31
|
+
uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: <%= RUBY_VERSION %>
|
34
|
+
bundler-cache: true
|
35
|
+
- name: Set up Node
|
36
|
+
uses: actions/setup-node@v1
|
37
|
+
with:
|
38
|
+
node-version: 14.9
|
39
|
+
- name: Install dependencies
|
40
|
+
run: |
|
41
|
+
sudo apt-get -yqq install libpq-dev build-essential libcurl4-openssl-dev
|
42
|
+
gem install bundler
|
43
|
+
bundle install --jobs 4
|
44
|
+
yarn install
|
45
|
+
- name: Setup databases
|
46
|
+
run: |
|
47
|
+
bin/rails db:setup
|
48
|
+
- name: Run tests
|
49
|
+
run: bin/rails test
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<% content_for :devise_form do %>
|
2
|
+
|
3
|
+
<h2 class="pt-4 mb-8 text-4xl font-bold heading">Resend confirmation instructions</h2>
|
4
|
+
|
5
|
+
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
|
6
|
+
<%= render "devise/shared/error_messages", resource: resource %>
|
7
|
+
|
8
|
+
<div class="input-group">
|
9
|
+
<%= f.label :email, class: "label" %>
|
10
|
+
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), class: "input" %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="input-group">
|
14
|
+
<%= f.submit "Resend confirmation instructions", class: "btn btn-default" %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<hr class="mt-6 border" />
|
19
|
+
|
20
|
+
<%= render "devise/shared/links" %>
|
21
|
+
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<%= render "devise/shared/form_wrap" %>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<% content_for :devise_form do %>
|
2
|
+
<h2 class="pt-4 mb-8 text-4xl font-bold heading">Change your password</h2>
|
3
|
+
|
4
|
+
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
5
|
+
<%= render "devise/shared/error_messages", resource: resource %>
|
6
|
+
<%= f.hidden_field :reset_password_token %>
|
7
|
+
|
8
|
+
<div class="input-group">
|
9
|
+
<div class="flex">
|
10
|
+
<%= f.label :password, "New password", class:"label" %>
|
11
|
+
<% if @minimum_password_length %>
|
12
|
+
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
<%= f.password_field :password, autofocus: true, autocomplete: "new-password", class: "input" %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<div class="input-group">
|
19
|
+
<%= f.label :password_confirmation, "Confirm new password", class: "label" %>
|
20
|
+
<%= f.password_field :password_confirmation, autocomplete: "off", class: "input" %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="input-group">
|
24
|
+
<%= f.submit "Change my password", class: "btn btn-default" %>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<hr class="mt-6 border" />
|
29
|
+
|
30
|
+
<%= render "devise/shared/links" %>
|
31
|
+
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<%= render "devise/shared/form_wrap" %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% content_for :devise_form do %>
|
2
|
+
|
3
|
+
<h2 class="pt-4 mb-8 text-4xl font-bold heading">Forgot your password?</h2>
|
4
|
+
|
5
|
+
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
6
|
+
<%= render "devise/shared/error_messages", resource: resource %>
|
7
|
+
|
8
|
+
<div class="input-group">
|
9
|
+
<%= f.label :email, class: "label" %>
|
10
|
+
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: "input" %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="input-group">
|
14
|
+
<%= f.submit "Send me reset password instructions", class: "btn btn-default" %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<hr class="mt-6 border" />
|
19
|
+
|
20
|
+
<%= render "devise/shared/links" %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<%= render "devise/shared/form_wrap" %>
|