Unverified Commit 6690c81e authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge tag '1.8.4'

Fedify 1.8.4
parents 9b970ef1 afaeb97b
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -9,6 +9,20 @@ Version 1.9.0
To be released.


Version 1.8.4
-------------

Released on August 7, 2025.

### @fedify/cli

 -  Fixed `fedify lookup` command's `-r`/`--raw`, `-C`/`--compact`, and
    `-e`/`--expand` options to properly output valid JSON format instead of
    Deno's object inspection format.  [[#357]]

[#357]: https://github.com/fedify-dev/fedify/issues/357


Version 1.8.3
-------------

+4 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import ora from "ora";
import { getContextLoader, getDocumentLoader } from "./docloader.ts";
import { renderImages } from "./imagerenderer.ts";
import { spawnTemporaryServer, type TemporaryServer } from "./tempserver.ts";
import { colorEnabled, formatCliObjectOutputWithColor } from "./utils.ts";
import { colorEnabled, formatObject } from "./utils.ts";

const logger = getLogger(["fedify", "cli", "lookup"]);

@@ -113,6 +113,7 @@ export async function writeObjectToStream(

  try {
    let content;
    let json = true;
    let imageUrls: URL[] = [];

    if (options.raw) {
@@ -123,10 +124,11 @@ export async function writeObjectToStream(
      content = await object.toJsonLd({ format: "expand", contextLoader });
    } else {
      content = object;
      json = false;
    }

    const enableColors = colorEnabled && options.output === undefined;
    content = formatCliObjectOutputWithColor(content, enableColors);
    content = formatObject(content, enableColors, json);

    const encoder = new TextEncoder();
    const bytes = encoder.encode(content + "\n");
+3 −5
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import * as colors from "@std/fmt/colors";
import { isICO, parseICO } from "icojs";
import { defaultFormats, defaultPlugins, intToRGBA } from "jimp";
import ora from "ora";
import { formatCliObjectOutputWithColor, printJson } from "./utils.ts";
import { formatObject } from "./utils.ts";

const logger = getLogger(["fedify", "cli", "nodeinfo"]);

@@ -62,7 +62,7 @@ export const command = new Command()
        Deno.exit(1);
      }
      spinner.succeed("NodeInfo document fetched.");
      printJson(nodeInfo);
      console.log(formatObject(nodeInfo, undefined, true));
      return;
    }
    const nodeInfo = await getNodeInfo(url, {
@@ -212,9 +212,7 @@ export const command = new Command()
      for (const [key, value] of Object.entries(nodeInfo.metadata)) {
        layout[next()] += `  ${colors.dim(key + ":")} ${
          indent(
            typeof value === "string"
              ? value
              : formatCliObjectOutputWithColor(value),
            typeof value === "string" ? value : formatObject(value),
            defaultWidth + 4 + key.length,
          )
        }`;
+8 −7
Original line number Diff line number Diff line
import { highlight } from "cli-highlight";

export function printJson(json: unknown): void {
  const formatted = JSON.stringify(json, null, 2);
  console.log(highlight(formatted, { language: "json" }));
}

export const colorEnabled: boolean = Deno.stdout.isTerminal() &&
  !Deno.env.has("NO_COLOR");

export function formatCliObjectOutputWithColor(
export function formatObject(
  obj: unknown,
  colors?: boolean,
  json?: boolean,
): string {
  const enableColors = colors ?? colorEnabled;
  return Deno.inspect(obj, { colors: enableColors });
  if (!json) return Deno.inspect(obj, { colors: enableColors });
  const formatted = JSON.stringify(obj, null, 2);
  if (enableColors) {
    return highlight(formatted, { language: "json" });
  }
  return formatted;
}
+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ import { Command, ValidationError } from "@cliffy/command";
import { toAcctUrl } from "@fedify/fedify/vocab";
import { lookupWebFinger } from "@fedify/fedify/webfinger";
import ora from "ora";
import { printJson } from "./utils.ts";
import { formatObject } from "./utils.ts";

export const command = new Command()
  .arguments("<...resources:string>")
@@ -40,7 +40,7 @@ export const command = new Command()
          new NotFoundError(resource).throw(); // throw NotFoundError if not found

        spinner.succeed(`WebFinger found for ${resource}:`); // Succeed the spinner
        printJson(webFinger); // Print the WebFinger
        console.log(formatObject(webFinger, undefined, true)); // Print the WebFinger
      } catch (error) {
        if (error instanceof InvalidHandleError) { // If the handle format is invalid,
          spinner.fail(`Invalid handle format: ${error.handle}`); // log error message with handle