Skip to content

Commit

Permalink
Merge pull request #163 from TAMULib/sprint-action-4-lighthouse-tool
Browse files Browse the repository at this point in the history
Added Lighthouse reporting tool for CAP
  • Loading branch information
jcreel authored Sep 28, 2021
2 parents b40ef6b + bb58e3d commit 35d8b6e
Show file tree
Hide file tree
Showing 9 changed files with 7,600 additions and 12 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ package-lock.json

.lighthouseci/

audit/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Build Status](https://github.com/TAMULib/CAP/workflows/Build/badge.svg)](https://github.com/TAMULib/CAP/actions?query=workflow%3ABuild)
[![Coverage Status](https://coveralls.io/repos/github/TAMULib/CAP/badge.svg)](https://coveralls.io/github/TAMULib/CAP)
<!--- [![Performance](https://tamulib.github.io/CAP/audit/assets/performance.svg)](https://tamulib.github.io/CAP/audit/#performance)
[![Performance](https://tamulib.github.io/CAP/audit/assets/performance.svg)](https://tamulib.github.io/CAP/audit/#performance)
[![Accessibility](https://tamulib.github.io/CAP/audit/assets/accessibility.svg)](https://tamulib.github.io/CAP/audit/#accessibility)
[![Best Practices](https://tamulib.github.io/CAP/audit/assets/best-practices.svg)](https://tamulib.github.io/CAP/audit/#best-practices)
[![SEO](https://tamulib.github.io/CAP/audit/assets/seo.svg)](https://tamulib.github.io/CAP/audit/#seo)
[![Progressive Web App](https://tamulib.github.io/CAP/audit/assets/pwa.svg)](https://tamulib.github.io/CAP/audit/#pwa) --->
[![Progressive Web App](https://tamulib.github.io/CAP/audit/assets/pwa.svg)](https://tamulib.github.io/CAP/audit/#pwa)

# CAP

Expand Down
30 changes: 21 additions & 9 deletions scripts/build-cap-lighthouse-badges.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const createBadges = resultList => {
});
}

const logSoreList = scoreList => {
const logScoreList = scoreList => {
console.log('Finished generating report');
console.log('Results:');
scoreList.forEach(s => {
Expand All @@ -52,15 +52,27 @@ const logSoreList = scoreList => {
}

const createGhPagesDir = () => {
const targetPath = 'target';
const ghPagesPath = `src/main/resources/gh-pages`;
const targetGhPagesPath = `${targetPath}/gh-pages`;
fs.ensureDir(ghPagesPath);
const targetPath = 'target/';
fs.ensureDir(targetPath);
fs.ensureDir(`${lighthousePath}`);
fs.copy(`./${ghPagesPath}/index.html`, `${targetPath}/gh-pages/index.html`);
fs.copy(`./${lighthousePath}/`, `${targetPath}/gh-pages/audit/`);
fs.copy(`./${lighthousePath}/assets/`, `${targetPath}/gh-pages/audit/assets/`);
fs.copy(`${targetPath}/generated-docs/`, `${targetPath}/gh-pages/api-docs/`);
}

fs.copy(`${targetPath}/generated-docs/`, `${targetGhPagesPath}/api-docs/`, err => {
if (err) return console.error(' \n Unable to copy generated-docs to : ',`${targetGhPagesPath}/api-docs/` , '\n', err);
console.log(`Copied generated-docs to ${targetGhPagesPath}/api-docs/ !`);
});

fs.copy(`./${ghPagesPath}/index.html`, `${targetGhPagesPath}/index.html`, err => {
if (err) return console.error(' \n Unable to copy src index file to : ',`${targetGhPagesPath}/index.html` , '\n', err);
console.log(`Copied index file to ${targetGhPagesPath}/index.html !`);
});

fs.copy(`./${ghPagesPath}/audit/`, `${targetGhPagesPath}/audit/`, err => {
if (err) return console.error(' \n Unable to copy src audit to : ',`${targetGhPagesPath}/audit/` , '\n', err);
console.log(`Copied audit to ${targetGhPagesPath}/audit/ !`);
});
};

if(fs.existsSync(lighthouseCiPath)) {
fs.ensureDir(`${lighthousePath}`);
Expand All @@ -71,7 +83,7 @@ if(fs.existsSync(lighthouseCiPath)) {
const scoreList = createScoreList(jsonReport);
createReport(htmlReportPath);
createBadges(scoreList);
logSoreList(scoreList);
logScoreList(scoreList);
createGhPagesDir();

} else {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/gh-pages/audit/assets/accessibility.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/gh-pages/audit/assets/performance.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/gh-pages/audit/assets/pwa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/gh-pages/audit/assets/seo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 35d8b6e

Please sign in to comment.