Skip to content

Commit 5b53551

Browse files
docs: add a CONTRIBUTING.md (#280)
1 parent 3065001 commit 5b53551

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

CONTRIBUTING.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
## Setting up the environment
2+
3+
This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable).
4+
Other package managers may work but are not officially supported for development.
5+
6+
To setup the repository, run:
7+
8+
```bash
9+
yarn
10+
yarn build
11+
```
12+
13+
This will install all the required dependencies and build output files to `dist/`.
14+
15+
## Modifying/Adding code
16+
17+
Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
18+
`src/lib/` and `examples/` directories are exceptions and will never be overridden.
19+
20+
## Adding and running examples
21+
22+
All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or
23+
added to.
24+
25+
```bash
26+
// add an example to examples/<your-example>.ts
27+
28+
#!/usr/bin/env -S npm run tsn -T
29+
30+
```
31+
32+
```
33+
chmod +x examples/<your-example>.ts
34+
# run the example against your api
35+
yarn tsn -T examples/<your-example>.ts
36+
```
37+
38+
## Using the repository from source
39+
40+
If you’d like to use the repository from source, you can either install from git or link to a cloned repository:
41+
42+
To install via git:
43+
44+
```bash
45+
npm install --save git+ssh://[email protected]:anthropics/anthropic-sdk-typescript.git
46+
```
47+
48+
Alternatively, to link a local copy of the repo:
49+
50+
```bash
51+
# Clone
52+
git clone https://www.github.com/anthropics/anthropic-sdk-typescript
53+
cd anthropic-sdk-typescript
54+
55+
# With yarn
56+
yarn link
57+
cd ../my-package
58+
yarn link @anthropic-ai/sdk
59+
60+
# With pnpm
61+
pnpm link --global
62+
cd ../my-package
63+
pnpm link -—global @anthropic-ai/sdk
64+
```
65+
66+
## Running tests
67+
68+
Most tests will require you to [setup a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
69+
70+
```bash
71+
npx prism path/to/your/openapi.yml
72+
```
73+
74+
```bash
75+
yarn run test
76+
```
77+
78+
## Linting and formatting
79+
80+
This repository uses [prettier](https://www.npmjs.com/package/prettier) and
81+
[eslint](https://www.npmjs.com/package/eslint) to format the code in the repository.
82+
83+
To lint:
84+
85+
```bash
86+
yarn lint
87+
```
88+
89+
To format and fix all lint issues automatically:
90+
91+
```bash
92+
yarn fix
93+
```
94+
95+
## Publishing and releases
96+
97+
Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If
98+
the changes aren't made through the automated pipeline, you may want to make releases manually.
99+
100+
### Publish with a GitHub workflow
101+
102+
You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/anthropics/anthropic-sdk-typescript/actions/workflows/publish-npm.yml). This will require a setup organization or repository secret to be set up.
103+
104+
### Publish manually
105+
106+
If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on
107+
the environment.

0 commit comments

Comments
 (0)