Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

CONTRIBUTING.md

161 lines6.1 KB

1# Contributing
2​
3## Questions
4​
5If you have questions about implementation details, help, or support, please use our dedicated community forum at [GitHub Discussions](https://github.com/TanStack/db/discussions). **PLEASE NOTE:** If you choose to open an issue for your question instead, your issue may be closed and redirected to the forum.
6​
7## Reporting issues
8​
9If you have found what you think is a bug, please [file an issue](https://github.com/TanStack/db/issues/new/choose). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues may be closed and redirected to [GitHub Discussions](https://github.com/TanStack/db/discussions).
10​
11## Suggesting new features
12​
13If you are here to suggest a feature, first create an issue if it does not already exist. From there, we can discuss use cases for the feature and how it could be implemented.
14​
15## Development
16​
17If you have been assigned to fix an issue or develop a new feature, please follow these steps to get started:
18​
19- Fork this repository.
20- Use the Node.js version mentioned in `.nvmrc`.
21​
22 ```bash
23 nvm use
24 ```
25​
26- Enable [Corepack](https://nodejs.org/api/corepack.html) so the [pnpm](https://pnpm.io/) version mentioned in `package.json` is used.
27​
28 ```bash
29 corepack enable
30 ```
31​
32- Install dependencies.
33​
34 ```bash
35 pnpm install
36 ```
37​
38- Build all packages.
39​
40 ```bash
41 pnpm build
42 ```
43​
44- Run tests.
45​
46 ```bash
47 pnpm test
48 ```
49​
50- Run linting.
51​
52 ```bash
53 pnpm lint
54 ```
55​
56- Implement your changes and tests in the relevant package or example.
57- For a production change that adds, removes, or changes observable behavior,
58 extend the primary oracle when it can express the governing law. A focused
59 unit test can supplement the oracle but cannot replace it. Internal refactors
60 need no new oracle coverage when existing oracles exercise the unchanged
61 contract. For a change that is not a bug fix, a focused test alone is
62 acceptable only when an oracle is not practical. Identify the relevant
63 coverage-map entry and explain why you cannot extend its owner, create an
64 independent oracle, or add a receiving witness. See the
65 [oracle coverage map](docs/contributing/oracle-coverage.md) and
66 [Oracle Testing Rubric](docs/contributing/oracle-rubric.md).
67- For a bug fix, state how the pull request evaluated and closed the declared
68 bug class. Include the violated law, exercised histories, production paths,
69 observation checkpoints, RED/GREEN evidence, and remaining limits. A passing
70 reproduction for one trace is not sufficient. The focused-test-only exception
71 does not apply to bug fixes. Resolve known in-scope gaps before submitting.
72- Document your changes in the appropriate doc page.
73- Git stage your required changes and commit them.
74- Submit a PR for review.
75​
76### Editing the docs locally and previewing changes
77​
78The documentation for all TanStack projects is hosted on [tanstack.com](https://tanstack.com), which is a TanStack Start application (https://github.com/TanStack/tanstack.com). You need to run this app locally to preview your changes in the `TanStack/db` docs.
79​
80> [!NOTE]
81> The website fetches doc pages from GitHub in production, and searches for them at `../db/docs` in development. Your local clone of `TanStack/db` needs to be in the same directory as the local clone of `TanStack/tanstack.com`.
82​
83You can follow these steps to set up the docs for local development:
84​
851. Make a new directory called `tanstack`.
86​
87```sh
88mkdir tanstack
89```
90​
912. Enter that directory and clone the [`TanStack/db`](https://github.com/TanStack/db) and [`TanStack/tanstack.com`](https://github.com/TanStack/tanstack.com) repos.
92​
93```sh
94cd tanstack
95git clone git@github.com:TanStack/db.git
96# We probably don't need all the branches and commit history
97# from the `tanstack.com` repo, so let's just create a shallow
98# clone of the latest version of the `main` branch.
99# Read more about shallow clones here:
100# https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/#user-content-shallow-clones
101git clone git@github.com:TanStack/tanstack.com.git --depth=1 --single-branch --branch=main
102```
103​
104> [!NOTE]
105> Your `tanstack` directory should look like this:
107> ```text
108> tanstack/
109> |
110> +-- db/ (<-- this directory cannot be called anything else!)
111> |
112> +-- tanstack.com/
113> ```
114​
1153. Enter the `tanstack/tanstack.com` directory, install the dependencies, and run the app in dev mode.
116​
117```sh
118cd tanstack.com
119pnpm i
120# The app will run on http://localhost:3000 by default
121pnpm dev
122```
123​
1244. Visit http://localhost:3000/db/latest/docs/overview in the browser and see the changes you make in `tanstack/db/docs` there.
125​
126> [!WARNING]
127> You will need to update `docs/config.json` if you add a new documentation page.
128​
129### Running examples
130​
131- Make sure you've installed dependencies in the repo's root directory.
132​
133 ```bash
134 pnpm install
135 ```
136​
137- If you want to run an example against your local changes, run the relevant package build/watch command from the repo root if needed. Otherwise, examples may run against the latest published TanStack DB release.
138​
139- Run the example from the selected example directory.
140​
141 ```bash
142 pnpm dev
143 ```
144​
145#### Note on standalone execution
146​
147If you want to run an example without installing dependencies for the whole repo, follow the instructions from the example's README.md file. It will then run against the latest TanStack DB release.
148​
149## Changesets
150​
151This repo uses [Changesets](https://github.com/changesets/changesets) to automate releases. If your PR should release a new package version (patch, minor, or major), please run `pnpm changeset` and commit the generated file. If your PR affects docs, examples, styles, etc., you probably don't need to generate a changeset.
152​
153## Pull requests
154​
155Maintainers merge pull requests by squashing all commits and editing the commit message if necessary using the GitHub user interface.
156​
157Use an appropriate commit type. Be especially careful with breaking changes.
158​
159## Releases
160​
161For each new commit added to `main`, a GitHub Workflow is triggered which runs the [Changesets Action](https://github.com/changesets/action). This generates a preview PR showing the impact of all changesets. When this PR is merged, the package will be published to npm.