Technology Stack Overview
Quality is assured by Jest unit tests.
Building SourceCred Locally
First, run the following commands to clone and build SourceCred:
git clone https://github.com/sourcecred/sourcecred.git
Visual Studio Code
SourceCred Instance Setup and Usage
Next, run the following commands to clone the SourceCred Instance:
git clone https://github.com/sourcecred/template-instance.git
Using this instance as a starting point, you can update the config to include the plugins you want, pointing at the data you care about. We recommend setting up your instance locally first and make sure its working before pushing your changes to master and using the Github Action.
Get Yarn and then run
yarnto install SourceCred and dependencies.
Enable the plugins you want to use by updating the
sourcecred.jsonfile. e.g. to enable all the plugins:
- If you are using the GitHub or Discord plugin, copy the
.env.examplefile to a
cp .env.example .env
- Follow the steps in the plugin guides below to setup
the config files and generate access tokens for each plugin and then paste
them into the
.envfile after the
Using A Modified Backend
You'll likely want to test out your modified version of SourceCred on an instance you're familiar with.
A convenient way to do that is to create an alias for your altered version of SourceCred.
Here's an example of how to do so in a bash shell:
# While in the SourceCred directory reopsitory
alias scdev='node "$SC_REPOSITORY_DIR"/packages/sourcecred/bin/sourcecred.js'
# Then go back to the Template Instance directory, for example:
# Run the `sourcecred go` command, in your instance, using your modified code.
Initialize the configs a. change https://github.com/sourcecred/template-instance/blob/master/config/grain.json#L2 to be non-zero b. change https://github.com/sourcecred/template-instance/blob/master/sourcecred.json#L2 to be ["sourcecred/discourse"]
from your local template-instance clone, run
scdev servego to the url it outputs.
The GitHub plugin loads GitHub repositories.
You can specify the repositories to load in
The Github Action automatically has its own GITHUB_TOKEN, but if you need to
load data from the GitHub plugin locally, you must have a GitHub API key in your
.env file as
SOURCECRED_GITHUB_TOKEN=<token> (copy the
for reference). The key should be read-only without any special scopes or
permissions (unless you are loading a private GitHub repository, in which case
the key needs access to your private repositories).
You can generate a GitHub API key here.
The Discourse plugin loads Discourse forums; currently, only one forum can be
loaded in any single instance. This does not require any special API keys or
permissions. You just need to set the server url in
The Discord plugin loads Discord servers, and mints Cred on Discord reactions.
In order for SourceCred to access your Discord server, you need to generate a
"bot token" and paste it in the
.env file as
SOURCECRED_DISCORD_TOKEN=<token> (copy the
.env.example file for reference).
You will also need to add it to your GitHub Action secrets.
The full instructions for setting up the Discord plugin can be found in the Discord plugin page in the SourceCred documentation.
To deactivate a plugin, just remove it from the
bundledPlugins array in the
sourcecred.json file. You can also remove its
directory for good measure.