Sha256: 5e20301fa4ca051ddfead8ff8f9e5758e9f01d025eaeeb97a0eb9698d756802b

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

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

require "pathname"

source_path = (Pathname.new(__FILE__).dirname + "../lib").expand_path
$LOAD_PATH << source_path

activate_rails_version = ->(rails_version) do
  rails_bin_path = Gem.activate_bin_path("railties", "rails", rails_version)
  rails_path = File.expand_path("../..", rails_bin_path)
  $LOAD_PATH.unshift(rails_path)
end

if (str = ARGV.first)
  str = str.b[/\A_(.*)_\z/, 1]

  if str && Gem::Version.correct?(str)
    rails_version = str
    ARGV.shift

    begin
      activate_rails_version.call(rails_version)
    rescue Gem::GemNotFoundException
      abort("Hephaestus error: Unable to find Rails version #{rails_version}")
    end
  else
    require "hephaestus/version"

    spec = Gem::Specification.find_by_name("rails", Hephaestus::RAILS_VERSION)

    activate_rails_version.call(spec.version.to_s)
  end
end

require "hephaestus"

if ARGV.empty?
  puts "Please provide a path for the new application"
  puts
  puts "See --help for more info"
  exit 0
elsif ["-v", "--version"].include?(ARGV[0])
  puts Hephaestus::VERSION
  exit 0
end

path = ARGV.first
if File.exist?(path)
  puts "The directory #{path} already exists."
  exit 1
end

unless path.start_with?("plug-")
  puts "The directory name must start with 'plug-'"
  exit 1
end

templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
Hephaestus::AppGenerator.source_root(templates_root)
Hephaestus::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root

ARGV.push("--minimal")
ARGV.push("--no-skip-active-job")
ARGV.push("--skip-asset-pipeline")
ARGV.push("--skip-active-record")
ARGV.push("--skip-active-record")
Hephaestus::AppGenerator.start

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hephaestus-0.1.3 bin/hephaestus
hephaestus-0.1.2 bin/hephaestus
hephaestus-0.1.1 bin/hephaestus