Skip to content

Commit a8ea020

Browse files
claude: add error,info,warning to quarto console api
also, load builtin engine extensions
1 parent a036936 commit a8ea020

File tree

5 files changed

+111
-2
lines changed

5 files changed

+111
-2
lines changed

packages/quarto-types/dist/index.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,25 @@ export interface SpinnerOptions {
726726
/** Message to display when done, or false to hide, or true to keep original message */
727727
doneMessage?: string | boolean;
728728
}
729+
/**
730+
* Options for log messages (info, warning, error)
731+
*/
732+
export interface LogMessageOptions {
733+
/** Whether to add a trailing newline (default: true) */
734+
newline?: boolean;
735+
/** Apply bold formatting */
736+
bold?: boolean;
737+
/** Apply dim/gray formatting */
738+
dim?: boolean;
739+
/** Number of spaces to indent each line */
740+
indent?: number;
741+
/** Custom format function applied to each line */
742+
format?: (line: string) => string;
743+
/** Enable color formatting (default: true) */
744+
colorize?: boolean;
745+
/** Remove ANSI escape codes from output */
746+
stripAnsiCode?: boolean;
747+
}
729748
/**
730749
* Render services available during check operations
731750
* Simplified version containing only what check operations need
@@ -1357,6 +1376,36 @@ export interface QuartoAPI {
13571376
* @param message - Message to display
13581377
*/
13591378
completeMessage: (message: string) => void;
1379+
/**
1380+
* Log an informational message to stderr
1381+
*
1382+
* Writes an info-level message to stderr using Quarto's custom logging handler.
1383+
* Supports formatting options like indentation, bold text, and color control.
1384+
*
1385+
* @param message - Message to log
1386+
* @param options - Optional formatting options
1387+
*/
1388+
info: (message: string, options?: LogMessageOptions) => void;
1389+
/**
1390+
* Log a warning message to stderr
1391+
*
1392+
* Writes a warning-level message to stderr with yellow color and "WARNING:" prefix.
1393+
* Uses Quarto's custom logging handler.
1394+
*
1395+
* @param message - Warning message to log
1396+
* @param options - Optional formatting options
1397+
*/
1398+
warning: (message: string, options?: LogMessageOptions) => void;
1399+
/**
1400+
* Log an error message to stderr
1401+
*
1402+
* Writes an error-level message to stderr with bright red color and "ERROR:" prefix.
1403+
* Uses Quarto's custom logging handler.
1404+
*
1405+
* @param message - Error message to log
1406+
* @param options - Optional formatting options
1407+
*/
1408+
error: (message: string, options?: LogMessageOptions) => void;
13601409
};
13611410
/**
13621411
* Cryptographic utilities

packages/quarto-types/src/console.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,23 @@ export interface SpinnerOptions {
1111
/** Message to display when done, or false to hide, or true to keep original message */
1212
doneMessage?: string | boolean;
1313
}
14+
15+
/**
16+
* Options for log messages (info, warning, error)
17+
*/
18+
export interface LogMessageOptions {
19+
/** Whether to add a trailing newline (default: true) */
20+
newline?: boolean;
21+
/** Apply bold formatting */
22+
bold?: boolean;
23+
/** Apply dim/gray formatting */
24+
dim?: boolean;
25+
/** Number of spaces to indent each line */
26+
indent?: number;
27+
/** Custom format function applied to each line */
28+
format?: (line: string) => string;
29+
/** Enable color formatting (default: true) */
30+
colorize?: boolean;
31+
/** Remove ANSI escape codes from output */
32+
stripAnsiCode?: boolean;
33+
}

packages/quarto-types/src/quarto-api.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import type {
2727
ExecProcessOptions,
2828
TempContext,
2929
} from "./system.ts";
30-
import type { SpinnerOptions } from "./console.ts";
30+
import type { LogMessageOptions, SpinnerOptions } from "./console.ts";
3131
import type {
3232
CheckRenderOptions,
3333
CheckRenderResult,
@@ -729,6 +729,39 @@ export interface QuartoAPI {
729729
* @param message - Message to display
730730
*/
731731
completeMessage: (message: string) => void;
732+
733+
/**
734+
* Log an informational message to stderr
735+
*
736+
* Writes an info-level message to stderr using Quarto's custom logging handler.
737+
* Supports formatting options like indentation, bold text, and color control.
738+
*
739+
* @param message - Message to log
740+
* @param options - Optional formatting options
741+
*/
742+
info: (message: string, options?: LogMessageOptions) => void;
743+
744+
/**
745+
* Log a warning message to stderr
746+
*
747+
* Writes a warning-level message to stderr with yellow color and "WARNING:" prefix.
748+
* Uses Quarto's custom logging handler.
749+
*
750+
* @param message - Warning message to log
751+
* @param options - Optional formatting options
752+
*/
753+
warning: (message: string, options?: LogMessageOptions) => void;
754+
755+
/**
756+
* Log an error message to stderr
757+
*
758+
* Writes an error-level message to stderr with bright red color and "ERROR:" prefix.
759+
* Uses Quarto's custom logging handler.
760+
*
761+
* @param message - Error message to log
762+
* @param options - Optional formatting options
763+
*/
764+
error: (message: string, options?: LogMessageOptions) => void;
732765
};
733766

734767
/**

src/core/quarto-api.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ import {
5858
import { completeMessage, withSpinner } from "./console.ts";
5959
import { checkRender } from "../command/check/check-render.ts";
6060
import type { RenderServiceWithLifetime } from "../command/render/types.ts";
61+
import type { LogMessageOptions } from "./log.ts";
62+
import { error, info, warning } from "../deno_ral/log.ts";
6163

6264
export interface QuartoAPI {
6365
markdownRegex: {
@@ -211,6 +213,9 @@ export interface QuartoAPI {
211213
fn: () => Promise<T>,
212214
) => Promise<T>;
213215
completeMessage: (message: string) => void;
216+
info: (message: string, options?: LogMessageOptions) => void;
217+
warning: (message: string, options?: LogMessageOptions) => void;
218+
error: (message: string, options?: LogMessageOptions) => void;
214219
};
215220
crypto: {
216221
md5Hash: (content: string) => string;
@@ -372,6 +377,9 @@ export const quartoAPI: QuartoAPI = {
372377
console: {
373378
withSpinner,
374379
completeMessage,
380+
info,
381+
warning,
382+
error,
375383
},
376384

377385
crypto: {

src/project/project-context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,6 @@ export async function resolveEngineExtensions(
756756
undefined,
757757
projectConfig,
758758
dir,
759-
{ builtIn: false },
760759
);
761760

762761
// Filter to only those with engines

0 commit comments

Comments
 (0)