From 46e0f5f651aec58b7a4cebd1be57d781b136bc10 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:19:42 +0000 Subject: [PATCH 1/4] Initial plan From 9507771f05cc47a13f99d4b6689e58f71041d21e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:23:39 +0000 Subject: [PATCH 2/4] Initial investigation of hook output issue Co-authored-by: justinmchase <10974+justinmchase@users.noreply.github.com> --- deno.lock | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deno.lock b/deno.lock index 0167c23..9f12ed5 100644 --- a/deno.lock +++ b/deno.lock @@ -1,16 +1,25 @@ { "version": "5", "specifiers": { + "jsr:@std/assert@^1.0.13": "1.0.14", + "jsr:@std/assert@^1.0.6": "1.0.14", "jsr:@std/fmt@^1.0.8": "1.0.8", "jsr:@std/internal@^1.0.10": "1.0.10", "jsr:@std/path@^1.0.6": "1.1.2", "jsr:@std/semver@^1.0.3": "1.0.5", + "jsr:@std/testing@^1.0.3": "1.0.15", "jsr:@std/yaml@^1.0.5": "1.0.9", "npm:json5@^2.2.3": "2.2.3", "npm:jsonc-parser@^3.2.1": "3.3.1", "npm:yargs@^17.7.2": "17.7.2" }, "jsr": { + "@std/assert@1.0.14": { + "integrity": "68d0d4a43b365abc927f45a9b85c639ea18a9fab96ad92281e493e4ed84abaa4", + "dependencies": [ + "jsr:@std/internal" + ] + }, "@std/fmt@1.0.8": { "integrity": "71e1fc498787e4434d213647a6e43e794af4fd393ef8f52062246e06f7e372b7" }, @@ -26,6 +35,13 @@ "@std/semver@1.0.5": { "integrity": "529f79e83705714c105ad0ba55bec0f9da0f24d2f726b6cc1c15e505cc2c0624" }, + "@std/testing@1.0.15": { + "integrity": "a490169f5ccb0f3ae9c94fbc69d2cd43603f2cffb41713a85f99bbb0e3087cbc", + "dependencies": [ + "jsr:@std/assert@^1.0.13", + "jsr:@std/internal" + ] + }, "@std/yaml@1.0.9": { "integrity": "6bad3dc766dd85b4b37eabcba81b6aa4eac7a392792ae29abcfb0f90602d55bb" } From 4a23ca823ca7ff225133162e8ef3d7d70d6ed7e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:26:42 +0000 Subject: [PATCH 3/4] Fix hook output to display version strings instead of [object Object] Co-authored-by: justinmchase <10974+justinmchase@users.noreply.github.com> --- src/hooks/patch.test.ts | 69 +++++++++++++++++++++++++++++++++++++++ src/hooks/replace.test.ts | 41 +++++++++++++++++++++++ src/hooks/replace.ts | 4 +-- 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 src/hooks/patch.test.ts create mode 100644 src/hooks/replace.test.ts diff --git a/src/hooks/patch.test.ts b/src/hooks/patch.test.ts new file mode 100644 index 0000000..16a9a42 --- /dev/null +++ b/src/hooks/patch.test.ts @@ -0,0 +1,69 @@ +import { describe, it } from "testing/bdd"; +import { assertSpyCall, stub } from "testing/mock"; +import { parse } from "semver"; +import { patch } from "./patch.ts"; + +describe("patch", () => { + it("should log formatted version string for csproj", async () => { + const consoleLogStub = stub(console, "log"); + const readTextFileStub = stub( + Deno, + "readTextFile", + () => + Promise.resolve( + "\n \n 1.0.0\n \n", + ), + ); + const writeTextFileStub = stub( + Deno, + "writeTextFile", + () => Promise.resolve(), + ); + + try { + await patch("test.csproj", parse("1.2.3")!); + + // Verify console.log was called with formatted string, not [object Object] + assertSpyCall(consoleLogStub, 0, { + args: ["patching 1.2.3 in test.csproj"], + }); + } finally { + consoleLogStub.restore(); + readTextFileStub.restore(); + writeTextFileStub.restore(); + } + }); + + it("should log formatted version string for package.json", async () => { + const consoleLogStub = stub(console, "log"); + const readTextFileStub = stub( + Deno, + "readTextFile", + () => Promise.resolve('{"version": "1.0.0"}'), + ); + const writeTextFileStub = stub( + Deno, + "writeTextFile", + () => Promise.resolve(), + ); + const statStub = stub( + Deno, + "stat", + () => Promise.reject(new Deno.errors.NotFound()), + ); + + try { + await patch("package.json", parse("1.2.3")!); + + // Verify console.log was called with formatted string, not [object Object] + assertSpyCall(consoleLogStub, 0, { + args: ["patching 1.2.3 in package.json"], + }); + } finally { + consoleLogStub.restore(); + readTextFileStub.restore(); + writeTextFileStub.restore(); + statStub.restore(); + } + }); +}); diff --git a/src/hooks/replace.test.ts b/src/hooks/replace.test.ts new file mode 100644 index 0000000..1434add --- /dev/null +++ b/src/hooks/replace.test.ts @@ -0,0 +1,41 @@ +import { describe, it } from "testing/bdd"; +import { assertSpyCall, stub } from "testing/mock"; +import { parse } from "semver"; +import { replace } from "./replace.ts"; + +describe("replace", () => { + it("should log formatted version strings", async () => { + const consoleLogStub = stub(console, "log"); + const readTextFileStub = stub( + Deno, + "readTextFile", + () => Promise.resolve("version 1.0.0"), + ); + const writeTextFileStub = stub( + Deno, + "writeTextFile", + () => Promise.resolve(), + ); + + try { + await replace("test.txt", parse("1.0.0")!, parse("1.2.3")!); + + // Verify console.log was called with formatted strings, not [object Object] + assertSpyCall(consoleLogStub, 0, { + args: ["replacing 1.0.0 -> 1.2.3 in test.txt"], + }); + + // Verify file operations + assertSpyCall(readTextFileStub, 0, { + args: ["test.txt"], + }); + assertSpyCall(writeTextFileStub, 0, { + args: ["test.txt", "version 1.2.3"], + }); + } finally { + consoleLogStub.restore(); + readTextFileStub.restore(); + writeTextFileStub.restore(); + } + }); +}); diff --git a/src/hooks/replace.ts b/src/hooks/replace.ts index fb8819c..2e50e24 100644 --- a/src/hooks/replace.ts +++ b/src/hooks/replace.ts @@ -5,10 +5,10 @@ export async function replace( previous: SemVer, current: SemVer, ) { - console.log(`replacing ${previous} -> ${current} in ${file}`); - const contents = await Deno.readTextFile(file); const previousString = format(previous); const currentString = format(current); + console.log(`replacing ${previousString} -> ${currentString} in ${file}`); + const contents = await Deno.readTextFile(file); const updated = contents.replaceAll(previousString, currentString); await Deno.writeTextFile(file, updated); } From 90f38e35fcaf3b0ff0380122acce7a33b49b1547 Mon Sep 17 00:00:00 2001 From: Justin Chase Date: Sat, 11 Oct 2025 16:30:47 -0500 Subject: [PATCH 4/4] Remove deprecated jsr:@std/assert version --- deno.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/deno.lock b/deno.lock index 5eb5cd4..85b9d84 100644 --- a/deno.lock +++ b/deno.lock @@ -2,7 +2,6 @@ "version": "5", "specifiers": { "jsr:@std/assert@^1.0.13": "1.0.14", - "jsr:@std/assert@^1.0.6": "1.0.14", "jsr:@std/fmt@^1.0.8": "1.0.8", "jsr:@std/internal@^1.0.10": "1.0.12", "jsr:@std/path@^1.0.6": "1.1.2",