Loading CHANGES.md +5 −1 Original line number Diff line number Diff line Loading @@ -64,9 +64,13 @@ To be released. - The scaffold project generated by `fedify init` command now enables tracing data into log messages. - Let the `fedify lookup` command take multiple arguments. [[#173], [#186] by PGD] [#162]: https://github.com/dahlia/fedify/issues/162 [#162]: https://github.com/dahlia/fedify/issues/162 [#173]: https://github.com/dahlia/fedify/issues/173 [#186]: https://github.com/dahlia/fedify/pull/186 Version 1.2.8 ------------- Loading cli/import_map.g.json +2 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ "@hongminhee/aitertools": "jsr:@hongminhee/aitertools@^0.6.0", "@hugoalh/http-header-link": "jsr:@hugoalh/http-header-link@^1.0.2", "@logtape/logtape": "jsr:@logtape/logtape@^0.8.0", "@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0", "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.27.0", "@phensley/language-tag": "npm:@phensley/language-tag@^1.9.0", "@std/assert": "jsr:@std/assert@^0.226.0", "@std/async": "jsr:@std/async@^1.0.5", Loading cli/lookup.ts +59 −32 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import { spawnTemporaryServer, type TemporaryServer } from "./tempserver.ts"; import { printJson } from "./utils.ts"; export const command = new Command() .arguments("<url:string>") .arguments("<...urls:string>") .description( "Lookup an Activity Streams object by URL or the actor handle. " + "The argument can be either a URL or an actor handle " + Loading @@ -32,7 +32,12 @@ export const command = new Command() conflicts: ["raw", "compact"], }) .option("-u, --user-agent <string>", "The custom User-Agent header value.") .action(async (options, url: string) => { .option( "-s, --separator <separator:string>", "Speicfy the separator between adjacent output object.", { default: "~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~" }, ) .action(async (options, ...urls: string[]) => { const spinner = ora({ text: "Looking up the object...", discardStdin: false, Loading Loading @@ -88,8 +93,17 @@ export const command = new Command() privateKey: key.privateKey, }); } spinner.text = "Initializing succeeded"; spinner.succeed(); let success = true; for (let i = 0; i < urls.length; i++) { const url = urls[i]; const spinnerForEachLookup = ora({ text: "Looking up an object...", discardStdin: false, }).start(); try { spinner.text = "Looking up the object..."; const object = await lookupObject( url, { Loading @@ -98,7 +112,7 @@ export const command = new Command() userAgent: options.userAgent, }, ); spinner.succeed(); if (object == null) { console.error("Failed to fetch the object."); if (authLoader == null) { Loading @@ -106,20 +120,33 @@ export const command = new Command() "It may be a private object. Try with -a/--authorized-fetch.", ); } Deno.exit(1); spinnerForEachLookup.text = `Failed to lookup: ${url}`; spinnerForEachLookup.fail(); success = false; continue; } spinnerForEachLookup.succeed(); if (options.raw) { printJson(await object.toJsonLd({ contextLoader })); } else if (options.compact) { printJson(await object.toJsonLd({ format: "compact", contextLoader })); printJson( await object.toJsonLd({ format: "compact", contextLoader }), ); } else if (options.expand) { printJson(await object.toJsonLd({ format: "expand", contextLoader })); } else { console.log(object); } if (i < urls.length - 1) { console.error(options.separator); } } catch (_) { spinner.fail(); } finally { spinnerForEachLookup.fail(); success = false; } } await server?.close(); if (!success) { Deno.exit(1); } }); Loading
CHANGES.md +5 −1 Original line number Diff line number Diff line Loading @@ -64,9 +64,13 @@ To be released. - The scaffold project generated by `fedify init` command now enables tracing data into log messages. - Let the `fedify lookup` command take multiple arguments. [[#173], [#186] by PGD] [#162]: https://github.com/dahlia/fedify/issues/162 [#162]: https://github.com/dahlia/fedify/issues/162 [#173]: https://github.com/dahlia/fedify/issues/173 [#186]: https://github.com/dahlia/fedify/pull/186 Version 1.2.8 ------------- Loading
cli/import_map.g.json +2 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ "@hongminhee/aitertools": "jsr:@hongminhee/aitertools@^0.6.0", "@hugoalh/http-header-link": "jsr:@hugoalh/http-header-link@^1.0.2", "@logtape/logtape": "jsr:@logtape/logtape@^0.8.0", "@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0", "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.27.0", "@phensley/language-tag": "npm:@phensley/language-tag@^1.9.0", "@std/assert": "jsr:@std/assert@^0.226.0", "@std/async": "jsr:@std/async@^1.0.5", Loading
cli/lookup.ts +59 −32 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import { spawnTemporaryServer, type TemporaryServer } from "./tempserver.ts"; import { printJson } from "./utils.ts"; export const command = new Command() .arguments("<url:string>") .arguments("<...urls:string>") .description( "Lookup an Activity Streams object by URL or the actor handle. " + "The argument can be either a URL or an actor handle " + Loading @@ -32,7 +32,12 @@ export const command = new Command() conflicts: ["raw", "compact"], }) .option("-u, --user-agent <string>", "The custom User-Agent header value.") .action(async (options, url: string) => { .option( "-s, --separator <separator:string>", "Speicfy the separator between adjacent output object.", { default: "~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~" }, ) .action(async (options, ...urls: string[]) => { const spinner = ora({ text: "Looking up the object...", discardStdin: false, Loading Loading @@ -88,8 +93,17 @@ export const command = new Command() privateKey: key.privateKey, }); } spinner.text = "Initializing succeeded"; spinner.succeed(); let success = true; for (let i = 0; i < urls.length; i++) { const url = urls[i]; const spinnerForEachLookup = ora({ text: "Looking up an object...", discardStdin: false, }).start(); try { spinner.text = "Looking up the object..."; const object = await lookupObject( url, { Loading @@ -98,7 +112,7 @@ export const command = new Command() userAgent: options.userAgent, }, ); spinner.succeed(); if (object == null) { console.error("Failed to fetch the object."); if (authLoader == null) { Loading @@ -106,20 +120,33 @@ export const command = new Command() "It may be a private object. Try with -a/--authorized-fetch.", ); } Deno.exit(1); spinnerForEachLookup.text = `Failed to lookup: ${url}`; spinnerForEachLookup.fail(); success = false; continue; } spinnerForEachLookup.succeed(); if (options.raw) { printJson(await object.toJsonLd({ contextLoader })); } else if (options.compact) { printJson(await object.toJsonLd({ format: "compact", contextLoader })); printJson( await object.toJsonLd({ format: "compact", contextLoader }), ); } else if (options.expand) { printJson(await object.toJsonLd({ format: "expand", contextLoader })); } else { console.log(object); } if (i < urls.length - 1) { console.error(options.separator); } } catch (_) { spinner.fail(); } finally { spinnerForEachLookup.fail(); success = false; } } await server?.close(); if (!success) { Deno.exit(1); } });