mochawesome-report-generator
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -5,2 +5,6 @@ # mochawesome-report-generator changelog | ||
## [5.1.0] - 2020-04-13 | ||
### Changed | ||
- Remove react dependencies | ||
## [5.0.0] - 2020-04-10 | ||
@@ -167,3 +171,4 @@ ### Changed | ||
[Unreleased]: https://github.com/adamgruber/mochawesome-report-generator/compare/5.0.0...HEAD | ||
[Unreleased]: https://github.com/adamgruber/mochawesome-report-generator/compare/5.1.0...HEAD | ||
[5.1.0]: https://github.com/adamgruber/mochawesome-report-generator/compare/5.0.0...5.1.0 | ||
[5.0.0]: https://github.com/adamgruber/mochawesome-report-generator/compare/4.1.0...5.0.0 | ||
@@ -170,0 +175,0 @@ [4.1.0]: https://github.com/adamgruber/mochawesome-report-generator/compare/4.0.1...4.1.0 |
"use strict"; | ||
/* eslint-disable react/no-danger */ | ||
var React = require('react'); | ||
var escapeHtml = require('escape-html'); | ||
/** | ||
* Escape entities for use in HTML | ||
* | ||
* @param {string} str Input string | ||
* | ||
* @return {string} | ||
*/ | ||
var PropTypes = require('prop-types'); | ||
function MainHTML(props) { | ||
function e(str) { | ||
return escapeHtml(str).replace(/'/g, '''); | ||
} | ||
/** | ||
* Render the main report HTML to a string | ||
* | ||
* @param {object} props Report properties | ||
* @param {string} data Raw report data | ||
* @param {string} inlineScripts App JS | ||
* @param {string} inlineStyles App CSS | ||
* @param {object} options App options | ||
* @param {string} scriptsUrl URL for app JS | ||
* @param {string} stylesUrl URL for app CSS | ||
* @param {string} title Report page title | ||
* @param {boolean} useInlineAssets Whether to render JS/CSS inline | ||
* | ||
* @return {string} | ||
*/ | ||
function renderMainHTML(props) { | ||
var data = props.data, | ||
@@ -17,44 +42,10 @@ inlineScripts = props.inlineScripts, | ||
useInlineAssets = props.useInlineAssets; | ||
return React.createElement("html", { | ||
lang: "en" | ||
}, React.createElement("head", null, React.createElement("meta", { | ||
charSet: "utf-8" | ||
}), React.createElement("meta", { | ||
httpEquiv: "X-UA-Compatible", | ||
content: "IE=edge" | ||
}), React.createElement("meta", { | ||
name: "viewport", | ||
content: "width=device-width, initial-scale=1" | ||
}), React.createElement("title", null, title), useInlineAssets ? React.createElement("style", { | ||
dangerouslySetInnerHTML: { | ||
__html: inlineStyles | ||
} | ||
}) : React.createElement("link", { | ||
rel: "stylesheet", | ||
href: stylesUrl | ||
})), React.createElement("body", { | ||
"data-raw": data, | ||
"data-config": JSON.stringify(options) | ||
}, React.createElement("div", { | ||
id: "report" | ||
}), useInlineAssets ? React.createElement("script", { | ||
type: "text/javascript", | ||
dangerouslySetInnerHTML: { | ||
__html: inlineScripts | ||
} | ||
}) : React.createElement("script", { | ||
src: scriptsUrl | ||
}))); | ||
var styles = useInlineAssets ? "<style>".concat(inlineStyles, "</style>") : "<link rel=\"stylesheet\" href=\"".concat(stylesUrl, "\"/>"); | ||
var scripts = useInlineAssets ? "<script type=\"text/javascript\">".concat(inlineScripts, "</script>") : "<script src=\"".concat(scriptsUrl, "\"></script>"); | ||
var meta = '<meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1"/>'; | ||
var head = "<head>".concat(meta, "<title>").concat(e(title), "</title>").concat(styles, "</head>"); | ||
var body = "<body data-raw=\"".concat(e(data), "\" data-config=\"").concat(e(JSON.stringify(options)), "\"><div id=\"report\"></div>").concat(scripts, "</body>"); | ||
return "<html lang=\"en\">".concat(head).concat(body, "</html>"); | ||
} | ||
MainHTML.propTypes = { | ||
data: PropTypes.string, | ||
inlineScripts: PropTypes.string, | ||
inlineStyles: PropTypes.string, | ||
options: PropTypes.object, | ||
scriptsUrl: PropTypes.string, | ||
stylesUrl: PropTypes.string, | ||
title: PropTypes.string, | ||
useInlineAssets: PropTypes.bool | ||
}; | ||
module.exports = MainHTML; | ||
module.exports = renderMainHTML; |
@@ -15,4 +15,2 @@ "use strict"; | ||
var React = require('react'); | ||
var opener = require('opener'); | ||
@@ -22,6 +20,4 @@ | ||
var render = require('react-dom/server').renderToStaticMarkup; | ||
var renderMainHTML = require('./main-html'); | ||
var MainHTML = require('./main-html'); | ||
var pkg = require('../package.json'); | ||
@@ -285,5 +281,4 @@ | ||
var assets = getAssets(reportOptions); // Render basic template to string | ||
// const { styles, scripts } = assets; | ||
var renderedHtml = render(React.createElement(MainHTML, _objectSpread({ | ||
var renderedHtml = renderMainHTML(_objectSpread({ | ||
data: data, | ||
@@ -293,3 +288,3 @@ options: reportOptions, | ||
useInlineAssets: reportOptions.inlineAssets && !reportOptions.cdn | ||
}, assets))); | ||
}, assets)); | ||
var html = "<!doctype html>\n".concat(renderedHtml); | ||
@@ -296,0 +291,0 @@ return { |
{ | ||
"name": "mochawesome-report-generator", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Generates gorgeous HTML reports from mochawesome reporter.", | ||
@@ -79,2 +79,3 @@ "scripts": { | ||
"dateformat": "^3.0.2", | ||
"escape-html": "^1.0.3", | ||
"fs-extra": "^7.0.0", | ||
@@ -90,6 +91,2 @@ "fsu": "^1.0.2", | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.5", | ||
"react-dom": "^16.8.5" | ||
}, | ||
"devDependencies": { | ||
@@ -155,2 +152,4 @@ "@babel/cli": "^7.1.0", | ||
"raf": "^3.4.0", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"react-test-renderer": "^16.8.5", | ||
@@ -157,0 +156,0 @@ "sinon": "^7.3.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1158156
12
75
2745
+ Addedescape-html@^1.0.3
+ Addedescape-html@1.0.3(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-dom@16.14.0(transitive)
- Removedscheduler@0.19.1(transitive)