Class: Rails::Generators::AppBase

Inherits:
Base
  • Object
show all
Includes:
AppName
Defined in:
lib/rails/generators/app_base.rb

Overview

:nodoc:

Direct Known Subclasses

AppGenerator, PluginGenerator

Defined Under Namespace

Classes: GemfileEntry

Constant Summary collapse

NODE_LTS_VERSION =
"20.11.1"
BUN_VERSION =
"1.0.1"
JAVASCRIPT_OPTIONS =
%w( importmap bun webpack esbuild rollup )
CSS_OPTIONS =
%w( tailwind bootstrap bulma postcss sass )

Constants included from AppName

Rails::Generators::AppName::RESERVED_NAMES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

base_root, class_option, default_source_root, desc, exit_on_failure?, hide!, hook_for, inherited, namespace, remove_hook_for, source_root

Methods included from Actions

#add_source, #environment, #gem, #gem_group, #generate, #git, #github, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Constructor Details

#initialize(positional_argv, option_argv) ⇒ AppBase

Returns a new instance of AppBase.



141
142
143
144
145
# File 'lib/rails/generators/app_base.rb', line 141

def initialize(positional_argv, option_argv, *)
  @argv = [*positional_argv, *option_argv]
  @gem_filter = lambda { |gem| true }
  super
end

Instance Attribute Details

#rails_templateObject

Returns the value of attribute rails_template.



23
24
25
# File 'lib/rails/generators/app_base.rb', line 23

def rails_template
  @rails_template
end

Class Method Details

.add_shared_options_for(name) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/rails/generators/app_base.rb', line 32

def self.add_shared_options_for(name)
  class_option :name,                type: :string, aliases: "-n",
                                     desc: "Name of the app"

  class_option :template,            type: :string, aliases: "-m",
                                     desc: "Path to some #{name} template (can be a filesystem path or URL)"

  class_option :database,            type: :string, aliases: "-d", default: "sqlite3",
                                     enum: Database::DATABASES,
                                     desc: "Preconfigure for selected database"

  class_option :skip_git,            type: :boolean, aliases: "-G", default: nil,
                                     desc: "Skip git init, .gitignore and .gitattributes"

  class_option :skip_docker,         type: :boolean, default: nil,
                                     desc: "Skip Dockerfile, .dockerignore and bin/docker-entrypoint"

  class_option :skip_keeps,          type: :boolean, default: nil,
                                     desc: "Skip source control .keep files"

  class_option :skip_action_mailer,  type: :boolean, aliases: "-M",
                                     default: nil,
                                     desc: "Skip Action Mailer files"

  class_option :skip_action_mailbox, type: :boolean, default: nil,
                                     desc: "Skip Action Mailbox gem"

  class_option :skip_action_text,    type: :boolean, default: nil,
                                     desc: "Skip Action Text gem"

  class_option :skip_active_record,  type: :boolean, aliases: "-O", default: nil,
                                     desc: "Skip Active Record files"

  class_option :skip_active_job,     type: :boolean, default: nil,
                                     desc: "Skip Active Job"

  class_option :skip_active_storage, type: :boolean, default: nil,
                                     desc: "Skip Active Storage files"

  class_option :skip_action_cable,   type: :boolean, aliases: "-C", default: nil,
                                     desc: "Skip Action Cable files"

  class_option :skip_asset_pipeline, type: :boolean, aliases: "-A", default: nil

  class_option :skip_javascript,     type: :boolean, aliases: ["-J", "--skip-js"], default: (true if name == "plugin"),
                                     desc: "Skip JavaScript files"

  class_option :skip_hotwire,        type: :boolean, default: nil,
                                     desc: "Skip Hotwire integration"

  class_option :skip_jbuilder,       type: :boolean, default: nil,
                                     desc: "Skip jbuilder gem"

  class_option :skip_test,           type: :boolean, aliases: "-T", default: nil,
                                     desc: "Skip test files"

  class_option :skip_system_test,    type: :boolean, default: nil,
                                     desc: "Skip system test files"

  class_option :skip_bootsnap,       type: :boolean, default: nil,
                                     desc: "Skip bootsnap gem"

  class_option :skip_dev_gems,       type: :boolean, default: nil,
                                     desc: "Skip development gems (e.g., web-console)"

  class_option :skip_thruster,       type: :boolean, default: nil,
                                     desc: "Skip Thruster setup"

  class_option :skip_rubocop,        type: :boolean, default: nil,
                                     desc: "Skip RuboCop setup"

  class_option :skip_brakeman,       type: :boolean, default: nil,
                                     desc: "Skip brakeman setup"

  class_option :skip_ci,             type: :boolean, default: nil,
                                     desc: "Skip GitHub CI files"

  class_option :skip_kamal,          type: :boolean, default: nil,
                                     desc: "Skip Kamal setup"

  class_option :skip_solid,          type: :boolean, default: nil,
                                     desc: "Skip Solid Cache, Queue, and Cable setup"

  class_option :dev,                 type: :boolean, default: nil,
                                     desc: "Set up the #{name} with Gemfile pointing to your Rails checkout"

  class_option :devcontainer,        type: :boolean, default: nil,
                                     desc: "Generate devcontainer files"

  class_option :edge,                type: :boolean, default: nil,
                                     desc: "Set up the #{name} with a Gemfile pointing to the #{edge_branch} branch on the Rails repository"

  class_option :main,                type: :boolean, default: nil, aliases: "--master",
                                     desc: "Set up the #{name} with Gemfile pointing to Rails repository main branch"

  class_option :rc,                  type: :string, default: nil,
                                     desc: "Path to file containing extra configuration options for rails command"

  class_option :no_rc,               type: :boolean, default: nil,
                                     desc: "Skip loading of extra configuration options from .railsrc file"

  class_option :help,                type: :boolean, aliases: "-h", group: :rails,
                                     desc: "Show this help message and quit"
end

.edge_branchObject

:nodoc:



137
138
139
# File 'lib/rails/generators/app_base.rb', line 137

def self.edge_branch # :nodoc:
  Rails.gem_version.prerelease? ? "main" : [*Rails.gem_version.segments.first(2), "stable"].join("-")
end

.strict_args_positionObject



28
29
30
# File 'lib/rails/generators/app_base.rb', line 28

def self.strict_args_position
  false
end