@fedify/cli 2.0.0-pr.479.1919 → 2.0.0
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/src/webfinger/error.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type Message, message } from "@optique/core";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generates a user-friendly error message based on the type of error
|
|
5
|
-
* encountered during WebFinger lookup.
|
|
6
|
-
* @param {string} resource The resource being looked up.
|
|
7
|
-
* @param {unknown} error The error encountered.
|
|
8
|
-
* @returns {string} A descriptive error message.
|
|
9
|
-
*/
|
|
10
|
-
export const getErrorMessage = (resource: string, error: unknown): Message =>
|
|
11
|
-
error instanceof InvalidHandleError
|
|
12
|
-
? message`Invalid handle format: ${error.handle}`
|
|
13
|
-
: error instanceof NotFoundError
|
|
14
|
-
? message`Resource not found: ${error.resource}`
|
|
15
|
-
: error instanceof Error
|
|
16
|
-
? message`Failed to look up WebFinger for ${resource}: ${error.message}`
|
|
17
|
-
: message`Failed to look up WebFinger for ${resource}: ${String(error)}`;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Custom error class for invalid handle formats.
|
|
21
|
-
* @param {string} handle The invalid handle that caused the error.
|
|
22
|
-
* @extends {Error}
|
|
23
|
-
*/
|
|
24
|
-
export class InvalidHandleError extends Error {
|
|
25
|
-
constructor(public handle: string) {
|
|
26
|
-
super(`Invalid handle format: ${handle}`);
|
|
27
|
-
this.name = "InvalidHandleError";
|
|
28
|
-
}
|
|
29
|
-
throw(): never {
|
|
30
|
-
throw this;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Custom error class for not found resources.
|
|
36
|
-
* @param {string} resource The resource that was not found.
|
|
37
|
-
* @extends {Error}
|
|
38
|
-
*/
|
|
39
|
-
export class NotFoundError extends Error {
|
|
40
|
-
constructor(public resource: string) {
|
|
41
|
-
super(`Resource not found: ${resource}`);
|
|
42
|
-
this.name = "NotFoundError";
|
|
43
|
-
}
|
|
44
|
-
throw(): never {
|
|
45
|
-
throw this;
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/webfinger/lib.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { toAcctUrl } from "@fedify/fedify";
|
|
2
|
-
import { getLogger } from "@logtape/logtape";
|
|
3
|
-
import { InvalidHandleError } from "./error.ts";
|
|
4
|
-
|
|
5
|
-
export const logger = getLogger(["fedify", "cli", "webfinger"]);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Converts a handle or URL to a URL object.
|
|
9
|
-
* If the input is a valid URL, it returns the URL object.
|
|
10
|
-
* If the input is a handle in the format `@username@domain`, it converts it to a URL.
|
|
11
|
-
* @param handleOrUrl The handle or URL to convert.
|
|
12
|
-
* @returns A URL object representing the handle or URL.
|
|
13
|
-
*/
|
|
14
|
-
export function convertUrlIfHandle(handleOrUrl: string): URL {
|
|
15
|
-
try {
|
|
16
|
-
return new URL(handleOrUrl); // Try to convert the input to a URL
|
|
17
|
-
} catch {
|
|
18
|
-
return convertHandleToUrl(handleOrUrl); // If it fails, treat it as a handle
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Converts a handle in the format `@username@domain` to a URL.
|
|
24
|
-
* The resulting URL will be in the format `https://domain/@username`.
|
|
25
|
-
* @param handle The handle to convert, in the format `@username@domain`.
|
|
26
|
-
* @returns A URL object representing the handle.
|
|
27
|
-
* @throws {Error} If the handle format is invalid.
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const url = convertHandleToUrl("@username@domain.com");
|
|
31
|
-
* console.log(url.toString()); // "https://domain.com/@username"
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export function convertHandleToUrl(handle: string): URL {
|
|
35
|
-
return toAcctUrl(handle) ?? // Convert the handle to a URL
|
|
36
|
-
new InvalidHandleError(handle).throw(); // or throw an error if invalid
|
|
37
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { parse } from "@optique/core/parser";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import test from "node:test";
|
|
4
|
-
import { lookupSingleWebFinger } from "./action.ts";
|
|
5
|
-
import { webFingerCommand } from "./command.ts";
|
|
6
|
-
|
|
7
|
-
const COMMAND = "webfinger";
|
|
8
|
-
const USER_AGENT = "MyUserAgent/1.0";
|
|
9
|
-
const RESOURCES = [
|
|
10
|
-
"@hongminhee@hackers.pub",
|
|
11
|
-
"@fedify@hollo.social",
|
|
12
|
-
];
|
|
13
|
-
const ALIASES = [
|
|
14
|
-
"https://hackers.pub/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c",
|
|
15
|
-
"https://hollo.social/@fedify",
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
test("Test webFingerCommand", () => {
|
|
19
|
-
// Resources only
|
|
20
|
-
const argsWithResourcesOnly = [COMMAND, ...RESOURCES];
|
|
21
|
-
assert.deepEqual(
|
|
22
|
-
parse(webFingerCommand, argsWithResourcesOnly),
|
|
23
|
-
{
|
|
24
|
-
success: true,
|
|
25
|
-
value: {
|
|
26
|
-
debug: false,
|
|
27
|
-
command: COMMAND,
|
|
28
|
-
resources: RESOURCES,
|
|
29
|
-
allowPrivateAddresses: undefined,
|
|
30
|
-
maxRedirection: 5,
|
|
31
|
-
userAgent: undefined,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
);
|
|
35
|
-
// With options
|
|
36
|
-
const maxRedirection = 10;
|
|
37
|
-
assert.deepEqual(
|
|
38
|
-
parse(webFingerCommand, [
|
|
39
|
-
...argsWithResourcesOnly,
|
|
40
|
-
"-d",
|
|
41
|
-
"-u",
|
|
42
|
-
USER_AGENT,
|
|
43
|
-
"--max-redirection",
|
|
44
|
-
String(maxRedirection),
|
|
45
|
-
"--allow-private-address",
|
|
46
|
-
]),
|
|
47
|
-
{
|
|
48
|
-
success: true,
|
|
49
|
-
value: {
|
|
50
|
-
debug: true,
|
|
51
|
-
command: COMMAND,
|
|
52
|
-
resources: RESOURCES,
|
|
53
|
-
allowPrivateAddresses: true,
|
|
54
|
-
maxRedirection,
|
|
55
|
-
userAgent: USER_AGENT,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
// Wrong option
|
|
60
|
-
const wrongOptionResult = parse(webFingerCommand, [
|
|
61
|
-
...argsWithResourcesOnly,
|
|
62
|
-
"-Q",
|
|
63
|
-
]);
|
|
64
|
-
assert.ok(!wrongOptionResult.success);
|
|
65
|
-
// Wrong option value
|
|
66
|
-
const wrongOptionValueResult = parse(
|
|
67
|
-
webFingerCommand,
|
|
68
|
-
[...argsWithResourcesOnly, "--max-redirection", "-10"],
|
|
69
|
-
);
|
|
70
|
-
assert.ok(!wrongOptionValueResult.success);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("Test lookupSingleWebFinger", async () => {
|
|
74
|
-
const aliases = (await Array.fromAsync(
|
|
75
|
-
RESOURCES,
|
|
76
|
-
(resource) => lookupSingleWebFinger({ resource }),
|
|
77
|
-
)).map((w) => w?.aliases?.[0]);
|
|
78
|
-
assert.deepEqual(aliases, ALIASES);
|
|
79
|
-
});
|
package/src/webfinger/mod.ts
DELETED
package/tsdown.config.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { cp } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { defineConfig } from "tsdown";
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
entry: ["src/mod.ts", "src/kv.bun.ts", "src/kv.node.ts"],
|
|
7
|
-
platform: "node",
|
|
8
|
-
unbundle: true,
|
|
9
|
-
inputOptions: {
|
|
10
|
-
onwarn(warning, defaultHandler) {
|
|
11
|
-
if (
|
|
12
|
-
warning.code === "UNRESOLVED_IMPORT" &&
|
|
13
|
-
["#kv", "bun:sqlite"].includes(warning.exporter ?? "")
|
|
14
|
-
) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
defaultHandler(warning);
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
outputOptions(outputOptions) {
|
|
21
|
-
outputOptions.intro = `
|
|
22
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
23
|
-
`;
|
|
24
|
-
return outputOptions;
|
|
25
|
-
},
|
|
26
|
-
hooks: {
|
|
27
|
-
"build:done": async (ctx) => {
|
|
28
|
-
await cp(
|
|
29
|
-
join("src", "init", "templates"),
|
|
30
|
-
join(ctx.options.outDir, "init", "templates"),
|
|
31
|
-
{ recursive: true },
|
|
32
|
-
);
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
});
|