Created
October 4, 2012 17:27
-
-
Save michaelminter/3835118 to your computer and use it in GitHub Desktop.
New project script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Create new project dir | |
| # project --heroku --sinatra "project_name" | |
| # | |
| PROJECTS="/Users/michaelminter/Google Drive/projects" | |
| SUCCESS="$(tput bold)$(tput setaf 2)[SUCCESS]$(tput sgr0)" | |
| FAIL="$(tput bold)$(tput setaf 1)[FAILURE]$(tput sgr0)" | |
| # Sort parameters | |
| if [ $1 == '--heroku' ] | |
| then | |
| PROJECT=$2 | |
| HEROKU=true | |
| else | |
| PROJECT=$1 | |
| HEROKU=false | |
| fi | |
| # validate name, return error ([a-z\-]) if false | |
| # Check the user supplied the project name | |
| if [ $# -ne 1 ] | |
| then | |
| echo "Usage: `basename $0` [params] {project_name}" | |
| exit $E_BADARGS | |
| fi | |
| # Check if Project already exists | |
| if [ -d "$PROJECTS/$PROJECT" ]; then | |
| echo -e "A project named \"$PROJECT\" already exists. \t\t $FAIL" | |
| exit 1 | |
| fi | |
| # Make sure in project dir | |
| cd ~/Google\ Drive/projects | |
| # Create project dir | |
| echo -e "Creating project directory. \t\t $SUCCESS" | |
| mkdir $PROJECT | |
| # Open project dir | |
| cd $PROJECT | |
| # Create RVM default-use file | |
| echo -e "Creating default rvmrc file. \t\t $SUCCESS" | |
| echo "rvm 1.9.2@$PROJECT --create" > .rvmrc | |
| # Relaod project dir | |
| cd . | |
| # Initialize git | |
| echo -e "Initializing git repository. \t\t $SUCCESS" | |
| git init | |
| # Create new heroku repo | |
| if [ $HEROKU == true ] | |
| then | |
| echo -e "Creating Heroku Repository. \t\t $SUCCESS" | |
| heroku login | |
| heroku create $PROJECT | |
| fi | |
| # Create public dir | |
| mkdir -p public/javascripts/ | |
| # Update jQuery | |
| echo -e "Setting up jQuery file. \t\t $SUCCESS" | |
| curl http://code.jquery.com/jquery.js > public/javascripts/jquery.js | |
| # Add new files to git repo | |
| git add . | |
| # Initial commit | |
| echo -e "Initiating first git commit. \t\t $SUCCESS" | |
| git commit -m 'Initial commit' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment