Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to useCDN #111

Merged
merged 1 commit into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ This expects the durations in the report to be in **nanoseconds**, which might r
If set to `true` the duration of steps will be expected to be in **milliseconds**, which might result in incorrect durations when using a version of Cucumber(JS 1 or 4) that does report in **nanaseconds**.
This parameter relies on `displayDuration: true`

### `useCDN`
- **Type:** `boolean`
- **Mandatory:** No

If you prefer, you can use CDN for assets.

### `customStyle`
- **Type:** `path`
- **Mandatory:** No
Expand Down
8 changes: 6 additions & 2 deletions lib/generate-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function generateReport(options) {
const durationInMS = options.durationInMS || false;
const pageTitle = options.pageTitle || 'Multiple Cucumber HTML Reporter';
const pageFooter = options.pageFooter || false;
const useCDN = options.useCDN || false;

fs.ensureDirSync(reportPath);
fs.ensureDirSync(path.resolve(reportPath, FEATURE_FOLDER));
Expand All @@ -72,6 +73,7 @@ function generateReport(options) {
customData: customData,
style: style,
customStyle: customStyle,
useCDN: useCDN,
displayDuration: displayDuration,
browser: 0,
name: '',
Expand Down Expand Up @@ -483,6 +485,7 @@ function generateReport(options) {
}),
customStyle: _readTemplateFile(suite.customStyle),
styles: _readTemplateFile(suite.style),
useCDN: suite.useCDN,
genericScript: _readTemplateFile(GENERIC_JS),
pageTitle: pageTitle,
reportName: reportName,
Expand Down Expand Up @@ -524,6 +527,7 @@ function generateReport(options) {
scenarios: feature.elements,
_: _
}),
useCDN: suite.useCDN,
customStyle: _readTemplateFile(suite.customStyle),
styles: _readTemplateFile(suite.style),
genericScript: _readTemplateFile(GENERIC_JS),
Expand All @@ -532,8 +536,8 @@ function generateReport(options) {
pageFooter: pageFooter,
})
);
// Copy the assets, but first check if they don't exists
if (!fs.pathExistsSync(path.resolve(reportPath, 'assets'))) {
// Copy the assets, but first check if they don't exists and not useCDN
if (!fs.pathExistsSync(path.resolve(reportPath, 'assets')) && !suite.useCDN) {
fs.copySync(
path.resolve(path.dirname(require.resolve('../package.json')), 'templates/assets'),
path.resolve(reportPath, 'assets')
Expand Down
50 changes: 36 additions & 14 deletions templates/feature-overview.index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,34 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= pageTitle %></title>
<!-- Bootstrap -->
<link rel="stylesheet" href="../assets/css/bootstrap.min.css" >
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.min.js"></script>
<script src="../assets/js/respond.min.js"></script>
<![endif]-->

<link href="../assets/css/font-awesome.min.css" rel="stylesheet">
<% if (useCDN) { %>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->

<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<% } else { %>
<!-- Bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css" >

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->

<!--[if lt IE 9]>
<script src="assets/js/html5shiv.min.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->

<link href="assets/css/font-awesome.min.css" rel="stylesheet">
<% } %>

<!-- Custom Theme Style -->
<style type="text/css">
Expand Down Expand Up @@ -90,11 +108,15 @@
<%= pageFooter %>
<% } %>

<script src="../assets/js/jquery-3.2.1.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>

<!-- Chart.js -->
<script src="../assets/js/Chart.min.js"></script>
<% if (useCDN) { %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<% } else { %>
<script src="assets/js/jquery-3.2.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/Chart.min.js"></script>
<% } %>

<!-- Custom -->
<script>
Expand Down
80 changes: 56 additions & 24 deletions templates/features-overview.index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,42 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= pageTitle %></title>

<!-- Bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.min.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->

<link href="assets/css/font-awesome.min.css" rel="stylesheet">

<!-- DataTables -->
<link href="assets/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="assets/css/responsive.dataTables.min.css" rel="stylesheet">
<% if (useCDN) { %>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->

<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />

<!-- DataTables -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/css/dataTables.bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.1.1/css/responsive.dataTables.min.css">

<% } else { %>
<!-- Bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css" >

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->

<!--[if lt IE 9]>
<script src="assets/js/html5shiv.min.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->

<link href="assets/css/font-awesome.min.css" rel="stylesheet">

<!-- DataTables -->
<link href="assets/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="assets/css/responsive.dataTables.min.css" rel="stylesheet">
<% } %>

<!-- Custom Theme Style -->
<style type="text/css">
Expand Down Expand Up @@ -77,16 +99,26 @@
<%= pageFooter %>
<% } %>

<script src="assets/js/jquery-3.2.1.min.js" ></script>
<script src="assets/js/bootstrap.min.js"></script>

<!-- DataTables -->
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/dataTables.bootstrap.min.js"></script>
<script src="assets/js/dataTables.responsive.min.js"></script>

<!-- Chart.js -->
<script src="assets/js/Chart.min.js"></script>
<% if (useCDN) { %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>

<!-- DataTables -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.1.1/js/dataTables.responsive.min.js"></script>

<% } else { %>
<script src="assets/js/jquery-3.2.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/Chart.min.js"></script>

<!-- DataTables -->
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/dataTables.bootstrap.min.js"></script>
<script src="assets/js/dataTables.responsive.min.js"></script>
<% } %>

<!-- Custom -->
<script>
Expand Down