Class: Utopia::Command::Site::Create
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Utopia::Command::Site::Create
- Defined in:
- lib/utopia/command/site.rb
Overview
Create a local site.
Instance Method Summary collapse
-
#invoke(parent) ⇒ Object
self.example = "utopia --in www.example.com site create".
Instance Method Details
#invoke(parent) ⇒ Object
self.example = "utopia --in www.example.com site create"
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/utopia/command/site.rb', line 32 def invoke(parent) destination_root = parent.root $stderr.puts "Setting up initial site in #{destination_root} for Utopia v#{Utopia::VERSION}..." Setup::Site::DIRECTORIES.each do |directory| FileUtils.mkdir_p(File.join(destination_root, directory)) end Find.find(Setup::Site::ROOT) do |source_path| # What is this doing? destination_path = File.join(destination_root, source_path[Setup::Site::ROOT.size..-1]) if File.directory?(source_path) FileUtils.mkdir_p(destination_path) else unless File.exist? destination_path FileUtils.copy_entry(source_path, destination_path) end end end Setup::Site::CONFIGURATION_FILES.each do |configuration_file| destination_path = File.join(destination_root, configuration_file) buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION) File.open(destination_path, "w") { |file| file.write(buffer) } end Dir.chdir(destination_root) do puts "Setting up site in #{destination_root}..." if `which bundle`.strip != '' puts "Generating initial package list with bundle..." system("bundle", "install", "--binstubs") or fail "could not install bundled gems" end if `which git`.strip == "" $stderr.puts "Now is a good time to learn about git: http://git-scm.com/" elsif !File.exist?('.git') puts "Setting up git repository..." system("git", "init") or fail "could not create git repository" system("git", "add", ".") or fail "could not add all files" system("git", "commit", "-q", "-m", "Initial Utopia v#{Utopia::VERSION} site.") or fail "could not commit files" end end name = `git config user.name || whoami`.chomp puts puts " #{name},".ljust(78) puts "Thank you for using Utopia!".center(78) puts "We sincerely hope that Utopia helps to".center(78) puts "make your life easier and more enjoyable.".center(78) puts "" puts "To start the development server, run:".center(78) puts "rake server".center(78) puts "" puts "For extreme productivity, please consult the online documentation".center(78) puts "https://github.com/ioquatix/utopia".center(78) puts " ~ Samuel. ".rjust(78) end |