iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 25
1
Software Development

模組化設計系列 第 25

Day25 - 一個好的模組應該要提供的其他資訊

  • 分享至 

  • twitterImage
  •  

CI 執行結果

常見 Open source 的模組,都是使用這兩套 CI 系統。

Travis

.travis.yml

language: node_js
node_js:
  - "8"
script:
  - npm run coverage
  - npm run report-coverage

Circle CI

早期的專案都是使用 Travis 居多,但是目前幾乎一面倒向 Circle CI 了。

範例

測試涵蓋率

https://codecov.io/gh/alincode/solidity-validator.js

一個輕量的模組,通常測試涵蓋率應該要可以輕鬆的高於 95%。

lint 和 coding style check

package scripts

模組應該要設定好常用的 script,讓使用可以簡易的學會怎麼執行你的模組。

常見的 script

  • compile
  • lint
  • publish
  • test
"scripts": {
  "bootstrap": "lerna bootstrap",
  "clean": "git clean -dfqX -- ./node_modules **/{dist,node_modules}/ ./packages/*/tsconfig*tsbuildinfo",
  "compile": "tsc --build tsconfig.build.json",
  "compile:clean": "tsc --build tsconfig.build.json --clean",
  "postinstall": "npm run compile",
  "lint": "eslint packages examples --ext=js,ts",
  "lint:fix": "yarn run lint:fix:md && yarn run lint --fix",
  "lint:fix:md": "prettier --write **/*.md",
  "lint:staged": "lint-staged",
  "publish": "yarn run clean && yarn run build && lerna publish",
  "prepublishOnly": "npm run build",
  "test": "npm run lint && npm run check && npm run testonly",
  "testonly": "jest --detectOpenHandles --forceExit",
  "testonly:cov": "jest --coverage --runInBand --detectOpenHandles --forceExit",
  "testonly:watch": "jest --watch",
  "preversion": "npm test"
},

資料來源 https://github.com/Yoctol/bottender/blob/master/package.json

Roadmap

範例


上一篇
Day24 - 模組的 README 設計
下一篇
Day26 - 確保你的相依模組安全性
系列文
模組化設計30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言