cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.2.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

CONTRIBUTING.md

107lines · modecode

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