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 'npm i'.

# File lib/clayoven/init.rb, line 14
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`
    fork { exec 'npm i >/dev/null' }
    Clayoven::Toplevel.main(is_aggressive: true)
  puts "[#{'INIT'.green}]: Initialization finished. Run `clayoven httpd` in #{destdir} to see your website"