Loading cli/inbox.tsx +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 { Loading @@ -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"; Loading cli/init.ts +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" }; Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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 { Loading Loading @@ -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"), ), ); } Loading @@ -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(" ") Loading Loading @@ -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 { Loading @@ -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 { Loading @@ -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); Loading @@ -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}`)); Loading @@ -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"), Loading Loading @@ -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"), Loading Loading @@ -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(" _____ _ _ __")} Loading cli/lookup.ts +1 −1 Original line number Diff line number Diff line import { colors } from "@cliffy/ansi"; import { Command, EnumType } from "@cliffy/command"; import { Application, Loading @@ -15,6 +14,7 @@ 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"; Loading cli/mod.ts +3 −1 Original line number Diff line number Diff line Loading @@ -13,8 +13,10 @@ import { command as nodeinfo } from "./nodeinfo.ts"; import { command as tunnel } from "./tunnel.ts"; import { command as webfinger } from "./webfinger.ts"; const colorEnabled = Deno.stdout.isTerminal(); const colorEnabled = Deno.stdout.isTerminal() && Deno.env.get("NO_COLOR") === undefined; setColorEnabled(colorEnabled); console.log("Color Enabled:", colorEnabled); const command = new Command() .name("fedify") Loading cli/nodeinfo.ts +10 −10 Original line number Diff line number Diff line import { colors } from "@cliffy/ansi"; import { Command } from "@cliffy/command"; import { formatSemVer, getNodeInfo, getUserAgent } from "@fedify/fedify"; import { createJimp } from "@jimp/core"; import webp from "@jimp/wasm-webp"; import { getLogger } from "@logtape/logtape"; import * as colors from "@std/fmt/colors"; import { isICO, parseICO } from "icojs"; import { defaultFormats, defaultPlugins, intToRGBA } from "jimp"; import ora from "ora"; Loading Loading @@ -139,7 +139,7 @@ export const command = new Command() }; layout[i] += colors.bold(url.host); layout[next()] += colors.dim("=".repeat(url.host.length)); layout[next()] += colors.bold.dim("Software:"); layout[next()] += colors.bold(colors.dim("Software:")); layout[next()] += ` ${nodeInfo.software.name} v${ formatSemVer(nodeInfo.software.version) }`; Loading @@ -151,19 +151,19 @@ export const command = new Command() colors.dim(nodeInfo.software.repository.href); } if (nodeInfo.protocols.length > 0) { layout[next()] += colors.bold.dim("Protocols:"); layout[next()] += colors.bold(colors.dim("Protocols:")); for (const protocol of nodeInfo.protocols) { layout[next()] += ` ${protocol}`; } } if (nodeInfo.services?.inbound?.length ?? 0 > 0) { layout[next()] += colors.bold.dim("Inbound services:"); layout[next()] += colors.bold(colors.dim("Inbound services:")); for (const service of nodeInfo.services?.inbound ?? []) { layout[next()] += ` ${service}`; } } if (nodeInfo.services?.outbound?.length ?? 0 > 0) { layout[next()] += colors.bold.dim("Outbound services:"); layout[next()] += colors.bold(colors.dim("Outbound services:")); for (const service of nodeInfo.services?.outbound ?? []) { layout[next()] += ` ${service}`; } Loading @@ -173,7 +173,7 @@ export const command = new Command() nodeInfo.usage.users.activeHalfyear != null || nodeInfo.usage.users.activeMonth != null) ) { layout[next()] += colors.bold.dim("Users:"); layout[next()] += colors.bold(colors.dim("Users:")); if (nodeInfo.usage.users.total != null) { layout[next()] += ` ${nodeInfo.usage.users.total.toLocaleString("en-US")} ` + Loading @@ -191,24 +191,24 @@ export const command = new Command() } } if (nodeInfo.usage?.localPosts != null) { layout[next()] += colors.bold.dim("Local posts: "); layout[next()] += colors.bold(colors.dim("Local posts: ")); layout[next()] += " " + nodeInfo.usage.localPosts.toLocaleString("en-US"); } if (nodeInfo.usage?.localComments != null) { layout[next()] += colors.bold.dim("Local comments:"); layout[next()] += colors.bold(colors.dim("Local comments:")); layout[next()] += " " + nodeInfo.usage.localComments.toLocaleString("en-US"); } if (nodeInfo.openRegistrations != null) { layout[next()] += colors.bold.dim("Open registrations:"); layout[next()] += colors.bold(colors.dim("Open registrations:")); layout[next()] += " " + (nodeInfo.openRegistrations ? "Yes" : "No"); } if ( options.metadata && nodeInfo.metadata != null && Object.keys(nodeInfo.metadata).length > 0 ) { layout[next()] += colors.bold.dim("Metadata:"); layout[next()] += colors.bold(colors.dim("Metadata:")); for (const [key, value] of Object.entries(nodeInfo.metadata)) { layout[next()] += ` ${colors.dim(key + ":")} ${ indent( Loading Loading
cli/inbox.tsx +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 { Loading @@ -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"; Loading
cli/init.ts +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" }; Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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"))} `, }), }, Loading Loading @@ -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 { Loading Loading @@ -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"), ), ); } Loading @@ -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(" ") Loading Loading @@ -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 { Loading @@ -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 { Loading @@ -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); Loading @@ -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}`)); Loading @@ -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"), Loading Loading @@ -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"), Loading Loading @@ -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(" _____ _ _ __")} Loading
cli/lookup.ts +1 −1 Original line number Diff line number Diff line import { colors } from "@cliffy/ansi"; import { Command, EnumType } from "@cliffy/command"; import { Application, Loading @@ -15,6 +14,7 @@ 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"; Loading
cli/mod.ts +3 −1 Original line number Diff line number Diff line Loading @@ -13,8 +13,10 @@ import { command as nodeinfo } from "./nodeinfo.ts"; import { command as tunnel } from "./tunnel.ts"; import { command as webfinger } from "./webfinger.ts"; const colorEnabled = Deno.stdout.isTerminal(); const colorEnabled = Deno.stdout.isTerminal() && Deno.env.get("NO_COLOR") === undefined; setColorEnabled(colorEnabled); console.log("Color Enabled:", colorEnabled); const command = new Command() .name("fedify") Loading
cli/nodeinfo.ts +10 −10 Original line number Diff line number Diff line import { colors } from "@cliffy/ansi"; import { Command } from "@cliffy/command"; import { formatSemVer, getNodeInfo, getUserAgent } from "@fedify/fedify"; import { createJimp } from "@jimp/core"; import webp from "@jimp/wasm-webp"; import { getLogger } from "@logtape/logtape"; import * as colors from "@std/fmt/colors"; import { isICO, parseICO } from "icojs"; import { defaultFormats, defaultPlugins, intToRGBA } from "jimp"; import ora from "ora"; Loading Loading @@ -139,7 +139,7 @@ export const command = new Command() }; layout[i] += colors.bold(url.host); layout[next()] += colors.dim("=".repeat(url.host.length)); layout[next()] += colors.bold.dim("Software:"); layout[next()] += colors.bold(colors.dim("Software:")); layout[next()] += ` ${nodeInfo.software.name} v${ formatSemVer(nodeInfo.software.version) }`; Loading @@ -151,19 +151,19 @@ export const command = new Command() colors.dim(nodeInfo.software.repository.href); } if (nodeInfo.protocols.length > 0) { layout[next()] += colors.bold.dim("Protocols:"); layout[next()] += colors.bold(colors.dim("Protocols:")); for (const protocol of nodeInfo.protocols) { layout[next()] += ` ${protocol}`; } } if (nodeInfo.services?.inbound?.length ?? 0 > 0) { layout[next()] += colors.bold.dim("Inbound services:"); layout[next()] += colors.bold(colors.dim("Inbound services:")); for (const service of nodeInfo.services?.inbound ?? []) { layout[next()] += ` ${service}`; } } if (nodeInfo.services?.outbound?.length ?? 0 > 0) { layout[next()] += colors.bold.dim("Outbound services:"); layout[next()] += colors.bold(colors.dim("Outbound services:")); for (const service of nodeInfo.services?.outbound ?? []) { layout[next()] += ` ${service}`; } Loading @@ -173,7 +173,7 @@ export const command = new Command() nodeInfo.usage.users.activeHalfyear != null || nodeInfo.usage.users.activeMonth != null) ) { layout[next()] += colors.bold.dim("Users:"); layout[next()] += colors.bold(colors.dim("Users:")); if (nodeInfo.usage.users.total != null) { layout[next()] += ` ${nodeInfo.usage.users.total.toLocaleString("en-US")} ` + Loading @@ -191,24 +191,24 @@ export const command = new Command() } } if (nodeInfo.usage?.localPosts != null) { layout[next()] += colors.bold.dim("Local posts: "); layout[next()] += colors.bold(colors.dim("Local posts: ")); layout[next()] += " " + nodeInfo.usage.localPosts.toLocaleString("en-US"); } if (nodeInfo.usage?.localComments != null) { layout[next()] += colors.bold.dim("Local comments:"); layout[next()] += colors.bold(colors.dim("Local comments:")); layout[next()] += " " + nodeInfo.usage.localComments.toLocaleString("en-US"); } if (nodeInfo.openRegistrations != null) { layout[next()] += colors.bold.dim("Open registrations:"); layout[next()] += colors.bold(colors.dim("Open registrations:")); layout[next()] += " " + (nodeInfo.openRegistrations ? "Yes" : "No"); } if ( options.metadata && nodeInfo.metadata != null && Object.keys(nodeInfo.metadata).length > 0 ) { layout[next()] += colors.bold.dim("Metadata:"); layout[next()] += colors.bold(colors.dim("Metadata:")); for (const [key, value] of Object.entries(nodeInfo.metadata)) { layout[next()] += ` ${colors.dim(key + ":")} ${ indent( Loading