Unverified Commit 5cddd681 authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge pull request #341 from crohasang/feature/257

parents ea70ce33 54907966
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -117,10 +117,15 @@ the versioning.
    in each activity, in addition to the activity's own type.
    [[#191], [#342] by Jang Hanarae]

 -  The `fedify` CLI now correctly disables color output when standard output
    isn't a TTY (for example, when redirecting to a file) or when the `NO_COLOR`
    environment variable is set.  [[#257], [#341] by Cho Hasang]

[#168]: https://github.com/fedify-dev/fedify/issues/168
[#191]: https://github.com/fedify-dev/fedify/issues/191
[#197]: https://github.com/fedify-dev/fedify/issues/197
[#248]: https://github.com/fedify-dev/fedify/issues/248
[#257]: https://github.com/fedify-dev/fedify/issues/257
[#260]: https://github.com/fedify-dev/fedify/issues/260
[#261]: https://github.com/fedify-dev/fedify/issues/261
[#262]: https://github.com/fedify-dev/fedify/issues/262
@@ -142,6 +147,7 @@ the versioning.
[#331]: https://github.com/fedify-dev/fedify/pull/331
[#332]: https://github.com/fedify-dev/fedify/pull/332
[#342]: https://github.com/fedify-dev/fedify/pull/342
[#341]: https://github.com/fedify-dev/fedify/pull/341


Version 1.7.7
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
    "@jimp/wasm-webp": "npm:@jimp/wasm-webp@^1.6.0",
    "@poppanator/http-constants": "npm:@poppanator/http-constants@^1.1.1",
    "@std/assert": "jsr:@std/assert@^1.0.13",
    "@std/fmt/colors": "jsr:@std/fmt@^0.224.0/colors",
    "@std/dotenv": "jsr:@std/dotenv@^0.225.2",
    "@std/assert": "jsr:@std/assert@^1.0.0",
    "@std/semver": "jsr:@std/semver@^1.0.5",
+1 −1
Original line number Diff line number Diff line
/** @jsx react-jsx */
/** @jsxImportSource hono/jsx */
import { colors } from "@cliffy/ansi";
import { Command } from "@cliffy/command";
import { Cell, Table } from "@cliffy/table";
import {
@@ -23,6 +22,7 @@ import {
  type Recipient,
} from "@fedify/fedify";
import { getLogger } from "@logtape/logtape";
import * as colors from "@std/fmt/colors";
import { parse } from "@std/semver";
import { type Context as HonoContext, Hono } from "hono";
import type { BlankEnv, BlankInput } from "hono/types";
+35 −25
Original line number Diff line number Diff line
import { colors } from "@cliffy/ansi";
import { Command, EnumType } from "@cliffy/command";
import { Select } from "@cliffy/prompt";
import { getLogger } from "@logtape/logtape";
import { stringify } from "@std/dotenv/stringify";
import * as colors from "@std/fmt/colors";
import { exists } from "@std/fs";
import { basename, dirname, join, normalize } from "@std/path";
import metadata from "./deno.json" with { type: "json" };
@@ -172,11 +172,11 @@ Deno.serve({ handler, ...config.server });
      instruction: `
To start the server, run the following command:

  ${colors.bold.green("deno task start")}
  ${colors.bold(colors.green("deno task start"))}

Then, try look up an actor from your server:

  ${colors.bold.green("fedify lookup http://localhost:8000/users/john")}
  ${colors.bold(colors.green("fedify lookup http://localhost:8000/users/john"))}
`,
    }),
  },
@@ -293,18 +293,18 @@ Deno.serve(
To start the server, run the following command:

  ${
        colors.bold.green(
        colors.bold(colors.green(
          runtime === "deno"
            ? "deno task dev"
            : runtime === "bun"
            ? "bun dev"
            : `${pm} run dev`,
        )
        ))
      }

Then, try look up an actor from your server:

  ${colors.bold.green("fedify lookup http://localhost:8000/users/john")}
  ${colors.bold(colors.green("fedify lookup http://localhost:8000/users/john"))}
`,
    }),
  },
@@ -377,11 +377,11 @@ app.listen(8000, () => {
      instruction: `
To start the server, run the following command:

  ${colors.bold.green(runtime === "bun" ? "bun dev" : `${pm} run dev`)}
  ${colors.bold(colors.green(runtime === "bun" ? "bun dev" : `${pm} run dev`))}

Then, try look up an actor from your server:

  ${colors.bold.green("fedify lookup http://localhost:8000/users/john")}
  ${colors.bold(colors.green("fedify lookup http://localhost:8000/users/john"))}
`,
    }),
  },
@@ -430,11 +430,11 @@ export default defineNitroConfig({
      instruction: `
To start the server, run the following command:

  ${colors.bold.green(runtime === "bun" ? "bun dev" : `${pm} run dev`)}
  ${colors.bold(colors.green(runtime === "bun" ? "bun dev" : `${pm} run dev`))}

Then, try look up an actor from your server:

  ${colors.bold.green("fedify lookup http://localhost:3000/users/john")}
  ${colors.bold(colors.green("fedify lookup http://localhost:3000/users/john"))}
`,
    }),
  },
@@ -879,18 +879,18 @@ Deno.serve(
To start the server, run the following command:

  ${
          colors.bold.green(
          colors.bold(colors.green(
            runtime === "deno"
              ? "deno task dev"
              : runtime === "bun"
              ? "bun dev"
              : `${packageManager} run dev`,
          )
          ))
        }

Then, try look up an actor from your server:

  ${colors.bold.green("fedify lookup http://localhost:8000/users/john")}
  ${colors.bold(colors.green("fedify lookup http://localhost:8000/users/john"))}
`,
      };
    } else {
@@ -1017,7 +1017,9 @@ await configure({

    if (dryRun) {
      console.log(
        colors.bold.yellow("🔍 DRY RUN MODE - No files will be created\n"),
        colors.bold(
          colors.yellow("🔍 DRY RUN MODE - No files will be created\n"),
        ),
      );
    }

@@ -1043,7 +1045,7 @@ await configure({
    }
    if (initializer.command != null) {
      if (dryRun) {
        console.log(colors.bold.cyan("📦 Would run command:"));
        console.log(colors.bold(colors.cyan("📦 Would run command:")));
        console.log(
          `  ${
            [initializer.command[0], ...initializer.command.slice(1)].join(" ")
@@ -1088,7 +1090,7 @@ await configure({
        .map(([name, version]) => `${name}@${version}`)
        .join("\n");
      if (deps) {
        console.log(colors.bold.cyan("📦 Would install dependencies:"));
        console.log(colors.bold(colors.cyan("📦 Would install dependencies:")));
        console.log(`${deps}\n`);
      }
    } else {
@@ -1111,7 +1113,9 @@ await configure({
          .map(([name, version]) => `${name}@${version}`)
          .join("\n");
        if (devDeps) {
          console.log(colors.bold.cyan("📦 Would install dev dependencies:"));
          console.log(
            colors.bold(colors.cyan("📦 Would install dev dependencies:")),
          );
          console.log(`${devDeps}\n`);
        }
      } else {
@@ -1125,7 +1129,7 @@ await configure({
      }
    }
    if (dryRun) {
      console.log(colors.bold.green("📄 Would create files:\n"));
      console.log(colors.bold(colors.green("📄 Would create files:\n")));
      for (const [filename, content] of Object.entries(files)) {
        const path = join(dir, filename);
        displayFileContent(path, content);
@@ -1140,7 +1144,7 @@ await configure({
    }
    if (prependFiles != null) {
      if (dryRun) {
        console.log(colors.bold.blue("Would prepend to files:\n"));
        console.log(colors.bold(colors.blue("Would prepend to files:\n")));
        for (const [filename, prefix] of Object.entries(prependFiles)) {
          const path = join(dir, filename);
          console.log(colors.blue(`${path}`));
@@ -1163,7 +1167,9 @@ await configure({
    }
    if (runtime === "deno") {
      if (dryRun) {
        console.log(colors.bold.green("Would create/update JSON files:\n"));
        console.log(
          colors.bold(colors.green("Would create/update JSON files:\n")),
        );
      }
      await rewriteJsonFile(
        join(dir, "deno.json"),
@@ -1248,7 +1254,9 @@ await configure({
      );
    } else {
      if (dryRun) {
        console.log(colors.bold.green("Would create/update JSON files:\n"));
        console.log(
          colors.bold(colors.green("Would create/update JSON files:\n")),
        );
      }
      await rewriteJsonFile(
        join(dir, "package.json"),
@@ -1362,23 +1370,25 @@ await configure({
    if (Object.keys(env).length > 0) {
      console.error(
        `Note that you probably want to edit the ${
          colors.bold.blue(".env")
          colors.bold(colors.blue(".env"))
        } file.  It currently contains the following values:\n`,
      );
      for (const key in env) {
        const value = stringify({ _: env[key] }).substring(2);
        console.error(`  ${colors.green.bold(key)}${colors.gray("=")}${value}`);
        console.error(
          `  ${colors.bold(colors.green(key))}${colors.gray("=")}${value}`,
        );
      }
      console.error();
    }
    console.error(`\
Start by editing the ${colors.bold.blue(initializer.federationFile)} \
Start by editing the ${colors.bold(colors.blue(initializer.federationFile))} \
file to define your federation!
`);
  });

function drawDinosaur() {
  const d = colors.bgBlue.black;
  const d = (text: string) => colors.bgBlue(colors.black(text));
  const f = colors.blue;
  console.error(`\
${d("             ___   ")}  ${f(" _____        _ _  __")}
+4 −4
Original line number Diff line number Diff line
import { colors } from "@cliffy/ansi";
import { Command, EnumType } from "@cliffy/command";
import {
  Application,
@@ -15,10 +14,12 @@ import {
  traverseCollection,
} from "@fedify/fedify";
import { getLogger } from "@logtape/logtape";
import * as colors from "@std/fmt/colors";
import { dirname, isAbsolute, resolve } from "@std/path";
import ora from "ora";
import { getContextLoader, getDocumentLoader } from "./docloader.ts";
import { spawnTemporaryServer, type TemporaryServer } from "./tempserver.ts";
import { colorEnabled, formatCliObjectOutputWithColor } from "./utils.ts";

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

@@ -107,9 +108,8 @@ export async function writeObjectToStream(
      content = object;
    }

    content = Deno.inspect(content, {
      colors: !(options.output),
    });
    const enableColors = colorEnabled && options.output === undefined;
    content = formatCliObjectOutputWithColor(content, enableColors);

    const encoder = new TextEncoder();
    const bytes = encoder.encode(content + "\n");
Loading