From 0ee6f7ed23a51652dd280de77633329c9c9bcc1c Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Tue, 3 Feb 2026 17:35:31 -0800 Subject: [PATCH] feat: more debugging --- src/services/gitService.ts | 62 +++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/src/services/gitService.ts b/src/services/gitService.ts index ed456c1..d7d8c3e 100644 --- a/src/services/gitService.ts +++ b/src/services/gitService.ts @@ -95,6 +95,50 @@ const getCurrentVersionOnBranch = async( ); }; +/** + * Runs pnpm install in the specified directory. + * @param logger - The logger instance. + * @param repoPath - The repository path. + */ +const runPnpmInstall = async( + logger: Logger, + repoPath: string, +): Promise => { + const pnpmPath = "/home/naomi/.local/share/pnpm/pnpm"; + /* eslint-disable capitalized-comments -- v8 coverage requires lowercase */ + /* v8 ignore start -- @preserve */ + /* eslint-enable capitalized-comments -- Re-enable rule */ + const pnpmEnvironment = { + ...process.env, + // eslint-disable-next-line @typescript-eslint/naming-convention -- Environment variables use SCREAMING_SNAKE_CASE + HOME: "/home/naomi", + // eslint-disable-next-line @typescript-eslint/naming-convention -- Environment variables use SCREAMING_SNAKE_CASE + PATH: `${process.env.PATH ?? ""}:/home/naomi/.local/share/pnpm`, + }; + /* eslint-disable capitalized-comments -- v8 coverage requires lowercase */ + /* v8 ignore stop -- @preserve */ + /* eslint-enable capitalized-comments -- Re-enable rule */ + try { + await execAsync(`${pnpmPath} install --no-frozen-lockfile`, { + cwd: repoPath, + env: pnpmEnvironment, + }); + } catch (pnpmError: unknown) { + /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Catch blocks receive unknown, cast needed to access stderr/stdout */ + const details = pnpmError as Error & { stderr?: string; stdout?: string }; + + /* eslint-disable capitalized-comments -- v8 coverage requires lowercase */ + /* v8 ignore next 5 -- @preserve */ + /* eslint-enable capitalized-comments -- Re-enable rule */ + /* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing -- Intentionally using || to treat empty strings as falsy */ + const errorMessage = details.stderr || details.stdout || details.message; + /* eslint-enable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing -- Re-enable rules */ + + void logger.log("info", `pnpm install failed: ${errorMessage}`); + throw pnpmError; + } +}; + /** * Updates package.json and creates a commit. * @param options - Configuration for which package to update and where. @@ -119,23 +163,7 @@ const updatePackageAndCommit = async( await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`); void logger.log("info", `Running pnpm install for ${packageName}...`); - const pnpmPath = "/home/naomi/.local/share/pnpm/pnpm"; - try { - await execAsync(`${pnpmPath} install --no-frozen-lockfile`, { cwd: repoPath }); - } catch (pnpmError: unknown) { - /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Catch blocks receive unknown, cast needed to access stderr/stdout */ - const details = pnpmError as Error & { stderr?: string; stdout?: string }; - - /* eslint-disable capitalized-comments -- v8 coverage requires lowercase */ - /* v8 ignore next 5 -- @preserve */ - /* eslint-enable capitalized-comments -- Re-enable rule */ - /* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing -- Intentionally using || to treat empty strings as falsy */ - const errorMessage = details.stderr || details.stdout || details.message; - /* eslint-enable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing -- Re-enable rules */ - - void logger.log("info", `pnpm install failed: ${errorMessage}`); - throw pnpmError; - } + await runPnpmInstall(logger, repoPath); await runGitCommand(logger, repoPath, "git add package.json pnpm-lock.yaml"); const commitMessage = `deps: update ${packageName} to ${targetVersion}`;