#!/usr/bin/env ruby
require "pathname"
require "rake"

include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path("../../",  __FILE__)
CACHE    = "#{ENV['HOME']}/.cache/yarn/ood-shell-app"

chdir APP_ROOT do
  # This script is a starting point to setup your application.
  # Add necessary setup steps to this file:

  puts "\n== Building Shell App =="

  puts "\n== Installing dependencies =="
  rm_rf "node_modules"
  sh "npm install --production --prefix tmp yarn"
  sh "tmp/node_modules/yarn/bin/yarn --production install --flat --cache-folder #{CACHE}"

  puts "\n== Restarting application server =="
  touch "tmp/restart.txt"
  puts ""
end
