Commit d6e49efd by 刘旭阳

Merge branch '0.1.1' into 'master'

feat:0.0.2版本增加说明文件 See merge request !13
parents f5dfdeca ee601c00
# babel-plugin-ry-istanbul-web # babel-plugin-ry-istanbul-web
## Babel-plugin-ry-isture-web is modified by babel-plugin-istanbul
## babel-plugin-ry-istanbul-web是通过babel-plugin-istanbul修改而来
[![Coverage Status](https://coveralls.io/repos/github/istanbuljs/babel-plugin-istanbul/badge.svg?branch=master)](https://coveralls.io/github/istanbuljs/babel-plugin-istanbul?branch=master) ## babel-plugin-istanbul documentation can be found here
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) https://www.npmjs.com/package/babel-plugin-istanbul
[![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com) ## babel-plugin-istanbul 文档可参考
http://www.npmdoc.org/babel-plugin-istanbulzhongwenwendangbabel-plugin-istanbul-jszhongwenjiaochengjiexi.html
_Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_. ### npm install it:
A Babel plugin that instruments your code with Istanbul coverage.
It can instantly be used with [karma-coverage](https://github.com/karma-runner/karma-coverage) and mocha on Node.js (through [nyc](https://github.com/bcoe/nyc)).
__Note:__ This plugin does not generate any report or save any data to any file;
it only adds instrumenting code to your JavaScript source code.
To integrate with testing tools, please see the [Integrations](#integrations) section.
## 新增目录istanlibment
此目录为插桩方法,日后优化时使用,现使用原版本文件
新增方法:增量插桩两种方式
Serve packjson启动增加配置到时候不需要可以更改IS_PITCHING_PILE为false即可
"serve": "cross-env IS_PITCHING_PILE=true;cross-env INCREMENT=true;cross-env BRANCH=origin/master; vue-cli-service serve --mode dev"
IS_PITCHING_PILE是否插桩
INCREMENT是否过滤增量文件
BRANCH需要对比的分支isPitchingPile为true时默认origin/master当ISPITCHINGPILE为false的时候可以不穿
第一种
[
babel-plugin-ry-istanbul,
{
extension: ['.js', '.vue'],
instrmenttation: { IS_PITCHING_PILE: true, INCREMENT: true, BRANCH: 'origin/master' }
}
]
]
## 新增全局传值方法
IS_PITCHING_PILE是否插桩
INCREMENT是否插桩增量代码
BRANCH需要对比的分支isPitchingPile为true时默认origin/master当ISPITCHINGPILE为false的时候可以不穿
全局配置:如.env.dev文件下增加全局变量插桩,babel-plugin-ry-istanbul同样可以取到对应值,如VUE全局变量前记得添加VUE_APP_前缀,其他则需要看使用框架是否需要添加前缀
## 新增parse-diff
新增parse-diff组件源码
## Usage
Install it:
``` ```
npm install --save-dev babel-plugin-ry-istanbul npm install --save-dev babel-plugin-ry-istanbul
``` ```
### npm安装方法
Add it to `.babelrc` in test mode:
```js
{
"env": {
"test": {
"plugins": [ "istanbul" ]
}
}
}
``` ```
npm install --save-dev babel-plugin-ry-istanbul
Optionally, use [cross-env](https://www.npmjs.com/package/cross-env) to set
`NODE_ENV=test`:
```json
{
"scripts": {
"test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.js"
}
}
``` ```
## Integrations * npm address:https://www.npmjs.com/package/babel-plugin-istanbul-ry
* Gitlab address:https://git.minrow.com/ry/babel-plugin-ry-istanbul
### karma * npm 地址:https://www.npmjs.com/package/babel-plugin-istanbul-ry
* Gitlab 地址:https://git.minrow.com/ry/babel-plugin-ry-istanbul
It _just works_ with Karma. First, make sure that the code is already transpiled by Babel (either using `karma-babel-preprocessor`, `karma-webpack`, or `karma-browserify`). Then, simply set up [karma-coverage](https://github.com/karma-runner/karma-coverage) according to the docs, but __don’t add the `coverage` preprocessor.__ This plugin has already instrumented your code, and Karma should pick it up automatically.
## Increasing the parameter indicates instrmenttation
It has been tested with [bemusic/bemuse](https://codecov.io/github/bemusic/bemuse) project, which contains ~2400 statements. | parameter | explain | type | An optional value | default | other description |
| ------------------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | -------- | ----------------------------------------------|
### mocha on node.js (through nyc) | IS_PITCHING_PILE | Whether in pile | String/Boolean | true (String、Boolean) /false (String、Boolean) | false (Boolean) | false (String, Boolean) true (String) disables instrumentation, true (Boolean) allows it |
| INCREMENT | Whether to filter delta files | String/Boolean | true (String、Boolean) /false (String、Boolean) | false (Boolean) | true (String, Boolean) looks at incremental code, false (String) looks at the full code (including incremental code), false (Boolean) looks at the full code, and does not display new or changed statements. |
Configure Mocha to transpile JavaScript code using Babel, then you can run your tests with [`nyc`](https://github.com/bcoe/nyc), which will collect all the coverage report. | BRANCH | git diff the branch to compare against | String | The branch name to compare against | origin/master | Don't wear it when the IS PITCHING PILE is false |
babel-plugin-ry-istanbul respects the `include`/`exclude` configuration options from nyc, ## 增加参数说明instrmenttation
but you also need to __configure NYC not to instrument your code__ by adding these settings in your `package.json`: | 参数 | 说明 | 类型 | 可选值 | 默认值 | 其他说明 |
| ------------------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | -------- | ---------- |
```js | IS_PITCHING_PILE | 是否插桩 | String/Boolean | true (String、Boolean) /false (String、Boolean) | false(Boolean) | false (String、Boolean) true(String)禁止插桩,true (Boolean)允许插桩 |
"nyc": { | INCREMENT | 是否过滤增量文件 | String/Boolean | true (String、Boolean) /false (String、Boolean) | false(Boolean) | true(String、Boolean)看增量代码,false(String)看全量代码(包括增量代码), false(Boolean)看全量代码,不显示“新增或变更语句” |
"sourceMap": false, | BRANCH | git diff需要对比的分支 | String | 需要对比的分支名 | origin/master | 当IS_PITCHING_PILE为false的时候可以不穿 |
"instrument": false
}, ## Increment interpolation
*In the case of `vue`, This is done via babel.config.js's plugins configuration, as shown in the following code:
``` ```
plugins: [
## Ignoring files [
'istanbul-ry',
You don't want to cover your test files as this will skew your coverage results. You can configure this by providing plugin options matching nyc's [`exclude`/`include` rules](https://github.com/bcoe/nyc#excluding-files): {
extension: ['.js', '.vue'],
```json instrmenttation: {
{ BRANCH: 'origin/master',
"env": { INCREMENT: 'true',
"test": { IS_PITCHING_PILE: true
"plugins": [
["istanbul", {
"exclude": [
"**/*.spec.js"
]
}]
]
} }
} }
} ]
]
``` ```
It is recommended to comment out the plugins when the code is uploaded or the instrmenttation does not transfer any value
If you don't provide options in your Babel config, the plugin will look for `exclude`/`include` config under an `"nyc"` key in `package.json`. ## 增量插桩
*`vue`为例,通过babel.config.js的plugins配置即可完成如下代码所示:
You can also use [istanbul's ignore hints](https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes) to specify specific lines of code to skip instrumenting. ```
plugins: [
## Source Maps [
'istanbul-ry',
By default, this plugin will pick up inline source maps and attach them to the instrumented code such that code coverage can be remapped back to the original source, even for multi-step build processes. This can be memory intensive. Set `useInlineSourceMaps` to prevent this behavior. {
extension: ['.js', '.vue'],
```json instrmenttation: {
{ BRANCH: 'origin/master',
"env": { INCREMENT: 'true',
"test": { IS_PITCHING_PILE: true
"plugins": [
["istanbul", {
"useInlineSourceMaps": false
}]
]
} }
} }
}
```
If you're instrumenting code programatically, you can pass a source map explicitly.
```js
import babelPluginIstanbul from 'babel-plugin-ry-istanbul';
function instrument(sourceCode, sourceMap, fileName) {
return babel.transform(sourceCode, {
filename,
plugins: [
[babelPluginIstanbul, {
inputSourceMap: sourceMap
}]
] ]
}) ]
}
``` ```
上传代码时需要将plugins注释掉即可,也可不传输instrmenttation参数,推荐注释后上传
## Credit where credit is due
## Description of New Features
The approach used in `babel-plugin-ry-istanbul` was inspired by [Thai Pangsakulyanont](https://github.com/dtinth)'s original library [`babel-plugin-__coverage__`](https://github.com/dtinth/babel-plugin-__coverage__). * Add the instrmenttation parameter
1. IS_PITCHING_PILE determines if code coverage can be instrumentalized
## `babel-plugin-ry-istanbul` for enterprise 2. Use the BRANCH parameter to identify the git branch you want to compare against
3. Use INCREMENT to determine if you want to see the incremental code
Available as part of the Tidelift Subscription. ## 新增功能说明
* 新增instrmenttation参数
The maintainers of `babel-plugin-ry-istanbul` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-babel-plugin-ry-istanbul?utm_source=npm-babel-plugin-ry-istanbul&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) 1. 通过IS_PITCHING_PILE判断是否可以插装收集代码覆盖率
2. 通过BRANCH参数确认需要对比的git分支
3. 通过INCREMENT判断是否需要查看增量代码
## other description
This plugin needs to be used with [ry-istanbul-web](https://www.npmjs.com/package/ry-istanbul-web) and [istanbul-middleware-ry](https://www.npmjs.com/package/istanbul-middleware-ry)
## 其他说明
本插件需配合[ry-istanbul-web](https://www.npmjs.com/package/ry-istanbul-web)[istanbul-middleware-ry](https://www.npmjs.com/package/istanbul-middleware-ry)一起使用
## ry-istanbul-web
* NPM address:https://www.npmjs.com/package/ry-istanbul-web
* GitLab address:https://git.minrow.com/ry/istanbul-web
* NPM地址:https://www.npmjs.com/package/ry-istanbul-web
* GitLab地址:https://git.minrow.com/ry/istanbul-web
* [ry-istok-web](https://www.npmjs.com/package/ry-istanbul-web) is modified from [istanbul](https://www.npmjs.com/package/istanbul), adding the changeLists array of window.__coverage__ for viewing the incremental code
* [ry-istok-web](https://www.npmjs.com/package/ry-istanbul-web)是由[istanbul](https://www.npmjs.com/package/istanbul)改装而来,增加window.__coverage__的changeLists数组用于查看增量代码
## istanbul-middleware-ry
* NPM address:https://www.npmjs.com/package/istanbul-middleware-ry
* GitLab address:https://git.minrow.com/ry/istanbul-middleware-ry
* NPM地址:https://www.npmjs.com/package/istanbul-middleware-ry
* GitLab地址:https://git.minrow.com/ry/istanbul-middleware-ry
* The [istanbul-middleware-ry](https://www.npmjs.com/package/istanbul-middleware-ry) istanbul viewing service is transformed from [istanbul-middleware](https://www.npmjs.com/package/istanbul-middleware), and the start service is added. The istanbul code coverage can be collected and viewed through the global command `coverage -n` start service.
* [istanbul-middleware-ry](https://www.npmjs.com/package/istanbul-middleware-ry) istanbul查看服务由[istanbul-middleware](https://www.npmjs.com/package/istanbul-middleware)改造而来,增加启动服务,可通过全局命令`coverage -n`启动服务收集并查看istanbul代码覆盖率。
{ {
"name": "babel-plugin-ry-istanbul-web", "name": "babel-plugin-istanbul-ry",
"version": "0.1.2", "version": "0.0.2",
"author": "Thai Pangsakulyanont @dtinth", "author": "Thai Pangsakulyanont @dtinth",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"description": "A babel plugin that adds istanbul instrumentation to ES6 code", "description": "A babel plugin that adds istanbul instrumentation to ES6 code",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment