@fedify/cli 2.3.0-dev.1299 → 2.3.0-dev.1344
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.
- package/dist/bench/action.js +189 -29
- package/dist/bench/command.js +43 -13
- package/dist/bench/compare/schema.js +16 -0
- package/dist/bench/compare.js +667 -0
- package/dist/bench/load/clock.js +20 -2
- package/dist/bench/load/generator.js +42 -9
- package/dist/bench/metrics/stats-client.js +65 -3
- package/dist/bench/mod.js +9 -2
- package/dist/bench/render/markdown.js +1 -0
- package/dist/bench/render/text.js +1 -0
- package/dist/bench/result/build.js +133 -10
- package/dist/bench/result/expect/evaluate.js +1 -1
- package/dist/bench/result/schema.js +353 -3
- package/dist/bench/safety/gate.js +4 -2
- package/dist/bench/scenario/normalize.js +1 -2
- package/dist/bench/scenario/schema.js +50 -9
- package/dist/bench/scenario/validate.js +2 -2
- package/dist/bench/scenarios/actor.js +38 -0
- package/dist/bench/scenarios/failure.js +363 -0
- package/dist/bench/scenarios/fanout.js +261 -0
- package/dist/bench/scenarios/inbox.js +4 -12
- package/dist/bench/scenarios/mixed.js +244 -0
- package/dist/bench/scenarios/object-discovery.js +211 -0
- package/dist/bench/scenarios/object.js +54 -0
- package/dist/bench/scenarios/read.js +108 -0
- package/dist/bench/scenarios/registry.js +19 -1
- package/dist/bench/scenarios/runner.js +21 -1
- package/dist/bench/scenarios/webfinger.js +1 -1
- package/dist/cache.js +1 -1
- package/dist/commands.js +110 -0
- package/dist/config.js +1 -1
- package/dist/deno.js +1 -1
- package/dist/docloader.js +1 -1
- package/dist/generate-vocab/action.js +1 -1
- package/dist/generate-vocab/command.js +5 -3
- package/dist/imagerenderer.js +2 -2
- package/dist/inbox/command.js +6 -4
- package/dist/inbox.js +4 -4
- package/dist/log.js +2 -2
- package/dist/lookup/command.js +121 -0
- package/dist/lookup.js +12 -123
- package/dist/mod.js +2 -23
- package/dist/nodeinfo.js +11 -9
- package/dist/options.js +1 -1
- package/dist/relay/command.js +6 -4
- package/dist/relay.js +2 -2
- package/dist/runner.js +69 -46
- package/dist/tempserver.js +1 -1
- package/dist/tunnel.js +6 -4
- package/dist/utils.js +5 -4
- package/dist/webfinger/action.js +1 -1
- package/dist/webfinger/command.js +6 -4
- package/dist/webfinger/lib.js +1 -1
- package/package.json +13 -12
- package/dist/generate-vocab/mod.js +0 -4
- package/dist/init/mod.js +0 -3
- package/dist/webfinger/mod.js +0 -4
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";
|
|
4
3
|
import { choice, constant, flag, map, merge, message, object, option, optional, or, string, withDefault } from "@optique/core";
|
|
5
4
|
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.
|
package/dist/relay/command.js
CHANGED
|
@@ -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
|
|
8
|
+
const relayOptions = 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,11 +40,13 @@ const relayCommand = command("relay", merge(object("Relay options", {
|
|
|
40
40
|
key: (config) => config.relay?.rejectFollow ?? [],
|
|
41
41
|
default: []
|
|
42
42
|
})
|
|
43
|
-
}), group("Tunnel options", createTunnelOption("relay")))
|
|
43
|
+
}), group("Tunnel options", createTunnelOption("relay")));
|
|
44
|
+
const relayMetadata = {
|
|
44
45
|
brief: message`Run an ephemeral ActivityPub relay server.`,
|
|
45
46
|
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.
|
|
46
47
|
|
|
47
48
|
By default, the server is tunneled to the public internet for external access. Use ${optionName("--no-tunnel")} to run locally only.`
|
|
48
|
-
}
|
|
49
|
+
};
|
|
50
|
+
command("relay", relayOptions, relayMetadata);
|
|
49
51
|
//#endregion
|
|
50
|
-
export {
|
|
52
|
+
export { relayMetadata, relayOptions };
|
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";
|
|
10
9
|
import ora from "ora";
|
|
11
|
-
import { createRelay } from "@fedify/relay";
|
|
12
10
|
import { SqliteKvStore } from "@fedify/sqlite";
|
|
13
11
|
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,27 +1,17 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
|
-
import { describeError } from "./utils.js";
|
|
3
|
-
import { version } from "./deno.js";
|
|
4
2
|
import { configContext, tryLoadToml } from "./config.js";
|
|
5
3
|
import { globalOptions } from "./options.js";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import "./
|
|
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";
|
|
4
|
+
import { describeError } from "./utils.js";
|
|
5
|
+
import { activityPubCommands, generatingCommands, networkCommands } from "./commands.js";
|
|
6
|
+
import { version } from "./deno.js";
|
|
17
7
|
import process from "node:process";
|
|
18
|
-
import { group, merge, message, or } from "@optique/core";
|
|
8
|
+
import { command, group, map, merge, message, or } from "@optique/core";
|
|
19
9
|
import { printError, run } from "@optique/run";
|
|
20
10
|
import { merge as merge$1 } from "es-toolkit";
|
|
21
|
-
import { homedir } from "node:os";
|
|
22
11
|
import { readFileSync } from "node:fs";
|
|
23
|
-
import {
|
|
12
|
+
import { homedir } from "node:os";
|
|
24
13
|
import { join } from "node:path";
|
|
14
|
+
import { parse } from "smol-toml";
|
|
25
15
|
//#region src/runner.ts
|
|
26
16
|
/**
|
|
27
17
|
* Returns the system-wide configuration file paths.
|
|
@@ -41,36 +31,35 @@ function getUserConfigPath() {
|
|
|
41
31
|
if (process.platform === "win32") return join(process.env.APPDATA || join(homedir(), "AppData", "Roaming"), "fedify", "config.toml");
|
|
42
32
|
return join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "fedify", "config.toml");
|
|
43
33
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} catch (error) {
|
|
54
|
-
printError(message`Could not load config file at ${parsed.configPath}: ${describeError(error)}`);
|
|
55
|
-
process.exit(1);
|
|
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);
|
|
56
43
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
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
|
+
}));
|
|
66
53
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
return {
|
|
74
63
|
contexts: [configContext],
|
|
75
64
|
contextOptions: { load: loadConfig },
|
|
76
65
|
programName: "fedify",
|
|
@@ -92,7 +81,41 @@ function runCli(args) {
|
|
|
92
81
|
maxWidth: process.stdout.columns,
|
|
93
82
|
showDefault: true,
|
|
94
83
|
showChoices: true
|
|
95
|
-
}
|
|
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)));
|
|
96
119
|
}
|
|
97
120
|
//#endregion
|
|
98
|
-
export {
|
|
121
|
+
export { parseCliProgram };
|
package/dist/tempserver.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import { getLogger } from "@logtape/logtape";
|
|
3
|
-
import { serve } from "srvx";
|
|
4
3
|
import { openTunnel } from "@hongminhee/localtunnel";
|
|
4
|
+
import { serve } from "srvx";
|
|
5
5
|
//#region src/tempserver.ts
|
|
6
6
|
const logger = getLogger([
|
|
7
7
|
"fedify",
|
package/dist/tunnel.js
CHANGED
|
@@ -7,19 +7,21 @@ 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
|
|
10
|
+
const tunnelOptions = 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
|
-
}))
|
|
17
|
+
}));
|
|
18
|
+
const tunnelMetadata = {
|
|
18
19
|
brief: message`Expose a local HTTP server to the public internet using a secure tunnel.`,
|
|
19
20
|
description: message`Expose a local HTTP server to the public internet using a secure tunnel.
|
|
20
21
|
|
|
21
22
|
Note that the HTTP requests through the tunnel have X-Forwarded-* headers.`
|
|
22
|
-
}
|
|
23
|
+
};
|
|
24
|
+
command("tunnel", tunnelOptions, tunnelMetadata);
|
|
23
25
|
async function runTunnel(command, deps = {
|
|
24
26
|
openTunnel,
|
|
25
27
|
ora,
|
|
@@ -49,4 +51,4 @@ async function runTunnel(command, deps = {
|
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
//#endregion
|
|
52
|
-
export { runTunnel,
|
|
54
|
+
export { runTunnel, tunnelMetadata, tunnelOptions };
|
package/dist/utils.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
|
-
import "node:fs/promises";
|
|
3
2
|
import process from "node:process";
|
|
4
|
-
import { getActorHandle } from "@fedify/vocab";
|
|
5
|
-
import "@fxts/core";
|
|
6
3
|
import { message } from "@optique/core";
|
|
7
4
|
import { print, printError } from "@optique/run";
|
|
5
|
+
import { flow } from "es-toolkit";
|
|
6
|
+
import { getActorHandle } from "@fedify/vocab";
|
|
7
|
+
import "@fxts/core";
|
|
8
8
|
import { Chalk } from "chalk";
|
|
9
9
|
import { highlight } from "cli-highlight";
|
|
10
|
-
import
|
|
10
|
+
import "node:child_process";
|
|
11
|
+
import "node:fs/promises";
|
|
11
12
|
import util from "node:util";
|
|
12
13
|
//#region src/utils.ts
|
|
13
14
|
const colorEnabled = process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "");
|
package/dist/webfinger/action.js
CHANGED
|
@@ -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 { formatMessage, message } from "@optique/core/message";
|
|
7
6
|
import ora from "ora";
|
|
7
|
+
import { formatMessage, message } from "@optique/core/message";
|
|
8
8
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
9
9
|
//#region src/webfinger/action.ts
|
|
10
10
|
async function runWebFinger({ command: _, resources, ...options }) {
|
|
@@ -14,16 +14,18 @@ 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
|
|
17
|
+
const webFingerOptions = 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)
|
|
22
|
+
}), userAgentOption);
|
|
23
|
+
const webFingerMetadata = {
|
|
23
24
|
brief: message`Look up WebFinger resources.`,
|
|
24
25
|
description: message`Look up WebFinger resources.
|
|
25
26
|
|
|
26
27
|
The argument can be multiple.`
|
|
27
|
-
}
|
|
28
|
+
};
|
|
29
|
+
command("webfinger", webFingerOptions, webFingerMetadata);
|
|
28
30
|
//#endregion
|
|
29
|
-
export {
|
|
31
|
+
export { webFingerMetadata, webFingerOptions };
|
package/dist/webfinger/lib.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/cli",
|
|
3
|
-
"version": "2.3.0-dev.
|
|
3
|
+
"version": "2.3.0-dev.1344+d573d413",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -59,9 +59,10 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@cfworker/json-schema": "^4.1.1",
|
|
61
61
|
"@fxts/core": "^1.20.0",
|
|
62
|
-
"@optique/config": "^1.0
|
|
63
|
-
"@optique/core": "^1.0
|
|
64
|
-
"@optique/
|
|
62
|
+
"@optique/config": "^1.1.0",
|
|
63
|
+
"@optique/core": "^1.1.0",
|
|
64
|
+
"@optique/discover": "^1.1.0",
|
|
65
|
+
"@optique/run": "^1.1.0",
|
|
65
66
|
"@standard-schema/spec": "^1.1.0",
|
|
66
67
|
"@hongminhee/localtunnel": "^0.3.0",
|
|
67
68
|
"@inquirer/prompts": "^7.8.4",
|
|
@@ -89,14 +90,14 @@
|
|
|
89
90
|
"srvx": "^0.8.7",
|
|
90
91
|
"valibot": "^1.4.0",
|
|
91
92
|
"yaml": "^2.9.0",
|
|
92
|
-
"@fedify/
|
|
93
|
-
"@fedify/
|
|
94
|
-
"@fedify/
|
|
95
|
-
"@fedify/
|
|
96
|
-
"@fedify/
|
|
97
|
-
"@fedify/vocab-tools": "2.3.0-dev.
|
|
98
|
-
"@fedify/webfinger": "2.3.0-dev.
|
|
99
|
-
"@fedify/
|
|
93
|
+
"@fedify/fedify": "2.3.0-dev.1344+d573d413",
|
|
94
|
+
"@fedify/init": "2.3.0-dev.1344+d573d413",
|
|
95
|
+
"@fedify/sqlite": "2.3.0-dev.1344+d573d413",
|
|
96
|
+
"@fedify/relay": "2.3.0-dev.1344+d573d413",
|
|
97
|
+
"@fedify/vocab": "2.3.0-dev.1344+d573d413",
|
|
98
|
+
"@fedify/vocab-tools": "2.3.0-dev.1344+d573d413",
|
|
99
|
+
"@fedify/webfinger": "2.3.0-dev.1344+d573d413",
|
|
100
|
+
"@fedify/vocab-runtime": "2.3.0-dev.1344+d573d413"
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
103
|
"@types/bun": "^1.2.23",
|
package/dist/init/mod.js
DELETED
package/dist/webfinger/mod.js
DELETED