Make it possible to show the used script(s) in the HTML. (#2298)
* Make it possible to show the used script(s) in the HTML.
This commit is contained in:
parent
ca0de37987
commit
cebad1424d
|
|
@ -898,6 +898,13 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|||
default: 10,
|
||||
group: 'HTML'
|
||||
})
|
||||
.option('html.showScript', {
|
||||
describe:
|
||||
'Show a link to the script you use to run. Be careful if your result is public and you keep passwords in your script.',
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
group: 'HTML'
|
||||
})
|
||||
.option('summary', {
|
||||
describe: 'Show brief text summary to stdout',
|
||||
default: false,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
const fs = require('fs');
|
||||
const { promisify } = require('util');
|
||||
const readFile = promisify(fs.readFile);
|
||||
|
||||
module.exports = async options => {
|
||||
const scripts = [];
|
||||
for (let file of options._) {
|
||||
// We could promise all these in the future
|
||||
if (!file.startsWith('http')) {
|
||||
try {
|
||||
const code = await readFile(file);
|
||||
scripts.push({ name: file, code: code });
|
||||
} catch (e) {
|
||||
// do nada
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
};
|
||||
|
|
@ -16,6 +16,7 @@ const summaryBoxesSetup = require('./setup/summaryBoxes'),
|
|||
detailedSetup = require('./setup/detailed');
|
||||
|
||||
const filmstrip = require('./filmstrip');
|
||||
const getScripts = require('./getScripts');
|
||||
|
||||
const TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
|
|
@ -120,6 +121,15 @@ class HTMLBuilder {
|
|||
pageDescription: 'A list of the largest assets for the analyzed pages.'
|
||||
};
|
||||
|
||||
if (options.multi && options.html.showScript) {
|
||||
const scripts = await getScripts(options);
|
||||
this.summary.scripts = {
|
||||
pageTitle: `Scripts used to run the analyze`,
|
||||
pageDescription: '',
|
||||
scripts
|
||||
};
|
||||
}
|
||||
|
||||
if (options.budget) {
|
||||
let totalFailing = 0;
|
||||
let totalWorking = 0;
|
||||
|
|
|
|||
|
|
@ -4,4 +4,10 @@
|
|||
p.small Tested #{timestamp} using #{h.cap(options.browsertime.browser)} for
|
||||
| #{ h.get(options, 'browsertime.chrome.android.package') ? h.get(options, 'browsertime.chrome.android.package') + ' ': ''}
|
||||
| #{options.preURL ? 'preURL ' + h.short(options.preURL, 60) + ' ' : ''}
|
||||
| #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{options.browsertime.connectivity.profile}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode.' : ''}
|
||||
| #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{options.browsertime.connectivity.profile}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode ' : ''}
|
||||
if options.multi && options.html.showScript
|
||||
| (
|
||||
a(href= rootPath + 'scripts.html')= 'script'
|
||||
| ).
|
||||
else if options.multi
|
||||
| .
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
extends ./layout.pug
|
||||
|
||||
block content
|
||||
.row
|
||||
.column
|
||||
include runInfo
|
||||
|
||||
if scripts.length > 0
|
||||
h1 Scripting
|
||||
each script in scripts
|
||||
b #{script.name}
|
||||
pre
|
||||
code #{script.code}
|
||||
else
|
||||
p No configured scripts.
|
||||
|
|
@ -3,4 +3,10 @@
|
|||
p.small Tested #{runTime} using #{h.cap(options.browsertime.browser)} #{browser.version} for
|
||||
| #{ h.get(options, 'browsertime.chrome.android.package') ? ' ' + h.get(options, 'browsertime.chrome.android.package') + ' ': ''}
|
||||
| #{options.preURL ? 'preURL ' + h.short(options.preURL, 60) + ' ': ''}
|
||||
| #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{options.browsertime.connectivity.profile}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode.' : ''}
|
||||
| #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{options.browsertime.connectivity.profile}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode ' : ''}
|
||||
if options.multi && options.html.showScript
|
||||
| (
|
||||
a(href= rootPath + 'scripts.html')= 'script'
|
||||
| ).
|
||||
else if options.multi
|
||||
| .
|
||||
|
|
|
|||
Loading…
Reference in New Issue