@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.
Files changed (160) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -3
  3. package/dist/cache.js +17 -3
  4. package/dist/config.js +105 -0
  5. package/dist/deno.js +18 -8
  6. package/dist/generate-vocab/action.js +1 -1
  7. package/dist/imagerenderer.js +1 -1
  8. package/dist/inbox/rendercode.js +11 -21
  9. package/dist/inbox.js +162 -132
  10. package/dist/init/mod.js +3 -3
  11. package/dist/log.js +35 -1
  12. package/dist/lookup.js +55 -23
  13. package/dist/mod.js +95 -18
  14. package/dist/nodeinfo.js +39 -22
  15. package/dist/options.js +84 -0
  16. package/dist/relay.js +136 -0
  17. package/dist/tempserver.js +15 -8
  18. package/dist/tunnel.js +6 -10
  19. package/dist/utils.js +19 -108
  20. package/dist/webfinger/action.js +1 -1
  21. package/dist/webfinger/command.js +17 -9
  22. package/dist/webfinger/lib.js +3 -3
  23. package/package.json +50 -28
  24. package/deno.json +0 -71
  25. package/dist/globals.js +0 -49
  26. package/dist/init/action/configs.js +0 -91
  27. package/dist/init/action/const.js +0 -10
  28. package/dist/init/action/deps.js +0 -50
  29. package/dist/init/action/dir.js +0 -16
  30. package/dist/init/action/env.js +0 -13
  31. package/dist/init/action/install.js +0 -20
  32. package/dist/init/action/mod.js +0 -39
  33. package/dist/init/action/notice.js +0 -55
  34. package/dist/init/action/patch.js +0 -147
  35. package/dist/init/action/precommand.js +0 -28
  36. package/dist/init/action/recommend.js +0 -24
  37. package/dist/init/action/set.js +0 -31
  38. package/dist/init/action/templates.js +0 -58
  39. package/dist/init/action/utils.js +0 -50
  40. package/dist/init/ask/dir.js +0 -82
  41. package/dist/init/ask/kv.js +0 -44
  42. package/dist/init/ask/mod.js +0 -16
  43. package/dist/init/ask/mq.js +0 -46
  44. package/dist/init/ask/pm.js +0 -49
  45. package/dist/init/ask/wf.js +0 -29
  46. package/dist/init/command.js +0 -50
  47. package/dist/init/const.js +0 -31
  48. package/dist/init/json/biome.js +0 -24
  49. package/dist/init/json/kv.js +0 -53
  50. package/dist/init/json/mq.js +0 -72
  51. package/dist/init/json/pm.js +0 -44
  52. package/dist/init/json/rt.js +0 -39
  53. package/dist/init/json/vscode-settings-for-deno.js +0 -53
  54. package/dist/init/json/vscode-settings.js +0 -49
  55. package/dist/init/lib.js +0 -136
  56. package/dist/init/templates/defaults/federation.ts.tpl +0 -23
  57. package/dist/init/templates/defaults/logging.ts.tpl +0 -23
  58. package/dist/init/templates/express/app.ts.tpl +0 -16
  59. package/dist/init/templates/express/index.ts.tpl +0 -6
  60. package/dist/init/templates/hono/app.tsx.tpl +0 -14
  61. package/dist/init/templates/hono/index/bun.ts.tpl +0 -10
  62. package/dist/init/templates/hono/index/deno.ts.tpl +0 -13
  63. package/dist/init/templates/hono/index/node.ts.tpl +0 -14
  64. package/dist/init/templates/next/middleware.ts.tpl +0 -45
  65. package/dist/init/templates/nitro/.env.test.tpl +0 -1
  66. package/dist/init/templates/nitro/nitro.config.ts.tpl +0 -14
  67. package/dist/init/templates/nitro/server/error.ts.tpl +0 -3
  68. package/dist/init/templates/nitro/server/middleware/federation.ts.tpl +0 -8
  69. package/dist/init/test/action.js +0 -17
  70. package/dist/init/test/create.js +0 -100
  71. package/dist/init/test/fill.js +0 -32
  72. package/dist/init/test/lookup.js +0 -190
  73. package/dist/init/test/run.js +0 -25
  74. package/dist/init/test/utils.js +0 -17
  75. package/dist/init/webframeworks.js +0 -136
  76. package/scripts/pack.ts +0 -71
  77. package/src/cache.ts +0 -17
  78. package/src/docloader.ts +0 -67
  79. package/src/generate-vocab/action.ts +0 -17
  80. package/src/generate-vocab/command.ts +0 -44
  81. package/src/generate-vocab/mod.ts +0 -2
  82. package/src/globals.ts +0 -43
  83. package/src/imagerenderer.ts +0 -149
  84. package/src/inbox/entry.ts +0 -10
  85. package/src/inbox/rendercode.ts +0 -68
  86. package/src/inbox/view.tsx +0 -598
  87. package/src/inbox.tsx +0 -536
  88. package/src/init/action/configs.ts +0 -133
  89. package/src/init/action/const.ts +0 -9
  90. package/src/init/action/deps.ts +0 -161
  91. package/src/init/action/dir.ts +0 -11
  92. package/src/init/action/env.ts +0 -14
  93. package/src/init/action/install.ts +0 -24
  94. package/src/init/action/mod.ts +0 -66
  95. package/src/init/action/notice.ts +0 -103
  96. package/src/init/action/patch.ts +0 -233
  97. package/src/init/action/precommand.ts +0 -29
  98. package/src/init/action/recommend.ts +0 -38
  99. package/src/init/action/set.ts +0 -65
  100. package/src/init/action/templates.ts +0 -96
  101. package/src/init/action/utils.ts +0 -64
  102. package/src/init/ask/dir.ts +0 -98
  103. package/src/init/ask/kv.ts +0 -82
  104. package/src/init/ask/mod.ts +0 -23
  105. package/src/init/ask/mq.ts +0 -86
  106. package/src/init/ask/pm.ts +0 -58
  107. package/src/init/ask/wf.ts +0 -27
  108. package/src/init/command.ts +0 -135
  109. package/src/init/const.ts +0 -4
  110. package/src/init/json/biome.json +0 -17
  111. package/src/init/json/kv.json +0 -39
  112. package/src/init/json/mq.json +0 -95
  113. package/src/init/json/pm.json +0 -47
  114. package/src/init/json/rt.json +0 -42
  115. package/src/init/json/vscode-settings-for-deno.json +0 -43
  116. package/src/init/json/vscode-settings.json +0 -41
  117. package/src/init/lib.ts +0 -223
  118. package/src/init/mod.ts +0 -3
  119. package/src/init/templates/defaults/federation.ts.tpl +0 -23
  120. package/src/init/templates/defaults/logging.ts.tpl +0 -23
  121. package/src/init/templates/express/app.ts.tpl +0 -16
  122. package/src/init/templates/express/index.ts.tpl +0 -6
  123. package/src/init/templates/hono/app.tsx.tpl +0 -14
  124. package/src/init/templates/hono/index/bun.ts.tpl +0 -10
  125. package/src/init/templates/hono/index/deno.ts.tpl +0 -13
  126. package/src/init/templates/hono/index/node.ts.tpl +0 -14
  127. package/src/init/templates/next/middleware.ts.tpl +0 -45
  128. package/src/init/templates/nitro/.env.test.tpl +0 -1
  129. package/src/init/templates/nitro/nitro.config.ts.tpl +0 -14
  130. package/src/init/templates/nitro/server/error.ts.tpl +0 -3
  131. package/src/init/templates/nitro/server/middleware/federation.ts.tpl +0 -8
  132. package/src/init/test/action.ts +0 -28
  133. package/src/init/test/create.ts +0 -137
  134. package/src/init/test/fill.ts +0 -67
  135. package/src/init/test/lookup.ts +0 -254
  136. package/src/init/test/run.ts +0 -39
  137. package/src/init/test/types.ts +0 -27
  138. package/src/init/test/utils.ts +0 -21
  139. package/src/init/types.ts +0 -89
  140. package/src/init/webframeworks.ts +0 -168
  141. package/src/kv.bun.ts +0 -12
  142. package/src/kv.node.ts +0 -11
  143. package/src/log.ts +0 -64
  144. package/src/lookup.test.ts +0 -182
  145. package/src/lookup.ts +0 -563
  146. package/src/mod.ts +0 -62
  147. package/src/nodeinfo.test.ts +0 -229
  148. package/src/nodeinfo.ts +0 -454
  149. package/src/table.ts +0 -17
  150. package/src/tempserver.ts +0 -87
  151. package/src/tunnel.test.ts +0 -157
  152. package/src/tunnel.ts +0 -94
  153. package/src/utils.ts +0 -254
  154. package/src/webfinger/action.ts +0 -50
  155. package/src/webfinger/command.ts +0 -64
  156. package/src/webfinger/error.ts +0 -47
  157. package/src/webfinger/lib.ts +0 -37
  158. package/src/webfinger/mod.test.ts +0 -79
  159. package/src/webfinger/mod.ts +0 -2
  160. package/tsdown.config.ts +0 -35
@@ -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
- }
@@ -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
- });
@@ -1,2 +0,0 @@
1
- export { default as runWebFinger } from "./action.ts";
2
- export { webFingerCommand } from "./command.ts";
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
- });