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

CONTRIBUTING.md

186 lines7.7 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 `pnpm lint:changed` runs only the `oracle/` rules, on the oracle files that
57 your branch changes. It does not replace `pnpm lint`. If you work with a
58 coding agent, the repository's hooks return oracle lint reports to it as it
59 edits. Codex and Gemini CLI run project hooks only after you
60 trust them in `/hooks`; review them again when they change. In a linked Git
61 worktree, Codex reads project hooks from the main checkout, not from the
62 worktree, so the hooks run there only after the main checkout has them.
63​
64- Implement your changes and tests in the relevant package or example.
65- For a production change that adds, removes, or changes observable behavior,
66 extend the primary oracle when it can express the governing law. A focused
67 unit test can supplement the oracle but cannot replace it. Internal refactors
68 need no new oracle coverage when existing oracles exercise the unchanged
69 contract. For a change that is not a bug fix, a focused test alone is
70 acceptable only when an oracle is not practical. Identify the relevant
71 coverage-map entry and explain why you cannot extend its owner, create an
72 independent oracle, or add a receiving witness. See the
73 [oracle coverage map](docs/contributing/oracle-coverage.md) and
74 [Oracle Testing Rubric](docs/contributing/oracle-rubric.md).
75- For a bug fix, state how the pull request evaluated and closed the declared
76 bug class. Include the violated law, exercised histories, production paths,
77 observation checkpoints, RED/GREEN evidence, and remaining limits. A passing
78 reproduction for one trace is not sufficient. The focused-test-only exception
79 does not apply to bug fixes. Resolve known in-scope gaps before submitting.
80- Document your changes in the appropriate doc page.
81- Git stage your required changes and commit them.
82- Submit a PR for review.
83​
84### Editing the docs locally and previewing changes
85​
86The 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.
87​
88> [!NOTE]
89> 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`.
90​
91You can follow these steps to set up the docs for local development:
92​
931. Make a new directory called `tanstack`.
94​
95```sh
96mkdir tanstack
97```
98​
992. Enter that directory and clone the [`TanStack/db`](https://github.com/TanStack/db) and [`TanStack/tanstack.com`](https://github.com/TanStack/tanstack.com) repos.
100​
101```sh
102cd tanstack
103git clone git@github.com:TanStack/db.git
104# We probably don't need all the branches and commit history
105# from the `tanstack.com` repo, so let's just create a shallow
106# clone of the latest version of the `main` branch.
107# Read more about shallow clones here:
108# https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/#user-content-shallow-clones
109git clone git@github.com:TanStack/tanstack.com.git --depth=1 --single-branch --branch=main
110```
111​
112> [!NOTE]
113> Your `tanstack` directory should look like this:
115> ```text
116> tanstack/
117> |
118> +-- db/ (<-- this directory cannot be called anything else!)
119> |
120> +-- tanstack.com/
121> ```
122​
1233. Enter the `tanstack/tanstack.com` directory, install the dependencies, and run the app in dev mode.
124​
125```sh
126cd tanstack.com
127pnpm i
128# The app will run on http://localhost:3000 by default
129pnpm dev
130```
131​
1324. Visit http://localhost:3000/db/latest/docs/overview in the browser and see the changes you make in `tanstack/db/docs` there.
133​
134> [!WARNING]
135> You will need to update `docs/config.json` if you add a new documentation page.
136​
137### Running examples
138​
139- Make sure you've installed dependencies in the repo's root directory.
140​
141 ```bash
142 pnpm install
143 ```
144​
145- 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.
146​
147- Run the example from the selected example directory.
148​
149 ```bash
150 pnpm dev
151 ```
152​
153#### Note on standalone execution
154​
155If 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.
156​
157## Changesets
158​
159This 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.
160​
161During the 1.0 release candidate period, use the same Changeset types. For a
162package at `1.0.0-rc.1`, a patch produces `1.0.0-rc.1.1`, and another patch
163produces `1.0.0-rc.1.2`. A minor or major change advances the candidate number:
164`1.0.0-rc.1.2` becomes `1.0.0-rc.2`. Packages already on stable 1.x versions,
165including `@tanstack/query-db-collection` and
166`@tanstack/offline-transactions`, continue to use normal semantic versioning
167and publish under npm's `latest` tag.
168​
169## Pull requests
170​
171Maintainers merge pull requests by squashing all commits and editing the commit message if necessary using the GitHub user interface.
172​
173Use an appropriate commit type. Be especially careful with breaking changes.
174​
175## Releases
176​
177For 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.
178​
179The first 1.0 candidate Changeset enters Changesets prerelease mode through
180`pnpm run changeset:version`. Leave `.changeset/pre.json` in prerelease mode
181for subsequent candidate releases; the normal release workflow handles each
182patch or minor Changeset. When the candidates are ready for stable 1.0, run
183`pnpm changeset pre exit` and commit the resulting `.changeset/pre.json` change.
184The next Version Packages PR promotes the candidate packages to `1.0.0`.
185Already stable packages keep their versions unless a pending Changeset
186explicitly releases them. Merge that PR to publish 1.0.