Setting Up Jetpack Developer Environment

Breaking the flow of Python posts I have made so far by writing a little bit about Jetpack (a product from Automattic, the company I work for).

This post covers how you can set up Jetpack Developer Environment locally. The first step is to install gitnode, npm, homebrew on your computer. Next install composer and yarn using homebrew as follows:

$ brew install composer
$ brew install yarn

Without Docker

Note: Skip this step if you’ll use the same docker dev environment that is used by Jetpack dev team!

Have a working WordPress installation with one of the popular local servers like MAMP, Vagrants, etc.

Clone Jetpack repo by going into the plugins folder wp-content/plugins/ in your WordPress installation and cd into it using cd jetpack.

Finally, enter yarn build and once that finishes, your Jetpack dev environment is ready.

With Docker

Download and install Docker on your machine. Next, simply clone the Jetpack repo anywhere on your computer and then cd into it using cd jetpack.

Next enter yarn docker:up. When that completes, your Jetpack dev environment will be ready. Just go to localhost in your web browser.

At this point, you’re all done. You can now start contributing to it.

Errors

If you run into any errors with yarn build or yarn docker:up, that’s probably because you cloned a forked repo which is not up to date with master.

To fix that, simply add a new remote called upstream that links to the original repo:

$ git remote add upstream https://github.com/Automattic/jetpack.git

And then fetch the updated code and merge it with your local master branch as follows:

$ git fetch upstream
$ git checkout master
$ git merge upstream/master

Now try yarn build again and everything should work just fine.