#!/bin/bash

source ./shell/core-bash.sh

TMP=/tmp/cupboard-$RANDOM;
CBD_DIR=`pwd`;

mkdir -p $TMP; cd $TMP;

# node is required for elgatokb
function install_node ()
{
	curl http://nodejs.org/dist/v0.6.1/node-v0.6.1.tar.gz > node.tar.gz;
	tar -xf node.tar.gz; cd node-v0.6.1;
	./configure; make; make install;
}

# npm module for node.js
function install_npm ()
{
	curl http://npmjs.org/install.sh > install-npm.sh;
	chmod 755 install-npm.sh; ./install-npm.sh;
	
	# TODO - npm install
	grey "Installing cupboard NPM modules\n"
	cd $CBD_DIR;
	npm install -g;
	cd $TMP;
}


function on_confirm_n () 
{
	npm install n -g;
}

#version control for node.js
function install_n ()
{
	confirm "Would you like to install N? (manages node.js versions)" "on_confirm_n";
}



install-all node npm n

# done installing, cleanup
rm -rf $TMP;