Sha256: cc290d038312b45b9f97610bfd1f03843769d2059d06b027169a6c67f9440249

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

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

require "pathname"
require 'rainbow'

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 Rainbow("\nError: The directory #{path} already exists.").red
  exit 1
end

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

unless path.length > "plug-".length
  puts Rainbow("\nError: The directory name must start with 'plug-'").red
  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")

Hephaestus::AppGenerator.start

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hephaestus-0.4.0 bin/hephaestus
hephaestus-0.3.1 bin/hephaestus
hephaestus-0.2.3 bin/hephaestus
hephaestus-0.2.2 bin/hephaestus