From 0a781da9eeb1d9b2691851078d9506e569b7a2ff Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Thu, 11 Jun 2020 11:29:27 -0400 Subject: [PATCH 1/3] feat: add overview messaging --- netlify.toml | 2 ++ src/index.js | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/netlify.toml b/netlify.toml index eddfa95e..3d7fca26 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,6 +8,8 @@ [[plugins]] package = "./src/index.js" + [plugins.inputs] + audit_url = 'https://erquh.art' [plugins.inputs.thresholds] performance = 0.9 accessibility = 0.9 diff --git a/src/index.js b/src/index.js index 221e79d7..97d19ff0 100644 --- a/src/index.js +++ b/src/index.js @@ -75,7 +75,9 @@ const formatResults = ({ results, thresholds }) => { })), }; - return { summary, errors }; + const message = categories.map(({ title, score }) => `${title}: ${score * 100}`).join(', '); + + return { summary, message, errors }; }; const getConfiguration = ({ constants, inputs }) => { @@ -134,11 +136,9 @@ module.exports = { if (error) { throw error; } else { - const { summary, errors } = formatResults({ results, thresholds }); + const { summary, message, errors } = formatResults({ results, thresholds }); console.log(summary); - show({ - summary: JSON.stringify(summary, null, 2), - }); + show(message); if (errors.length > 0) { throw new Error(`\n${errors.join('\n')}`); From d84eba0e05a075a89733ec8e793b28e6fdad14e6 Mon Sep 17 00:00:00 2001 From: erezrokah Date: Thu, 11 Jun 2020 19:39:47 +0300 Subject: [PATCH 2/3] style: format code --- netlify.toml | 2 -- src/index.js | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/netlify.toml b/netlify.toml index 3d7fca26..eddfa95e 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,8 +8,6 @@ [[plugins]] package = "./src/index.js" - [plugins.inputs] - audit_url = 'https://erquh.art' [plugins.inputs.thresholds] performance = 0.9 accessibility = 0.9 diff --git a/src/index.js b/src/index.js index 97d19ff0..4b973c0d 100644 --- a/src/index.js +++ b/src/index.js @@ -75,7 +75,9 @@ const formatResults = ({ results, thresholds }) => { })), }; - const message = categories.map(({ title, score }) => `${title}: ${score * 100}`).join(', '); + const message = categories + .map(({ title, score }) => `${title}: ${score * 100}`) + .join(', '); return { summary, message, errors }; }; @@ -136,7 +138,10 @@ module.exports = { if (error) { throw error; } else { - const { summary, message, errors } = formatResults({ results, thresholds }); + const { summary, message, errors } = formatResults({ + results, + thresholds, + }); console.log(summary); show(message); From 9a0916967da0b2d07014685771428e335ff5bfaa Mon Sep 17 00:00:00 2001 From: erezrokah Date: Thu, 11 Jun 2020 19:48:07 +0300 Subject: [PATCH 3/3] fix: update call to show method --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 4b973c0d..58a77d83 100644 --- a/src/index.js +++ b/src/index.js @@ -75,11 +75,11 @@ const formatResults = ({ results, thresholds }) => { })), }; - const message = categories + const shortSummary = categories .map(({ title, score }) => `${title}: ${score * 100}`) .join(', '); - return { summary, message, errors }; + return { summary, shortSummary, errors }; }; const getConfiguration = ({ constants, inputs }) => { @@ -138,12 +138,12 @@ module.exports = { if (error) { throw error; } else { - const { summary, message, errors } = formatResults({ + const { summary, shortSummary, errors } = formatResults({ results, thresholds, }); console.log(summary); - show(message); + show({ summary: shortSummary }); if (errors.length > 0) { throw new Error(`\n${errors.join('\n')}`);