Sha256: ec73f48e1202f050f6ef6ebf06df505c3a6b2f16031acb4d1fdea6db111498a9

Contents?: true

Size: 1.81 KB

Versions: 15

Compression:

Stored size: 1.81 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "thor"
require_relative "../lib/rails_template18f/version"

class CLI < Thor
  include Thor::Actions

  desc "new APP_DIRECTORY [options] [rails new arguments]", "Run rails new with 18F flavor"
  option :hotwire, type: :boolean, default: false, desc: "Enable hotwire JS framework"
  long_desc <<-LONGDESC
    Create a new rails application in <APP_DIRECTORY> as customized by

    * railsrc: https://github.com/18F/rails-template/blob/main/railsrc

    * template.rb: https://github.com/18F/rails-template/blob/main/template.rb

    with --hotwire option, includes the Hotwire JS framework

    all other arguments will be passed as-is to `rails new`
  LONGDESC
  def new(app_directory, *rails_arguments)
    gem_path = File.expand_path("..", __dir__)
    railsrc = options[:hotwire] ? "railsrc-hotwire" : "railsrc"
    run "rails new #{app_directory} --rc=#{File.join(gem_path, railsrc)} --template=#{File.join(gem_path, "template.rb")} #{rails_arguments.join(" ")}"
  end

  desc "update", "Run rails app:update with some enhancements"
  long_desc <<-LONGDESC
    Run `rails app:update` with frameworks fully defined by what is commented out at the top
    of config/application.rb

    Example: to enable ActiveStorage

    1) Uncomment `require "active_storage/engine"` in `config/application.rb`

    2) Run `bin/rails active_storage:install`

    3) Run bundle exec rails_template_18f update

    4) Optional: run other rails_template18f generators that may be applicable
  LONGDESC
  def update
    require_relative "../lib/rails_template18f/app_updater"
    require "rails/command"
    Rails::Command.invoke "app:update"
  end

  desc "version", "Output gem version"
  def version
    puts RailsTemplate18f::VERSION
  end

  def self.exit_on_failure?
    true
  end
end

CLI.start(ARGV)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rails_template_18f-1.1.0 exe/rails_template_18f
rails_template_18f-1.0.0 exe/rails_template_18f
rails_template_18f-0.8.2 exe/rails_template_18f
rails_template_18f-0.8.1 exe/rails_template_18f
rails_template_18f-0.8.0 exe/rails_template_18f
rails_template_18f-0.7.2 exe/rails_template_18f
rails_template_18f-0.7.1 exe/rails_template_18f
rails_template_18f-0.7.0 exe/rails_template_18f
rails_template_18f-0.6.0 exe/rails_template_18f
rails_template_18f-0.5.3 exe/rails_template_18f
rails_template_18f-0.5.2 exe/rails_template_18f
rails_template_18f-0.5.1 exe/rails_template_18f
rails_template_18f-0.5.0 exe/rails_template_18f
rails_template_18f-0.4.1 exe/rails_template_18f
rails_template_18f-0.4.0 exe/rails_template_18f