@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/init/command.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
argument,
|
|
3
|
-
choice,
|
|
4
|
-
command,
|
|
5
|
-
constant,
|
|
6
|
-
type InferValue,
|
|
7
|
-
merge,
|
|
8
|
-
message,
|
|
9
|
-
multiple,
|
|
10
|
-
object,
|
|
11
|
-
option,
|
|
12
|
-
optional,
|
|
13
|
-
optionNames,
|
|
14
|
-
or,
|
|
15
|
-
} from "@optique/core";
|
|
16
|
-
import { path } from "@optique/run";
|
|
17
|
-
import { debugOption } from "../globals.ts";
|
|
18
|
-
import {
|
|
19
|
-
KV_STORE,
|
|
20
|
-
MESSAGE_QUEUE,
|
|
21
|
-
PACKAGE_MANAGER,
|
|
22
|
-
WEB_FRAMEWORK,
|
|
23
|
-
} from "./const.ts";
|
|
24
|
-
|
|
25
|
-
const webFramework = optional(option(
|
|
26
|
-
"-w",
|
|
27
|
-
"--web-framework",
|
|
28
|
-
choice(WEB_FRAMEWORK, { metavar: "WEB_FRAMEWORK" }),
|
|
29
|
-
{
|
|
30
|
-
description: message`The web framework to integrate Fedify with.`,
|
|
31
|
-
},
|
|
32
|
-
));
|
|
33
|
-
const packageManager = optional(option(
|
|
34
|
-
"-p",
|
|
35
|
-
"--package-manager",
|
|
36
|
-
choice(PACKAGE_MANAGER, { metavar: "PACKAGE_MANAGER" }),
|
|
37
|
-
{
|
|
38
|
-
description:
|
|
39
|
-
message`The package manager to use for installing dependencies.`,
|
|
40
|
-
},
|
|
41
|
-
));
|
|
42
|
-
const kvStore = optional(option(
|
|
43
|
-
"-k",
|
|
44
|
-
"--kv-store",
|
|
45
|
-
choice(KV_STORE, { metavar: "KV_STORE" }),
|
|
46
|
-
{
|
|
47
|
-
description:
|
|
48
|
-
message`The key-value store to use for caching and some other features.`,
|
|
49
|
-
},
|
|
50
|
-
));
|
|
51
|
-
const messageQueue = optional(option(
|
|
52
|
-
"-m",
|
|
53
|
-
"--message-queue",
|
|
54
|
-
choice(MESSAGE_QUEUE, { metavar: "MESSAGE_QUEUE" }),
|
|
55
|
-
{
|
|
56
|
-
description: message`The message queue to use for background tasks.`,
|
|
57
|
-
},
|
|
58
|
-
));
|
|
59
|
-
const testMode = option(
|
|
60
|
-
"--test-mode",
|
|
61
|
-
{
|
|
62
|
-
description: message`The test mode to use for testing purposes.`,
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
export const initCommand = command(
|
|
67
|
-
"init",
|
|
68
|
-
object("Initialization options", {
|
|
69
|
-
command: constant("init"),
|
|
70
|
-
dir: optional(argument(path({ metavar: "DIR" }), {
|
|
71
|
-
description:
|
|
72
|
-
message`The project directory to initialize. If a specified directory does not exist, it will be created.`,
|
|
73
|
-
})),
|
|
74
|
-
webFramework,
|
|
75
|
-
packageManager,
|
|
76
|
-
kvStore,
|
|
77
|
-
messageQueue,
|
|
78
|
-
dryRun: option("--dry-run", {
|
|
79
|
-
description: message`Perform a trial run with no changes made.`,
|
|
80
|
-
}),
|
|
81
|
-
debugOption,
|
|
82
|
-
testMode,
|
|
83
|
-
}),
|
|
84
|
-
{
|
|
85
|
-
brief: message`Initialize a new Fedify project directory.`,
|
|
86
|
-
description: message`Initialize a new Fedify project directory.
|
|
87
|
-
|
|
88
|
-
By default, it initializes the current directory. You can specify a different directory as an argument.
|
|
89
|
-
|
|
90
|
-
Unless you specify all options (${optionNames(["-w", "--web-framework"])}, ${
|
|
91
|
-
optionNames(["-p", "--package-manager"])
|
|
92
|
-
}, ${optionNames(["-k", "--kv-store"])}, and ${
|
|
93
|
-
optionNames(["-m", "--message-queue"])
|
|
94
|
-
}), it will prompt you to select the options interactively.`,
|
|
95
|
-
},
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
export type InitCommand = InferValue<typeof initCommand>;
|
|
99
|
-
|
|
100
|
-
const noHydRun = object({
|
|
101
|
-
noHydRun: option("--no-hyd-run", {
|
|
102
|
-
description: message`Log outputs without creating files.`,
|
|
103
|
-
}),
|
|
104
|
-
});
|
|
105
|
-
const noDryRun = object({
|
|
106
|
-
noDryRun: option("--no-dry-run", {
|
|
107
|
-
description: message`Test with files creations and installations.`,
|
|
108
|
-
}),
|
|
109
|
-
});
|
|
110
|
-
export const testInitCommand = command(
|
|
111
|
-
"test-init",
|
|
112
|
-
merge(
|
|
113
|
-
object("Initialization options", {
|
|
114
|
-
command: constant("test-init"),
|
|
115
|
-
webFramework: multiple(webFramework),
|
|
116
|
-
packageManager: multiple(packageManager),
|
|
117
|
-
kvStore: multiple(kvStore),
|
|
118
|
-
messageQueue: multiple(messageQueue),
|
|
119
|
-
debugOption,
|
|
120
|
-
}),
|
|
121
|
-
optional(or(noHydRun, noDryRun)),
|
|
122
|
-
),
|
|
123
|
-
{
|
|
124
|
-
brief: message`Test an initializing command .`,
|
|
125
|
-
description: message`Test an initializing command on temporary directories.
|
|
126
|
-
|
|
127
|
-
Unless you specify all options (${optionNames(["-w", "--web-framework"])}, ${
|
|
128
|
-
optionNames(["-p", "--package-manager"])
|
|
129
|
-
}, ${optionNames(["-k", "--kv-store"])}, and ${
|
|
130
|
-
optionNames(["-m", "--message-queue"])
|
|
131
|
-
}), it will test all combinations of the options.`,
|
|
132
|
-
},
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
export type TestInitCommand = InferValue<typeof testInitCommand>;
|
package/src/init/const.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export const PACKAGE_MANAGER = ["deno", "pnpm", "bun", "yarn", "npm"] as const;
|
|
2
|
-
export const WEB_FRAMEWORK = ["hono", "nitro", "next", "express"] as const;
|
|
3
|
-
export const MESSAGE_QUEUE = ["denokv", "redis", "postgres", "amqp"] as const;
|
|
4
|
-
export const KV_STORE = ["denokv", "redis", "postgres"] as const;
|
package/src/init/json/biome.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
|
|
3
|
-
"organizeImports": {
|
|
4
|
-
"enabled": true
|
|
5
|
-
},
|
|
6
|
-
"formatter": {
|
|
7
|
-
"enabled": true,
|
|
8
|
-
"indentStyle": "space",
|
|
9
|
-
"indentWidth": 2
|
|
10
|
-
},
|
|
11
|
-
"linter": {
|
|
12
|
-
"enabled": true,
|
|
13
|
-
"rules": {
|
|
14
|
-
"recommended": true
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/init/json/kv.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"redis": {
|
|
3
|
-
"label": "Redis",
|
|
4
|
-
"packageManagers": ["deno", "bun", "npm", "yarn", "pnpm"],
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"npm:ioredis": "^5.4.1"
|
|
7
|
-
},
|
|
8
|
-
"imports": {
|
|
9
|
-
"@fedify/redis": { "RedisKvStore": "RedisKvStore" },
|
|
10
|
-
"ioredis": { "Redis": "Redis" }
|
|
11
|
-
},
|
|
12
|
-
"object": "new RedisKvStore(new Redis(process.env.REDIS_URL))",
|
|
13
|
-
"env": {
|
|
14
|
-
"REDIS_URL": "redis://localhost:6379"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"postgres": {
|
|
18
|
-
"label": "PostgreSQL",
|
|
19
|
-
"packageManagers": ["deno", "bun", "npm", "yarn", "pnpm"],
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"npm:postgres": "^3.4.5"
|
|
22
|
-
},
|
|
23
|
-
"imports": {
|
|
24
|
-
"@fedify/postgres": { "PostgresKvStore": "PostgresKvStore" },
|
|
25
|
-
"postgres": { "default": "postgres" }
|
|
26
|
-
},
|
|
27
|
-
"object": "new PostgresKvStore(postgres(process.env.DATABASE_URL))",
|
|
28
|
-
"env": {
|
|
29
|
-
"DATABASE_URL": "postgres://postgres@localhost:5432/postgres"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"denokv": {
|
|
33
|
-
"label": "Deno KV",
|
|
34
|
-
"packageManagers": ["deno"],
|
|
35
|
-
"imports": { "@fedify/denokv": { "DenoKvStore": "DenoKvStore" } },
|
|
36
|
-
"object": "new DenoKvStore(await Deno.openKv())",
|
|
37
|
-
"denoUnstable": ["kv"]
|
|
38
|
-
}
|
|
39
|
-
}
|
package/src/init/json/mq.json
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"redis": {
|
|
3
|
-
"label": "Redis",
|
|
4
|
-
"packageManagers": [
|
|
5
|
-
"deno",
|
|
6
|
-
"bun",
|
|
7
|
-
"npm",
|
|
8
|
-
"yarn",
|
|
9
|
-
"pnpm"
|
|
10
|
-
],
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"npm:ioredis": "^5.4.1"
|
|
13
|
-
},
|
|
14
|
-
"imports": {
|
|
15
|
-
"@fedify/redis": {
|
|
16
|
-
"RedisMessageQueue": "RedisMessageQueue"
|
|
17
|
-
},
|
|
18
|
-
"ioredis": {
|
|
19
|
-
"Redis": "Redis"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"object": "new RedisMessageQueue(() => new Redis(process.env.REDIS_URL))",
|
|
23
|
-
"env": {
|
|
24
|
-
"REDIS_URL": "redis://localhost:6379"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"postgres": {
|
|
28
|
-
"label": "PostgreSQL",
|
|
29
|
-
"packageManagers": [
|
|
30
|
-
"deno",
|
|
31
|
-
"bun",
|
|
32
|
-
"npm",
|
|
33
|
-
"yarn",
|
|
34
|
-
"pnpm"
|
|
35
|
-
],
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"npm:postgres": "^3.4.5"
|
|
38
|
-
},
|
|
39
|
-
"imports": {
|
|
40
|
-
"@fedify/postgres": {
|
|
41
|
-
"PostgresMessageQueue": "PostgresMessageQueue"
|
|
42
|
-
},
|
|
43
|
-
"postgres": {
|
|
44
|
-
"default": "postgres"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"object": "new PostgresMessageQueue(postgres(process.env.DATABASE_URL))",
|
|
48
|
-
"env": {
|
|
49
|
-
"DATABASE_URL": "postgres://postgres@localhost:5432/postgres"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"amqp": {
|
|
53
|
-
"label": "AMQP (e.g., RabbitMQ)",
|
|
54
|
-
"packageManagers": [
|
|
55
|
-
"deno",
|
|
56
|
-
"bun",
|
|
57
|
-
"npm",
|
|
58
|
-
"yarn",
|
|
59
|
-
"pnpm"
|
|
60
|
-
],
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"npm:amqplib": "^0.10.4"
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"npm:@types/amqplib": "^0.10.5"
|
|
66
|
-
},
|
|
67
|
-
"imports": {
|
|
68
|
-
"@fedify/amqp": {
|
|
69
|
-
"AmqpMessageQueue": "AmqpMessageQueue"
|
|
70
|
-
},
|
|
71
|
-
"amqplib": {
|
|
72
|
-
"connect": "connect"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"object": "new AmqpMessageQueue(await connect(process.env.AMQP_URL))",
|
|
76
|
-
"env": {
|
|
77
|
-
"AMQP_URL": "amqp://localhost"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
"denokv": {
|
|
81
|
-
"label": "Deno KV",
|
|
82
|
-
"packageManagers": [
|
|
83
|
-
"deno"
|
|
84
|
-
],
|
|
85
|
-
"imports": {
|
|
86
|
-
"@fedify/denokv": {
|
|
87
|
-
"DenoKvMessageQueue": "DenoKvMessageQueue"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
"object": "new DenoKvMessageQueue(await Deno.openKv())",
|
|
91
|
-
"denoUnstable": [
|
|
92
|
-
"kv"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
}
|
package/src/init/json/pm.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"deno": {
|
|
3
|
-
"label": "deno",
|
|
4
|
-
"checkCommand": [
|
|
5
|
-
"deno",
|
|
6
|
-
"--version"
|
|
7
|
-
],
|
|
8
|
-
"outputPattern": "^deno\\s+\\d+\\.\\d+\\.\\d+\\b",
|
|
9
|
-
"installUrl": "https://docs.deno.com/runtime/getting_started/installation"
|
|
10
|
-
},
|
|
11
|
-
"bun": {
|
|
12
|
-
"label": "bun",
|
|
13
|
-
"checkCommand": [
|
|
14
|
-
"bun",
|
|
15
|
-
"--version"
|
|
16
|
-
],
|
|
17
|
-
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
18
|
-
"installUrl": "https://bun.sh/docs/installation"
|
|
19
|
-
},
|
|
20
|
-
"npm": {
|
|
21
|
-
"label": "npm",
|
|
22
|
-
"checkCommand": [
|
|
23
|
-
"npm",
|
|
24
|
-
"--version"
|
|
25
|
-
],
|
|
26
|
-
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
27
|
-
"installUrl": "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"
|
|
28
|
-
},
|
|
29
|
-
"yarn": {
|
|
30
|
-
"label": "Yarn",
|
|
31
|
-
"checkCommand": [
|
|
32
|
-
"yarn",
|
|
33
|
-
"--version"
|
|
34
|
-
],
|
|
35
|
-
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
36
|
-
"installUrl": "https://classic.yarnpkg.com/en/docs/install/#windows-stable"
|
|
37
|
-
},
|
|
38
|
-
"pnpm": {
|
|
39
|
-
"label": "pnpm",
|
|
40
|
-
"checkCommand": [
|
|
41
|
-
"pnpm",
|
|
42
|
-
"--version"
|
|
43
|
-
],
|
|
44
|
-
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
45
|
-
"installUrl": "https://pnpm.io/installation"
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/init/json/rt.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"deno": {
|
|
3
|
-
"label": "Deno",
|
|
4
|
-
"checkCommand": [
|
|
5
|
-
"deno",
|
|
6
|
-
"--version"
|
|
7
|
-
],
|
|
8
|
-
"outputPattern": "^deno\\s+\\d+\\.\\d+\\.\\d+\\b"
|
|
9
|
-
},
|
|
10
|
-
"bun": {
|
|
11
|
-
"label": "Bun",
|
|
12
|
-
"checkCommand": [
|
|
13
|
-
"bun",
|
|
14
|
-
"--version"
|
|
15
|
-
],
|
|
16
|
-
"outputPattern": "^\\d+\\.\\d+\\.\\d+$"
|
|
17
|
-
},
|
|
18
|
-
"pnpm": {
|
|
19
|
-
"label": "Node.js",
|
|
20
|
-
"checkCommand": [
|
|
21
|
-
"node",
|
|
22
|
-
"--version"
|
|
23
|
-
],
|
|
24
|
-
"outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
|
|
25
|
-
},
|
|
26
|
-
"yarn": {
|
|
27
|
-
"label": "Node.js",
|
|
28
|
-
"checkCommand": [
|
|
29
|
-
"node",
|
|
30
|
-
"--version"
|
|
31
|
-
],
|
|
32
|
-
"outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
|
|
33
|
-
},
|
|
34
|
-
"npm": {
|
|
35
|
-
"label": "Node.js",
|
|
36
|
-
"checkCommand": [
|
|
37
|
-
"node",
|
|
38
|
-
"--version"
|
|
39
|
-
],
|
|
40
|
-
"outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"deno.enable": true,
|
|
3
|
-
"deno.unstable": true,
|
|
4
|
-
"editor.detectIndentation": false,
|
|
5
|
-
"editor.indentSize": 2,
|
|
6
|
-
"editor.insertSpaces": true,
|
|
7
|
-
"[javascript]": {
|
|
8
|
-
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
9
|
-
"editor.formatOnSave": true,
|
|
10
|
-
"editor.codeActionsOnSave": {
|
|
11
|
-
"source.sortImports": "always"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"[javascriptreact]": {
|
|
15
|
-
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
16
|
-
"editor.formatOnSave": true,
|
|
17
|
-
"editor.codeActionsOnSave": {
|
|
18
|
-
"source.sortImports": "always"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"[json]": {
|
|
22
|
-
"editor.defaultFormatter": "vscode.json-language-features",
|
|
23
|
-
"editor.formatOnSave": true
|
|
24
|
-
},
|
|
25
|
-
"[jsonc]": {
|
|
26
|
-
"editor.defaultFormatter": "vscode.json-language-features",
|
|
27
|
-
"editor.formatOnSave": true
|
|
28
|
-
},
|
|
29
|
-
"[typescript]": {
|
|
30
|
-
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
31
|
-
"editor.formatOnSave": true,
|
|
32
|
-
"editor.codeActionsOnSave": {
|
|
33
|
-
"source.sortImports": "always"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"[typescriptreact]": {
|
|
37
|
-
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
38
|
-
"editor.formatOnSave": true,
|
|
39
|
-
"editor.codeActionsOnSave": {
|
|
40
|
-
"source.sortImports": "always"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"editor.detectIndentation": false,
|
|
3
|
-
"editor.indentSize": 2,
|
|
4
|
-
"editor.insertSpaces": true,
|
|
5
|
-
"[javascript]": {
|
|
6
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
7
|
-
"editor.formatOnSave": true,
|
|
8
|
-
"editor.codeActionsOnSave": {
|
|
9
|
-
"source.organizeImports.biome": "always"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"[javascriptreact]": {
|
|
13
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
14
|
-
"editor.formatOnSave": true,
|
|
15
|
-
"editor.codeActionsOnSave": {
|
|
16
|
-
"source.organizeImports.biome": "always"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"[json]": {
|
|
20
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
21
|
-
"editor.formatOnSave": true
|
|
22
|
-
},
|
|
23
|
-
"[jsonc]": {
|
|
24
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
25
|
-
"editor.formatOnSave": true
|
|
26
|
-
},
|
|
27
|
-
"[typescript]": {
|
|
28
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
29
|
-
"editor.formatOnSave": true,
|
|
30
|
-
"editor.codeActionsOnSave": {
|
|
31
|
-
"source.organizeImports.biome": "always"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"[typescriptreact]": {
|
|
35
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
36
|
-
"editor.formatOnSave": true,
|
|
37
|
-
"editor.codeActionsOnSave": {
|
|
38
|
-
"source.organizeImports.biome": "always"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/init/lib.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
entries,
|
|
3
|
-
evolve,
|
|
4
|
-
fromEntries,
|
|
5
|
-
isObject,
|
|
6
|
-
map,
|
|
7
|
-
negate,
|
|
8
|
-
pipe,
|
|
9
|
-
throwIf,
|
|
10
|
-
when,
|
|
11
|
-
} from "@fxts/core";
|
|
12
|
-
import { getLogger } from "@logtape/logtape";
|
|
13
|
-
import type { Message } from "@optique/core";
|
|
14
|
-
import { commandLine, message } from "@optique/core/message";
|
|
15
|
-
import { toMerged } from "es-toolkit";
|
|
16
|
-
import { readFileSync } from "node:fs";
|
|
17
|
-
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
18
|
-
import { dirname, join as joinPath } from "node:path";
|
|
19
|
-
import process from "node:process";
|
|
20
|
-
import metadata from "../../deno.json" with { type: "json" };
|
|
21
|
-
import { isNotFoundError, runSubCommand } from "../utils.ts";
|
|
22
|
-
import kv from "./json/kv.json" with { type: "json" };
|
|
23
|
-
import mq from "./json/mq.json" with { type: "json" };
|
|
24
|
-
import pm from "./json/pm.json" with { type: "json" };
|
|
25
|
-
import rt from "./json/rt.json" with { type: "json" };
|
|
26
|
-
import type {
|
|
27
|
-
KvStores,
|
|
28
|
-
MessageQueues,
|
|
29
|
-
PackageManager,
|
|
30
|
-
PackageManagers,
|
|
31
|
-
Runtimes,
|
|
32
|
-
} from "./types.ts";
|
|
33
|
-
import webFrameworks from "./webframeworks.ts";
|
|
34
|
-
|
|
35
|
-
export const PACKAGE_VERSION = metadata.version;
|
|
36
|
-
export const logger = getLogger(["fedify", "cli", "init"]);
|
|
37
|
-
|
|
38
|
-
const addFedifyDeps = <T extends object>(json: T): T =>
|
|
39
|
-
Object.fromEntries(
|
|
40
|
-
Object.entries(json).map(([key, value]) => [
|
|
41
|
-
key,
|
|
42
|
-
toMerged(value, {
|
|
43
|
-
dependencies: {
|
|
44
|
-
[`@fedify/${key}`]: PACKAGE_VERSION,
|
|
45
|
-
},
|
|
46
|
-
}),
|
|
47
|
-
]),
|
|
48
|
-
) as T;
|
|
49
|
-
export const kvStores = addFedifyDeps(kv as KvStores);
|
|
50
|
-
export const messageQueues = addFedifyDeps(mq as MessageQueues);
|
|
51
|
-
const toRegExp = (str: string): RegExp => new RegExp(str);
|
|
52
|
-
const convertPattern = <K extends string, T extends { outputPattern: string }>(
|
|
53
|
-
obj: Record<K, T>,
|
|
54
|
-
): Record<K, Omit<T, "outputPattern"> & { outputPattern: RegExp }> =>
|
|
55
|
-
pipe(
|
|
56
|
-
obj,
|
|
57
|
-
entries as (obj: Record<K, T>) => Generator<[K, T]>,
|
|
58
|
-
map(([key, value]: [K, T]) =>
|
|
59
|
-
[key, evolve({ outputPattern: toRegExp })(value)] as const
|
|
60
|
-
),
|
|
61
|
-
fromEntries,
|
|
62
|
-
) as Record<K, Omit<T, "outputPattern"> & { outputPattern: RegExp }>;
|
|
63
|
-
const packageManagers = convertPattern(pm) as PackageManagers;
|
|
64
|
-
const runtimes = convertPattern(rt) as Runtimes;
|
|
65
|
-
|
|
66
|
-
export const getLabel = (name: string) =>
|
|
67
|
-
pipe(
|
|
68
|
-
name,
|
|
69
|
-
whenHasLabel(webFrameworks),
|
|
70
|
-
whenHasLabel(packageManagers),
|
|
71
|
-
whenHasLabel(messageQueues),
|
|
72
|
-
whenHasLabel(kvStores),
|
|
73
|
-
whenHasLabel(runtimes),
|
|
74
|
-
);
|
|
75
|
-
const whenHasLabel = <T extends Record<string, { label: string }>>(desc: T) =>
|
|
76
|
-
when((name: string) => name in desc, (name) => desc[name as keyof T].label);
|
|
77
|
-
|
|
78
|
-
export const getInstallUrl = (pm: PackageManager) =>
|
|
79
|
-
packageManagers[pm].installUrl;
|
|
80
|
-
|
|
81
|
-
export async function isPackageManagerAvailable(
|
|
82
|
-
pm: PackageManager,
|
|
83
|
-
): Promise<boolean> {
|
|
84
|
-
if (await isCommandAvailable(packageManagers[pm])) return true;
|
|
85
|
-
if (process.platform !== "win32") return false;
|
|
86
|
-
const cmd: [string, ...string[]] = [
|
|
87
|
-
packageManagers[pm].checkCommand[0] + ".cmd",
|
|
88
|
-
...packageManagers[pm].checkCommand.slice(1),
|
|
89
|
-
];
|
|
90
|
-
if (
|
|
91
|
-
await isCommandAvailable({
|
|
92
|
-
...packageManagers[pm],
|
|
93
|
-
checkCommand: cmd,
|
|
94
|
-
})
|
|
95
|
-
) return true;
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const readTemplate: (templatePath: string) => string = (
|
|
100
|
-
templatePath,
|
|
101
|
-
) =>
|
|
102
|
-
readFileSync(
|
|
103
|
-
joinPath(
|
|
104
|
-
import.meta.dirname!,
|
|
105
|
-
"templates",
|
|
106
|
-
...(templatePath + ".tpl").split("/"),
|
|
107
|
-
),
|
|
108
|
-
"utf8",
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
export const getInstruction: (
|
|
112
|
-
packageManager: PackageManager,
|
|
113
|
-
port: number,
|
|
114
|
-
) => Message = (pm, port) =>
|
|
115
|
-
message`
|
|
116
|
-
To start the server, run the following command:
|
|
117
|
-
|
|
118
|
-
${commandLine(getDevCommand(pm))}
|
|
119
|
-
|
|
120
|
-
Then, try look up an actor from your server:
|
|
121
|
-
|
|
122
|
-
${commandLine(`fedify lookup http://localhost:${port}/users/john`)}
|
|
123
|
-
|
|
124
|
-
`;
|
|
125
|
-
|
|
126
|
-
export const getDevCommand = (pm: PackageManager) =>
|
|
127
|
-
pm === "deno" ? "deno task dev" : pm === "bun" ? "bun dev" : `${pm} run dev`;
|
|
128
|
-
|
|
129
|
-
async function isCommandAvailable(
|
|
130
|
-
{ checkCommand, outputPattern }: {
|
|
131
|
-
checkCommand: [string, ...string[]];
|
|
132
|
-
outputPattern: RegExp;
|
|
133
|
-
},
|
|
134
|
-
): Promise<boolean> {
|
|
135
|
-
try {
|
|
136
|
-
const { stdout } = await runSubCommand(checkCommand, {
|
|
137
|
-
stdio: [null, "pipe", null],
|
|
138
|
-
});
|
|
139
|
-
logger.debug(
|
|
140
|
-
"The stdout of the command {command} is: {stdout}",
|
|
141
|
-
{ command: checkCommand, stdout },
|
|
142
|
-
);
|
|
143
|
-
return outputPattern.exec(stdout.trim()) ? true : false;
|
|
144
|
-
} catch (error) {
|
|
145
|
-
if (isNotFoundError(error)) return false;
|
|
146
|
-
logger.debug(
|
|
147
|
-
"The command {command} failed with the error: {error}",
|
|
148
|
-
{ command: checkCommand, error },
|
|
149
|
-
);
|
|
150
|
-
throw error;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export async function createFile(path: string, content: string): Promise<void> {
|
|
155
|
-
await mkdir(dirname(path), { recursive: true });
|
|
156
|
-
await writeFile(path, content);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const isNotExistsError = (e: unknown) =>
|
|
160
|
-
isObject(e) && "code" in e && e.code === "ENOENT";
|
|
161
|
-
|
|
162
|
-
export const throwUnlessNotExists = throwIf(negate(isNotExistsError));
|
|
163
|
-
|
|
164
|
-
export const isDirectoryEmpty = async (
|
|
165
|
-
path: string,
|
|
166
|
-
): Promise<boolean> => {
|
|
167
|
-
try {
|
|
168
|
-
const files = await readdir(path);
|
|
169
|
-
return files.length === 0;
|
|
170
|
-
} catch (e) {
|
|
171
|
-
throwUnlessNotExists(e);
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Converts a package manager to its corresponding runtime.
|
|
178
|
-
* @param pm - The package manager (deno, bun, npm, yarn, pnpm)
|
|
179
|
-
* @returns The runtime name (deno, bun, or node)
|
|
180
|
-
*/
|
|
181
|
-
export const packageManagerToRuntime = (
|
|
182
|
-
pm: PackageManager,
|
|
183
|
-
): "deno" | "bun" | "node" =>
|
|
184
|
-
pm === "deno" ? "deno" : pm === "bun" ? "bun" : "node";
|
|
185
|
-
|
|
186
|
-
export const getNextInitCommand = (
|
|
187
|
-
pm: PackageManager,
|
|
188
|
-
): string[] => [...createNextAppCommand(pm), ".", "--yes"];
|
|
189
|
-
|
|
190
|
-
const createNextAppCommand = (pm: PackageManager): string[] =>
|
|
191
|
-
pm === "deno"
|
|
192
|
-
? ["deno", "-Ar", "npm:create-next-app@latest"]
|
|
193
|
-
: pm === "bun"
|
|
194
|
-
? ["bun", "create", "next-app"]
|
|
195
|
-
: pm === "npm"
|
|
196
|
-
? ["npx", "create-next-app"]
|
|
197
|
-
: [pm, "dlx", "create-next-app"];
|
|
198
|
-
|
|
199
|
-
export const getNitroInitCommand = (
|
|
200
|
-
pm: PackageManager,
|
|
201
|
-
): string[] => [
|
|
202
|
-
...createNitroAppCommand(pm),
|
|
203
|
-
pm === "deno" ? "npm:giget@latest" : "giget@latest",
|
|
204
|
-
"nitro",
|
|
205
|
-
".",
|
|
206
|
-
"&&",
|
|
207
|
-
"rm",
|
|
208
|
-
"nitro.config.ts", // Remove default nitro config file
|
|
209
|
-
// This file will be created from template
|
|
210
|
-
];
|
|
211
|
-
|
|
212
|
-
const createNitroAppCommand = (pm: PackageManager): string[] =>
|
|
213
|
-
pm === "deno"
|
|
214
|
-
? ["deno", "run", "-A"]
|
|
215
|
-
: pm === "bun"
|
|
216
|
-
? ["bunx"]
|
|
217
|
-
: pm === "npm"
|
|
218
|
-
? ["npx"]
|
|
219
|
-
: [pm, "dlx"];
|
|
220
|
-
|
|
221
|
-
export const isTest: <
|
|
222
|
-
T extends { testMode: boolean },
|
|
223
|
-
>({ testMode }: T) => boolean = ({ testMode }) => testMode;
|
package/src/init/mod.ts
DELETED