feat: release 2.5.1

This commit is contained in:
2026-09-27 10:40:50 +00:00 Unverified
parent 46d97138dc
commit 5f7509a9c5
53 changed files with 2871 additions and 370 deletions
+22
View File
@@ -49,6 +49,13 @@ function defaultWriter(): LogEventWriter {
};
}
export function parseLogTailLines(value: string): number {
const tailLines = Number(value);
if (!/^\d+$/.test(value) || !Number.isSafeInteger(tailLines))
throw new Error("-n must be a non-negative integer");
return tailLines;
}
export async function runLogs(
project: string,
service: string | undefined,
@@ -56,10 +63,17 @@ export async function runLogs(
signal?: AbortSignal,
stream: LogsApiStream = apiStreamNdjson,
write: LogEventWriter = defaultWriter(),
tailLines?: number,
): Promise<void> {
if (
tailLines !== undefined &&
(!Number.isSafeInteger(tailLines) || tailLines < 0)
)
throw new Error("-n must be a non-negative integer");
const query = new URLSearchParams();
if (service) query.set("service", service);
if (follow) query.set("follow", "true");
if (tailLines !== undefined) query.set("tailLines", String(tailLines));
const suffix = query.size ? `?${query}` : "";
for await (const event of stream<LogApiEvent>(
@@ -87,6 +101,11 @@ export const logs = defineCommand({
alias: "f",
description: "Follow log output",
},
tail: {
type: "string",
alias: "n",
description: "Show the last N lines per container",
},
},
async run({ args }) {
const service = args._[0];
@@ -100,6 +119,9 @@ export const logs = defineCommand({
service,
Boolean(args.follow),
controller.signal,
apiStreamNdjson,
defaultWriter(),
args.tail === undefined ? undefined : parseLogTailLines(args.tail),
);
} catch (error) {
if (!controller.signal.aborted) throw error;