+# put before calles to cd
+# child scripts must be marked as chmod +x
+source ./readme-starter.sh
+# Requires: [sudo] npm install -g json
+ echo "Usage: node-starter.sh package-name"
+printf 'PACKAGE NAME: %s\n' "$packageName"
+if [ -d $packageName ]; then
+ echo "ERROR: folder ${packageName} already exists"
+ echo "Folder ${packageName} does not exist"
+BITBUCKET_USER=mitchallen
+AUTHOR_NAME='Mitch Allen'
+AUTHOR_EMAIL='npm@mitchallen.com'
+AUTHOR_URL='http://mitchallen.com'
+npmAuthor="$AUTHOR_NAME <$AUTHOR_EMAIL> ($AUTHOR_URL)"
+# Change to the package folder
+touch test/smoke-test.js
+buildReadme $NPM_SCOPE $packageName $BITBUCKET_USER
+echo "// Author: Mitch Allen" >> index.js
+echo "// Package: @${NPM_SCOPE}/${packageName}" >> index.js
+# Clone my public Gruntfile.js starter file
+gruntStarter="starter-gruntfile"
+# Note, you can change starter to anything - that's what the folder will be called
+git clone git@bitbucket.org:snippets/mitchallen/n48z6/${gruntStarter}.git
+cp $gruntStarter/Gruntfile.js .
+# Clone my public package.json starter file
+packageStarter="starter-package-json"
+# Note, you can change starter to anything - that's what the folder will be called
+git clone git@bitbucket.org:snippets/mitchallen/qjMg8/${packageStarter}.git
+cp $packageStarter/package.json .
+json -I -f package.json -e "this.name='@${NPM_SCOPE}/${packageName}'"
+json -I -f package.json -e "this.author='${npmAuthor}'"
+json -I -f package.json -e "this.repository.url='https://bitbucket.org/$BITBUCKET_USER/${packageName}.git'"
+git commit -m 'init commit'
+# Create Bitbucket Repo (THIS WILL BE PUBLIC BY DEFAULT)
+# Password retrieved from env var: BB_PASSWORD (TODO - use auth token instead)
+curl --user $BITBUCKET_USER:$BB_PASSWORD https://api.bitbucket.org/1.0/repositories --data name=$packageName
+git remote add origin git@bitbucket.org:$BITBUCKET_USER/$packageName.git
+# Reference: http://blog.kevinlee.io/2013/03/11/git-push-to-pull-from-both-github-and-bitbucket/
+# TODO - append GITHUB to Origina
+# git remote set-url origin --add git@bitbucket.org:$GITHUB_USER/$packagename.git
+git push -u origin --all # pushes up the repo and its refs for the first time
+git push origin --tags # pushes up any tags
+# Run grunt (to do a lint check)
+# Verify testing is setup
+echo "========================================================================"
+echo "* New starter project created in $packageName"
+echo "* Created PUBLIC $packageName on Bitbucket"
+echo "========================================================================"