Module: Jets::Generators::Overrides::App::AppBaseOverrides::ClassMethods

Defined in:
lib/jets/generators/overrides/app/app_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_shared_options_for(name) ⇒ Object

Override to support jets options only



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jets/generators/overrides/app/app_generator.rb', line 17

def 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: "mysql",
                          desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"

  class_option :mode, default: 'html',
                      desc: "mode: #{VALID_MODES.join(',')}"

  class_option :javascript, type: :string, aliases: "-j", default: "importmap",
                            desc: "Choose JavaScript approach [options: importmap (default)]"

end

:doc:



50
51
52
# File 'lib/jets/generators/overrides/app/app_generator.rb', line 50

def banner # :doc:
  "jets new #{arguments.map(&:usage).join(' ')} [options]"
end

#exit_on_failure?Boolean

We want to exit on failure to be kind to other libraries This is only when accessing via CLI

Returns:

  • (Boolean)


65
66
67
# File 'lib/jets/generators/overrides/app/app_generator.rb', line 65

def exit_on_failure?
  true
end

#jets_generator_rootObject



46
47
48
# File 'lib/jets/generators/overrides/app/app_generator.rb', line 46

def jets_generator_root
  File.expand_path(__dir__)
end

#jets_templates_pathObject



42
43
44
# File 'lib/jets/generators/overrides/app/app_generator.rb', line 42

def jets_templates_path
  File.join(jets_generator_root, "templates")
end

#source_pathsObject

Prepend jets_template_path to source_paths so that the jets templates can override the rails templates.



37
38
39
40
# File 'lib/jets/generators/overrides/app/app_generator.rb', line 37

def source_paths
  rails_templates_path = Rails::Generators::AppGenerator.source_root
  [jets_templates_path, rails_templates_path] + super
end

#usage_pathObject



54
55
56
57
58
59
60
61
# File 'lib/jets/generators/overrides/app/app_generator.rb', line 54

def usage_path
  path = File.join(jets_generator_root, "USAGE")
  if File.exist?(path)
    path
  else
    super
  end
end