Sha256: c632c0c5f8891f647bef801aef633ff2f8606ec595f91ee31967fd6d213ebf6a

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

#!/usr/bin/env ruby
require 'fileutils'

working_dir = Dir.pwd

spec = Gem::Specification.find_by_name("shopify-sinatra-app")
gem_root = spec.gem_dir
gem_lib = gem_root + "/lib"

generator_dir = gem_lib + "/generator"

if ARGV.length < 2
  puts "Usage:\n./shopify-sinatra-app new <app_name>"
else
  app_name = ARGV[1]
  app_dir = working_dir + "/" + app_name

  begin
    Dir.mkdir(app_dir)

    FileUtils.cp_r(generator_dir + "/config",    app_dir + "/config")
    FileUtils.cp_r(generator_dir + "/db",        app_dir + "/db")
    FileUtils.cp_r(generator_dir + "/lib",       app_dir + "/lib")
    FileUtils.cp_r(generator_dir + "/public",    app_dir + "/public")
    FileUtils.cp_r(generator_dir + "/views",     app_dir + "/views")

    FileUtils.cp(generator_dir   + "/config.ru", app_dir + "/config.ru")
    FileUtils.cp(generator_dir   + "/Procfile",  app_dir + "/Procfile")
    FileUtils.cp(generator_dir   + "/Rakefile",  app_dir + "/Rakefile")
    FileUtils.cp(generator_dir   + "/Gemfile",  app_dir + "/Gemfile")
    FileUtils.cp(generator_dir   + "/README.md",  app_dir + "/README.md")

    Dir.chdir(app_dir)

    pipe = IO.popen("bundle install")
    while (line = pipe.gets)
      print line
    end

    pipe = IO.popen("bundle exec rake db:migrate")
    while (line = pipe.gets)
      print line
    end

  rescue Errno::EEXIST => e
    puts "App directory alread exists, pick a new app name or delete the existing folder"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-sinatra-app-0.0.1 bin/shopify-sinatra-app-generator