@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/src/init/test/run.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { always, filter, map, pipe, tap, unless } from "@fxts/core";
|
|
2
|
-
import { optionNames } from "@optique/core";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { printMessage } from "../../utils.ts";
|
|
5
|
-
import createTestApp, { filterOptions, generateTestCases } from "./create.ts";
|
|
6
|
-
import runServerAndLookupUser from "./lookup.ts";
|
|
7
|
-
import type { InitTestData } from "./types.ts";
|
|
8
|
-
|
|
9
|
-
const runTests =
|
|
10
|
-
(dry: boolean) =>
|
|
11
|
-
<T extends InitTestData>({ testDirPrefix, dryRun, hydRun, ...options }: T) =>
|
|
12
|
-
pipe(
|
|
13
|
-
options,
|
|
14
|
-
printStartMessage(dry),
|
|
15
|
-
generateTestCases,
|
|
16
|
-
filter(filterOptions),
|
|
17
|
-
map(createTestApp(join(testDirPrefix, getMid(dryRun, hydRun, dry)), dry)),
|
|
18
|
-
Array.fromAsync<string>,
|
|
19
|
-
unless(always(dry), runServerAndLookupUser),
|
|
20
|
-
);
|
|
21
|
-
export default runTests;
|
|
22
|
-
|
|
23
|
-
const printStartMessage: (dry: boolean) => <T>(t: T) => T = (dry: boolean) =>
|
|
24
|
-
tap(
|
|
25
|
-
() =>
|
|
26
|
-
printMessage`\n
|
|
27
|
-
Init ${dry ? "Dry" : "Hyd"} Test start!
|
|
28
|
-
Options: ${
|
|
29
|
-
optionNames([
|
|
30
|
-
"Web Framework",
|
|
31
|
-
"Package Manager",
|
|
32
|
-
"KV Store",
|
|
33
|
-
"Message Queue",
|
|
34
|
-
])
|
|
35
|
-
}`,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const getMid = (dryRun: boolean, hydRun: boolean, dry: boolean) =>
|
|
39
|
-
dryRun === hydRun ? dry ? "dry" : "hyd" : "";
|
package/src/init/test/types.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { TestInitCommand } from "../command.ts";
|
|
2
|
-
|
|
3
|
-
export interface InitTestData extends DefineAllOptions<TestInitCommand> {
|
|
4
|
-
runId: string;
|
|
5
|
-
testDirPrefix: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type MultipleOption =
|
|
9
|
-
| "webFramework"
|
|
10
|
-
| "packageManager"
|
|
11
|
-
| "kvStore"
|
|
12
|
-
| "messageQueue";
|
|
13
|
-
|
|
14
|
-
export type DefineOption<T extends TestInitCommand, K extends MultipleOption> =
|
|
15
|
-
& Omit<T, K>
|
|
16
|
-
& {
|
|
17
|
-
[Key in MultipleOption]: Key extends K ? TestInitCommand[Key] & string[]
|
|
18
|
-
: T[Key];
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type NoRunMode = "noHydRun" | "noDryRun";
|
|
22
|
-
type RunMode = "hydRun" | "dryRun";
|
|
23
|
-
|
|
24
|
-
export type DefineAllOptions<T extends TestInitCommand> =
|
|
25
|
-
& Omit<T, MultipleOption | NoRunMode>
|
|
26
|
-
& { [K in MultipleOption]: (TestInitCommand[K][number] & string)[] }
|
|
27
|
-
& { [R in RunMode]: boolean };
|
package/src/init/test/utils.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { tmpdir } from "node:os";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { printMessage } from "../../utils.ts";
|
|
4
|
-
|
|
5
|
-
export const genRunId = () =>
|
|
6
|
-
`${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
7
|
-
|
|
8
|
-
export const genTestDirPrefix = <T extends { runId: string }>({ runId }: T) =>
|
|
9
|
-
join(tmpdir(), "fedify-init", runId);
|
|
10
|
-
|
|
11
|
-
export const emptyTestDir = <
|
|
12
|
-
T extends { testDirPrefix: string },
|
|
13
|
-
>({ testDirPrefix }: T) =>
|
|
14
|
-
Deno.remove(testDirPrefix, { recursive: true }).catch(() => {});
|
|
15
|
-
|
|
16
|
-
export const logTestDir = <
|
|
17
|
-
T extends { runId: string; testDirPrefix: string },
|
|
18
|
-
>({ runId, testDirPrefix }: T) =>
|
|
19
|
-
printMessage`Test run completed.
|
|
20
|
-
Run ID: ${runId}
|
|
21
|
-
Path: ${testDirPrefix}`;
|
package/src/init/types.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type { Message } from "@optique/core";
|
|
2
|
-
import type { RequiredNotNull } from "../utils.ts";
|
|
3
|
-
import type { InitCommand } from "./command.ts";
|
|
4
|
-
import type {
|
|
5
|
-
KV_STORE,
|
|
6
|
-
MESSAGE_QUEUE,
|
|
7
|
-
PACKAGE_MANAGER,
|
|
8
|
-
WEB_FRAMEWORK,
|
|
9
|
-
} from "./const.ts";
|
|
10
|
-
|
|
11
|
-
export type PackageManager = typeof PACKAGE_MANAGER[number];
|
|
12
|
-
export type WebFramework = typeof WEB_FRAMEWORK[number];
|
|
13
|
-
export type MessageQueue = typeof MESSAGE_QUEUE[number];
|
|
14
|
-
export type KvStore = typeof KV_STORE[number];
|
|
15
|
-
|
|
16
|
-
export type MessageQueues = Record<MessageQueue, MessageQueueDescription>;
|
|
17
|
-
export type KvStores = Record<KvStore, KvStoreDescription>;
|
|
18
|
-
export type WebFrameworks = Record<WebFramework, WebFrameworkDescription>;
|
|
19
|
-
export type PackageManagers = Record<PackageManager, PackageManagerDescription>;
|
|
20
|
-
export type Runtimes = Record<PackageManager, RuntimeDescription>;
|
|
21
|
-
|
|
22
|
-
export interface RuntimeDescription {
|
|
23
|
-
label: string;
|
|
24
|
-
checkCommand: [string, ...string[]];
|
|
25
|
-
outputPattern: RegExp;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface PackageManagerDescription {
|
|
29
|
-
label: string;
|
|
30
|
-
checkCommand: [string, ...string[]];
|
|
31
|
-
outputPattern: RegExp;
|
|
32
|
-
installUrl: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface WebFrameworkInitializer {
|
|
36
|
-
command?: string[];
|
|
37
|
-
dependencies?: object;
|
|
38
|
-
devDependencies?: object;
|
|
39
|
-
federationFile: string;
|
|
40
|
-
loggingFile: string;
|
|
41
|
-
files?: Record<string, string>;
|
|
42
|
-
compilerOptions?: Record<string, string | boolean | number | string[] | null>;
|
|
43
|
-
tasks?: Record<string, string>;
|
|
44
|
-
instruction: Message;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface WebFrameworkDescription {
|
|
48
|
-
label: string;
|
|
49
|
-
packageManagers: readonly PackageManager[];
|
|
50
|
-
defaultPort: number;
|
|
51
|
-
init(
|
|
52
|
-
data: InitCommandOptions & { projectName: string },
|
|
53
|
-
): WebFrameworkInitializer;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface MessageQueueDescription {
|
|
57
|
-
label: string;
|
|
58
|
-
packageManagers: readonly PackageManager[];
|
|
59
|
-
dependencies?: Record<string, string>;
|
|
60
|
-
devDependencies?: Record<string, string>;
|
|
61
|
-
imports: Record<string, Record<string, string>>;
|
|
62
|
-
object: string;
|
|
63
|
-
denoUnstable?: string[];
|
|
64
|
-
env?: Record<string, string>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface KvStoreDescription {
|
|
68
|
-
label: string;
|
|
69
|
-
packageManagers: readonly PackageManager[];
|
|
70
|
-
dependencies?: Record<string, string>;
|
|
71
|
-
devDependencies?: Record<string, string>;
|
|
72
|
-
imports: Record<string, Record<string, string>>;
|
|
73
|
-
object: string;
|
|
74
|
-
denoUnstable?: string[];
|
|
75
|
-
env?: Record<string, string>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export type InitCommandOptions = RequiredNotNull<InitCommand>;
|
|
79
|
-
|
|
80
|
-
export interface InitCommandData extends InitCommandOptions {
|
|
81
|
-
readonly projectName: string;
|
|
82
|
-
readonly initializer: WebFrameworkInitializer;
|
|
83
|
-
readonly kv: KvStoreDescription;
|
|
84
|
-
readonly mq: MessageQueueDescription;
|
|
85
|
-
readonly env: Record<string, string>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type InitCommandIo = (data: InitCommandData) => void;
|
|
89
|
-
export type InitCommandAsyncIo = (data: InitCommandData) => Promise<void>;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { pipe } from "@fxts/core";
|
|
2
|
-
import { replace } from "../utils.ts";
|
|
3
|
-
import { PACKAGE_MANAGER } from "./const.ts";
|
|
4
|
-
import {
|
|
5
|
-
getInstruction,
|
|
6
|
-
getNextInitCommand,
|
|
7
|
-
getNitroInitCommand,
|
|
8
|
-
PACKAGE_VERSION,
|
|
9
|
-
packageManagerToRuntime,
|
|
10
|
-
readTemplate,
|
|
11
|
-
} from "./lib.ts";
|
|
12
|
-
import type { WebFrameworks } from "./types.ts";
|
|
13
|
-
|
|
14
|
-
const webFrameworks: WebFrameworks = {
|
|
15
|
-
hono: {
|
|
16
|
-
label: "Hono",
|
|
17
|
-
packageManagers: PACKAGE_MANAGER,
|
|
18
|
-
init: ({ projectName, packageManager: pm }) => ({
|
|
19
|
-
dependencies: pm === "deno"
|
|
20
|
-
? {
|
|
21
|
-
"@std/dotenv": "^0.225.2",
|
|
22
|
-
"@hono/hono": "^4.5.0",
|
|
23
|
-
"@hongminhee/x-forwarded-fetch": "^0.2.0",
|
|
24
|
-
"@fedify/hono": PACKAGE_VERSION,
|
|
25
|
-
}
|
|
26
|
-
: pm === "bun"
|
|
27
|
-
? {
|
|
28
|
-
hono: "^4.5.0",
|
|
29
|
-
"x-forwarded-fetch": "^0.2.0",
|
|
30
|
-
"@fedify/hono": PACKAGE_VERSION,
|
|
31
|
-
}
|
|
32
|
-
: {
|
|
33
|
-
"@dotenvx/dotenvx": "^1.14.1",
|
|
34
|
-
hono: "^4.5.0",
|
|
35
|
-
"@hono/node-server": "^1.12.0",
|
|
36
|
-
tsx: "^4.17.0",
|
|
37
|
-
"x-forwarded-fetch": "^0.2.0",
|
|
38
|
-
"@fedify/hono": PACKAGE_VERSION,
|
|
39
|
-
},
|
|
40
|
-
devDependencies: pm === "bun" ? { "@types/bun": "^1.1.6" } : {},
|
|
41
|
-
federationFile: "src/federation.ts",
|
|
42
|
-
loggingFile: "src/logging.ts",
|
|
43
|
-
files: {
|
|
44
|
-
"src/app.tsx": pipe(
|
|
45
|
-
"hono/app.tsx",
|
|
46
|
-
readTemplate,
|
|
47
|
-
replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"),
|
|
48
|
-
replace(/\/\* logger \*\//, projectName),
|
|
49
|
-
),
|
|
50
|
-
"src/index.ts": readTemplate(
|
|
51
|
-
`hono/index/${packageManagerToRuntime(pm)}.ts`,
|
|
52
|
-
),
|
|
53
|
-
},
|
|
54
|
-
compilerOptions: pm === "deno" ? undefined : {
|
|
55
|
-
"lib": ["ESNext", "DOM"],
|
|
56
|
-
"target": "ESNext",
|
|
57
|
-
"module": "NodeNext",
|
|
58
|
-
"moduleResolution": "NodeNext",
|
|
59
|
-
"allowImportingTsExtensions": true,
|
|
60
|
-
"verbatimModuleSyntax": true,
|
|
61
|
-
"noEmit": true,
|
|
62
|
-
"strict": true,
|
|
63
|
-
"jsx": "react-jsx",
|
|
64
|
-
"jsxImportSource": "hono/jsx",
|
|
65
|
-
},
|
|
66
|
-
tasks: {
|
|
67
|
-
"dev": pm === "deno"
|
|
68
|
-
? "deno run -A --watch ./src/index.ts"
|
|
69
|
-
: pm === "bun"
|
|
70
|
-
? "bun run --hot ./src/index.ts"
|
|
71
|
-
: "dotenvx run -- tsx watch ./src/index.ts",
|
|
72
|
-
"prod": pm === "deno"
|
|
73
|
-
? "deno run -A ./src/index.ts"
|
|
74
|
-
: pm === "bun"
|
|
75
|
-
? "bun run ./src/index.ts"
|
|
76
|
-
: "dotenvx run -- node --import tsx ./src/index.ts",
|
|
77
|
-
},
|
|
78
|
-
instruction: getInstruction(pm, 8000),
|
|
79
|
-
}),
|
|
80
|
-
defaultPort: 8000,
|
|
81
|
-
},
|
|
82
|
-
express: {
|
|
83
|
-
label: "Express",
|
|
84
|
-
packageManagers: PACKAGE_MANAGER,
|
|
85
|
-
init: ({ projectName, packageManager: pm }) => ({
|
|
86
|
-
dependencies: {
|
|
87
|
-
"npm:express": "^4.19.2",
|
|
88
|
-
"@fedify/express": PACKAGE_VERSION,
|
|
89
|
-
...(pm !== "deno" && pm !== "bun"
|
|
90
|
-
? { "@dotenvx/dotenvx": "^1.14.1", tsx: "^4.17.0" }
|
|
91
|
-
: {}),
|
|
92
|
-
},
|
|
93
|
-
devDependencies: {
|
|
94
|
-
"@types/express": "^4.17.21",
|
|
95
|
-
...(pm === "bun" ? { "@types/bun": "^1.1.6" } : {}),
|
|
96
|
-
},
|
|
97
|
-
federationFile: "src/federation.ts",
|
|
98
|
-
loggingFile: "src/logging.ts",
|
|
99
|
-
files: {
|
|
100
|
-
"src/app.ts": readTemplate("express/app.ts")
|
|
101
|
-
.replace(/\/\* logger \*\//, projectName),
|
|
102
|
-
"src/index.ts": readTemplate("express/index.ts"),
|
|
103
|
-
},
|
|
104
|
-
compilerOptions: pm === "deno" ? undefined : {
|
|
105
|
-
"lib": ["ESNext", "DOM"],
|
|
106
|
-
"target": "ESNext",
|
|
107
|
-
"module": "NodeNext",
|
|
108
|
-
"moduleResolution": "NodeNext",
|
|
109
|
-
"allowImportingTsExtensions": true,
|
|
110
|
-
"verbatimModuleSyntax": true,
|
|
111
|
-
"noEmit": true,
|
|
112
|
-
"strict": true,
|
|
113
|
-
},
|
|
114
|
-
tasks: {
|
|
115
|
-
"dev": pm === "bun"
|
|
116
|
-
? "bun run --hot ./src/index.ts"
|
|
117
|
-
: pm === "deno"
|
|
118
|
-
? "deno run --allow-net --allow-env --allow-sys --watch ./src/index.ts"
|
|
119
|
-
: "dotenvx run -- tsx watch ./src/index.ts",
|
|
120
|
-
"prod": pm === "bun"
|
|
121
|
-
? "bun run ./src/index.ts"
|
|
122
|
-
: pm === "deno"
|
|
123
|
-
? "deno run --allow-net --allow-env --allow-sys ./src/index.ts"
|
|
124
|
-
: "dotenvx run -- node --import tsx ./src/index.ts",
|
|
125
|
-
},
|
|
126
|
-
instruction: getInstruction(pm, 8000),
|
|
127
|
-
}),
|
|
128
|
-
defaultPort: 8000,
|
|
129
|
-
},
|
|
130
|
-
nitro: {
|
|
131
|
-
label: "Nitro",
|
|
132
|
-
packageManagers: PACKAGE_MANAGER,
|
|
133
|
-
init: ({ packageManager: pm, testMode }) => ({
|
|
134
|
-
command: getNitroInitCommand(pm),
|
|
135
|
-
dependencies: { "@fedify/h3": PACKAGE_VERSION },
|
|
136
|
-
federationFile: "server/federation.ts",
|
|
137
|
-
loggingFile: "server/logging.ts",
|
|
138
|
-
files: {
|
|
139
|
-
"server/middleware/federation.ts": readTemplate(
|
|
140
|
-
"nitro/server/middleware/federation.ts",
|
|
141
|
-
),
|
|
142
|
-
"server/error.ts": readTemplate("nitro/server/error.ts"),
|
|
143
|
-
"nitro.config.ts": readTemplate("nitro/nitro.config.ts"),
|
|
144
|
-
...(
|
|
145
|
-
testMode ? { ".env": readTemplate("nitro/.env.test") } : {}
|
|
146
|
-
),
|
|
147
|
-
},
|
|
148
|
-
instruction: getInstruction(pm, 3000),
|
|
149
|
-
}),
|
|
150
|
-
defaultPort: 3000,
|
|
151
|
-
},
|
|
152
|
-
next: {
|
|
153
|
-
label: "Next.js",
|
|
154
|
-
packageManagers: PACKAGE_MANAGER,
|
|
155
|
-
init: ({ packageManager: pm }) => ({
|
|
156
|
-
label: "Next.js",
|
|
157
|
-
command: getNextInitCommand(pm),
|
|
158
|
-
dependencies: { "@fedify/next": PACKAGE_VERSION },
|
|
159
|
-
devDependencies: { "@types/node": "^20.11.2" },
|
|
160
|
-
federationFile: "federation/index.ts",
|
|
161
|
-
loggingFile: "logging.ts",
|
|
162
|
-
files: { "middleware.ts": readTemplate("next/middleware.ts") },
|
|
163
|
-
instruction: getInstruction(pm, 3000),
|
|
164
|
-
}),
|
|
165
|
-
defaultPort: 3000,
|
|
166
|
-
},
|
|
167
|
-
} as const;
|
|
168
|
-
export default webFrameworks;
|
package/src/kv.bun.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { KvStore } from "@fedify/fedify/federation";
|
|
2
|
-
import { SqliteKvStore } from "@fedify/sqlite";
|
|
3
|
-
import { Database } from "bun:sqlite";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import type { DatabaseSync } from "node:sqlite";
|
|
6
|
-
import { getCacheDir } from "./cache.ts";
|
|
7
|
-
|
|
8
|
-
export async function getKvStore(): Promise<KvStore> {
|
|
9
|
-
const path = join(await getCacheDir(), "sqlite");
|
|
10
|
-
const sqlite = new Database(path);
|
|
11
|
-
return new SqliteKvStore(sqlite as unknown as DatabaseSync);
|
|
12
|
-
}
|
package/src/kv.node.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { KvStore } from "@fedify/fedify/federation";
|
|
2
|
-
import { SqliteKvStore } from "@fedify/sqlite";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { DatabaseSync } from "node:sqlite";
|
|
5
|
-
import { getCacheDir } from "./cache.ts";
|
|
6
|
-
|
|
7
|
-
export async function getKvStore(): Promise<KvStore> {
|
|
8
|
-
const path = join(await getCacheDir(), "sqlite");
|
|
9
|
-
const sqlite = new DatabaseSync(path);
|
|
10
|
-
return new SqliteKvStore(sqlite);
|
|
11
|
-
}
|
package/src/log.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { getFileSink } from "@logtape/file";
|
|
2
|
-
import {
|
|
3
|
-
configure,
|
|
4
|
-
getConsoleSink,
|
|
5
|
-
type LogRecord,
|
|
6
|
-
type Sink,
|
|
7
|
-
} from "@logtape/logtape";
|
|
8
|
-
import { dirname } from "node:path";
|
|
9
|
-
import process from "node:process";
|
|
10
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
-
import { mkdir } from "node:fs/promises";
|
|
12
|
-
|
|
13
|
-
export interface RecordingSink extends Sink {
|
|
14
|
-
startRecording(): void;
|
|
15
|
-
stopRecording(): void;
|
|
16
|
-
getRecords(): LogRecord[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getRecordingSink(): RecordingSink {
|
|
20
|
-
let records: LogRecord[] = [];
|
|
21
|
-
let recording = false;
|
|
22
|
-
const sink: RecordingSink = (record: LogRecord) => {
|
|
23
|
-
if (recording) records.push(record);
|
|
24
|
-
};
|
|
25
|
-
sink.startRecording = () => {
|
|
26
|
-
records = [];
|
|
27
|
-
recording = true;
|
|
28
|
-
};
|
|
29
|
-
sink.stopRecording = () => {
|
|
30
|
-
recording = false;
|
|
31
|
-
};
|
|
32
|
-
sink.getRecords = () => [...records];
|
|
33
|
-
return sink;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const recordingSink = getRecordingSink();
|
|
37
|
-
|
|
38
|
-
export const logFile = process.env["FEDIFY_LOG_FILE"];
|
|
39
|
-
if (logFile != null) {
|
|
40
|
-
await mkdir(dirname(logFile), { recursive: true });
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
await configure({
|
|
44
|
-
sinks: {
|
|
45
|
-
console: getConsoleSink(),
|
|
46
|
-
recording: recordingSink,
|
|
47
|
-
file: logFile == null ? () => undefined : getFileSink(logFile),
|
|
48
|
-
},
|
|
49
|
-
filters: {},
|
|
50
|
-
loggers: [
|
|
51
|
-
{
|
|
52
|
-
category: "fedify",
|
|
53
|
-
lowestLevel: "debug",
|
|
54
|
-
sinks: ["recording", "file"],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
category: ["logtape", "meta"],
|
|
58
|
-
lowestLevel: "warning",
|
|
59
|
-
sinks: ["console", "file"],
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
contextLocalStorage: new AsyncLocalStorage(),
|
|
63
|
-
reset: true,
|
|
64
|
-
});
|
package/src/lookup.test.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Activity, Note } from "@fedify/fedify";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import test from "node:test";
|
|
4
|
-
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
5
|
-
import { getContextLoader } from "./docloader.ts";
|
|
6
|
-
import {
|
|
7
|
-
clearTimeoutSignal,
|
|
8
|
-
createTimeoutSignal,
|
|
9
|
-
TimeoutError,
|
|
10
|
-
writeObjectToStream,
|
|
11
|
-
} from "./lookup.ts";
|
|
12
|
-
|
|
13
|
-
test("writeObjectToStream - writes Note object with default options", async () => {
|
|
14
|
-
const testDir = "./test_output_note";
|
|
15
|
-
const testFile = `${testDir}/note.txt`;
|
|
16
|
-
|
|
17
|
-
await mkdir(testDir, { recursive: true });
|
|
18
|
-
|
|
19
|
-
const note = new Note({
|
|
20
|
-
id: new URL("https://example.com/notes/1"),
|
|
21
|
-
content: "Hello, fediverse!",
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const contextLoader = await getContextLoader({});
|
|
25
|
-
await writeObjectToStream(note, testFile, undefined, contextLoader);
|
|
26
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
27
|
-
|
|
28
|
-
const content = await readFile(testFile, { encoding: "utf8" });
|
|
29
|
-
|
|
30
|
-
assert.ok(content);
|
|
31
|
-
assert.match(content, /Hello, fediverse!/);
|
|
32
|
-
assert.match(content, /id/);
|
|
33
|
-
|
|
34
|
-
await rm(testDir, { recursive: true });
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("writeObjectToStream - writes Activity object in raw JSON-LD format", async () => {
|
|
38
|
-
const testDir = "./test_output_activity";
|
|
39
|
-
const testFile = `${testDir}/raw.json`;
|
|
40
|
-
|
|
41
|
-
await mkdir(testDir, { recursive: true });
|
|
42
|
-
|
|
43
|
-
const activity = new Activity({
|
|
44
|
-
id: new URL("https://example.com/activities/1"),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const contextLoader = await getContextLoader({});
|
|
48
|
-
await writeObjectToStream(activity, testFile, "raw", contextLoader);
|
|
49
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
50
|
-
|
|
51
|
-
// Verify file exists and contains JSON-LD
|
|
52
|
-
const content = await readFile(testFile);
|
|
53
|
-
|
|
54
|
-
assert.ok(content);
|
|
55
|
-
assert.ok(content.includes("@context"));
|
|
56
|
-
assert.ok(content.includes("id"));
|
|
57
|
-
|
|
58
|
-
await rm(testDir, { recursive: true });
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("writeObjectToStream - writes object in compact JSON-LD format", async () => {
|
|
62
|
-
const testDir = "./test_output_compact";
|
|
63
|
-
const testFile = `${testDir}/compact.json`;
|
|
64
|
-
|
|
65
|
-
await mkdir(testDir, { recursive: true });
|
|
66
|
-
|
|
67
|
-
const note = new Note({
|
|
68
|
-
id: new URL("https://example.com/notes/1"),
|
|
69
|
-
content: "Test note",
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const contextLoader = await getContextLoader({});
|
|
73
|
-
await writeObjectToStream(note, testFile, "compact", contextLoader);
|
|
74
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
75
|
-
|
|
76
|
-
// Verify file exists and contains compacted JSON-LD
|
|
77
|
-
const content = await readFile(testFile);
|
|
78
|
-
assert.ok(content);
|
|
79
|
-
assert.ok(content.includes("Test note"));
|
|
80
|
-
|
|
81
|
-
await rm(testDir, { recursive: true });
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("writeObjectToStream - writes object in expanded JSON-LD format", async () => {
|
|
85
|
-
const testDir = "./test_output_expand";
|
|
86
|
-
const testFile = `${testDir}/expand.json`;
|
|
87
|
-
|
|
88
|
-
await mkdir(testDir, { recursive: true });
|
|
89
|
-
|
|
90
|
-
const note = new Note({
|
|
91
|
-
id: new URL("https://example.com/notes/1"),
|
|
92
|
-
content: "Test note for expansion",
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const contextLoader = await getContextLoader({});
|
|
96
|
-
await writeObjectToStream(note, testFile, "expand", contextLoader);
|
|
97
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
98
|
-
|
|
99
|
-
const content = await readFile(testFile);
|
|
100
|
-
assert.ok(content);
|
|
101
|
-
assert.ok(content.includes("Test note for expansion"));
|
|
102
|
-
|
|
103
|
-
await rm(testDir, { recursive: true });
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test("writeObjectToStream - writes to stdout when no output file specified", async () => {
|
|
107
|
-
const note = new Note({
|
|
108
|
-
id: new URL("https://example.com/notes/1"),
|
|
109
|
-
content: "Test stdout note",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const contextLoader = await getContextLoader({});
|
|
113
|
-
|
|
114
|
-
await writeObjectToStream(note, undefined, undefined, contextLoader);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test("writeObjectToStream - handles empty content properly", async () => {
|
|
118
|
-
const testDir = "./test_output_empty";
|
|
119
|
-
const testFile = `${testDir}/empty.txt`;
|
|
120
|
-
|
|
121
|
-
await mkdir(testDir, { recursive: true });
|
|
122
|
-
|
|
123
|
-
const note = new Note({
|
|
124
|
-
id: new URL("https://example.com/notes/1"),
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
const contextLoader = await getContextLoader({});
|
|
128
|
-
|
|
129
|
-
await writeObjectToStream(note, testFile, undefined, contextLoader);
|
|
130
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
131
|
-
|
|
132
|
-
const content = await readFile(testFile);
|
|
133
|
-
assert.ok(content);
|
|
134
|
-
assert.ok(content.includes("Note"));
|
|
135
|
-
|
|
136
|
-
await rm(testDir, { recursive: true });
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test("createTimeoutSignal - returns undefined when no timeout specified", () => {
|
|
140
|
-
const signal = createTimeoutSignal();
|
|
141
|
-
assert.strictEqual(signal, undefined);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test("createTimeoutSignal - returns undefined when timeout is null", () => {
|
|
145
|
-
const signal = createTimeoutSignal(undefined);
|
|
146
|
-
assert.strictEqual(signal, undefined);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test("createTimeoutSignal - creates AbortSignal that aborts after timeout", async () => {
|
|
150
|
-
const signal = createTimeoutSignal(0.1);
|
|
151
|
-
assert.ok(signal);
|
|
152
|
-
assert.ok(!signal.aborted);
|
|
153
|
-
|
|
154
|
-
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
155
|
-
|
|
156
|
-
assert.ok(signal.aborted);
|
|
157
|
-
assert.ok(signal.reason instanceof TimeoutError);
|
|
158
|
-
assert.equal(
|
|
159
|
-
(signal.reason as TimeoutError).message,
|
|
160
|
-
"Request timed out after 0.1 seconds",
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test("createTimeoutSignal - signal is not aborted before timeout", () => {
|
|
165
|
-
const signal = createTimeoutSignal(1); // 1 second timeout
|
|
166
|
-
assert.ok(signal);
|
|
167
|
-
assert.ok(!signal.aborted);
|
|
168
|
-
|
|
169
|
-
clearTimeoutSignal(signal);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
test("clearTimeoutSignal - cleans up timer properly", async () => {
|
|
173
|
-
const signal = createTimeoutSignal(0.05); // 50ms timeout
|
|
174
|
-
assert.ok(signal);
|
|
175
|
-
assert.ok(!signal.aborted);
|
|
176
|
-
|
|
177
|
-
clearTimeoutSignal(signal);
|
|
178
|
-
|
|
179
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
180
|
-
|
|
181
|
-
assert.ok(!signal.aborted);
|
|
182
|
-
});
|