@fedify/cli 2.0.0-pr.479.1922 → 2.0.1
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/LICENSE +1 -1
- package/README.md +3 -3
- package/dist/cache.js +17 -3
- package/dist/config.js +105 -0
- package/dist/deno.js +18 -8
- package/dist/generate-vocab/action.js +1 -1
- package/dist/imagerenderer.js +1 -1
- package/dist/inbox/rendercode.js +11 -21
- package/dist/inbox.js +162 -132
- package/dist/init/mod.js +3 -3
- package/dist/log.js +35 -1
- package/dist/lookup.js +55 -23
- package/dist/mod.js +95 -18
- package/dist/nodeinfo.js +39 -22
- package/dist/options.js +84 -0
- package/dist/relay.js +136 -0
- package/dist/tempserver.js +15 -8
- package/dist/tunnel.js +6 -10
- package/dist/utils.js +19 -108
- package/dist/webfinger/action.js +1 -1
- package/dist/webfinger/command.js +17 -9
- package/dist/webfinger/lib.js +3 -3
- package/package.json +50 -28
- package/deno.json +0 -71
- package/dist/globals.js +0 -49
- package/dist/init/action/configs.js +0 -91
- package/dist/init/action/const.js +0 -10
- package/dist/init/action/deps.js +0 -50
- package/dist/init/action/dir.js +0 -16
- package/dist/init/action/env.js +0 -13
- package/dist/init/action/install.js +0 -20
- package/dist/init/action/mod.js +0 -39
- package/dist/init/action/notice.js +0 -55
- package/dist/init/action/patch.js +0 -147
- package/dist/init/action/precommand.js +0 -28
- package/dist/init/action/recommend.js +0 -24
- package/dist/init/action/set.js +0 -31
- package/dist/init/action/templates.js +0 -58
- package/dist/init/action/utils.js +0 -50
- package/dist/init/ask/dir.js +0 -82
- package/dist/init/ask/kv.js +0 -44
- package/dist/init/ask/mod.js +0 -16
- package/dist/init/ask/mq.js +0 -46
- package/dist/init/ask/pm.js +0 -49
- package/dist/init/ask/wf.js +0 -29
- package/dist/init/command.js +0 -50
- package/dist/init/const.js +0 -31
- package/dist/init/json/biome.js +0 -24
- package/dist/init/json/kv.js +0 -53
- package/dist/init/json/mq.js +0 -72
- package/dist/init/json/pm.js +0 -44
- package/dist/init/json/rt.js +0 -39
- package/dist/init/json/vscode-settings-for-deno.js +0 -53
- package/dist/init/json/vscode-settings.js +0 -49
- package/dist/init/lib.js +0 -136
- package/dist/init/templates/defaults/federation.ts.tpl +0 -23
- package/dist/init/templates/defaults/logging.ts.tpl +0 -23
- package/dist/init/templates/express/app.ts.tpl +0 -16
- package/dist/init/templates/express/index.ts.tpl +0 -6
- package/dist/init/templates/hono/app.tsx.tpl +0 -14
- package/dist/init/templates/hono/index/bun.ts.tpl +0 -10
- package/dist/init/templates/hono/index/deno.ts.tpl +0 -13
- package/dist/init/templates/hono/index/node.ts.tpl +0 -14
- package/dist/init/templates/next/middleware.ts.tpl +0 -45
- package/dist/init/templates/nitro/.env.test.tpl +0 -1
- package/dist/init/templates/nitro/nitro.config.ts.tpl +0 -14
- package/dist/init/templates/nitro/server/error.ts.tpl +0 -3
- package/dist/init/templates/nitro/server/middleware/federation.ts.tpl +0 -8
- package/dist/init/test/action.js +0 -17
- package/dist/init/test/create.js +0 -100
- package/dist/init/test/fill.js +0 -32
- package/dist/init/test/lookup.js +0 -190
- package/dist/init/test/run.js +0 -25
- package/dist/init/test/utils.js +0 -17
- package/dist/init/webframeworks.js +0 -136
- package/scripts/pack.ts +0 -71
- package/src/cache.ts +0 -17
- package/src/docloader.ts +0 -67
- package/src/generate-vocab/action.ts +0 -17
- package/src/generate-vocab/command.ts +0 -44
- package/src/generate-vocab/mod.ts +0 -2
- package/src/globals.ts +0 -43
- package/src/imagerenderer.ts +0 -149
- package/src/inbox/entry.ts +0 -10
- package/src/inbox/rendercode.ts +0 -68
- package/src/inbox/view.tsx +0 -598
- package/src/inbox.tsx +0 -536
- package/src/init/action/configs.ts +0 -133
- package/src/init/action/const.ts +0 -9
- package/src/init/action/deps.ts +0 -161
- package/src/init/action/dir.ts +0 -11
- package/src/init/action/env.ts +0 -14
- package/src/init/action/install.ts +0 -24
- package/src/init/action/mod.ts +0 -66
- package/src/init/action/notice.ts +0 -103
- package/src/init/action/patch.ts +0 -233
- package/src/init/action/precommand.ts +0 -29
- package/src/init/action/recommend.ts +0 -38
- package/src/init/action/set.ts +0 -65
- package/src/init/action/templates.ts +0 -96
- package/src/init/action/utils.ts +0 -64
- package/src/init/ask/dir.ts +0 -98
- package/src/init/ask/kv.ts +0 -82
- package/src/init/ask/mod.ts +0 -23
- package/src/init/ask/mq.ts +0 -86
- package/src/init/ask/pm.ts +0 -58
- package/src/init/ask/wf.ts +0 -27
- package/src/init/command.ts +0 -135
- package/src/init/const.ts +0 -4
- package/src/init/json/biome.json +0 -17
- package/src/init/json/kv.json +0 -39
- package/src/init/json/mq.json +0 -95
- package/src/init/json/pm.json +0 -47
- package/src/init/json/rt.json +0 -42
- package/src/init/json/vscode-settings-for-deno.json +0 -43
- package/src/init/json/vscode-settings.json +0 -41
- package/src/init/lib.ts +0 -223
- package/src/init/mod.ts +0 -3
- package/src/init/templates/defaults/federation.ts.tpl +0 -23
- package/src/init/templates/defaults/logging.ts.tpl +0 -23
- package/src/init/templates/express/app.ts.tpl +0 -16
- package/src/init/templates/express/index.ts.tpl +0 -6
- package/src/init/templates/hono/app.tsx.tpl +0 -14
- package/src/init/templates/hono/index/bun.ts.tpl +0 -10
- package/src/init/templates/hono/index/deno.ts.tpl +0 -13
- package/src/init/templates/hono/index/node.ts.tpl +0 -14
- package/src/init/templates/next/middleware.ts.tpl +0 -45
- package/src/init/templates/nitro/.env.test.tpl +0 -1
- package/src/init/templates/nitro/nitro.config.ts.tpl +0 -14
- package/src/init/templates/nitro/server/error.ts.tpl +0 -3
- package/src/init/templates/nitro/server/middleware/federation.ts.tpl +0 -8
- package/src/init/test/action.ts +0 -28
- package/src/init/test/create.ts +0 -137
- package/src/init/test/fill.ts +0 -67
- package/src/init/test/lookup.ts +0 -254
- package/src/init/test/run.ts +0 -39
- package/src/init/test/types.ts +0 -27
- package/src/init/test/utils.ts +0 -21
- package/src/init/types.ts +0 -89
- package/src/init/webframeworks.ts +0 -168
- package/src/kv.bun.ts +0 -12
- package/src/kv.node.ts +0 -11
- package/src/log.ts +0 -64
- package/src/lookup.test.ts +0 -182
- package/src/lookup.ts +0 -563
- package/src/mod.ts +0 -62
- package/src/nodeinfo.test.ts +0 -229
- package/src/nodeinfo.ts +0 -454
- package/src/table.ts +0 -17
- package/src/tempserver.ts +0 -87
- package/src/tunnel.test.ts +0 -157
- package/src/tunnel.ts +0 -94
- package/src/utils.ts +0 -254
- package/src/webfinger/action.ts +0 -50
- package/src/webfinger/command.ts +0 -64
- package/src/webfinger/error.ts +0 -47
- package/src/webfinger/lib.ts +0 -37
- package/src/webfinger/mod.test.ts +0 -79
- package/src/webfinger/mod.ts +0 -2
- package/tsdown.config.ts +0 -35
package/dist/tempserver.js
CHANGED
|
@@ -12,10 +12,12 @@ const logger = getLogger([
|
|
|
12
12
|
"tempserver"
|
|
13
13
|
]);
|
|
14
14
|
async function spawnTemporaryServer(fetch, options = {}) {
|
|
15
|
+
const serverPort = options.port ?? 0;
|
|
15
16
|
if (options.noTunnel) {
|
|
16
17
|
const server$1 = serve({
|
|
17
|
-
port:
|
|
18
|
+
port: serverPort,
|
|
18
19
|
hostname: "::",
|
|
20
|
+
silent: true,
|
|
19
21
|
fetch
|
|
20
22
|
});
|
|
21
23
|
await server$1.ready();
|
|
@@ -30,10 +32,10 @@ async function spawnTemporaryServer(fetch, options = {}) {
|
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
const server = serve({
|
|
33
|
-
fetch: (request) => {
|
|
35
|
+
fetch: "Deno" in globalThis ? (request) => {
|
|
34
36
|
const url$1 = new URL(request.url);
|
|
35
37
|
url$1.protocol = "https:";
|
|
36
|
-
|
|
38
|
+
const newRequest = new Request(url$1, {
|
|
37
39
|
method: request.method,
|
|
38
40
|
headers: request.headers,
|
|
39
41
|
body: request.method === "GET" || request.method === "HEAD" ? null : request.body,
|
|
@@ -47,16 +49,21 @@ async function spawnTemporaryServer(fetch, options = {}) {
|
|
|
47
49
|
keepalive: request.keepalive,
|
|
48
50
|
signal: request.signal
|
|
49
51
|
});
|
|
50
|
-
return
|
|
51
|
-
},
|
|
52
|
-
port:
|
|
53
|
-
hostname: "::"
|
|
52
|
+
return fetch(newRequest);
|
|
53
|
+
} : fetch,
|
|
54
|
+
port: serverPort,
|
|
55
|
+
hostname: "::",
|
|
56
|
+
silent: true,
|
|
57
|
+
protocol: "https"
|
|
54
58
|
});
|
|
55
59
|
await server.ready();
|
|
56
60
|
const url = new URL(server.url);
|
|
57
61
|
const port = url.port;
|
|
58
62
|
logger.debug("Temporary server is listening on port {port}.", { port });
|
|
59
|
-
const tun = await openTunnel({
|
|
63
|
+
const tun = await openTunnel({
|
|
64
|
+
port: parseInt(port),
|
|
65
|
+
service: options.service
|
|
66
|
+
});
|
|
60
67
|
logger.debug("Temporary server is tunneled to {url}.", { url: tun.url.href });
|
|
61
68
|
return {
|
|
62
69
|
url: tun.url,
|
package/dist/tunnel.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
|
|
4
|
-
import { configureLogging
|
|
5
|
-
import {
|
|
6
|
-
import { print, printError } from "@optique/run";
|
|
4
|
+
import { configureLogging } from "./log.js";
|
|
5
|
+
import { createTunnelServiceOption } from "./options.js";
|
|
7
6
|
import process from "node:process";
|
|
7
|
+
import { argument, command, constant, integer, merge, message, object } from "@optique/core";
|
|
8
|
+
import { print, printError } from "@optique/run";
|
|
8
9
|
import ora from "ora";
|
|
9
10
|
import { openTunnel } from "@hongminhee/localtunnel";
|
|
10
|
-
import { choice as choice$1 } from "@optique/core/valueparser";
|
|
11
11
|
|
|
12
12
|
//#region src/tunnel.ts
|
|
13
13
|
const tunnelCommand = command("tunnel", merge("Tunnel options", object({ command: constant("tunnel") }), object({
|
|
@@ -16,12 +16,8 @@ const tunnelCommand = command("tunnel", merge("Tunnel options", object({ command
|
|
|
16
16
|
min: 0,
|
|
17
17
|
max: 65535
|
|
18
18
|
}), { description: message`The local port number to expose.` }),
|
|
19
|
-
service:
|
|
20
|
-
|
|
21
|
-
"serveo.net",
|
|
22
|
-
"pinggy.io"
|
|
23
|
-
], { metavar: "SERVICE" }), { description: message`The tunneling service to use.` }))
|
|
24
|
-
}), debugOption), {
|
|
19
|
+
service: createTunnelServiceOption(["-s", "--service"])
|
|
20
|
+
})), {
|
|
25
21
|
brief: message`Expose a local HTTP server to the public internet using a secure tunnel.`,
|
|
26
22
|
description: message`Expose a local HTTP server to the public internet using a secure tunnel.
|
|
27
23
|
|
package/dist/utils.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import "node:fs/promises";
|
|
5
|
+
import process from "node:process";
|
|
5
6
|
import { message } from "@optique/core";
|
|
6
7
|
import { print, printError } from "@optique/run";
|
|
7
|
-
import
|
|
8
|
+
import { flow } from "es-toolkit";
|
|
9
|
+
import { getActorHandle } from "@fedify/vocab";
|
|
8
10
|
import util from "node:util";
|
|
9
|
-
import
|
|
11
|
+
import "@fxts/core";
|
|
10
12
|
import { Chalk } from "chalk";
|
|
11
13
|
import { highlight } from "cli-highlight";
|
|
12
|
-
import
|
|
13
|
-
import { spawn } from "node:child_process";
|
|
14
|
+
import "node:child_process";
|
|
14
15
|
|
|
15
16
|
//#region src/utils.ts
|
|
16
17
|
const colorEnabled = process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "");
|
|
@@ -22,113 +23,23 @@ function formatObject(obj, colors$1, json) {
|
|
|
22
23
|
if (enableColors) return highlight(formatted, { language: "json" });
|
|
23
24
|
return formatted;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...obj,
|
|
35
|
-
[key]: result
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const merge$1 = (source = {}) => (target = {}) => toMerged(target, source);
|
|
40
|
-
const isNotFoundError = (e) => isObject(e) && "code" in e && e.code === "ENOENT";
|
|
41
|
-
var CommandError = class extends Error {
|
|
42
|
-
commandLine;
|
|
43
|
-
constructor(message$1, stdout, stderr, code, command$1) {
|
|
44
|
-
super(message$1);
|
|
45
|
-
this.stdout = stdout;
|
|
46
|
-
this.stderr = stderr;
|
|
47
|
-
this.code = code;
|
|
48
|
-
this.command = command$1;
|
|
49
|
-
this.name = "CommandError";
|
|
50
|
-
this.commandLine = command$1.join(" ");
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const runSubCommand = async (command$1, options) => {
|
|
54
|
-
const commands = command$1.reduce((acc, cur) => {
|
|
55
|
-
if (cur === "&&") acc.push([]);
|
|
56
|
-
else {
|
|
57
|
-
if (acc.length === 0) acc.push([]);
|
|
58
|
-
acc[acc.length - 1].push(cur);
|
|
59
|
-
}
|
|
60
|
-
return acc;
|
|
61
|
-
}, []);
|
|
62
|
-
const results = {
|
|
63
|
-
stdout: "",
|
|
64
|
-
stderr: ""
|
|
65
|
-
};
|
|
66
|
-
for (const cmd of commands) try {
|
|
67
|
-
const result = await runSingularCommand(cmd, options);
|
|
68
|
-
results.stdout += (results.stdout ? "\n" : "") + result.stdout;
|
|
69
|
-
results.stderr += (results.stderr ? "\n" : "") + result.stderr;
|
|
70
|
-
} catch (e) {
|
|
71
|
-
if (e instanceof CommandError) {
|
|
72
|
-
results.stdout += (results.stdout ? "\n" : "") + e.stdout;
|
|
73
|
-
results.stderr += (results.stderr ? "\n" : "") + e.stderr;
|
|
26
|
+
async function matchesActor(actor, actorList) {
|
|
27
|
+
const actorUri = actor.id;
|
|
28
|
+
let actorHandle = void 0;
|
|
29
|
+
if (actorUri == null) return false;
|
|
30
|
+
for (let uri of actorList) {
|
|
31
|
+
if (uri == "*") return true;
|
|
32
|
+
if (uri.startsWith("http:") || uri.startsWith("https:")) {
|
|
33
|
+
uri = new URL(uri).href;
|
|
34
|
+
if (uri === actorUri.href) return true;
|
|
74
35
|
}
|
|
75
|
-
|
|
36
|
+
if (actorHandle == null) actorHandle = await getActorHandle(actor);
|
|
37
|
+
if (actorHandle === uri) return true;
|
|
76
38
|
}
|
|
77
|
-
return
|
|
78
|
-
};
|
|
79
|
-
const runSingularCommand = (command$1, options) => new Promise((resolve, reject) => {
|
|
80
|
-
let stdout = "";
|
|
81
|
-
let stderr = "";
|
|
82
|
-
const child = spawn(command$1[0], command$1.slice(1), options);
|
|
83
|
-
child.stdout?.on("data", (data) => {
|
|
84
|
-
stdout += data.toString();
|
|
85
|
-
});
|
|
86
|
-
child.stderr?.on("data", (data) => {
|
|
87
|
-
stderr += data.toString();
|
|
88
|
-
});
|
|
89
|
-
child.on("close", (code) => {
|
|
90
|
-
if (code === 0) resolve({
|
|
91
|
-
stdout: stdout.trim(),
|
|
92
|
-
stderr: stderr.trim()
|
|
93
|
-
});
|
|
94
|
-
else reject(new CommandError(`Command exited with code ${code ?? "unknown"}`, stdout.trim(), stderr.trim(), code ?? -1, command$1));
|
|
95
|
-
});
|
|
96
|
-
child.on("error", (error) => {
|
|
97
|
-
reject(error);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
const getCwd = () => process.cwd();
|
|
101
|
-
const replace = (pattern, replacement) => (text$1) => text$1.replace(pattern, replacement);
|
|
102
|
-
const replaceAll = (pattern, replacement) => (text$1) => text$1.replaceAll(pattern, replacement);
|
|
103
|
-
const getOsType = () => process.platform;
|
|
104
|
-
const formatJson = (obj) => JSON.stringify(obj, null, 2) + "\n";
|
|
105
|
-
const notEmpty = (s) => s.length > 0;
|
|
106
|
-
const exit = (code) => process.exit(code);
|
|
107
|
-
/**
|
|
108
|
-
* ```haskell
|
|
109
|
-
* product::[[a], [b], ...] -> [[a, b, ...]]
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* Cartesian product of the input iterables.
|
|
113
|
-
* Inspired by Python's `itertools.product`.
|
|
114
|
-
*
|
|
115
|
-
* @param {...Iterable<unknown>} iters - The input iterables to compute the Cartesian product.
|
|
116
|
-
* @returns {Generator<ItersItems<T>>} A generator that yields arrays containing one element from each iterable.
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```ts
|
|
120
|
-
* const iter1 = [1, 2];
|
|
121
|
-
* const iter2 = ['a', 'b'];
|
|
122
|
-
* const iter3 = [true, false];
|
|
123
|
-
* const productIter = product(iter1, iter2, iter3);
|
|
124
|
-
* console.log(Array.from(productIter)); // Output: [[1, 'a', true], [1, 'a', false], [
|
|
125
|
-
*/
|
|
126
|
-
function* product(...[head, ...tail]) {
|
|
127
|
-
if (!head) yield [];
|
|
128
|
-
else for (const x of head) for (const xs of product(...tail)) yield [x, ...xs];
|
|
39
|
+
return false;
|
|
129
40
|
}
|
|
130
41
|
const printMessage = flow(message, print);
|
|
131
42
|
const printErrorMessage = flow(message, printError);
|
|
132
43
|
|
|
133
44
|
//#endregion
|
|
134
|
-
export {
|
|
45
|
+
export { colorEnabled, colors, formatObject, matchesActor };
|
package/dist/webfinger/action.js
CHANGED
|
@@ -7,7 +7,7 @@ import { convertUrlIfHandle } from "./lib.js";
|
|
|
7
7
|
import { print } from "@optique/run";
|
|
8
8
|
import { formatMessage, message } from "@optique/core/message";
|
|
9
9
|
import ora from "ora";
|
|
10
|
-
import { lookupWebFinger } from "@fedify/
|
|
10
|
+
import { lookupWebFinger } from "@fedify/webfinger";
|
|
11
11
|
|
|
12
12
|
//#region src/webfinger/action.ts
|
|
13
13
|
async function runWebFinger({ command: _, resources,...options }) {
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { configContext } from "../config.js";
|
|
5
|
+
import { userAgentOption } from "../options.js";
|
|
6
|
+
import { argument, command, constant, flag, group, integer, merge, message, multiple, object, option, string } from "@optique/core";
|
|
7
|
+
import { bindConfig } from "@optique/config";
|
|
6
8
|
|
|
7
9
|
//#region src/webfinger/command.ts
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const allowPrivateAddresses = bindConfig(flag("-p", "--allow-private-address", { description: message`Allow private IP addresses in the URL.` }), {
|
|
11
|
+
context: configContext,
|
|
12
|
+
key: (config) => config.webfinger?.allowPrivateAddress ?? false,
|
|
13
|
+
default: false
|
|
14
|
+
});
|
|
15
|
+
const maxRedirection = bindConfig(option("--max-redirection", integer({ min: 0 }), { description: message`Maximum number of redirections to follow.` }), {
|
|
16
|
+
context: configContext,
|
|
17
|
+
key: (config) => config.webfinger?.maxRedirection ?? 5,
|
|
18
|
+
default: 5
|
|
19
|
+
});
|
|
20
|
+
const webFingerCommand = command("webfinger", merge("Network options", object({
|
|
12
21
|
command: constant("webfinger"),
|
|
13
|
-
resources: multiple(argument(string({ metavar: "RESOURCE" }), { description: message`WebFinger resource(s) to look up.` }), { min: 1 }),
|
|
14
|
-
userAgent,
|
|
22
|
+
resources: group("Arguments", multiple(argument(string({ metavar: "RESOURCE" }), { description: message`WebFinger resource(s) to look up.` }), { min: 1 })),
|
|
15
23
|
allowPrivateAddresses,
|
|
16
24
|
maxRedirection
|
|
17
|
-
}),
|
|
25
|
+
}), userAgentOption), {
|
|
18
26
|
brief: message`Look up WebFinger resources.`,
|
|
19
27
|
description: message`Look up WebFinger resources.
|
|
20
28
|
|
package/dist/webfinger/lib.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
|
|
4
4
|
import { InvalidHandleError } from "./error.js";
|
|
5
|
-
import { toAcctUrl } from "@fedify/
|
|
5
|
+
import { toAcctUrl } from "@fedify/vocab";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
|
|
8
8
|
//#region src/webfinger/lib.ts
|
|
@@ -27,14 +27,14 @@ function convertUrlIfHandle(handleOrUrl) {
|
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Converts a handle in the format `@username@domain` to a URL.
|
|
30
|
-
* The resulting URL will be in the format `
|
|
30
|
+
* The resulting URL will be in the format `acct:username@domain`.
|
|
31
31
|
* @param handle The handle to convert, in the format `@username@domain`.
|
|
32
32
|
* @returns A URL object representing the handle.
|
|
33
33
|
* @throws {Error} If the handle format is invalid.
|
|
34
34
|
* @example
|
|
35
35
|
* ```ts
|
|
36
36
|
* const url = convertHandleToUrl("@username@domain.com");
|
|
37
|
-
* console.log(url.toString()); // "
|
|
37
|
+
* console.log(url.toString()); // "acct:username@domain.com"
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
function convertHandleToUrl(handle) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"README.md",
|
|
7
|
+
"dist/"
|
|
8
|
+
],
|
|
9
|
+
"bin": {
|
|
10
|
+
"fedify": "./dist/mod.js"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20.0.0",
|
|
14
|
+
"bun": ">=1.2.0",
|
|
15
|
+
"deno": ">=2.0.0"
|
|
16
|
+
},
|
|
17
|
+
"os": [
|
|
18
|
+
"darwin",
|
|
19
|
+
"linux",
|
|
20
|
+
"win32"
|
|
21
|
+
],
|
|
22
|
+
"cpu": [
|
|
23
|
+
"x64",
|
|
24
|
+
"arm64"
|
|
25
|
+
],
|
|
4
26
|
"description": "CLI toolchain for Fedify and debugging ActivityPub",
|
|
5
27
|
"keywords": [
|
|
6
28
|
"fedify",
|
|
@@ -27,15 +49,6 @@
|
|
|
27
49
|
"url": "git+https://github.com/fedify-dev/fedify.git",
|
|
28
50
|
"directory": "packages/cli"
|
|
29
51
|
},
|
|
30
|
-
"type": "module",
|
|
31
|
-
"engines": {
|
|
32
|
-
"node": ">=20.0.0",
|
|
33
|
-
"bun": ">=1.2.0",
|
|
34
|
-
"denp": ">=2.0.0"
|
|
35
|
-
},
|
|
36
|
-
"bin": {
|
|
37
|
-
"fedify": "./dist/mod.js"
|
|
38
|
-
},
|
|
39
52
|
"exports": "./dist/mod.js",
|
|
40
53
|
"imports": {
|
|
41
54
|
"#kv": {
|
|
@@ -44,24 +57,24 @@
|
|
|
44
57
|
}
|
|
45
58
|
},
|
|
46
59
|
"dependencies": {
|
|
47
|
-
"@fxts/core": "^1.
|
|
60
|
+
"@fxts/core": "^1.20.0",
|
|
61
|
+
"@optique/config": "^0.10.6",
|
|
62
|
+
"@optique/core": "^0.10.6",
|
|
63
|
+
"@optique/run": "^0.10.6",
|
|
48
64
|
"@hongminhee/localtunnel": "^0.3.0",
|
|
49
65
|
"@inquirer/prompts": "^7.8.4",
|
|
50
66
|
"@jimp/core": "^1.6.0",
|
|
51
67
|
"@jimp/wasm-webp": "^1.6.0",
|
|
52
68
|
"@js-temporal/polyfill": "^0.5.1",
|
|
53
|
-
"@logtape/file": "^
|
|
54
|
-
"@logtape/logtape": "^
|
|
55
|
-
"@optique/core": "^0.6.1",
|
|
56
|
-
"@optique/run": "^0.6.1",
|
|
69
|
+
"@logtape/file": "^2.0.0",
|
|
70
|
+
"@logtape/logtape": "^2.0.0",
|
|
57
71
|
"@poppanator/http-constants": "^1.1.1",
|
|
58
72
|
"byte-encodings": "^1.0.11",
|
|
59
73
|
"chalk": "^5.6.2",
|
|
60
74
|
"cli-highlight": "^2.1.11",
|
|
61
75
|
"cli-table3": "^0.6.5",
|
|
62
76
|
"enquirer": "^2.4.1",
|
|
63
|
-
"
|
|
64
|
-
"es-toolkit": "1.39.10",
|
|
77
|
+
"es-toolkit": "1.43.0",
|
|
65
78
|
"fetch-mock": "^12.5.4",
|
|
66
79
|
"hono": "^4.8.3",
|
|
67
80
|
"icojs": "^0.19.5",
|
|
@@ -70,11 +83,17 @@
|
|
|
70
83
|
"jimp": "^1.6.0",
|
|
71
84
|
"ora": "^8.2.0",
|
|
72
85
|
"shiki": "^1.6.4",
|
|
86
|
+
"smol-toml": "^1.6.0",
|
|
73
87
|
"srvx": "^0.8.7",
|
|
74
|
-
"
|
|
75
|
-
"@fedify/
|
|
76
|
-
"@fedify/
|
|
77
|
-
"@fedify/
|
|
88
|
+
"valibot": "^1.2.0",
|
|
89
|
+
"@fedify/init": "2.0.1",
|
|
90
|
+
"@fedify/relay": "2.0.1",
|
|
91
|
+
"@fedify/fedify": "2.0.1",
|
|
92
|
+
"@fedify/sqlite": "2.0.1",
|
|
93
|
+
"@fedify/vocab": "2.0.1",
|
|
94
|
+
"@fedify/vocab-runtime": "2.0.1",
|
|
95
|
+
"@fedify/vocab-tools": "2.0.1",
|
|
96
|
+
"@fedify/webfinger": "2.0.1"
|
|
78
97
|
},
|
|
79
98
|
"devDependencies": {
|
|
80
99
|
"@types/bun": "^1.2.23",
|
|
@@ -83,13 +102,16 @@
|
|
|
83
102
|
"typescript": "^5.9.3"
|
|
84
103
|
},
|
|
85
104
|
"scripts": {
|
|
86
|
-
"
|
|
87
|
-
"build": "pnpm
|
|
88
|
-
"prepublish": "pnpm
|
|
89
|
-
"
|
|
90
|
-
"test
|
|
91
|
-
"
|
|
92
|
-
"
|
|
105
|
+
"build:self": "tsdown",
|
|
106
|
+
"build": "pnpm --filter @fedify/cli... run build:self",
|
|
107
|
+
"prepublish": "pnpm build",
|
|
108
|
+
"pretest": "pnpm build",
|
|
109
|
+
"test": "node --test --experimental-transform-types 'src/**/*.test.ts' '!src/init/test/**'",
|
|
110
|
+
"test-init": "deno task test-init",
|
|
111
|
+
"pretest:bun": "pnpm build",
|
|
112
|
+
"test:bun": "bun test",
|
|
113
|
+
"run": "pnpm build && node --disable-warning=ExperimentalWarning dist/mod.js",
|
|
114
|
+
"runi": "tsdown && node --disable-warning=ExperimentalWarning dist/mod.js",
|
|
93
115
|
"run:bun": "pnpm build && bun dist/mod.js",
|
|
94
116
|
"runi:bun": "tsdown && bun dist/mod.js"
|
|
95
117
|
}
|
package/deno.json
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fedify/cli",
|
|
3
|
-
"version": "2.0.0-pr.479.1922+564a1890",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"exports": "./src/mod.ts",
|
|
6
|
-
"imports": {
|
|
7
|
-
"@fxts/core": "npm:@fxts/core@^1.15.0",
|
|
8
|
-
"@hongminhee/localtunnel": "jsr:@hongminhee/localtunnel@^0.3.0",
|
|
9
|
-
"@inquirer/prompts": "npm:@inquirer/prompts@^7.8.4",
|
|
10
|
-
"@jimp/core": "npm:@jimp/core@^1.6.0",
|
|
11
|
-
"@jimp/wasm-webp": "npm:@jimp/wasm-webp@^1.6.0",
|
|
12
|
-
"@optique/core": "jsr:@optique/core@^0.6.1",
|
|
13
|
-
"@optique/run": "jsr:@optique/run@^0.6.1",
|
|
14
|
-
"@poppanator/http-constants": "npm:@poppanator/http-constants@^1.1.1",
|
|
15
|
-
"chalk": "npm:chalk@^5.6.2",
|
|
16
|
-
"cli-table3": "npm:cli-table3@^0.6.5",
|
|
17
|
-
"env-paths": "npm:env-paths@^3.0.0",
|
|
18
|
-
"fetch-mock": "npm:fetch-mock@^12.5.4",
|
|
19
|
-
"hono": "jsr:@hono/hono@^4.8.3",
|
|
20
|
-
"icojs": "npm:icojs@^0.19.5",
|
|
21
|
-
"inquirer-toggle": "npm:inquirer-toggle@^1.0.1",
|
|
22
|
-
"ora": "npm:ora@^8.2.0",
|
|
23
|
-
"shiki": "npm:shiki@^1.6.4",
|
|
24
|
-
"srvx": "npm:srvx@^0.8.7",
|
|
25
|
-
"#kv": "./src/kv.node.ts"
|
|
26
|
-
},
|
|
27
|
-
"exclude": [
|
|
28
|
-
"dist/",
|
|
29
|
-
"fedify-cli-*.tar.xz",
|
|
30
|
-
"fedify-cli-*.tgz",
|
|
31
|
-
"fedify-cli-*.zip"
|
|
32
|
-
],
|
|
33
|
-
"tasks": {
|
|
34
|
-
"codegen": "deno task -f @fedify/fedify codegen",
|
|
35
|
-
"check": {
|
|
36
|
-
"command": "deno task codegen && deno fmt --check && deno lint && deno check src/**/*.ts",
|
|
37
|
-
"dependencies": [
|
|
38
|
-
"codegen"
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
"run": {
|
|
42
|
-
"command": "deno run --allow-all src/mod.ts",
|
|
43
|
-
"dependencies": [
|
|
44
|
-
"codegen"
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
"runi": "deno run --allow-all src/mod.ts",
|
|
48
|
-
"pack": {
|
|
49
|
-
"command": "deno run -A scripts/pack.ts",
|
|
50
|
-
"dependencies": [
|
|
51
|
-
"codegen"
|
|
52
|
-
]
|
|
53
|
-
},
|
|
54
|
-
"test": {
|
|
55
|
-
"command": "deno test --allow-all",
|
|
56
|
-
"dependencies": [
|
|
57
|
-
"codegen"
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"fmt": {
|
|
62
|
-
"exclude": [
|
|
63
|
-
"src/init/templates/**"
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
"lint": {
|
|
67
|
-
"exclude": [
|
|
68
|
-
"src/init/templates/**"
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
}
|
package/dist/globals.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
4
|
-
import { recordingSink } from "./log.js";
|
|
5
|
-
import { message, object, option } from "@optique/core";
|
|
6
|
-
import process from "node:process";
|
|
7
|
-
import { configure, getConsoleSink } from "@logtape/logtape";
|
|
8
|
-
import { getFileSink } from "@logtape/file";
|
|
9
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
|
-
|
|
11
|
-
//#region src/globals.ts
|
|
12
|
-
const debugOption = object("Global options", { debug: option("-d", "--debug", { description: message`Enable debug mode.` }) });
|
|
13
|
-
async function configureLogging() {
|
|
14
|
-
const logFile = process.env["FEDIFY_LOG_FILE"];
|
|
15
|
-
await configure({
|
|
16
|
-
sinks: {
|
|
17
|
-
console: getConsoleSink(),
|
|
18
|
-
recording: recordingSink,
|
|
19
|
-
file: logFile == null ? () => void 0 : getFileSink(logFile)
|
|
20
|
-
},
|
|
21
|
-
filters: {},
|
|
22
|
-
loggers: [
|
|
23
|
-
{
|
|
24
|
-
category: "fedify",
|
|
25
|
-
lowestLevel: "debug",
|
|
26
|
-
sinks: [
|
|
27
|
-
"console",
|
|
28
|
-
"recording",
|
|
29
|
-
"file"
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
category: "localtunnel",
|
|
34
|
-
lowestLevel: "debug",
|
|
35
|
-
sinks: ["console", "file"]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
category: ["logtape", "meta"],
|
|
39
|
-
lowestLevel: "warning",
|
|
40
|
-
sinks: ["console", "file"]
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
reset: true,
|
|
44
|
-
contextLocalStorage: new AsyncLocalStorage()
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { configureLogging, debugOption };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
4
|
-
import { merge } from "../../utils.js";
|
|
5
|
-
import biome_default from "../json/biome.js";
|
|
6
|
-
import vscode_settings_for_deno_default from "../json/vscode-settings-for-deno.js";
|
|
7
|
-
import vscode_settings_default from "../json/vscode-settings.js";
|
|
8
|
-
import { PACKAGES_PATH } from "./const.js";
|
|
9
|
-
import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.js";
|
|
10
|
-
import { join, relative } from "node:path";
|
|
11
|
-
import { uniq } from "es-toolkit";
|
|
12
|
-
import { realpathSync } from "node:fs";
|
|
13
|
-
import { concat, filter, keys, map, pick, pipe, toArray } from "@fxts/core/index.js";
|
|
14
|
-
|
|
15
|
-
//#region src/init/action/configs.ts
|
|
16
|
-
/**
|
|
17
|
-
* Loads Deno configuration object with compiler options, unstable features, and tasks.
|
|
18
|
-
* Combines unstable features required by KV store and message queue with framework-specific options.
|
|
19
|
-
*
|
|
20
|
-
* @param param0 - Destructured initialization data containing KV, MQ, initializer, and directory
|
|
21
|
-
* @returns Configuration object with path and Deno-specific settings
|
|
22
|
-
*/
|
|
23
|
-
const loadDenoConfig = (data) => ({
|
|
24
|
-
path: "deno.json",
|
|
25
|
-
data: {
|
|
26
|
-
...pick(["compilerOptions", "tasks"], data.initializer),
|
|
27
|
-
unstable: getUnstable(data),
|
|
28
|
-
nodeModulesDir: "auto",
|
|
29
|
-
imports: joinDepsReg("deno")(getDependencies(data)),
|
|
30
|
-
...data.testMode ? { links: getLinks(data) } : {}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const getUnstable = ({ kv: { denoUnstable: kv = [] }, mq: { denoUnstable: mq = [] } }) => pipe(["temporal"], concat(kv), concat(mq), toArray, uniq);
|
|
34
|
-
const getLinks = ({ kv, mq, initializer, dir }) => pipe({ "@fedify/fedify": "" }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), keys, filter((dep) => dep.includes("@fedify/")), map((dep) => dep.replace("@fedify/", "")), map((dep) => join(PACKAGES_PATH, dep)), map((absolutePath) => realpathSync(absolutePath)), map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)), toArray);
|
|
35
|
-
/**
|
|
36
|
-
* Loads TypeScript configuration object for Node.js/Bun projects.
|
|
37
|
-
* Uses compiler options from the framework initializer.
|
|
38
|
-
*
|
|
39
|
-
* @param param0 - Destructured initialization data containing initializer and directory
|
|
40
|
-
* @returns Configuration object with path and TypeScript compiler options
|
|
41
|
-
*/
|
|
42
|
-
const loadTsConfig = ({ initializer, dir }) => ({
|
|
43
|
-
path: join(dir, "tsconfig.json"),
|
|
44
|
-
data: { compilerOptions: initializer.compilerOptions }
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* Loads package.json configuration object for Node.js/Bun projects.
|
|
48
|
-
* Sets up ES modules and includes framework-specific npm scripts.
|
|
49
|
-
*
|
|
50
|
-
* @param param0 - Destructured initialization data containing initializer and directory
|
|
51
|
-
* @returns Configuration object with path and package.json settings
|
|
52
|
-
*/
|
|
53
|
-
const loadPackageJson = (data) => ({
|
|
54
|
-
path: "package.json",
|
|
55
|
-
data: {
|
|
56
|
-
type: "module",
|
|
57
|
-
scripts: data.initializer.tasks,
|
|
58
|
-
dependencies: getDependencies(data),
|
|
59
|
-
devDependencies: getDevDependencies(data)
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* Configuration objects for various development tool setup files.
|
|
64
|
-
* Contains predefined configurations for code formatting, VS Code settings, and extensions
|
|
65
|
-
* based on the project type (Node.js/Bun or Deno).
|
|
66
|
-
*/
|
|
67
|
-
const devToolConfigs = {
|
|
68
|
-
biome: {
|
|
69
|
-
path: join("biome.json"),
|
|
70
|
-
data: biome_default
|
|
71
|
-
},
|
|
72
|
-
vscExt: {
|
|
73
|
-
path: join(".vscode", "extensions.json"),
|
|
74
|
-
data: { recommendations: ["biomejs.biome"] }
|
|
75
|
-
},
|
|
76
|
-
vscSet: {
|
|
77
|
-
path: join(".vscode", "settings.json"),
|
|
78
|
-
data: vscode_settings_default
|
|
79
|
-
},
|
|
80
|
-
vscSetDeno: {
|
|
81
|
-
path: join(".vscode", "settings.json"),
|
|
82
|
-
data: vscode_settings_for_deno_default
|
|
83
|
-
},
|
|
84
|
-
vscExtDeno: {
|
|
85
|
-
path: join(".vscode", "extensions.json"),
|
|
86
|
-
data: { recommendations: ["denoland.vscode-deno"] }
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
|
-
export { devToolConfigs, loadDenoConfig, loadPackageJson, loadTsConfig };
|