committing for push

This commit is contained in:
Emma Short
2025-04-22 14:21:58 -06:00
parent 597c52eefe
commit 08bba857db
9 changed files with 164 additions and 14 deletions

23
main.ts
View File

@@ -1,25 +1,22 @@
import {PDFDocument} from "pdf-lib";
import { PDFDocument } from "pdf-lib";
import { loadPdfForm } from "./saveLoadPdf.ts";
let [pdfPath, csPath] = Deno.args;
while (!pdfPath || !pdfPath.endsWith('.pdf')) pdfPath = prompt("Please provide path to PDF file:") || "";
while (!csPath || !csPath.endsWith('.cs')) csPath = prompt("Please provide path to CS class file:") || "";
const pdfBytes = await Deno.readFile(pdfPath);
const pdfDoc = await PDFDocument.load(pdfBytes);
const form = pdfDoc.getForm();
const form = await loadPdfForm(pdfPath);
const fields = form.getFields();
const csFiles = await Promise.all(csPath.split(",").map(c => Deno.readTextFile(c.trim())));
const fieldNames:string[] = fields.map(f => f.getName())
.filter(f => {
const rx = new RegExp(`(?<!//\s?)case ?"${f}"`)
return !csFiles.some(c => rx.test(c))
})
.filter(f => !f.toLowerCase().includes("signature"));
const fieldNames: string[] = fields.map(f => f.getName())
.filter(f => {
const rx = new RegExp(`(?<!//\s?)case ?"${f.replace(/\[\d\]/, '\\[\\?\\]')}"`)
return !csFiles.some(c => rx.test(c))
})
.filter(f => !f.toLowerCase().includes("signature"));
if (fieldNames.length) {
console.log("%cThe following field names are not present in the CS code", "color: red")
@@ -29,3 +26,5 @@ if (fieldNames.length) {
console.log("%cAll form fields present", 'color: lime')
alert("Ok!")
}
/additionalAdviser.personalInfo.npn\[\?\]/