Follow these instructions to set up your development environment, which you need to do before you start contributing code to this project.
Note: The installation steps assume you are using a Unix-like shell. If you are using Windows, you will need to use copy
instead of cp
.
-
Install Node.js. The recommended way is to Node through nvm. You can also install node.js version 16.14.2 directly from the Node.js website.
-
Fork the p5.js Web Editor repository into your own GitHub account.
-
Clone your new fork of the repository from GitHub onto your local computer.
$ git clone https://github.com/YOUR_USERNAME/p5.js-web-editor.git
-
If you are using nvm, run
$ nvm use 16.14.2
to set your Node version to 16.14.2 -
Ensure your npm version is set to 8.5.0. If it isn't, run
npm install -g [email protected]
to install it. -
Navigate into the project folder and install all its necessary dependencies with npm.
$ cd p5.js-web-editor $ npm install
-
Install MongoDB and make sure it is running
- For Mac OSX with homebrew:
brew tap mongodb/brew
thenbrew install mongodb-community
and finally start the server withbrew services start mongodb-community
or you can visit the installation guide here Installation Guide For MacOS - For Windows and Linux: MongoDB Installation
- For Mac OSX with homebrew:
-
$ cp .env.example .env
-
(Optional) Update
.env
with necessary keys to enable certain app behaviors, i.e. add Github ID and Github Secret if you want to be able to log in with Github.- See the GitHub API Configuration section for information on how to authenticate with Github.
- See the S3 Bucket Configuration section for information on how to set up an S3 bucket
-
Run
$ npm run fetch-examples
to download the example sketches into a user called 'p5'. Note that you need to configure your GitHub Credentials, which you can do by following the Github API Configuration section. -
Enable Prettier in your text editor by following this guide.
-
$ npm start
-
Navigate to http://localhost:8000 in your browser
-
Install the React Developer Tools
-
Open and close the Redux DevTools using
ctrl+h
, and move them withctrl+w
Note: The installation steps assume you are using a Unix-like shell. If you are using Windows, you will need to use copy
instead of cp
.
Using Docker, you can have a complete, consistent development environment without having to manually install dependencies such as Node, Mongo, etc. It also helps isolate these dependencies and their data from other projects that you may have on the same computer that use different/conflicting versions, etc.
Note that this takes up a significant amount of space on your machine. Make sure you have at least 5GB free.
- Install Docker for your operating system
- Install Docker Desktop
- Clone this repository and cd into it
$ docker-compose -f docker-compose-development.yml build
- Note: Depending on which version of Docker Compose you are using, the base command will be either
docker-compose
ordocker compose
. More information about it can be found in Docker Compose's documentation for their V1 to V2 transition.
- Note: Depending on which version of Docker Compose you are using, the base command will be either
$ cp .env.example .env
- (Optional) Update
.env
with necessary keys to enable certain app behaviors, i.e. add Github ID and Github Secret if you want to be able to log in with Github.- See the GitHub API Configuration section for information on how to authenticate with Github.
- See the S3 Bucket Configuration section for information on how to set up an S3 bucket
$ docker-compose -f docker-compose-development.yml run --rm app npm run fetch-examples
- note that you need to configure your GitHub Credentials, which you can do by following the Github API Configuration section.- Enable Prettier in your text editor by following this guide.
Now, anytime you wish to start the server with its dependencies, you can run:
$ docker-compose -f docker-compose-development.yml up
- Navigate to http://localhost:8000 in your browser
To open a terminal/shell in the running Docker server (i.e. after docker-compose up
has been run):
$ docker-compose -f docker-compose-development.yml exec app bash -l
If you don't have the full server environment running, you can launch a one-off container instance (and have it automatically deleted after you're done using it):
$ docker-compose -f docker-compose-development.yml run app --rm bash -l
See this configuration guide for information about how to configure your own S3 bucket. These instructions were adapted from this gist.
Note that this is optional unless you are working on the part of the application that allows a user to upload images, videos, etc.
In this application, GitHub credentials are used for:
- Authentication with GitHub
- Importing the p5.js examples to your local database
- Rendering the 404 pages
If you are working on a part of the application that requires one of the above uses, then you will need to get GitHub API credentials.
When you go to the Developer settings in your GitHub account, you will see that you can create two types of Apps: GitHub Apps
and OAuth Apps
(differences between GitHub Apps and OAuth Apps). This project requires you to make an OAuth App
. After clicking on "New OAuth App", you will need to fill in the following fields:
- Application name:
p5.js Web Editor - Local
- Homepage URL:
http://localhost:8000
- Authorization Callback URL:
http://localhost:8000/auth/github/callback
Once you've created a new OAuth app, update your .env
:
GITHUB_ID={GITHUB_ID}
GITHUB_SECRET={GITHUB_SECRET}
If you would like to learn more about what you can do with the GitHub API, you can look at the API documentation.