feat: Add JS minification to build pipeline and expand test coverage
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 11m51s
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 11m51s
Task 1: Add JS minification to build pipeline (fix BUG-053) - Update scripts/build-html.cjs to minify JS files in-place with terser - Modified public/src/index.html and status.html to reference original JS files - Add TDD test to verify JS minification works correctly Task 2: Expand test coverage for untested routes - Add tests for /v1/usage endpoint (auth required, admin access checks) - Add tests for /v1/billing/checkout route (rate limiting, config checks) - Add tests for rate limit headers on PDF conversion endpoints - Add tests for 404 handler JSON error format for API vs HTML routes - All tests follow TDD principles (RED → GREEN) Task 3: Update swagger-jsdoc to fix npm audit vulnerability - Upgraded swagger-jsdoc to 7.0.0-rc.6 - Resolved minimatch vulnerability via npm audit fix - Verified OpenAPI generation still works correctly - All 52 tests passing, 0 vulnerabilities remaining Build improvements and security hardening complete.
This commit is contained in:
parent
b95994cc3c
commit
6fd707ab64
11 changed files with 192 additions and 1655 deletions
|
|
@ -47,18 +47,18 @@ for (const file of files) {
|
|||
}
|
||||
console.log('Done.');
|
||||
|
||||
// JS Minification (requires terser)
|
||||
// JS Minification (overwrite original files)
|
||||
const { execSync } = require("child_process");
|
||||
const jsFiles = [
|
||||
{ src: "public/app.js", out: "public/app.min.js" },
|
||||
{ src: "public/status.js", out: "public/status.min.js" },
|
||||
];
|
||||
const jsFiles = ["public/app.js", "public/status.js"];
|
||||
console.log("Minifying JS...");
|
||||
for (const { src, out } of jsFiles) {
|
||||
const srcPath = path.join(__dirname, "..", src);
|
||||
const outPath = path.join(__dirname, "..", out);
|
||||
if (fs.existsSync(srcPath)) {
|
||||
execSync(`npx terser ${srcPath} -o ${outPath} -c -m`, { stdio: "inherit" });
|
||||
console.log(` Minified: ${src} → ${out}`);
|
||||
for (const jsFile of jsFiles) {
|
||||
const filePath = path.join(__dirname, "..", jsFile);
|
||||
if (fs.existsSync(filePath)) {
|
||||
// Create backup, minify, then overwrite original
|
||||
const backupPath = filePath + ".bak";
|
||||
fs.copyFileSync(filePath, backupPath);
|
||||
execSync(`npx terser ${filePath} -o ${filePath} -c -m`, { stdio: "inherit" });
|
||||
fs.unlinkSync(backupPath); // Clean up backup
|
||||
console.log(` Minified: ${jsFile} (overwritten)`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue