Skip to content

Commit

Permalink
fix: 🐛 master
Browse files Browse the repository at this point in the history
规范版本管理
  • Loading branch information
陈家敬 committed Oct 3, 2020
1 parent ded325b commit 5ce7160
Show file tree
Hide file tree
Showing 3 changed files with 730 additions and 31 deletions.
46 changes: 37 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ $ yarn add good-mock -D
data (可多级目录和多个 js 文件)中 `.js` 中文件格式如下:
其中 `mock/data`中参数是用于设置数据 mock 接口,以 k-v 的方式进行设置,接口的 HTTP 方法通过在 key 中进行指定,支持的 HTTP 方法有:`['GET', 'POST', 'HEAD', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH']`

### 步骤一
#### 步骤一

`./mock/data/api.js``./mock/data/user/api.js`

```javascript
module.exports = {
// GET => method , /api/info/1 =>api path , 3000 => 数据返回时间,毫秒(ms),会覆盖配置的中 resTime
'GET /api/info/1 3000': {
name: 'xxx'
"GET /api/info/1 3000": {
name: "xxx"
},

'POST /api/info': {
file: 'xxxx'
"POST /api/info": {
file: "xxxx"
}
};
```

### 步骤二
#### 步骤二

`./mock/config.js` 配置文件

```js
// mock 配置文件
module.exports = {
host: 'localhost', // host
host: "localhost", // host
port: 1234, // 端口
https: false, // 是否https 请求
resTime: 600 // 全局数据返回时间,毫秒
};
```

### 步骤三
#### 步骤三

shell 中执行

Expand All @@ -69,7 +69,7 @@ nodemon --watch mock ./node_modules/good-mock/lib/index.js

end `npm run mock `

### 参数
## 参数

`mock/index.js` 中可以接受如下参数:

Expand All @@ -79,3 +79,31 @@ end `npm run mock `
| port | number || 设置数据 mock 服务端口,默认为 1234 |
| https | boolean || 是否是 https (暂不可用) |
| resTime | number || 全局请求后数据返回时间,毫秒,默认为 500 |

### 发布

#### 提交版本

1. 修订版本号:patch 不定时会进行日常 bugfix 更新。(如果有紧急的 bugfix,则任何时候都可发布)列:`1.0.0 -> 1.0.1`

```shell
npm run patch
```

2. 次版本号:minor 一个 feature 或多个 feature 同时发布,列:`1.0.0 -> 1.1.0`

```shell
npm run minor
```

3. 主版本号:major 含有破坏性更新和新特性,不在发布周期内,列:`1.0.0 -> 2.0.0`

```shell
npm run major
```

#### 发布到 npm

```shell
npm run pub
```
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"url": "https://github.com/chenjiajing23/good-mock.git"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
"registry": "https://registry.npmjs.org"
},
"keywords": [
"mock",
Expand All @@ -33,7 +33,11 @@
"fix": "eslint src --ext .tsx,.ts --color --fix",
"test": "parcel test/index.html --out-dir test/dist --port 3000",
"mock": "npm run build && npm link good-mock && nodemon --watch mock ./dist/lib/index.js",
"gc": "git-cz"
"gc": "git-cz",
"patch": "standard-version -r patch",
"minor": "standard-version -r minor",
"major": "standard-version -r major",
"pub": "npm run build && npx git push --follow-tags origin master && npx npm publish --access=public"
},
"dependencies": {
"express": "^4.17.1",
Expand Down Expand Up @@ -76,6 +80,7 @@
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.27.3",
"rollup-watch": "^4.3.1",
"standard-version": "^9.0.0",
"typescript": "^4.0.3"
},
"config": {
Expand Down
Loading

0 comments on commit 5ce7160

Please sign in to comment.