Class: Utopia::Command::Site::Create
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Utopia::Command::Site::Create
- Defined in:
- lib/utopia/command.rb
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”
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/utopia/command.rb', line 91 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::SYMLINKS.each do |path, target| FileUtils.ln_s(target, File.join(destination_root, path), force: true) 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") 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") system("git", "add", ".") system("git", "commit", "-q", "-m", "Initial Utopia v#{Utopia::VERSION} site.") 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 |