Skip to content

Latest commit

 

History

History
71 lines (46 loc) · 2.9 KB

CONTRIBUTING.md

File metadata and controls

71 lines (46 loc) · 2.9 KB

Contributing to the JavaScript client

This is a quick guide to help you contribute to the JavaScript client of Mpl Bubblegum.

Getting started

Ensure you have pnpm installed and run the following command to install the client's dependencies.

pnpm install

You can then run the following commands to build, test and lint the client.

# Build the client.
pnpm build

# Test the client (requires building first).
pnpm build && pnpm test

# Test a specific file or set of files.
pnpm build && pnpm test test/somefile.test.js
pnpm build && pnpm test test/somePattern*

# Lint and/or format the client.
pnpm lint:fix
pnpm format:fix

When something changes in the program(s), make sure to run pnpm generate in the root directory, to re-generate the clients accordingly.

Set up local environment variables

Some of the tests are using a devnet ReadAPI RPC to ensure the Read API client is working as expected. To run these tests locally, you'll need to set up the READ_API_RPC_DEVNET environment variable. Simply add a .env file in the clients/js directory and add the variable to it.

cd clients/js
cp .env.example .env

# Edit the .env file and add the following line.
READ_API_RPC_DEVNET="INSERT_RPC_ENDPOINT_HERE"

Deploying the JavaScript client

You can deploy a new version of the JavaScript client by manually dispatching the "Deploy JS Client" workflow in the GitHub Actions tab of the repository.

Click on the "Actions" tab, then on the "Deploy JS Client" workflow, then on the "Run workflow" dropdown. Select your options before clicking on the final "Run workflow" button inside the dropdown body.

For this to work, some initial setup is required on the repository as explained below.

Setting up GitHub actions

To deploy JavaScript clients using GitHub actions, we first need the following secret variables to be set up on the repository.

  • NPM_TOKEN — An access token that can publish your packages to NPM.
  • VERCEL_TOKEN — An access token that can deploy to Vercel.
  • VERCEL_ORG_ID — The ID of the Vercel organization you want to deploy to.

Then, we'll need to create a new GitHub environment called js-client-documentation for the generated documentation of the JavaScript client. We can then select the main branch only and add the following secret variable to this specific environment.

  • VERCEL_PROJECT_ID — The ID of the Vercel project you want to deploy to. The convention for Metaplex is to create a new Vercel project named mpl-bubblegum-js-docs with the following deployment settings:

    • Build Command: pnpm run build:docs
    • Output Directory: docs
    • Install Command: pnpm install
    • Development Command: None

With all that set up, you can now run the "Deploy JS Client" workflow by dispatching it from the GitHub UI.