From 51aaf27fda1333c6ab6b500bc5d5145d430beac6 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 7 May 2025 10:29:15 -0600 Subject: [PATCH 1/5] new version --- CHANGELOG.md | 4 ++-- deno.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41b67d0..a8fa311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.0.0 (2025-07-25) +## v1.0.0 (2025-07-25) ### Features @@ -20,7 +20,7 @@ - ascii art is broken (sad face) - banana doesn't work -## 0.0.0 (never) +## v0.0.0 (never) this is just here for a reference to the auto-changelog diff --git a/deno.json b/deno.json index c620ea1..84dbf51 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@bearmetal/pdf-tools", - "version": "1.0.0", + "version": "1.0.1", "license": "GPL 3.0", "tasks": { "dev": "deno run -A --env-file=.env --watch main.ts", From 43d5916e52b307e1b0a7373c474bc84669c94bab Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 7 May 2025 12:55:19 -0600 Subject: [PATCH 2/5] fix: field rename preview --- tools/fieldRename.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/fieldRename.ts b/tools/fieldRename.ts index 3fc6e6e..dedda92 100644 --- a/tools/fieldRename.ts +++ b/tools/fieldRename.ts @@ -123,8 +123,9 @@ class RenameFields implements ITool { const match = patternRegex.exec(name); if (match) { const toChange = evaluateChange(change, match); + const preview = name.replace(new RegExp(patternRegex), toChange); foundUpdates.push([ - `${colorize(name, "red")} -> ${colorize(toChange, "green")}`, + `${colorize(name, "red")} -> ${colorize(preview, "green")}`, () => { applyRename(field, name, patternRegex, toChange); }, From 4f043d2bd767fe5a5f8abde724822f1589423302 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 7 May 2025 13:07:47 -0600 Subject: [PATCH 3/5] fix: banana --- cli/index.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index 9decc4e..39476a5 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -6,8 +6,6 @@ import { selectMenuInteractive } from "./selectMenu.ts"; import { TerminalBlock, TerminalLayout } from "./TerminalLayout.ts"; import { cliAlert, cliLog } from "./prompts.ts"; import type { ITool } from "../types.ts"; -import { join, toFileUrl } from "@std/path"; -import { log } from "util/logfile.ts"; // Register tools here (filename, no extension) const toolRegistry: [string, Promise<{ default: ITool }>][] = [ @@ -23,6 +21,7 @@ export class PdfToolsCli { private args = ArgParser.parse(Deno.args).setFlagDefs({ help: ["-h", "--help"], + banana: ["-b", "--banana"], }); async importTools() { @@ -43,9 +42,7 @@ export class PdfToolsCli { private async banana() { const asciiArt = await getAsciiArt("banana"); - const body = this.terminalLayout.getBlock("body"); - body.clearAll(); - cliLog(colorize(asciiArt, "yellow"), body); + this.closeMessage = colorize(asciiArt, "yellow"); } private async help() { @@ -64,6 +61,11 @@ export class PdfToolsCli { this.terminalLayout.register("title", titleBlock); const bodyBlock = new TerminalBlock(); this.terminalLayout.register("body", bodyBlock); + if (this.args.getFlag("banana")) { + titleBlock.setFixedHeight(0); + await this.banana(); + return; + } if (this.args.getFlag("help") && !this.args.task) { await this.help(); return; @@ -75,12 +77,16 @@ export class PdfToolsCli { await this.runTool(toCase(task, "title")); } } finally { - this.terminalLayout.clearAll(); - Deno.stdin.setRaw(false); - if (this.closeMessage) console.log(this.closeMessage); + this.cleanup(); } } + private cleanup() { + this.terminalLayout.clearAll(); + Deno.stdin.setRaw(false); + if (this.closeMessage) console.log(this.closeMessage); + } + private async toolMenu() { const tools = this.tools.keys().toArray(); const bodyBlock = this.terminalLayout.getBlock("body"); From 711880a6709c8aa28f68fbb3cd5415c6650768c6 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 7 May 2025 13:16:11 -0600 Subject: [PATCH 4/5] fix: temporarily defaults asciiart to hosted file --- util/asciiArt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/asciiArt.ts b/util/asciiArt.ts index 01795f4..2c0a590 100644 --- a/util/asciiArt.ts +++ b/util/asciiArt.ts @@ -26,5 +26,5 @@ function getBearmetalAsciiPath() { return filename.name; } } - return null; + return "https://git.cyborggrizzly.com/BearMetal/pdf-tools/raw/branch/main/asciiart.txt"; } From 1a1431c85e8f4e223884ad0e81267eb8d9904842 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 7 May 2025 13:28:46 -0600 Subject: [PATCH 5/5] chore: changelog and new readme --- CHANGELOG.md | 8 +++++++ README.md | 63 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8fa311..1e03926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## v1.0.1 (2025-07-25) + + + +### Known Issues + +- help flags can cause issues + ## v1.0.0 (2025-07-25) ### Features diff --git a/README.md b/README.md index 6c65625..82be0dd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,16 @@ -# Emma's Simple Form Field Checker +# BearMetal PDF Tools -Compares a PDF form to a list of CS class files to see if all field names are -present, excluding signature fields. +A collection of tools for working with PDF forms. + +## Features + +- Check Code Tool + - reads supplied code files to see if form fields are present and represented + in a switch statement +- Field Rename Tool + - provide a search and replace pattern to bulk rename form fields +- List Form Fields + - Sometimes you just need to see what fields there are ## Prereqs @@ -20,17 +29,51 @@ Deno >=2.2 (not required if downloading .exe) > If you want it to be a global command, create an executables directory and add > it to the PATH +### Precompiled + +Download the latest release from the +[releases page](https://git.cyborggrizzly.com/BearMetal/pdf-tools/releases) + ## Usage -`checkfields ` --OR- `checkfields` and follow prompts. +`pdf-tools ` -> `` is one of the following -### Output +- check-code +- field-rename +- list-form-fields -> All form fields present! +## Contributing --OR- +Contributions are welcome! -> The following field names are not present in the CS code +## License -> \ +GPL 3.0 + +--- + +### About this project + +BearMetal PDF Tools is a collection of tools made to fix the current state of +PDF form editing. Adobe Acrobat is a great tool, but it's not always the easiest +to use, nor is it free. It also lacks some features that I find useful, such as +bulk renaming of form fields. There's also a lack of powerful, free, and open +source tools for PDF editing. + +This project aims to fill that gap by providing a set of tools that can be used +to edit PDF forms. The tools are written in Deno, a modern and secure runtime +for JavaScript and TypeScript. They are designed to be easy to use and to +provide a great user experience. + +The tools are designed to be used in a terminal, and are not designed to be +integrated into other applications. They are also not designed to be used as a +library, but rather as a command line tool. + +### About BearMetal + +BearMetal is a project that aims to decrapify modern web development. It is a +collection of tools, libraries, and resources that aim to make web development +more accessible and less intimidating. The project is open source and free to +use, and is designed to be used by anyone, regardless of skill level or +experience. You can find a list of libraries and tools on +[JSR](https://jsr.io/@bearmetal).