$
This commit is contained in:
571
node_modules/istanbul-lib-instrument/CHANGELOG.md
generated
vendored
Normal file
571
node_modules/istanbul-lib-instrument/CHANGELOG.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
node_modules/istanbul-lib-instrument/LICENSE
generated
vendored
Normal file
24
node_modules/istanbul-lib-instrument/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
Copyright 2012-2015 Yahoo! Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Yahoo! Inc. nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21
node_modules/istanbul-lib-instrument/README.md
generated
vendored
Normal file
21
node_modules/istanbul-lib-instrument/README.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
## istanbul-lib-instrument
|
||||
|
||||
[](https://travis-ci.org/istanbuljs/istanbul-lib-instrument)
|
||||
|
||||
Istanbul instrumenter library.
|
||||
|
||||
Version 1.1.x now implements instrumentation using `Babel`. The implementation is inspired
|
||||
by prior art by @dtinth as demonstrated in the `__coverage__` babel plugin.
|
||||
|
||||
It provides 2 "modes" of instrumentation.
|
||||
|
||||
- The old API that is mostly unchanged (except for incompatibilities noted) and
|
||||
performs the instrumentation using babel as a library.
|
||||
|
||||
- A `programVisitor` function for the Babel AST that can be used by a Babel plugin
|
||||
to emit instrumentation for ES6 code directly without any source map
|
||||
processing. This is the preferred path for babel users. The Babel plugin is
|
||||
called `babel-plugin-istanbul`.
|
||||
|
||||
Incompatibilities and changes to instrumentation behavior can be found in
|
||||
[v0-changes.md](v0-changes.md).
|
22
node_modules/istanbul-lib-instrument/dist/constants.js
generated
vendored
Normal file
22
node_modules/istanbul-lib-instrument/dist/constants.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.MAGIC_VALUE = exports.MAGIC_KEY = exports.SHA = void 0;
|
||||
|
||||
var _crypto = require("crypto");
|
||||
|
||||
var _semver = require("semver");
|
||||
|
||||
var _package = require("../package.json");
|
||||
|
||||
// function to use for creating hashes
|
||||
const SHA = 'sha1'; // name of coverage data magic key
|
||||
|
||||
exports.SHA = SHA;
|
||||
const MAGIC_KEY = '_coverageSchema'; // name of coverage data magic value
|
||||
|
||||
exports.MAGIC_KEY = MAGIC_KEY;
|
||||
const MAGIC_VALUE = (0, _crypto.createHash)(SHA).update(_package.name + '@' + (0, _semver.major)(_package.version)).digest('hex');
|
||||
exports.MAGIC_VALUE = MAGIC_VALUE;
|
42
node_modules/istanbul-lib-instrument/dist/index.js
generated
vendored
Normal file
42
node_modules/istanbul-lib-instrument/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createInstrumenter = createInstrumenter;
|
||||
Object.defineProperty(exports, "programVisitor", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _visitor.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "readInitialCoverage", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _readCoverage.default;
|
||||
}
|
||||
});
|
||||
exports.defaultOpts = void 0;
|
||||
|
||||
var _schema = require("@istanbuljs/schema");
|
||||
|
||||
var _instrumenter = _interopRequireDefault(require("./instrumenter"));
|
||||
|
||||
var _visitor = _interopRequireDefault(require("./visitor"));
|
||||
|
||||
var _readCoverage = _interopRequireDefault(require("./read-coverage"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* createInstrumenter creates a new instrumenter with the
|
||||
* supplied options.
|
||||
* @param {Object} opts - instrumenter options. See the documentation
|
||||
* for the Instrumenter class.
|
||||
*/
|
||||
function createInstrumenter(opts) {
|
||||
return new _instrumenter.default(opts);
|
||||
}
|
||||
|
||||
const defaultOpts = _schema.defaults.instrumenter;
|
||||
exports.defaultOpts = defaultOpts;
|
182
node_modules/istanbul-lib-instrument/dist/instrumenter.js
generated
vendored
Normal file
182
node_modules/istanbul-lib-instrument/dist/instrumenter.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _core = require("@babel/core");
|
||||
|
||||
var _schema = require("@istanbuljs/schema");
|
||||
|
||||
var _visitor = _interopRequireDefault(require("./visitor"));
|
||||
|
||||
var _readCoverage = _interopRequireDefault(require("./read-coverage"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
Copyright 2012-2015, Yahoo Inc.
|
||||
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Instrumenter is the public API for the instrument library.
|
||||
* It is typically used for ES5 code. For ES6 code that you
|
||||
* are already running under `babel` use the coverage plugin
|
||||
* instead.
|
||||
* @param {Object} opts optional.
|
||||
* @param {string} [opts.coverageVariable=__coverage__] name of global coverage variable.
|
||||
* @param {boolean} [opts.preserveComments=false] preserve comments in output
|
||||
* @param {boolean} [opts.compact=true] generate compact code.
|
||||
* @param {boolean} [opts.esModules=false] set to true to instrument ES6 modules.
|
||||
* @param {boolean} [opts.autoWrap=false] set to true to allow `return` statements outside of functions.
|
||||
* @param {boolean} [opts.produceSourceMap=false] set to true to produce a source map for the instrumented code.
|
||||
* @param {Array} [opts.ignoreClassMethods=[]] set to array of class method names to ignore for coverage.
|
||||
* @param {Function} [opts.sourceMapUrlCallback=null] a callback function that is called when a source map URL
|
||||
* is found in the original code. This function is called with the source file name and the source map URL.
|
||||
* @param {boolean} [opts.debug=false] - turn debugging on
|
||||
* @param {array} [opts.parserPlugins] - set babel parser plugins, see @istanbuljs/schema for defaults.
|
||||
*/
|
||||
class Instrumenter {
|
||||
constructor(opts = {}) {
|
||||
this.opts = { ..._schema.defaults.instrumenter,
|
||||
...opts
|
||||
};
|
||||
this.fileCoverage = null;
|
||||
this.sourceMap = null;
|
||||
}
|
||||
/**
|
||||
* instrument the supplied code and track coverage against the supplied
|
||||
* filename. It throws if invalid code is passed to it. ES5 and ES6 syntax
|
||||
* is supported. To instrument ES6 modules, make sure that you set the
|
||||
* `esModules` property to `true` when creating the instrumenter.
|
||||
*
|
||||
* @param {string} code - the code to instrument
|
||||
* @param {string} filename - the filename against which to track coverage.
|
||||
* @param {object} [inputSourceMap] - the source map that maps the not instrumented code back to it's original form.
|
||||
* Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the
|
||||
* coverage to the untranspiled source.
|
||||
* @returns {string} the instrumented code.
|
||||
*/
|
||||
|
||||
|
||||
instrumentSync(code, filename, inputSourceMap) {
|
||||
if (typeof code !== 'string') {
|
||||
throw new Error('Code must be a string');
|
||||
}
|
||||
|
||||
filename = filename || String(new Date().getTime()) + '.js';
|
||||
const {
|
||||
opts
|
||||
} = this;
|
||||
let output = {};
|
||||
const babelOpts = {
|
||||
configFile: false,
|
||||
babelrc: false,
|
||||
ast: true,
|
||||
filename: filename || String(new Date().getTime()) + '.js',
|
||||
inputSourceMap,
|
||||
sourceMaps: opts.produceSourceMap,
|
||||
compact: opts.compact,
|
||||
comments: opts.preserveComments,
|
||||
parserOpts: {
|
||||
allowReturnOutsideFunction: opts.autoWrap,
|
||||
sourceType: opts.esModules ? 'module' : 'script',
|
||||
plugins: opts.parserPlugins
|
||||
},
|
||||
plugins: [[({
|
||||
types
|
||||
}) => {
|
||||
const ee = (0, _visitor.default)(types, filename, {
|
||||
coverageVariable: opts.coverageVariable,
|
||||
coverageGlobalScope: opts.coverageGlobalScope,
|
||||
coverageGlobalScopeFunc: opts.coverageGlobalScopeFunc,
|
||||
ignoreClassMethods: opts.ignoreClassMethods,
|
||||
inputSourceMap
|
||||
});
|
||||
return {
|
||||
visitor: {
|
||||
Program: {
|
||||
enter: ee.enter,
|
||||
|
||||
exit(path) {
|
||||
output = ee.exit(path);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}]]
|
||||
};
|
||||
const codeMap = (0, _core.transformSync)(code, babelOpts);
|
||||
|
||||
if (!output || !output.fileCoverage) {
|
||||
const initialCoverage = (0, _readCoverage.default)(codeMap.ast) ||
|
||||
/* istanbul ignore next: paranoid check */
|
||||
{};
|
||||
this.fileCoverage = initialCoverage.coverageData;
|
||||
this.sourceMap = inputSourceMap;
|
||||
return code;
|
||||
}
|
||||
|
||||
this.fileCoverage = output.fileCoverage;
|
||||
this.sourceMap = codeMap.map;
|
||||
const cb = this.opts.sourceMapUrlCallback;
|
||||
|
||||
if (cb && output.sourceMappingURL) {
|
||||
cb(filename, output.sourceMappingURL);
|
||||
}
|
||||
|
||||
return codeMap.code;
|
||||
}
|
||||
/**
|
||||
* callback-style instrument method that calls back with an error
|
||||
* as opposed to throwing one. Note that in the current implementation,
|
||||
* the callback will be called in the same process tick and is not asynchronous.
|
||||
*
|
||||
* @param {string} code - the code to instrument
|
||||
* @param {string} filename - the filename against which to track coverage.
|
||||
* @param {Function} callback - the callback
|
||||
* @param {Object} inputSourceMap - the source map that maps the not instrumented code back to it's original form.
|
||||
* Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the
|
||||
* coverage to the untranspiled source.
|
||||
*/
|
||||
|
||||
|
||||
instrument(code, filename, callback, inputSourceMap) {
|
||||
if (!callback && typeof filename === 'function') {
|
||||
callback = filename;
|
||||
filename = null;
|
||||
}
|
||||
|
||||
try {
|
||||
const out = this.instrumentSync(code, filename, inputSourceMap);
|
||||
callback(null, out);
|
||||
} catch (ex) {
|
||||
callback(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* returns the file coverage object for the last file instrumented.
|
||||
* @returns {Object} the file coverage object.
|
||||
*/
|
||||
|
||||
|
||||
lastFileCoverage() {
|
||||
return this.fileCoverage;
|
||||
}
|
||||
/**
|
||||
* returns the source map produced for the last file instrumented.
|
||||
* @returns {null|Object} the source map object.
|
||||
*/
|
||||
|
||||
|
||||
lastSourceMap() {
|
||||
return this.sourceMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var _default = Instrumenter;
|
||||
exports.default = _default;
|
87
node_modules/istanbul-lib-instrument/dist/read-coverage.js
generated
vendored
Normal file
87
node_modules/istanbul-lib-instrument/dist/read-coverage.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = readInitialCoverage;
|
||||
|
||||
var _core = require("@babel/core");
|
||||
|
||||
var _schema = require("@istanbuljs/schema");
|
||||
|
||||
var _constants = require("./constants");
|
||||
|
||||
function getAst(code) {
|
||||
if (typeof code === 'object' && typeof code.type === 'string') {
|
||||
// Assume code is already a babel ast.
|
||||
return code;
|
||||
}
|
||||
|
||||
if (typeof code !== 'string') {
|
||||
throw new Error('Code must be a string');
|
||||
} // Parse as leniently as possible
|
||||
|
||||
|
||||
return (0, _core.parseSync)(code, {
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
parserOpts: {
|
||||
allowImportExportEverywhere: true,
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
sourceType: 'script',
|
||||
plugins: _schema.defaults.instrumenter.parserPlugins
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function readInitialCoverage(code) {
|
||||
const ast = getAst(code);
|
||||
let covScope;
|
||||
(0, _core.traverse)(ast, {
|
||||
ObjectProperty(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
|
||||
if (!node.computed && path.get('key').isIdentifier() && node.key.name === _constants.MAGIC_KEY) {
|
||||
const magicValue = path.get('value').evaluate();
|
||||
|
||||
if (!magicValue.confident || magicValue.value !== _constants.MAGIC_VALUE) {
|
||||
return;
|
||||
}
|
||||
|
||||
covScope = path.scope.getFunctionParent() || path.scope.getProgramParent();
|
||||
path.stop();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (!covScope) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const result = {};
|
||||
|
||||
for (const key of ['path', 'hash', 'gcv', 'coverageData']) {
|
||||
const binding = covScope.getOwnBinding(key);
|
||||
|
||||
if (!binding) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const valuePath = binding.path.get('init');
|
||||
const value = valuePath.evaluate();
|
||||
|
||||
if (!value.confident) {
|
||||
return null;
|
||||
}
|
||||
|
||||
result[key] = value.value;
|
||||
}
|
||||
|
||||
delete result.coverageData[_constants.MAGIC_KEY];
|
||||
delete result.coverageData.hash;
|
||||
return result;
|
||||
}
|
121
node_modules/istanbul-lib-instrument/dist/source-coverage.js
generated
vendored
Normal file
121
node_modules/istanbul-lib-instrument/dist/source-coverage.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.SourceCoverage = void 0;
|
||||
|
||||
var _istanbulLibCoverage = require("istanbul-lib-coverage");
|
||||
|
||||
function cloneLocation(loc) {
|
||||
return {
|
||||
start: {
|
||||
line: loc && loc.start.line,
|
||||
column: loc && loc.start.column
|
||||
},
|
||||
end: {
|
||||
line: loc && loc.end.line,
|
||||
column: loc && loc.end.column
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* SourceCoverage provides mutation methods to manipulate the structure of
|
||||
* a file coverage object. Used by the instrumenter to create a full coverage
|
||||
* object for a file incrementally.
|
||||
*
|
||||
* @private
|
||||
* @param pathOrObj {String|Object} - see the argument for {@link FileCoverage}
|
||||
* @extends FileCoverage
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
|
||||
class SourceCoverage extends _istanbulLibCoverage.classes.FileCoverage {
|
||||
constructor(pathOrObj) {
|
||||
super(pathOrObj);
|
||||
this.meta = {
|
||||
last: {
|
||||
s: 0,
|
||||
f: 0,
|
||||
b: 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
newStatement(loc) {
|
||||
const s = this.meta.last.s;
|
||||
this.data.statementMap[s] = cloneLocation(loc);
|
||||
this.data.s[s] = 0;
|
||||
this.meta.last.s += 1;
|
||||
return s;
|
||||
}
|
||||
|
||||
newFunction(name, decl, loc) {
|
||||
const f = this.meta.last.f;
|
||||
name = name || '(anonymous_' + f + ')';
|
||||
this.data.fnMap[f] = {
|
||||
name,
|
||||
decl: cloneLocation(decl),
|
||||
loc: cloneLocation(loc),
|
||||
// DEPRECATED: some legacy reports require this info.
|
||||
line: loc && loc.start.line
|
||||
};
|
||||
this.data.f[f] = 0;
|
||||
this.meta.last.f += 1;
|
||||
return f;
|
||||
}
|
||||
|
||||
newBranch(type, loc) {
|
||||
const b = this.meta.last.b;
|
||||
this.data.b[b] = [];
|
||||
this.data.branchMap[b] = {
|
||||
loc: cloneLocation(loc),
|
||||
type,
|
||||
locations: [],
|
||||
// DEPRECATED: some legacy reports require this info.
|
||||
line: loc && loc.start.line
|
||||
};
|
||||
this.meta.last.b += 1;
|
||||
return b;
|
||||
}
|
||||
|
||||
addBranchPath(name, location) {
|
||||
const bMeta = this.data.branchMap[name];
|
||||
const counts = this.data.b[name];
|
||||
/* istanbul ignore if: paranoid check */
|
||||
|
||||
if (!bMeta) {
|
||||
throw new Error('Invalid branch ' + name);
|
||||
}
|
||||
|
||||
bMeta.locations.push(cloneLocation(location));
|
||||
counts.push(0);
|
||||
return counts.length - 1;
|
||||
}
|
||||
/**
|
||||
* Assigns an input source map to the coverage that can be used
|
||||
* to remap the coverage output to the original source
|
||||
* @param sourceMap {object} the source map
|
||||
*/
|
||||
|
||||
|
||||
inputSourceMap(sourceMap) {
|
||||
this.data.inputSourceMap = sourceMap;
|
||||
}
|
||||
|
||||
freeze() {
|
||||
// prune empty branches
|
||||
const map = this.data.branchMap;
|
||||
const branches = this.data.b;
|
||||
Object.keys(map).forEach(b => {
|
||||
if (map[b].locations.length === 0) {
|
||||
delete map[b];
|
||||
delete branches[b];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.SourceCoverage = SourceCoverage;
|
683
node_modules/istanbul-lib-instrument/dist/visitor.js
generated
vendored
Normal file
683
node_modules/istanbul-lib-instrument/dist/visitor.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
54
node_modules/istanbul-lib-instrument/package.json
generated
vendored
Normal file
54
node_modules/istanbul-lib-instrument/package.json
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "istanbul-lib-instrument",
|
||||
"version": "4.0.3",
|
||||
"description": "Core istanbul API for JS code coverage",
|
||||
"author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"release": "babel src --out-dir dist && documentation build -f md -o api.md src",
|
||||
"test": "nyc --nycrc-path=../../monorepo-per-package-nycrc.json --require=@babel/register --include=src mocha",
|
||||
"prepublish": "npm run release"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.7.5",
|
||||
"@istanbuljs/schema": "^0.1.2",
|
||||
"istanbul-lib-coverage": "^3.0.0",
|
||||
"semver": "^6.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.5",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"chai": "^4.2.0",
|
||||
"clone": "^2.1.2",
|
||||
"debug": "^4.1.1",
|
||||
"documentation": "^12.1.4",
|
||||
"js-yaml": "^3.13.1",
|
||||
"mocha": "^6.2.2",
|
||||
"nopt": "^4.0.1",
|
||||
"nyc": "^15.0.0-beta.2"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"bugs": {
|
||||
"url": "https://github.com/istanbuljs/istanbuljs/issues"
|
||||
},
|
||||
"homepage": "https://istanbul.js.org/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/istanbuljs/istanbuljs.git",
|
||||
"directory": "packages/istanbul-lib-instrument"
|
||||
},
|
||||
"keywords": [
|
||||
"coverage",
|
||||
"istanbul",
|
||||
"js",
|
||||
"instrumentation"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"gitHead": "2c6f0e24680d050503d404de0ebff53467fefbff"
|
||||
}
|
Reference in New Issue
Block a user