Skip to content

Commit 7e7ad15

Browse files
authored
docs: document development and release workflow (#80)
## What - document setup, dependency, test, compatibility, and package workflows - mark private-codegen output as generated - document Conventional Commits and Release Please to npm ## Why Contributors need one current path from local change through release. ## Test - `bazel test //...` (8/8) - `bazel test //:test //:package_checks //e2e:sdk_parity` - `bazel run //:gazelle -- -mode=diff` - Oxfmt
1 parent 061abdc commit 7e7ad15

1 file changed

Lines changed: 56 additions & 48 deletions

File tree

CONTRIBUTING.md

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,97 @@
1-
## Setting up the environment
1+
# Contributing
22

3-
This repository uses Bazel 9.2, Node 26, and [`pnpm`](https://pnpm.io/installation).
3+
## Setup
44

5-
To set up the repository, run:
5+
Install Node 26 and [Bazelisk](https://github.com/bazelbuild/bazelisk), then
6+
enable the repository's pinned `pnpm`:
67

78
```sh
8-
$ corepack enable pnpm
9-
$ pnpm install
10-
$ pnpm lefthook install
11-
$ bazel build //:pkg
9+
npm install --global corepack@latest
10+
corepack enable pnpm
11+
pnpm install --frozen-lockfile
12+
pnpm lefthook install
13+
bazel build //:pkg
1214
```
1315

14-
This installs dependencies and builds the publishable package at `bazel-bin/package/`.
16+
The publishable package is written to `bazel-bin/package/`.
1517

16-
## Modifying/Adding code
18+
## Make changes
1719

18-
API resources are generated from the OpenAPI specification. Keep manual helpers in `src/lib/`.
20+
Handwritten client, transport, and helper code lives in `src/client.ts`,
21+
`src/core/`, `src/internal/`, and `src/lib/`. Do not edit `src/generated/`,
22+
`src/resources.ts`, or `src/resources/`; the code is produced by a private SDK
23+
codegen pipeline.
1924

20-
Run Gazelle after adding, removing, or changing TypeScript imports. Gazelle owns
21-
TypeScript sources and dependencies in `BUILD.bazel` files.
25+
Tests live beside handwritten code under `src/test/`. Compatibility and live
26+
API tests live under `e2e/`.
27+
28+
After changing TypeScript imports or adding files, update BUILD files:
2229

2330
```sh
24-
$ bazel run //:gazelle
31+
bazel run //:gazelle
2532
```
2633

27-
## Adding and running examples
34+
For a dependency change, update `package.json`, run
35+
`pnpm install --frozen-lockfile=false`, then run Gazelle. Commit
36+
`pnpm-lock.yaml` and generated `BUILD.bazel` changes.
2837

29-
Examples can be added under `examples/`.
38+
Use [Conventional Commits](https://www.conventionalcommits.org/), such as
39+
`fix: handle empty responses` or `feat: add a resource`. Release Please uses
40+
these commits to choose the next version and build the changelog.
3041

31-
```ts
32-
// add an example to examples/<your-example>.mts
42+
## Test
3343

34-
#!/usr/bin/env -S node --experimental-transform-types
35-
36-
```
44+
Run the same main test suite as CI:
3745

3846
```sh
39-
$ chmod +x examples/<your-example>.mts
40-
# run the example against your api
41-
$ node --experimental-transform-types examples/<your-example>.mts
47+
bazel test //...
4248
```
4349

44-
## Using the repository from source
45-
46-
To link a local build:
50+
Run core, package, and published-SDK compatibility gates explicitly:
4751

4852
```sh
49-
$ bazel build //:pkg
50-
$ pnpm --dir bazel-bin/package link --global
51-
$ cd ../my-package
52-
$ pnpm link --global @perplexity-ai/perplexity_ai
53+
bazel test //:test //:package_checks //e2e:sdk_parity
5354
```
5455

55-
## Running tests
56+
Validate formatting, lint, and generated BUILD files:
5657

5758
```sh
58-
$ bazel test //...
59+
pnpm lefthook run pre-commit --all-files --force --fail-on-changes
5960
```
6061

61-
## Linting and formatting
62-
63-
This repository uses [Oxfmt](https://www.npmjs.com/package/oxfmt) and
64-
[Oxlint](https://www.npmjs.com/package/oxlint) to format and lint the code.
65-
66-
To lint:
62+
Apply formatting and lint fixes:
6763

6864
```sh
69-
$ pnpm lefthook run pre-commit --all-files --force --fail-on-changes
65+
pnpm lefthook run pre-commit --all-files
7066
```
7167

72-
To format and fix all lint issues automatically:
68+
Live tests call the production API and require a token. Run only the relevant
69+
shard:
7370

7471
```sh
75-
$ pnpm lefthook run pre-commit --all-files
72+
PPLX_API_TOKEN=... bazel test //e2e/live:search --test_env=PPLX_API_TOKEN
7673
```
7774

78-
## Publishing and releases
75+
Build the publishable package:
7976

80-
Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If
81-
the changes aren't made through the automated pipeline, you may want to make releases manually.
77+
```sh
78+
bazel build //:pkg
79+
```
8280

83-
### Publish with a GitHub workflow
81+
## Release
8482

85-
You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/perplexityai/perplexity-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.
83+
Do not bump versions or publish from a development branch.
8684

87-
### Publish manually
85+
1. Merge normal PRs into `main`.
86+
2. Release Please creates or updates a `release: <version>` PR from Conventional
87+
Commits.
88+
3. Review and merge that PR. It updates the changelog and version files, then
89+
creates the `v<version>` tag and GitHub release.
90+
4. The published GitHub release triggers `Publish NPM`, which builds `//:pkg`
91+
and publishes it with npm provenance.
8892

89-
If needed, build the package with `bazel build //:pkg` and publish `bazel-bin/package` with npm.
93+
Stable versions use the `latest` npm tag. Prerelease versions use their
94+
prerelease identifier as the npm tag. Release automation requires
95+
`RELEASE_TOKEN`; npm publishing uses GitHub Actions OIDC and an npm trusted
96+
publisher for `publish-npm.yml`. For a failed upload, rerun `Publish NPM`
97+
against the existing release tag; do not create a new version.

0 commit comments

Comments
 (0)