Developer environment - JasperDhaene/codecombat GitHub Wiki
Getting started
The easy, hands-off way
If you're running Mac OS X, you can see a screencast of the process here. If you're running Ubuntu, you can see a screencast here.
These directions apply to Linux and Mac OS X. For Windows, see the paragraph near the bottom of this section.
-
Set up a GitHub account if you don't already have one.
-
(Optional) If you'd like your changes able to be integrated into the official CodeCombat repository, click the Fork button in the upper right hand corner of the page.
-
Open a terminal.
- If you've forked the repository, paste in the following command with your forked repository URL
curl https://raw.github.com/codecombat/codecombat/master/scripts/devSetup/bootstrap.sh | bash -s your_repository_url- If you haven't forked the repository, copy and paste in the following command
curl https://raw.github.com/codecombat/codecombat/master/scripts/devSetup/bootstrap.sh | bash -
Follow the prompts. This should download and install all the necessary dependencies. If you've used the script above, it will prompt you to run the command below. If you cloned the repository yourself, you can also run the script below (you may need to edit it based on your current working directory.)
sudo python ./coco/scripts/devSetup/setup.py -
Run each of these scripts in their own separate terminal window:
coco/bin/coco-mongodb(starts MongoDB, which stays running and awaits connections)coco/bin/coco-brunch(starts brunch, which stays running and watches for file changes, may need to be run as sudo to increase the ulimit if brunch fails)coco/bin/coco-dev-server(starts your local webserver, which stays running and watches for file changes)
-
Do the MongoDB database import (we're working to making this optional)
-
Go to http://localhost:3000 to see your local CodeCombat in action.
NOTE: The repository will be in the coco subdirectory. You should not run a separate git clone, as that is taken care of.
This should work on Mac and Linux, but it's brand new, so please let us know of any problems you run into. On Mac, you'll need Xcode Developer Tools. On Linux, you'll need ruby, curl, and git installed.
If you face issues with bower not being able to clone git repositories, you could try - Clone over https.
To get a sandbox copy of the CodeCombat database for your local Mongo, see Restoring a backup.
###Windows
The-fully-automatic-easy-way:
Follow the instructions from this step-by-step guide. The complete process is fully automated for all supported Windows versions.
We support the following, and only the following versions:
- Windows Vista (not yet confirmed)
- Windows 7 (tests in progress)
- Windows 8.0 (not yet confirmed)
- Windows 8.1 (not yet confirmed)
Other versions, newer then Windows XP, and not listed above, might work, but we don't guarantee that they will.
The-do-it-manual-way:
To install on Windows, follow the Windows Development Environment Setup Guide, or run the VM as detailed below. Unless you have Visual Studio C++, running the VM may be more convenient.
The-do-it-via-a-vm-way:
If you want to run the VM, you'll have to download VirtualBox, install it, then download (torrent) and import the CodeCombat Linux appliance by going to File:Import Appliance (note that occasionally the large download may be corrupted, so it's often easier to use the torrent.) The "CodeCombat" user account password is "coco". Once you have the Linux virtual machine running, the follow the directions above. To ease development, you can set up a shared folder so that you can edit files in Windows and have them accessible to the Ubuntu VM. See directions for setting up shared folders here. You can also set up bridged networking so that your server is accessible from Windows.
The do-it-yourself way
TODO: document this better
If you're on Ubuntu, check out Steve Malmskog's instructions.
- Set up a GitHub account if you don't already have one.
- Fork the CodeCombat project.
git cloneit to your computer.- Install software
- sudo npm install
- sudo npm install -g bower
- bower install ( bower install each dependency from bower.json )
- sudo npm install -g brunch
- Download MongoDB 2.5.4 and put the mongo folder in bin
- Run bin/coco-mongodb, bin/coco-brunch and bin/coco-dev-server.
- Go to http://localhost:3000 to see your local CodeCombat in action.
Working in the environment
You don't need any particular IDE to work with CodeCombat. Scott uses WebStorm, Nick uses Emacs, and George uses Sublime Text, so already the most important parts are IDE-agnostic. We need help making it friendly for Linux and Windows, though, since we all develop on Mac.
Live-coding
If Brunch is running and you have a page open to the development server and you make changes to the programming logic one way or another, Brunch will reload the page automatically. So open the page you are working on in your browser, make changes in your editor, save, and the page will refresh so you can see the changes. Try to make whatever you're working on be the first thing you see when you open the page, so you don't have to lose focus on your editor while iterating. If you edit just the styling, Brunch will apply the new styling without refreshing.
Brunch is good, but it is finicky (or possibly improperly configured). Its finicks include but are not limited to:
- Stops reloading the page properly
- Takes strangely long to compile
- Doesn't compile every file into app.js
Usually, restarting it by hitting Ctrl-C once in the Brunch terminal window will fix it. Because of the frequency of it needing restarting, it will automatically restart when terminated once, and will only really stop if it's terminated twice in a row manually.
Database
When building in the dev environment, you have a filtered copy of the live database with just the publicly available data. It may look like what you'll find on the site, but changes you make won't show up on the site. Currently, there's no easy way to transfer data you make on your dev environment back to production, so be sure to build levels you want to share on the site, not on the dev server.
Setup
Download the public CodeCombat MongoDB sandbox copy backup(updated every 10 minutes) and import it into your locally running database with the following steps. (NOTE: If you experience corruption of the download, there is a not up-to-date version here. If you go on the chatroom, we will update it if you are having problems downloading the other version.)
- Make sure the database is running on your computer (./bin/coco-mongodb).
- If the backup file is compressed, uncompress it (for instance, if it is a .tar.gz file, run
tar xzvf [filename]) - Step 2 should generate a
dumpfolder. To import this runmongorestore [path to dump]if mongorestore is in your path. If it's not and you used the script, run[path to CodeCombat folder]/bin/mongo/mongorestore [path to dump]
Third Party Services
API services we use such as MailChimp will not be accessible unless you have an API key. Generally you shouldn't need them to work on the site, but if you do then let us know and we'll see if we can get something worked out. Some systems may break without the keys, and so will need to be modified to soldier on without them.