theatre/CONTRIBUTING.md

265 lines
7.4 KiB
Markdown
Raw Normal View History

2021-06-21 14:06:23 +02:00
# Contributing to Theatre.js
2021-10-06 12:49:04 +02:00
## Development workflow
2021-10-05 13:56:42 +02:00
2021-10-06 12:49:04 +02:00
### Setting up the environment
2021-10-06 12:49:04 +02:00
Make sure you have [`node 14+`](https://nodejs.org/) installed:
```sh
2021-10-05 13:56:42 +02:00
$ node -v
> v14.0.0
```
2021-10-06 12:49:04 +02:00
and [`yarn 1.22+`](https://classic.yarnpkg.com/en/):
```sh
2021-10-05 13:56:42 +02:00
$ yarn -v
> 1.22.10
```
2021-10-06 12:49:04 +02:00
Then clone the repo:
```sh
# for SSH:
$ git clone git@github.com:<github-username>/theatre.git
# for HTTPS:
$ git clone https://github.com/<github-username>/theatre.git
2021-10-05 13:56:42 +02:00
$ cd theatre
```
2021-10-06 12:49:04 +02:00
And fetch the dependencies with yarn:
2021-10-05 13:56:42 +02:00
```sh
2021-10-06 12:49:04 +02:00
$ yarn
```
- Notes about Yarn:
- This project uses [yarn workspaces](https://yarnpkg.com/features/workspaces)
so `npm install` will not work.
- This repo uses Yarn v2. You don't have to install yarn v2 globally. If you
do have yarn 1.22.10+ on your machine, yarn will automatically switch to v2
when you `cd` into theatre. Read more about Yarn v2
[here](https://yarnpkg.com/).
2021-10-06 12:49:04 +02:00
### Hacking with `playground`
2021-10-05 13:56:42 +02:00
The quickest way to start tweaking things is to run the `playground` package.
```sh
$ cd ./packages/playground
$ yarn serve
2022-02-28 13:15:27 +01:00
# or, shortcut:
$ cd root
$ yarn playground
2021-10-05 13:56:42 +02:00
```
The playground is a bunch of ready-made projects that you can run to experiment
with Theatre.js. It also contains the project's end-to-end tests.
2021-10-02 00:42:34 +02:00
Read more at
[`./packages/playground/README.md`](./packages/playground/README.md).
2021-10-06 12:49:04 +02:00
### Hacking with `examples/`
Other than `playground`, the [`examples/`](./examples) folder contains a few
small projects that use Theatre.js with [parcel](https://parceljs.org),
[Create react app](create-react-app.dev), and other build tools. This means that
unlike `playground`, you have to build all the packages before running the
examples.
2021-10-06 12:49:04 +02:00
You can do that by running the `build` command at the root of the repo:
```sh
$ yarn build
```
Then build any of the examples:
2021-10-06 12:49:04 +02:00
```
$ cd examples/dom-cra
$ yarn start
```
2022-02-28 13:15:27 +01:00
### Running unit/integration tests
2021-10-06 12:49:04 +02:00
We use a single [jest](https://jestjs.io/) setup for the repo. The tests files
have the `.test.ts` or `.test.tsx` extension.
2021-10-06 12:49:04 +02:00
You can run the tests at the root of the repo:
```sh
$ yarn test
# or run them in watch mode:
$ yarn test --watch
```
2022-02-28 13:15:27 +01:00
### Running end-to-end tests
End-to-end tests are hosted in the playground package. More details
[there](./packages/playground/README.md).
2022-02-28 13:15:27 +01:00
2021-10-06 12:49:04 +02:00
### Type checking
The packages in this repo have full typescript coverage, so you should be able
to get diagnostics and intellisense if your editor supports typescript.
2021-10-06 12:49:04 +02:00
You can also run a typecheck of the whole repo from the root:
```sh
$ yarn typecheck
# or in watch mode:
$ yarn typecheck --watch
```
- If you're using VSCode, we have a ["Typescript watch"](./.vscode/tasks.json)
task for VSCode that you can use by
[running](https://code.visualstudio.com/Docs/editor/tasks) "Run Task ->
Typescript watch".
- If you wish to contribute code without typescript annotations, that's totally
fine. We're happy to add the annotations to your PR.
2021-10-06 12:49:04 +02:00
### Linting
We're using a minimal [ESLint](https://code.visualstudio.com/Docs/editor/tasks)
setup for linting. If your editor supports ESLint, you should get diagnostics as
you code. You can also run the lint command from the root of the repo:
2021-10-06 12:49:04 +02:00
```sh
$ yarn lint:all
```
Some lint rules have
[autofix](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems),
so you can run:
2021-10-06 12:49:04 +02:00
```sh
$ yarn lint:all --fix
```
### Publishing to npm
Currently all packages (except for [`@theatre/r3f`](./packages/r3f/)) share the
same version number. In order to publish to npm, you can run the `release`
script from the root of the repo:
2021-10-06 12:49:04 +02:00
```sh
$ yarn release x.y.z # npm publish version x.y.z
$ yarn release x.y.z-dev.w # npm publish version x.y.z-dev.w and tag it as "dev"
$ yarn release x.y.z-rc.w # npm publish version x.y.z-rc.w and tag it as "rc"
```
2022-02-05 18:14:40 +01:00
2021-10-05 13:56:42 +02:00
## Project structure
2021-10-06 12:49:04 +02:00
The [monorepo](https://en.wikipedia.org/wiki/Monorepo) consists of:
2021-10-02 00:42:34 +02:00
- `@theatre/core` The core animation library at
[`./theatre/core`](./theatre/core).
- `@theatre/studio` The visual editor at
[`./theatre/studio`](./theatre/studio).
- `@theatre/dataverse` The reactive dataflow library at
[`./packages/dataverse`](./packages/dataverse).
- `@theatre/react` Utilities for using Theatre.js with React at
[`./packages/react`](./packages/react).
- `@theatre/r3f` The react-three-fiber extension at
[`./packages/r3f`](./packages/r3f).
- `playground` The playground explained [above](#hacking-with-playground),
located at [`./packages/playground`](./packages/playground)
- `examples/` \* A bunch of [examples](#hacking-with-examples) at
[./examples](./examples).
In addition, each package may contain a `dotEnv/` folder that holds some
dev-related files, like bundle configuration, lint setup, etc.
2021-10-06 12:49:04 +02:00
## Commands
2021-10-06 10:21:55 +02:00
These commands are available at the root workspace:
```sh
2021-10-05 13:56:42 +02:00
# Run the playground. It's a shortcut for `cd ./playground; yarn run serve`
2021-10-06 12:49:04 +02:00
$ yarn playground
2021-10-05 13:56:42 +02:00
# Run all the tests.
2021-10-06 12:49:04 +02:00
$ yarn test
2021-10-05 13:56:42 +02:00
# Run tests in watch mode.
2021-10-06 12:49:04 +02:00
$ yarn test --watch
2021-10-05 13:56:42 +02:00
# Typecheck all the packages
2021-10-06 12:49:04 +02:00
$ yarn typecheck
# Typecheck all the packages in watch mode
$ yarn typecheck --watch
2021-10-05 13:56:42 +02:00
# Run eslint on the repo
2021-10-06 12:49:04 +02:00
$ yarn lint:all
2021-10-05 13:56:42 +02:00
# Run eslint and auto fix
2021-10-06 12:49:04 +02:00
$ yarn lint:all --fix
# Build all the packages
$ yarn build
2021-10-05 13:56:42 +02:00
```
> Yarn passes all extra parameters to the internal scripts. So, for example, if
> you wish to run the tests in watch mode, you can run `yarn test --watch`.
## Documentation
The libraries come bundled with typescript definitions with TSDoc comments. You
can explore the API if your editor is configured to display TSDoc comments.
Other references
2022-09-29 14:06:43 +02:00
- [Documentation: https://www.theatrejs.com/docs](https://www.theatrejs.com/docs)
- [API docs: https://www.theatrejs.com/docs/latest/api](https://www.theatrejs.com/docs/latest/api)
2021-10-06 13:01:55 +02:00
## What to contribute
You can contribute with:
- Bug fixes
- Feature suggestions
- Features implementations
2022-09-29 14:06:43 +02:00
- [Documentation](https://github.com/theatre-js/website/) (or write/record
tutorials of your own which we'll showcase)
- Create examples projects for your own particular dev stack (eg. using
Pixie/Vue/THREE.js/Babylon/etc)
2021-10-06 13:01:55 +02:00
Another great way to help is to join our
[community](https://discord.gg/bm9f8F9Y9N) and chime in on questions and share
ideas.
2021-10-06 13:01:55 +02:00
### Helping with outstanding issues
Feel free to chime in on any
[issue](https://github.com/theatre-js/theatre/issues). We have labeled some with
["Help wanted"](https://github.com/theatre-js/theatre/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22)
or
["Good first issue"](https://github.com/theatre-js/theatre/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22good+first+issue%22)
if you're just getting started with the codebase.
2021-10-06 13:01:55 +02:00
2022-02-10 10:04:01 +01:00
## Sending pull requests
We use Github's regular PR workflow. Basically fork the repo, push your commits,
and send a pull request.
2022-02-10 10:04:01 +01:00
If you're a core contributor and have write access to the repo, you should
submit your pull requests from a branch rather than a personal fork. The naming
convention for these branches should be:
2022-02-10 10:04:01 +01:00
- `(feature|hotfix|docs)/[identifier]` or
- an autogenerated branch name from a Github issue (On an issue without a PR,
look under the "Development" sidebar heading for a "create a branch link")
Squash & merge should be preferred most of the time to keep the main branch clean, unless the commit history is relevant, in which case rebase should be used.
Always update your feature branch with a rebase from the main branch to make sure that you don't accidentally break main with an undetected conflict.
Branches belonging to merged PRs should be deleted.