Skip to content

Commit 010305c

Browse files
yes1amjpsong
andauthored
docs: add CONTRIBUTING.md (#84)
Co-authored-by: jpsong <[email protected]>
1 parent 4c28df9 commit 010305c

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

CONTRIBUTING.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
我们推荐使用 [pnpm](https://github.com/pnpm/pnpm) 作为包管理工具
2+
3+
## 1. 下载项目、安装依赖
4+
5+
```shell
6+
git [email protected]:open-jike/jike-sdk.git
7+
cd jike-sdk
8+
pnpm install
9+
```
10+
11+
## 2. 创建本地开发文件
12+
13+
- 新建 `playground/main.ts` 文件
14+
- 编写代码,例如:
15+
16+
```ts
17+
import { api, setApiConfig } from '../src'
18+
19+
setApiConfig({
20+
endpointId: 'jike',
21+
endpointUrl: '<jike-endpoint-url>', // 请自行替换
22+
bundleId: '<bundle-id>', // 请自行替换
23+
buildNo: '<build-no>', // 请自行替换
24+
userAgent: '<jike-sdk-user-agent>', // 请自行替换
25+
accessToken: '<access-token>', // 请自行替换
26+
appVersion: '<app-version>', // 请自行替换
27+
deviceId: '<device-id>', // 请自行替换
28+
})
29+
30+
api.topic
31+
.getTabsSquareFeed('562dfeb0daf87d13002cad92', {
32+
limit: 10,
33+
})
34+
.then((res) => {
35+
console.log('请求成功', res.data.data)
36+
})
37+
.catch((err) => {
38+
console.log('请求错误', err)
39+
})
40+
```
41+
42+
## 3. 运行本地开发文件
43+
44+
```shell
45+
pnpm run dev
46+
```
47+
48+
## 4. 测试
49+
50+
1. 新建 `tests/config.ts` 配置文件, 内容如下:
51+
52+
```ts
53+
export const config = {
54+
endpointId: 'jike',
55+
endpointUrl: '<jike-endpoint-url>', // 请自行替换
56+
bundleId: '<bundle-id>', // 请自行替换
57+
buildNo: '<build-no>', // 请自行替换
58+
userAgent: '<jike-sdk-user-agent>', // 请自行替换
59+
accessToken: '<access-token>', // 请自行替换
60+
appVersion: '<app-version>', // 请自行替换
61+
deviceId: '<device-id>', // 请自行替换
62+
}
63+
```
64+
65+
2. 新建测试文件, 如 `tests/api/topic.test.ts`, 编写测试代码
66+
67+
3. 执行测试用例
68+
69+
```shell
70+
pnpm run test
71+
72+
# 测试指定的测试文件, 如只测试新增的 topic.test.ts
73+
pnpm run test topic
74+
```

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ const client = ApiClient(apiConfig)
151151
client.users.profile()
152152
```
153153

154+
## Contributing [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
155+
156+
see [CONTRIBUTING.md](./CONTRIBUTING.md)
157+
154158
## Sponsors
155159

156160
<p align="center">

0 commit comments

Comments
 (0)