module Clayoven::Init

Entry point for clayoven init

It copies the dist directory from the source tree to the new project, invokes git init and npm i. Having node.js installed is a prerequisite.

Public Class Methods

dist_location() click to toggle source

Location of the dist directory

# File lib/clayoven/init.rb, line 11
def self.dist_location
  File.join(__dir__, *%w[.. .. dist])
end
init(destdir = ".") click to toggle source

The entry point for ‘clayoven init’. Does a ‘cp -rv #{distdir} #{destdir}“, ’git init’, and ‘yarn install’.

# File lib/clayoven/init.rb, line 16
def self.init(destdir = ".")
  puts "[#{"INIT".yellow}]: Populating directory with clayoven starter project"
  FileUtils.mkdir_p "#{destdir}/.clayoven"
  Dir.chdir destdir do
    FileUtils.cp_r "#{dist_location}/.", "."
    `git init 2>/dev/null`
    system "yarn install >/dev/null"
    Process.waitall
    Clayoven::Toplevel.main(is_aggressive: true)
  end
  puts "[#{"INIT".green}]: Initialization finished. Run `clayoven httpd` in #{destdir} to see your website"
end