Skip to content

Instantly share code, notes, and snippets.

@salami162
Created August 13, 2013 21:27
Show Gist options
  • Save salami162/6225859 to your computer and use it in GitHub Desktop.
Save salami162/6225859 to your computer and use it in GitHub Desktop.
Setup Dev Environment

Getting Started

This document explains how to get Node.js applications running on your machine.

Setting up a Mac

XCode

Download XCode from the Apple App Store. Once you've installed XCode, you'll also need to install the Command Line Tools for XCode. Go to XCode > Preferences, click on the Downloads tab, and install the tools from there.

Homebrew

Install homebrew. If you already have homebrew installed, you may need to run brew update. Once you've installed homebrew, you may need to close your current terminal session and start a new one before your system will recognize that brew is installed.

To verify homebrew installed correctly, run brew doctor and do what it says. You will probably need to add /usr/local/bin to your PATH in your .bash_profile. If you don't have a .bash_profile in your home directory, create one: touch ~/.bash_profile, and edit it to include this:

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Once you've done this, you should be able to run brew doctor and it should tell you that your system is "raring to brew."

> brew doctor
Your system is raring to brew.

If it tells you that something may be bad on your system, either solve it, or ask someone who uses homebrew whether it's an important error. It's best to get this right.

Install Tools

Use homebrew to install git, nginx, and hub.

# -vd is verbose and debug
# In the early days of Snow Leopard there were quite a few llvm vs. gcc bugs
#  -- so by habit, this author also adds the `--use-gcc` flag to `upgrade`s and `install`s.
#  -- your mileage may vary : brew install <package> --use-gcc -vd
brew install git -vd
brew install nginx -vd
brew install hub -vd

Install Nave

For these next steps, you should be in the directory where you plan to put the APP repo. So, if you plan to put the APP repo at ~/code/APP, then you should be in ~/code. You should make the ~/code directory if it doesn't exist (or give it another name if you'd like -- basically this is where you keep all of your "projects").

Use hub and git to download and setup nave:

cd ~/code # or whatever dir you plan to put firebird in
hub clone isaacs/nave # use hub to clone the nave repo
ln -s ~/code/nave/nave.sh /usr/local/bin/nave # put nave in path

Optional Steps

While not absolutely necessary, there are a few things you can do to potentially improve upon your workflow or code development processes. These optional steps are things that members of our team have found useful in the past, so feel free to pick and choose what works for you.

Improve your shell

Alex Sexton has a nice writeup on Forrst detailing how to Make your shell prettier with zsh, including a detailed custom prompt. It does involve switching to zsh, but there are good details about why you may wish to do just that.

If you're a bash stalwart but still want an improved prompt experience, check out Ben Alman's prompt.

Or you can install git bash-completion, and modify your .bash_profile.

brew install git bash-completion # install git bash completion.

When you're done, either source ~/.bash_profile or open a new terminal window.

EditorConfig

EditorConfig is a useful means of automatically configuring your text editor of choice with certain common values that can vary from project to project, such as whether or not indenting should be spaces or tabs, and whether that indent should be 2 or 4 characters, etc. Using this plugin will help ensure that you're matching our style guide.

The EditorConfig plugin automatically configures your editor to match the values as specified in a .editorconfig file, which can exist at a wide variety of levels. There's already one in the top level Firebird folder, so you don't need to do anything other than install the appropriate plugin for your editor.

Go check out the list of EditorConfig plugins to see if your editor is supported (including Vim, Sublime Text 2, and TextMate).


General setup for Mac and Linux

These are tasks that must be performed regardless of the operating system you're running.

Get the proper node version

You installed nave up above. Now:

nave ls  # what nodes are installed locally
nave ls-remote  # what nodes are available

# install node
nave install 0.10.15

Now, edit your .bash_profile (or other profile file) to add node to your path:

# add nave-installed version of node into path
export PATH=/usr/local/bin:/usr/local/sbin:/Users/USERNAME/.nave/installed/0.10.15/bin:$PATH;

When you're done, either source ~/.bash_profile or open a new terminal window.

> source ~/.bash_profile
> node -v
v0.10.15

> npm -v
1.2.14

Install some node things

npm install nodemon -g
npm install supervisor -g
npm install grunt-cli -g

Github

  • Create a Github account if you don't already have one

You'll need to make an ssh key in order to push to Github. When you make an ssh key, you'll also need to come up with a password. Don't forget it, as you'll have to type it in whenever you want interact with Github.

ssh-keygen -t rsa -C "email.you.told.github.about@mail.com"
cat id_rsa.pub // to see the key and to paste it into you github / account / ssh keys

Additionally, you can configure git to remember your name, email, etc.

git config --global user.name "Milo Simpson"
git config --global user.email "milo.simpson@gmail.com"
git config --global github.user milosimpson
git config --global github.token GUID-LIKE-TOKEN

If you already have a personal email address associated with your Github account, you may also want to go to your email settings on Github to add your Bazaarvoice email. Once you do this, you can choose for certain repos to send emails to your Bazaarvoice email rather than your personal email (under Notification Center).

Getting Project

You should fork the Firebird repo to your Github account. To do this, go to the repo and click the Fork button. Next, copy the git URL for your fork; it should look something like git@github.com:yourname/ontheside.git.

Now, cd to the directory where you want to put the repo and then clone the repo:

cd ~/code
git clone git@github.com:yourname/ontheside.git
cd ontheside

# your fork is now "origin"; add a "salami162" remote as well
git remote add salami162 git@github.com:salami162/ontheside.git

# get the latest from the salami162 remote's master branch
git pull salami162 master

In this case you will not be able to see any static files being served by nginx and the firebird application will appear unavailable in the browser.

You can resolve the problem by finding the file config/local/server-config.json and editing the following line where the port for nginx is defined as 80:

  "port"         : "80",

and change it to 8080:

  "port"         : "8080",

Your application should be happy now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment