Contributing to Outstatic
March 19, 2024 · View on GitHub
-
Before jumping into a PR be sure to search existing PRs or issues for an open or closed item that relates to your submission.
-
If you can't get something to work the way you expect, open a question in our discussion forums.
-
If you are interested in adding a feature or improving the code, please start a discussion about it first.
-
Here's a summary of the monorepo structure:
. #root of the repository ├──── apps │ └──── dev # development blog using the monorepo's version of `outstatic` │ └──── web # Outstatic's website: https://outstatic.com ├──── examples │ └──── blog # example blog using the latest `outstatic` release └──── packages └──── outstatic # the actual library codeNote: changes to
/apps/devshould be copied over to/examples/blog.
Developing
- The development branch is
canary. - All pull requests should be opened against
canary. - Note: Offline development is very limited. Outstatic relies heavily on making calls to the GitHub API.
To develop locally:
-
Install the GitHub CLI.
-
Create a fork of the Outstatic repository:
gh repo fork avitorio/outstaticWhen prompted: 'Would you like to clone the fork?' answer
Yand pressEnter. -
Enable pnpm:
corepack enable pnpm -
Install the dependencies with:
pnpm install
Setting up Outstatic
There are a few particularities to how Outstatic works. Since most editor actions (creating collections, editing documents, etc...) result in commits, you should avoid editor originated commits being added to your development branches. Ideally, when developing, point your OST_REPO_BRANCH to a different branch than the one you are working on.
- We recommend developing the library together with the
outstatic-dev-bloglocated at/apps/dev. For that you should create a.env.localfile in that folder and add the following environment variables:OST_GITHUB_ID=YOUR_GITHUB_OAUTH_ID OST_GITHUB_SECRET=YOUR_GITHUB_OAUTH_SECRET OST_REPO_SLUG=outstatic OST_REPO_BRANCH=main OST_CONTENT_PATH=outstatic/content OST_MONOREPO_PATH=apps/dev
Continue developing
- Create a new branch:
git checkout -b MY_BRANCH_NAME origin/canary - Start developing and watch for code changes:
The above command will tell turborepo to only load thepnpm devoutstaticlibrary and theoutstatic-dev-blogproject. - When your changes are finished, commit them to the branch:
git add . git commit -m "DESCRIBE_YOUR_CHANGES_HERE" - To open a pull request you can use the GitHub CLI which automatically forks and sets up a remote branch. Follow the prompts when running:
gh pr create
That's it. We will review your PR and hopefully integrate it in the project. Thank you for your help!
Other details
GraphQL Schema
We use graphql-codegen to generate queries, mutations and other GraphQL related code. Whenever you create new queries or mutations, you should go to the /packages/outstatic folder and run:
pnpm graphql-codegen
Deploying to Vercel
You can deploy the outstatic-dev-blog to Vercel by adding a new project with the following configuration:
-
Set the Root Directory to
apps/dev -
On the Build and Output Settings section add the following to your
Build Command:cd ../.. && pnpm turbo run build --scope=outstatic-dev-blog --include-dependencies --no-deps -
Setup your Environment Variables:
OST_GITHUB_ID=YOUR_GITHUB_OAUTH_ID OST_GITHUB_SECRET=YOUR_GITHUB_OAUTH_SECRET OST_REPO_SLUG=outstatic OST_REPO_BRANCH=main OST_CONTENT_PATH=outstatic/content OST_MONOREPO_PATH=apps/devKeep in mind that, if you want to log in to your Outstatic Dashboard on Vercel, you should probably create a different GitHub OAuth App from the one you use for local development, since the callback url is going to be different.