Skip to content

Commit

Permalink
Consolidating bin shell scripts, cake bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Apr 11, 2012
1 parent 3a52f88 commit 789e08c
Show file tree
Hide file tree
Showing 57 changed files with 6,474 additions and 5,994 deletions.
25 changes: 11 additions & 14 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fs = require('fs')
# Helpers

ask = (q, fn) ->
console.log("\n#{q}")
console.log("\n\033[1;33m#{q}\033[0m")
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on 'data', (path) ->
Expand All @@ -17,6 +17,15 @@ replaceProcess = (cmd) ->

# Tasks

task 'bootstrap', 'update bootstrap', (options) ->
console.log [
"\n\033[1;31mIf you haven't already:\033[0m"
"\n git clone git://github.com/twitter/bootstrap.git"
"\n Modify less/bootstrap.less to customize package."
].join("\n")
ask 'Where is your bootstrap clone?', (path) ->
replaceProcess("bin/client.sh bootstrap '#{path}'")

task 'install', 'install dependencies', (options) ->
invoke('install:node')
invoke('install:ruby')
Expand All @@ -36,19 +45,7 @@ task 'new', 'create a new project', (options) ->
url = url.match(/.+@github.com:.+\/(.+)\.git/)
if url
[ url, name ] = url
cmd = [
"cd ../"
"git init #{name}"
"cd #{name}"
"git remote add origin #{url}"
"git remote add template git://github.com/winton/node_template.git"
"git fetch template"
"git merge template/master"
"cake install"
"echo \"\n\\033[1;32mSuccess!\\033[0m\n\""
"echo \"\\033[1;33mStart your server:\\033[0m cd ../#{name} && cake start\n\""
].join(' && ')
replaceProcess(cmd)
replaceProcess("bin/client.sh new '#{name}' '#{url}'")
else
console.log('Unrecognized Github repo SSH URL.')

Expand Down
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
client: bin/client.sh
server: bin/server.sh
client: bin/client.sh start
server: bin/server.sh start
39 changes: 37 additions & 2 deletions bin/client.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
#!/bin/bash

cd client
stasis -p ../public -d
# If command is 'start' and (development or no env specified)
if [ $1 = 'start' ] && ([ "$NODE_ENV" = 'development' ] || [ -z "$STATE" ]); then
cd client
stasis -p ../public -d
fi

# If command is 'start' and production
if [ $1 = 'start' ] && [ "$NODE_ENV" = 'production' ]; then
cd client
stasis -p ../public
fi

# If command is 'new'
if [ $1 = 'new' ]; then
cd ../ && \
git init $2 && \
cd $2 && \
git remote add origin $3 && \
git remote add template git://github.com/winton/node_template.git && \
git fetch template && \
git merge template/master && \
cake install && \
echo -e "\n\033[1;32mSuccess!\033[0m" && \
echo -e "\n\033[1;33mStart your server:\033[0m cd ../$1 && cake start\n"
fi

# If command is 'bootstrap'
if [ $1 = 'bootstrap' ]; then
pwd=`pwd`
cd $2
make bootstrap
cp -f bootstrap/css/bootstrap.css $pwd/client/css/lib
cp -f bootstrap/css/bootstrap-responsive.css $pwd/client/css/lib
rm -rf $pwd/client/js/lib/bootstrap
mkdir -p $pwd/client/js/lib/bootstrap
cp -f bootstrap/js/*.js $pwd/client/js/lib/bootstrap
fi
6 changes: 0 additions & 6 deletions bin/production.sh

This file was deleted.

12 changes: 11 additions & 1 deletion bin/server.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/bin/bash

./node_modules/.bin/supervisor -e 'js|coffee' -w 'server,node_modules' server/app.js
# If command is 'start' and (development or no env specified)
if [ $1 = 'start' ] && ([ "$NODE_ENV" = 'development' ] || [ -z "$STATE" ]); then
./node_modules/.bin/supervisor -e 'js|coffee' -w 'server,node_modules' server/app.js
fi

# If command is 'start' and production
if [ $1 = 'start' ] && [ "$NODE_ENV" = 'production' ]; then
export NODE_PATH=/usr/lib/node_modules
export NODE_ENV=production
PORT=$2 /usr/bin/node server/app.js >> log/production.$1.log 2>&1
fi
Loading

0 comments on commit 789e08c

Please sign in to comment.