Sha256: 9449134b36b5c86243f094efc574dd360f8cc7c58d04e8864a4e3ab95577933c

Contents?: true

Size: 1.05 KB

Versions: 45

Compression:

Stored size: 1.05 KB

Contents

require 'fileutils'

module Prick::SubCommand
  def self.init(dir, name, title, database, username)
    if dir
      !File.exist?(dir) or raise Prick::Error, "Directory #{dir} exists"
      FileUtils.mkdir_p(dir)
      Dir.chdir(dir)
    else
      dir = "."
    end
    name ||= File.basename(Dir.getwd)
    title ||= name
    database ||= name
    username ||= name

    Command.command %(
      git init .
      cp -a #{SHARE_PATH}/init/. .
      git add .
      git commit -am "Initial import"
    ), fail: false

    Command.status == 0 or raise Prick::Fail, "Init script failed"

    state = State.new
    state.name = name
    state.title = title
    state.prick_version = PrickVersion.new VERSION
    state.version = PrickVersion.new("0.0.0")
    state.environment = :development
    state.database = database
    state.username = username
    state.save

    Command.command %(
      set -e
      git commit -am "Release 0.0.0"
      git tag v0.0.0
    ), fail: false

    Command.status == 0 or raise Prick::Fail, "Init script failed"

    [dir, state]
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
prick-0.29.2 lib/prick/subcommand/prick-init.rb
prick-0.29.1 lib/prick/subcommand/prick-init.rb
prick-0.29.0 lib/subcommand/prick-init.rb
prick-0.28.1 lib/subcommand/prick-init.rb
prick-0.28.0 lib/subcommand/prick-init.rb
prick-0.27.2 lib/subcommand/prick-init.rb
prick-0.27.1 lib/subcommand/prick-init.rb
prick-0.27.0 lib/subcommand/prick-init.rb
prick-0.26.0 lib/subcommand/prick-init.rb
prick-0.25.2 lib/subcommand/prick-init.rb
prick-0.25.1 lib/subcommand/prick-init.rb
prick-0.25.0 lib/subcommand/prick-init.rb
prick-0.24.0 lib/subcommand/prick-init.rb
prick-0.23.0 lib/subcommand/prick-init.rb
prick-0.22.0 lib/subcommand/prick-init.rb
prick-0.21.3 lib/subcommand/prick-init.rb
prick-0.21.2 lib/subcommand/prick-init.rb
prick-0.21.1 lib/subcommand/prick-init.rb
prick-0.21.0 lib/subcommand/prick-init.rb
prick-0.20.28 lib/subcommand/prick-init.rb