Skip to content
17 changes: 17 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@
}
}
}
},
{
// Disallow console except in the loggers and CLI command files.
"includes": [
"packages/*/src/**",
"!packages/core/src/logger.ts",
"!packages/version/src/utils/logging.ts",
"!packages/*/src/command.ts",
"!packages/*/src/commands/**"
],
"linter": {
"rules": {
"suspicious": {
"noConsole": "error"
}
}
}
}
],
"assist": {
Expand Down
6 changes: 4 additions & 2 deletions packages/notes/src/llm/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export function debugLogMessages(providerName: string, messages: LLMMessage[]):
if (process.env.RELEASEKIT_DEBUG !== '1') {
return;
}
console.error(`[RELEASEKIT_DEBUG] ${providerName} messages (${messages.length}):`);
const lines = [`[RELEASEKIT_DEBUG] ${providerName} messages (${messages.length}):`];
for (const msg of messages) {
const preview = msg.content.length > 300 ? `${msg.content.slice(0, 300)}…` : msg.content;
console.error(` [${msg.role}]: ${preview}`);
lines.push(` [${msg.role}]: ${preview}`);
}
// biome-ignore lint/suspicious/noConsole: RELEASEKIT_DEBUG=1 should always print this; the logger would hide it under --quiet
console.error(lines.join('\n'));
}
2 changes: 1 addition & 1 deletion packages/release/src/preview/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export async function runPreview(options: PreviewOptions): Promise<void> {
});

if (!context || !forge) {
// Dry-run mode or GitHub context unavailable — print to stdout
// biome-ignore lint/suspicious/noConsole: no PR to post to (dry run or no GitHub context), so print it
console.log(commentBody);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/version/src/core/versionCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import { cwd } from 'node:process';
import { inspect } from 'node:util';
import { sanitizePackageName, shouldMatchPackageTargets } from '@releasekit/core';
import { Bumper } from 'conventional-recommended-bump';
import type { ReleaseType } from 'semver';
Expand Down Expand Up @@ -493,7 +494,7 @@ async function calculateVersionInner(config: Config, options: VersionOptions): P
log(`Error in conventional commits calculation`, 'debug');
// Handle errors during conventional bump calculation
log(`Failed to calculate version for ${name || 'project'}`, 'error');
console.error(error);
log(inspect(error), 'error');
// Check if the error is specifically due to no tags found by underlying git commands
if (error instanceof Error && error.message.includes('No names found')) {
log('No tags found, proceeding with initial version calculation (if applicable).', 'info');
Expand All @@ -508,7 +509,7 @@ async function calculateVersionInner(config: Config, options: VersionOptions): P
log(`Error in version calculation`, 'debug');
// Handle errors during conventional bump calculation
log(`Failed to calculate version for ${name || 'project'}`, 'error');
console.error(error);
log(inspect(error), 'error');
// Check if the error is specifically due to no tags found by underlying git commands
if (error instanceof Error && error.message.includes('No names found')) {
log('No tags found, proceeding with initial version calculation (if applicable).', 'info');
Expand Down
11 changes: 6 additions & 5 deletions packages/version/src/core/versionEngine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { cwd } from 'node:process';
import { inspect } from 'node:util';
import { getPackagesSync, type Package, type Packages } from '@manypkg/get-packages';
import { filterPackagesByConfig, parseCargoToml, parsePubspec } from '@releasekit/config';
import { isPrivatePackageJson, shouldMatchPackageTargets } from '@releasekit/core';
Expand Down Expand Up @@ -621,7 +622,7 @@ export class VersionEngine {
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
log(`Failed to get packages information: ${errorMessage}`, 'error');
console.error(error);
log(inspect(error), 'error');

// Throw a more specific error for better error handling upstream
throw createVersionError(VersionErrorCode.WORKSPACE_ERROR, errorMessage);
Expand Down Expand Up @@ -649,11 +650,11 @@ export class VersionEngine {

// Enhanced error logging for GitError
if (error instanceof GitError) {
console.error('Git error details:');
log('Git error details:', 'error');
if (error.message.includes('Command failed:')) {
const cmdOutput = error.message.split('Command failed:')[1];
if (cmdOutput) {
console.error('Command output:', cmdOutput.trim());
log(`Command output: ${cmdOutput.trim()}`, 'error');
}
}
}
Expand All @@ -662,8 +663,8 @@ export class VersionEngine {
log(`Version engine failed: ${errorMessage}`, 'error');

if (error instanceof Error && error.stack) {
console.error('Error stack trace:');
console.error(error.stack);
log('Error stack trace:', 'error');
log(error.stack, 'error');
}
}
throw error;
Expand Down
13 changes: 7 additions & 6 deletions packages/version/src/git/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { cwd } from 'node:process';
import { inspect } from 'node:util';
import { createGitCli, type Git } from '@releasekit/git';
import { createGitError, GitError, GitErrorCode } from '../errors/gitError.js';
import { addTag, setCommitMessage } from '../utils/jsonOutput.js';
Expand Down Expand Up @@ -152,8 +153,8 @@ export async function gitProcess(options: GitProcessOptions, git: Git = createGi
log(`Git process error: ${errorMessage}`, 'error');

if (err instanceof Error && err.stack) {
console.error('Git process stack trace:');
console.error(err.stack);
log('Git process stack trace:', 'error');
log(err.stack, 'error');
}

throw createGitError(GitErrorCode.GIT_PROCESS_ERROR, errorMessage);
Expand Down Expand Up @@ -218,18 +219,18 @@ export async function createGitCommitAndTag(
// Enhanced error logging
if (error instanceof Error) {
// Log the full stack trace for debugging
console.error('Git operation error details:');
console.error(error.stack || error.message);
log('Git operation error details:', 'error');
log(error.stack || error.message, 'error');

// Extract and log command output if available
if (errorMessage.includes('Command failed:')) {
const cmdOutput = errorMessage.split('Command failed:')[1];
if (cmdOutput) {
console.error('Git command output:', cmdOutput.trim());
log(`Git command output: ${cmdOutput.trim()}`, 'error');
}
}
} else {
console.error('Unknown git error:', error);
log(`Unknown git error: ${inspect(error)}`, 'error');
}

throw new GitError(`Git operation failed: ${errorMessage}`, GitErrorCode.GIT_ERROR);
Expand Down
1 change: 1 addition & 0 deletions packages/version/src/utils/jsonOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export function getJsonData(): VersionOutput {
*/
export function printJsonOutput(): void {
if (_jsonOutputMode) {
// biome-ignore lint/suspicious/noConsole: prints the --json result
console.log(JSON.stringify(_jsonData, null, 2));
}
}
Loading