@fedify/cli 2.3.0-dev.1347 → 2.3.0-dev.1361

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/bench/action.js +29 -189
  2. package/dist/bench/command.js +13 -43
  3. package/dist/bench/load/clock.js +2 -20
  4. package/dist/bench/load/generator.js +9 -42
  5. package/dist/bench/metrics/stats-client.js +3 -65
  6. package/dist/bench/mod.js +2 -9
  7. package/dist/bench/render/markdown.js +0 -1
  8. package/dist/bench/render/text.js +0 -1
  9. package/dist/bench/result/build.js +10 -133
  10. package/dist/bench/result/expect/evaluate.js +1 -1
  11. package/dist/bench/result/schema.js +3 -353
  12. package/dist/bench/safety/gate.js +2 -4
  13. package/dist/bench/scenario/normalize.js +2 -1
  14. package/dist/bench/scenario/schema.js +9 -50
  15. package/dist/bench/scenario/validate.js +2 -2
  16. package/dist/bench/scenarios/inbox.js +12 -4
  17. package/dist/bench/scenarios/registry.js +1 -19
  18. package/dist/bench/scenarios/runner.js +1 -21
  19. package/dist/bench/scenarios/webfinger.js +1 -1
  20. package/dist/cache.js +1 -1
  21. package/dist/config.js +1 -1
  22. package/dist/deno.js +1 -1
  23. package/dist/docloader.js +1 -1
  24. package/dist/generate-vocab/action.js +1 -1
  25. package/dist/generate-vocab/command.js +3 -5
  26. package/dist/generate-vocab/mod.js +4 -0
  27. package/dist/imagerenderer.js +2 -2
  28. package/dist/inbox/command.js +4 -6
  29. package/dist/inbox.js +4 -4
  30. package/dist/init/mod.js +3 -0
  31. package/dist/log.js +2 -2
  32. package/dist/lookup.js +123 -12
  33. package/dist/mod.js +23 -2
  34. package/dist/nodeinfo.js +9 -11
  35. package/dist/options.js +1 -1
  36. package/dist/relay/command.js +4 -6
  37. package/dist/relay.js +2 -2
  38. package/dist/runner.js +46 -69
  39. package/dist/tempserver.js +1 -1
  40. package/dist/tunnel.js +4 -6
  41. package/dist/utils.js +4 -5
  42. package/dist/webfinger/action.js +1 -1
  43. package/dist/webfinger/command.js +4 -6
  44. package/dist/webfinger/lib.js +1 -1
  45. package/dist/webfinger/mod.js +4 -0
  46. package/package.json +12 -13
  47. package/dist/bench/compare/schema.js +0 -16
  48. package/dist/bench/compare.js +0 -667
  49. package/dist/bench/scenarios/actor.js +0 -38
  50. package/dist/bench/scenarios/failure.js +0 -363
  51. package/dist/bench/scenarios/fanout.js +0 -261
  52. package/dist/bench/scenarios/mixed.js +0 -244
  53. package/dist/bench/scenarios/object-discovery.js +0 -211
  54. package/dist/bench/scenarios/object.js +0 -54
  55. package/dist/bench/scenarios/read.js +0 -108
  56. package/dist/commands.js +0 -110
  57. package/dist/lookup/command.js +0 -121
package/dist/options.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import { configContext } from "./config.js";
3
+ import { getUserAgent } from "@fedify/vocab-runtime";
3
4
  import { choice, constant, flag, map, merge, message, object, option, optional, or, string, withDefault } from "@optique/core";
4
5
  import { bindConfig } from "@optique/config";
5
- import { getUserAgent } from "@fedify/vocab-runtime";
6
6
  //#region src/options.ts
7
7
  /**
8
8
  * Available tunneling services for exposing local servers to the public internet.
@@ -5,7 +5,7 @@ import { command, constant, group, integer, merge, message, multiple, object, op
5
5
  import { bindConfig } from "@optique/config";
6
6
  import { choice as choice$1 } from "@optique/core/valueparser";
7
7
  //#region src/relay/command.ts
8
- const relayOptions = merge(object("Relay options", {
8
+ const relayCommand = command("relay", merge(object("Relay options", {
9
9
  command: constant("relay"),
10
10
  protocol: bindConfig(option("-p", "--protocol", choice$1(["mastodon", "litepub"], { metavar: "TYPE" }), { description: message`The relay protocol to use. ${value("mastodon")} for Mastodon-compatible relay, ${value("litepub")} for LitePub-compatible relay.` }), {
11
11
  context: configContext,
@@ -40,13 +40,11 @@ const relayOptions = merge(object("Relay options", {
40
40
  key: (config) => config.relay?.rejectFollow ?? [],
41
41
  default: []
42
42
  })
43
- }), group("Tunnel options", createTunnelOption("relay")));
44
- const relayMetadata = {
43
+ }), group("Tunnel options", createTunnelOption("relay"))), {
45
44
  brief: message`Run an ephemeral ActivityPub relay server.`,
46
45
  description: message`Spins up an ActivityPub relay server that forwards activities between federated instances. The server can use either Mastodon or LitePub compatible relay protocol.
47
46
 
48
47
  By default, the server is tunneled to the public internet for external access. Use ${optionName("--no-tunnel")} to run locally only.`
49
- };
50
- command("relay", relayOptions, relayMetadata);
48
+ });
51
49
  //#endregion
52
- export { relayMetadata, relayOptions };
50
+ export { relayCommand };
package/dist/relay.js CHANGED
@@ -6,11 +6,11 @@ import { spawnTemporaryServer } from "./tempserver.js";
6
6
  import process from "node:process";
7
7
  import { MemoryKvStore } from "@fedify/fedify";
8
8
  import { getLogger } from "@logtape/logtape";
9
+ import Table from "cli-table3";
9
10
  import ora from "ora";
11
+ import { createRelay } from "@fedify/relay";
10
12
  import { SqliteKvStore } from "@fedify/sqlite";
11
13
  import { DatabaseSync } from "node:sqlite";
12
- import Table from "cli-table3";
13
- import { createRelay } from "@fedify/relay";
14
14
  //#region src/relay.ts
15
15
  const logger = getLogger([
16
16
  "fedify",
package/dist/runner.js CHANGED
@@ -1,17 +1,27 @@
1
1
  import "@js-temporal/polyfill";
2
- import { configContext, tryLoadToml } from "./config.js";
3
- import { globalOptions } from "./options.js";
4
2
  import { describeError } from "./utils.js";
5
- import { activityPubCommands, generatingCommands, networkCommands } from "./commands.js";
6
3
  import { version } from "./deno.js";
4
+ import { configContext, tryLoadToml } from "./config.js";
5
+ import { globalOptions } from "./options.js";
6
+ import { benchCommand } from "./bench/command.js";
7
+ import generateVocabCommand from "./generate-vocab/command.js";
8
+ import "./generate-vocab/mod.js";
9
+ import { initCommand } from "./init/mod.js";
10
+ import { nodeInfoCommand } from "./nodeinfo.js";
11
+ import { lookupCommand } from "./lookup.js";
12
+ import { inboxCommand } from "./inbox/command.js";
13
+ import { relayCommand } from "./relay/command.js";
14
+ import { tunnelCommand } from "./tunnel.js";
15
+ import { webFingerCommand } from "./webfinger/command.js";
16
+ import "./webfinger/mod.js";
7
17
  import process from "node:process";
8
- import { command, group, map, merge, message, or } from "@optique/core";
18
+ import { group, merge, message, or } from "@optique/core";
9
19
  import { printError, run } from "@optique/run";
10
20
  import { merge as merge$1 } from "es-toolkit";
11
- import { readFileSync } from "node:fs";
12
21
  import { homedir } from "node:os";
13
- import { join } from "node:path";
22
+ import { readFileSync } from "node:fs";
14
23
  import { parse } from "smol-toml";
24
+ import { join } from "node:path";
15
25
  //#region src/runner.ts
16
26
  /**
17
27
  * Returns the system-wide configuration file paths.
@@ -31,35 +41,36 @@ function getUserConfigPath() {
31
41
  if (process.platform === "win32") return join(process.env.APPDATA || join(homedir(), "AppData", "Roaming"), "fedify", "config.toml");
32
42
  return join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "fedify", "config.toml");
33
43
  }
34
- const selectedCommand = "__fedifyCliSelectedCommand";
35
- const selectedRun = "__fedifyCliRunCommand";
36
- function staticCommandParser(staticCommand) {
37
- if (staticCommand.path.length < 1) throw new TypeError("Static command path must not be empty.");
38
- let parser = staticCommand.parser;
39
- for (let i = staticCommand.path.length - 1; i >= 0; i--) {
40
- const name = staticCommand.path[i];
41
- if (name == null) throw new TypeError("Static command path contains an empty segment.");
42
- parser = command(name, parser, i === staticCommand.path.length - 1 ? staticCommand.metadata : void 0);
44
+ const command$1 = merge(or(group("Generating code", or(initCommand, generateVocabCommand)), group("ActivityPub tools", or(webFingerCommand, lookupCommand, inboxCommand, nodeInfoCommand, relayCommand, benchCommand)), group("Network tools", tunnelCommand)), globalOptions);
45
+ function loadConfig(parsed) {
46
+ if (parsed.ignoreConfig) return void 0;
47
+ const system = getSystemConfigPaths().map(tryLoadToml).reduce((acc, config) => merge$1(acc, config), {});
48
+ const user = tryLoadToml(getUserConfigPath());
49
+ const project = tryLoadToml(join(process.cwd(), ".fedify.toml"));
50
+ let custom = {};
51
+ if (parsed.configPath) try {
52
+ custom = parse(readFileSync(parsed.configPath, "utf-8"));
53
+ } catch (error) {
54
+ printError(message`Could not load config file at ${parsed.configPath}: ${describeError(error)}`);
55
+ process.exit(1);
43
56
  }
44
- const runCommand = staticCommand.run;
45
- return map(parser, (value) => ({
46
- ...value,
47
- [selectedCommand]: staticCommand,
48
- [selectedRun]: (globalOptions) => runCommand({
49
- ...value,
50
- ...globalOptions
51
- })
52
- }));
53
- }
54
- function staticCommandsParser(commands) {
55
- const parsers = commands.map(staticCommandParser);
56
- if (parsers.length < 1) throw new TypeError("Static command group must not be empty.");
57
- return parsers.length === 1 ? parsers[0] : or(...parsers);
58
- }
59
- const runnableCommand = merge(or(group("Generating code", staticCommandsParser(generatingCommands)), group("ActivityPub tools", staticCommandsParser(activityPubCommands)), group("Network tools", staticCommandsParser(networkCommands))), globalOptions);
60
- map(runnableCommand, ({ [selectedCommand]: _selectedCommand, [selectedRun]: _selectedRun, ...value }) => value);
61
- function getRunOptions(args) {
62
57
  return {
58
+ config: [
59
+ system,
60
+ user,
61
+ project,
62
+ custom
63
+ ].reduce((acc, config) => merge$1(acc, config), {}),
64
+ meta: void 0
65
+ };
66
+ }
67
+ /**
68
+ * Runs the Fedify CLI with the given command-line arguments.
69
+ * @param args Command-line arguments, usually `process.argv.slice(2)`.
70
+ * @returns The parsed command result from Optique's runner.
71
+ */
72
+ function runCli(args) {
73
+ return run(command$1, {
63
74
  contexts: [configContext],
64
75
  contextOptions: { load: loadConfig },
65
76
  programName: "fedify",
@@ -81,41 +92,7 @@ function getRunOptions(args) {
81
92
  maxWidth: process.stdout.columns,
82
93
  showDefault: true,
83
94
  showChoices: true
84
- };
85
- }
86
- function loadConfig(parsed) {
87
- if (parsed.ignoreConfig) return void 0;
88
- const system = getSystemConfigPaths().map(tryLoadToml).reduce((acc, config) => merge$1(acc, config), {});
89
- const user = tryLoadToml(getUserConfigPath());
90
- const project = tryLoadToml(join(process.cwd(), ".fedify.toml"));
91
- let custom = {};
92
- if (parsed.configPath) try {
93
- custom = parse(readFileSync(parsed.configPath, "utf-8"));
94
- } catch (error) {
95
- printError(message`Could not load config file at ${parsed.configPath}: ${describeError(error)}`);
96
- process.exit(1);
97
- }
98
- return {
99
- config: [
100
- system,
101
- user,
102
- project,
103
- custom
104
- ].reduce((acc, config) => merge$1(acc, config), {}),
105
- meta: void 0
106
- };
107
- }
108
- function toCliProgram(parsed) {
109
- const { [selectedCommand]: command, [selectedRun]: runCommand, ...value } = parsed;
110
- const publicValue = value;
111
- return {
112
- command,
113
- value: publicValue,
114
- run: () => runCommand(publicValue)
115
- };
116
- }
117
- async function parseCliProgram(args) {
118
- return toCliProgram(await run(runnableCommand, getRunOptions(args)));
95
+ });
119
96
  }
120
97
  //#endregion
121
- export { parseCliProgram };
98
+ export { runCli };
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import { getLogger } from "@logtape/logtape";
3
- import { openTunnel } from "@hongminhee/localtunnel";
4
3
  import { serve } from "srvx";
4
+ import { openTunnel } from "@hongminhee/localtunnel";
5
5
  //#region src/tempserver.ts
6
6
  const logger = getLogger([
7
7
  "fedify",
package/dist/tunnel.js CHANGED
@@ -7,21 +7,19 @@ import { print, printError } from "@optique/run";
7
7
  import ora from "ora";
8
8
  import { openTunnel } from "@hongminhee/localtunnel";
9
9
  //#region src/tunnel.ts
10
- const tunnelOptions = merge("Tunnel options", object({ command: constant("tunnel") }), object({
10
+ const tunnelCommand = command("tunnel", merge("Tunnel options", object({ command: constant("tunnel") }), object({
11
11
  port: argument(integer({
12
12
  metavar: "PORT",
13
13
  min: 0,
14
14
  max: 65535
15
15
  }), { description: message`The local port number to expose.` }),
16
16
  service: createTunnelServiceOption(["-s", "--service"])
17
- }));
18
- const tunnelMetadata = {
17
+ })), {
19
18
  brief: message`Expose a local HTTP server to the public internet using a secure tunnel.`,
20
19
  description: message`Expose a local HTTP server to the public internet using a secure tunnel.
21
20
 
22
21
  Note that the HTTP requests through the tunnel have X-Forwarded-* headers.`
23
- };
24
- command("tunnel", tunnelOptions, tunnelMetadata);
22
+ });
25
23
  async function runTunnel(command, deps = {
26
24
  openTunnel,
27
25
  ora,
@@ -51,4 +49,4 @@ async function runTunnel(command, deps = {
51
49
  });
52
50
  }
53
51
  //#endregion
54
- export { runTunnel, tunnelMetadata, tunnelOptions };
52
+ export { runTunnel, tunnelCommand };
package/dist/utils.js CHANGED
@@ -1,14 +1,13 @@
1
1
  import "@js-temporal/polyfill";
2
+ import "node:fs/promises";
2
3
  import process from "node:process";
3
- import { message } from "@optique/core";
4
- import { print, printError } from "@optique/run";
5
- import { flow } from "es-toolkit";
6
4
  import { getActorHandle } from "@fedify/vocab";
7
5
  import "@fxts/core";
6
+ import { message } from "@optique/core";
7
+ import { print, printError } from "@optique/run";
8
8
  import { Chalk } from "chalk";
9
9
  import { highlight } from "cli-highlight";
10
- import "node:child_process";
11
- import "node:fs/promises";
10
+ import { flow } from "es-toolkit";
12
11
  import util from "node:util";
13
12
  //#region src/utils.ts
14
13
  const colorEnabled = process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "");
@@ -3,8 +3,8 @@ import { formatObject } from "../utils.js";
3
3
  import { NotFoundError, getErrorMessage } from "./error.js";
4
4
  import { convertUrlIfHandle } from "./lib.js";
5
5
  import { print } from "@optique/run";
6
- import ora from "ora";
7
6
  import { formatMessage, message } from "@optique/core/message";
7
+ import ora from "ora";
8
8
  import { lookupWebFinger } from "@fedify/webfinger";
9
9
  //#region src/webfinger/action.ts
10
10
  async function runWebFinger({ command: _, resources, ...options }) {
@@ -14,18 +14,16 @@ const maxRedirection = bindConfig(option("--max-redirection", integer({ min: 0 }
14
14
  key: (config) => config.webfinger?.maxRedirection ?? 5,
15
15
  default: 5
16
16
  });
17
- const webFingerOptions = merge("Network options", object({
17
+ const webFingerCommand = command("webfinger", merge("Network options", object({
18
18
  command: constant("webfinger"),
19
19
  resources: group("Arguments", multiple(argument(string({ metavar: "RESOURCE" }), { description: message`WebFinger resource(s) to look up.` }), { min: 1 })),
20
20
  allowPrivateAddresses,
21
21
  maxRedirection
22
- }), userAgentOption);
23
- const webFingerMetadata = {
22
+ }), userAgentOption), {
24
23
  brief: message`Look up WebFinger resources.`,
25
24
  description: message`Look up WebFinger resources.
26
25
 
27
26
  The argument can be multiple.`
28
- };
29
- command("webfinger", webFingerOptions, webFingerMetadata);
27
+ });
30
28
  //#endregion
31
- export { webFingerMetadata, webFingerOptions };
29
+ export { webFingerCommand };
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import { InvalidHandleError } from "./error.js";
3
- import { getLogger } from "@logtape/logtape";
4
3
  import { toAcctUrl } from "@fedify/vocab";
4
+ import { getLogger } from "@logtape/logtape";
5
5
  getLogger([
6
6
  "fedify",
7
7
  "cli",
@@ -0,0 +1,4 @@
1
+ import "@js-temporal/polyfill";
2
+ import "./action.js";
3
+ import "./command.js";
4
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/cli",
3
- "version": "2.3.0-dev.1347+35dea445",
3
+ "version": "2.3.0-dev.1361+15c6e619",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "README.md",
@@ -59,10 +59,9 @@
59
59
  "dependencies": {
60
60
  "@cfworker/json-schema": "^4.1.1",
61
61
  "@fxts/core": "^1.20.0",
62
- "@optique/config": "^1.1.0",
63
- "@optique/core": "^1.1.0",
64
- "@optique/discover": "^1.1.0",
65
- "@optique/run": "^1.1.0",
62
+ "@optique/config": "^1.0.2",
63
+ "@optique/core": "^1.0.2",
64
+ "@optique/run": "^1.0.2",
66
65
  "@standard-schema/spec": "^1.1.0",
67
66
  "@hongminhee/localtunnel": "^0.3.0",
68
67
  "@inquirer/prompts": "^7.8.4",
@@ -90,14 +89,14 @@
90
89
  "srvx": "^0.8.7",
91
90
  "valibot": "^1.4.0",
92
91
  "yaml": "^2.9.0",
93
- "@fedify/fedify": "2.3.0-dev.1347+35dea445",
94
- "@fedify/init": "2.3.0-dev.1347+35dea445",
95
- "@fedify/relay": "2.3.0-dev.1347+35dea445",
96
- "@fedify/sqlite": "2.3.0-dev.1347+35dea445",
97
- "@fedify/vocab": "2.3.0-dev.1347+35dea445",
98
- "@fedify/vocab-runtime": "2.3.0-dev.1347+35dea445",
99
- "@fedify/vocab-tools": "2.3.0-dev.1347+35dea445",
100
- "@fedify/webfinger": "2.3.0-dev.1347+35dea445"
92
+ "@fedify/fedify": "2.3.0-dev.1361+15c6e619",
93
+ "@fedify/relay": "2.3.0-dev.1361+15c6e619",
94
+ "@fedify/init": "2.3.0-dev.1361+15c6e619",
95
+ "@fedify/vocab": "2.3.0-dev.1361+15c6e619",
96
+ "@fedify/sqlite": "2.3.0-dev.1361+15c6e619",
97
+ "@fedify/vocab-runtime": "2.3.0-dev.1361+15c6e619",
98
+ "@fedify/vocab-tools": "2.3.0-dev.1361+15c6e619",
99
+ "@fedify/webfinger": "2.3.0-dev.1361+15c6e619"
101
100
  },
102
101
  "devDependencies": {
103
102
  "@types/bun": "^1.2.23",
@@ -1,16 +0,0 @@
1
- import "@js-temporal/polyfill";
2
- //#region src/bench/compare/schema.ts
3
- /**
4
- * The embedded JSON Schema (draft 2020-12) for benchmark comparison output.
5
- *
6
- * The comparison report embeds the two benchmark reports it compares; this
7
- * schema validates the comparison envelope and checks that the embedded reports
8
- * look like current benchmark reports without duplicating the complete report
9
- * schema in two published files.
10
- * @since 2.3.0
11
- * @module
12
- */
13
- /** The hosted URL that serves the comparison report schema. */
14
- const COMPARE_REPORT_SCHEMA_ID = "https://json-schema.fedify.dev/bench/compare-report-v1.json";
15
- //#endregion
16
- export { COMPARE_REPORT_SCHEMA_ID };