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

feat: remove accordion details if reportTooBig is true #425

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3e63979
feat: remove accordion details if reportTooBig is true
shioju Dec 18, 2024
e17e254
feat: generate both report.html and report_summary.html
shioju Dec 19, 2024
b56498a
feat: gzip scanData/scanItems and base64 encode before writing to html
shioju Dec 23, 2024
dca9661
Merge branch 'master' into feat/summary-report
shioju Dec 25, 2024
bb09198
Merge branch 'master' into feat/summary-report
shioju Dec 26, 2024
e4bb339
feat: use streaming when stringifying json
shioju Dec 26, 2024
f8658fc
feat: replace bfj with custom json utils
shioju Dec 31, 2024
762372d
feat: hide chevrons when accordion items are not clickable
shioju Dec 31, 2024
a1e36b8
chore: update readme with instructions on extracting JSON files
shioju Dec 31, 2024
fba82cf
feat: inline pako.min.js into report.html
shioju Dec 31, 2024
71a0d8a
feat: clean up the generated JSON files if user did not ask for them
shioju Dec 31, 2024
bc841f5
chore: revert to chunking handling of large object and json
shioju Dec 31, 2024
e4d8c08
feat: change to base64 encoding without pipe char between chunks
shioju Jan 4, 2025
d40ab1a
feat: streaming decode, unzip and parsing in report.html
shioju Jan 6, 2025
4888ef8
chore: add script for generating decodeUnzipParse.ejs
shioju Jan 8, 2025
e7fe180
feat: add an iterative object serializer
shioju Jan 12, 2025
54132d8
chore: only proceed with scripts after scanData and scanItems loaded
shioju Jan 12, 2025
a875ddd
fix: use structuredClone instead of parse/stringify to avoid long str…
shioju Jan 12, 2025
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
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ Options:
ks
[string] [choices: "default", "disable-oobee", "enable-wcag-aaa", "disable-oob
ee,enable-wcag-aaa"] [default: "default"]
-g, --generateJsonFiles Generate two JSON files containing the
results of the accessibility scan:
-g, --generateJsonFiles Generate two gzipped and base64-encoded
JSON files containing the results of the
accessibility scan:
1. `scanData.json`: Provides an overview of
the scan, including:
- WCAG compliance score
Expand All @@ -363,6 +364,13 @@ Options:
- URL of the pages violated the WCAG clauses
Useful for in-depth analysis or integration
with external reporting tools.

To obtain the JSON files, you need to base64-decode
the file followed by gunzip. For example:
(macOS) base64 -D -i scanData.json.gz.b64 |
gunzip > scanData.json\n
(linux) base64 -d scanData.json.gz.b64 |
gunzip > scanData.json\n
[string] [choices: "yes", "no"] [default: "no"]

Examples:
Expand Down
168 changes: 160 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@napi-rs/canvas": "^0.1.53",
"axe-core": "^4.10.2",
"axios": "^1.7.4",
"base64-stream": "^1.0.0",
"cheerio": "^1.0.0-rc.12",
"crawlee": "^3.11.1",
"ejs": "^3.1.9",
Expand Down Expand Up @@ -39,6 +40,7 @@
"devDependencies": {
"@eslint/eslintrc": "^3.0.2",
"@eslint/js": "^9.6.0",
"@types/base64-stream": "^1.0.5",
"@types/eslint__js": "^8.42.3",
"@types/fs-extra": "^11.0.4",
"@types/inquirer": "^9.0.7",
Expand All @@ -47,13 +49,15 @@
"@types/validator": "^13.11.10",
"@types/which": "^3.0.4",
"@types/xml2js": "^0.4.14",
"browserify-zlib": "^0.2.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-import": "^2.27.4",
"eslint-plugin-prettier": "^5.0.0",
"globals": "^15.2.0",
"jest": "^29.7.0",
"readable-stream": "^4.7.0",
"typescript-eslint": "^8.3.0"
},
"overrides": {
Expand Down Expand Up @@ -93,4 +97,4 @@
"url": "https://github.com/GovTechSG/oobee/issues"
},
"homepage": "https://github.com/GovTechSG/oobee#readme"
}
}
29 changes: 29 additions & 0 deletions scripts/decodeUnzipParse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Run the below command to get /src/static/ejs/partials/scripts/decodeUnzipParse.ejs */
/* ( echo '<script>'; npx browserify decodeUnzipParse.js --standalone decodeUnzipParse | npx uglify-js; echo '</script>' ) > decodeUnzipParse.ejs */
const { Readable } = require('readable-stream');
const { Base64Decode } = require('base64-stream');
const { createGunzip } = require('browserify-zlib');
const { parser } = require('stream-json');
const Asm = require('stream-json/Assembler');

module.exports = function parseGzipBase64Json(base64String) {
return new Promise((resolve, reject) => {
const pipeline = Readable.from([base64String])
.pipe(new Base64Decode())
.pipe(createGunzip())
.pipe(parser());

// Assembler to assemble the streamed JSON tokens
const assembler = Asm.connectTo(pipeline);

// On 'done' event, the entire JSON object is ready
assembler.on('done', asm => {
resolve(asm.current);
});

// If anything goes wrong at any stage, reject the promise
pipeline.on('error', err => {
reject(err);
});
});
};
Loading