@fedify/cli 1.8.12 → 2.0.0-dev.1761
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/deno.json +71 -0
- package/dist/cache.js +17 -0
- package/dist/deno.js +71 -0
- package/dist/docloader.js +52 -0
- package/dist/globals.js +49 -0
- package/dist/imagerenderer.js +105 -0
- package/dist/inbox/rendercode.js +57 -0
- package/dist/inbox/view.js +508 -0
- package/dist/inbox.js +315 -0
- package/dist/init/action/configs.js +81 -0
- package/dist/init/action/deps.js +52 -0
- package/dist/init/action/dir.js +16 -0
- package/dist/init/action/env.js +13 -0
- package/dist/init/action/install.js +22 -0
- package/dist/init/action/mod.js +39 -0
- package/dist/init/action/notice.js +62 -0
- package/dist/init/action/patch.js +141 -0
- package/dist/init/action/precommand.js +23 -0
- package/dist/init/action/recommend.js +24 -0
- package/dist/init/action/set.js +31 -0
- package/dist/init/action/templates.js +57 -0
- package/dist/init/action/utils.js +50 -0
- package/dist/init/ask/dir.js +82 -0
- package/dist/init/ask/kv.js +33 -0
- package/dist/init/ask/mod.js +16 -0
- package/dist/init/ask/mq.js +33 -0
- package/dist/init/ask/pm.js +49 -0
- package/dist/init/ask/wf.js +29 -0
- package/dist/init/command.js +25 -0
- package/dist/init/const.js +31 -0
- package/dist/init/json/biome.js +24 -0
- package/dist/init/json/kv.js +53 -0
- package/dist/init/json/mq.js +72 -0
- package/dist/init/json/pm.js +44 -0
- package/dist/init/json/rt.js +39 -0
- package/dist/init/json/vscode-settings-for-deno.js +53 -0
- package/dist/init/json/vscode-settings.js +49 -0
- package/dist/init/lib.js +129 -0
- package/dist/init/mod.js +5 -0
- package/dist/init/webframeworks.js +133 -0
- package/dist/kv.bun.js +17 -0
- package/dist/kv.node.js +17 -0
- package/dist/log.js +52 -0
- package/dist/lookup.js +287 -0
- package/dist/mod.js +34 -0
- package/dist/nodeinfo.js +261 -0
- package/dist/table.js +24 -0
- package/dist/tempserver.js +71 -0
- package/dist/tunnel.js +21 -0
- package/dist/utils.js +67 -0
- package/dist/webfinger/action.js +44 -0
- package/dist/webfinger/command.js +20 -0
- package/dist/webfinger/error.js +47 -0
- package/dist/webfinger/lib.js +45 -0
- package/dist/webfinger/mod.js +5 -0
- package/package.json +64 -24
- package/scripts/pack.ts +64 -0
- package/src/cache.ts +17 -0
- package/src/docloader.ts +67 -0
- package/src/globals.ts +43 -0
- package/src/imagerenderer.ts +149 -0
- package/src/inbox/entry.ts +10 -0
- package/src/inbox/rendercode.ts +68 -0
- package/src/inbox/view.tsx +598 -0
- package/src/inbox.tsx +535 -0
- package/src/init/action/configs.ts +88 -0
- package/src/init/action/deps.ts +93 -0
- package/src/init/action/dir.ts +11 -0
- package/src/init/action/env.ts +14 -0
- package/src/init/action/install.ts +59 -0
- package/src/init/action/mod.ts +66 -0
- package/src/init/action/notice.ts +101 -0
- package/src/init/action/patch.ts +212 -0
- package/src/init/action/precommand.ts +22 -0
- package/src/init/action/recommend.ts +38 -0
- package/src/init/action/set.ts +78 -0
- package/src/init/action/templates.ts +95 -0
- package/src/init/action/utils.ts +64 -0
- package/src/init/ask/dir.ts +98 -0
- package/src/init/ask/kv.ts +39 -0
- package/src/init/ask/mod.ts +23 -0
- package/src/init/ask/mq.ts +37 -0
- package/src/init/ask/pm.ts +58 -0
- package/src/init/ask/wf.ts +27 -0
- package/src/init/command.ts +64 -0
- package/src/init/const.ts +4 -0
- package/src/init/json/biome.json +17 -0
- package/src/init/json/kv.json +39 -0
- package/src/init/json/mq.json +95 -0
- package/src/init/json/pm.json +47 -0
- package/src/init/json/rt.json +42 -0
- package/src/init/json/vscode-settings-for-deno.json +43 -0
- package/src/init/json/vscode-settings.json +41 -0
- package/src/init/lib.ts +220 -0
- package/src/init/mod.ts +2 -0
- package/src/init/templates/defaults/federation.ts.tpl +23 -0
- package/src/init/templates/defaults/logging.ts.tpl +23 -0
- package/src/init/templates/express/app.ts.tpl +16 -0
- package/src/init/templates/express/index.ts.tpl +6 -0
- package/src/init/templates/hono/app.tsx.tpl +14 -0
- package/src/init/templates/hono/index/bun.ts.tpl +10 -0
- package/src/init/templates/hono/index/deno.ts.tpl +13 -0
- package/src/init/templates/hono/index/node.ts.tpl +14 -0
- package/src/init/templates/next/middleware.ts.tpl +45 -0
- package/src/init/templates/nitro/nitro.config.ts.tpl +5 -0
- package/src/init/templates/nitro/server/error.ts.tpl +3 -0
- package/src/init/templates/nitro/server/middleware/federation.ts.tpl +8 -0
- package/src/init/types.ts +88 -0
- package/src/init/webframeworks.ts +151 -0
- package/src/kv.bun.ts +12 -0
- package/src/kv.node.ts +11 -0
- package/src/log.ts +64 -0
- package/src/lookup.test.ts +182 -0
- package/src/lookup.ts +558 -0
- package/src/mod.ts +45 -0
- package/src/nodeinfo.test.ts +229 -0
- package/src/nodeinfo.ts +447 -0
- package/src/table.ts +17 -0
- package/src/tempserver.ts +87 -0
- package/src/tunnel.ts +32 -0
- package/src/utils.ts +136 -0
- package/src/webfinger/action.ts +50 -0
- package/src/webfinger/command.ts +59 -0
- package/src/webfinger/error.ts +47 -0
- package/src/webfinger/lib.ts +37 -0
- package/src/webfinger/mod.test.ts +79 -0
- package/src/webfinger/mod.ts +2 -0
- package/tsdown.config.ts +24 -0
- package/src/install.mjs +0 -189
- package/src/run.mjs +0 -22
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
//#region src/init/json/kv.json
|
|
5
|
+
var redis = {
|
|
6
|
+
"label": "Redis",
|
|
7
|
+
"packageManagers": [
|
|
8
|
+
"deno",
|
|
9
|
+
"bun",
|
|
10
|
+
"npm",
|
|
11
|
+
"yarn",
|
|
12
|
+
"pnpm"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": { "npm:ioredis": "^5.4.1" },
|
|
15
|
+
"imports": {
|
|
16
|
+
"@fedify/redis": { "RedisKvStore": "RedisKvStore" },
|
|
17
|
+
"ioredis": { "Redis": "Redis" }
|
|
18
|
+
},
|
|
19
|
+
"object": "new RedisKvStore(new Redis(process.env.REDIS_URL))",
|
|
20
|
+
"env": { "REDIS_URL": "redis://localhost:6379" }
|
|
21
|
+
};
|
|
22
|
+
var postgres = {
|
|
23
|
+
"label": "PostgreSQL",
|
|
24
|
+
"packageManagers": [
|
|
25
|
+
"deno",
|
|
26
|
+
"bun",
|
|
27
|
+
"npm",
|
|
28
|
+
"yarn",
|
|
29
|
+
"pnpm"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": { "npm:postgres": "^3.4.5" },
|
|
32
|
+
"imports": {
|
|
33
|
+
"@fedify/postgres": { "PostgresKvStore": "PostgresKvStore" },
|
|
34
|
+
"postgres": { "default": "postgres" }
|
|
35
|
+
},
|
|
36
|
+
"object": "new PostgresKvStore(postgres(process.env.DATABASE_URL))",
|
|
37
|
+
"env": { "DATABASE_URL": "postgres://postgres@localhost:5432/postgres" }
|
|
38
|
+
};
|
|
39
|
+
var denokv = {
|
|
40
|
+
"label": "Deno KV",
|
|
41
|
+
"packageManagers": ["deno"],
|
|
42
|
+
"imports": { "@fedify/denokv": { "DenoKvStore": "DenoKvStore" } },
|
|
43
|
+
"object": "new DenoKvStore(await Deno.openKv())",
|
|
44
|
+
"denoUnstable": ["kv"]
|
|
45
|
+
};
|
|
46
|
+
var kv_default = {
|
|
47
|
+
redis,
|
|
48
|
+
postgres,
|
|
49
|
+
denokv
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { kv_default as default };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
//#region src/init/json/mq.json
|
|
5
|
+
var redis = {
|
|
6
|
+
"label": "Redis",
|
|
7
|
+
"packageManagers": [
|
|
8
|
+
"deno",
|
|
9
|
+
"bun",
|
|
10
|
+
"npm",
|
|
11
|
+
"yarn",
|
|
12
|
+
"pnpm"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": { "npm:ioredis": "^5.4.1" },
|
|
15
|
+
"imports": {
|
|
16
|
+
"@fedify/redis": { "RedisMessageQueue": "RedisMessageQueue" },
|
|
17
|
+
"ioredis": { "Redis": "Redis" }
|
|
18
|
+
},
|
|
19
|
+
"object": "new RedisMessageQueue(() => new Redis(process.env.REDIS_URL))",
|
|
20
|
+
"env": { "REDIS_URL": "redis://localhost:6379" }
|
|
21
|
+
};
|
|
22
|
+
var postgres = {
|
|
23
|
+
"label": "PostgreSQL",
|
|
24
|
+
"packageManagers": [
|
|
25
|
+
"deno",
|
|
26
|
+
"bun",
|
|
27
|
+
"npm",
|
|
28
|
+
"yarn",
|
|
29
|
+
"pnpm"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": { "npm:postgres": "^3.4.5" },
|
|
32
|
+
"imports": {
|
|
33
|
+
"@fedify/postgres": { "PostgresMessageQueue": "PostgresMessageQueue" },
|
|
34
|
+
"postgres": { "default": "postgres" }
|
|
35
|
+
},
|
|
36
|
+
"object": "new PostgresMessageQueue(postgres(process.env.DATABASE_URL))",
|
|
37
|
+
"env": { "DATABASE_URL": "postgres://postgres@localhost:5432/postgres" }
|
|
38
|
+
};
|
|
39
|
+
var amqp = {
|
|
40
|
+
"label": "AMQP (e.g., RabbitMQ)",
|
|
41
|
+
"packageManagers": [
|
|
42
|
+
"deno",
|
|
43
|
+
"bun",
|
|
44
|
+
"npm",
|
|
45
|
+
"yarn",
|
|
46
|
+
"pnpm"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": { "npm:amqplib": "^0.10.4" },
|
|
49
|
+
"devDependencies": { "npm:@types/amqplib": "^0.10.5" },
|
|
50
|
+
"imports": {
|
|
51
|
+
"@fedify/amqp": { "AmqpMessageQueue": "AmqpMessageQueue" },
|
|
52
|
+
"amqplib": { "connect": "connect" }
|
|
53
|
+
},
|
|
54
|
+
"object": "new AmqpMessageQueue(await connect(process.env.AMQP_URL))",
|
|
55
|
+
"env": { "AMQP_URL": "amqp://localhost" }
|
|
56
|
+
};
|
|
57
|
+
var denokv = {
|
|
58
|
+
"label": "Deno KV",
|
|
59
|
+
"packageManagers": ["deno"],
|
|
60
|
+
"imports": { "@fedify/denokv": { "DenoKvMessageQueue": "DenoKvMessageQueue" } },
|
|
61
|
+
"object": "new DenoKvMessageQueue(await Deno.openKv())",
|
|
62
|
+
"denoUnstable": ["kv"]
|
|
63
|
+
};
|
|
64
|
+
var mq_default = {
|
|
65
|
+
redis,
|
|
66
|
+
postgres,
|
|
67
|
+
amqp,
|
|
68
|
+
denokv
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { mq_default as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
//#region src/init/json/pm.json
|
|
5
|
+
var deno = {
|
|
6
|
+
"label": "deno",
|
|
7
|
+
"checkCommand": ["deno", "--version"],
|
|
8
|
+
"outputPattern": "^deno\\s+\\d+\\.\\d+\\.\\d+\\b",
|
|
9
|
+
"installUrl": "https://docs.deno.com/runtime/getting_started/installation"
|
|
10
|
+
};
|
|
11
|
+
var bun = {
|
|
12
|
+
"label": "bun",
|
|
13
|
+
"checkCommand": ["bun", "--version"],
|
|
14
|
+
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
15
|
+
"installUrl": "https://bun.sh/docs/installation"
|
|
16
|
+
};
|
|
17
|
+
var npm = {
|
|
18
|
+
"label": "npm",
|
|
19
|
+
"checkCommand": ["npm", "--version"],
|
|
20
|
+
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
21
|
+
"installUrl": "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"
|
|
22
|
+
};
|
|
23
|
+
var yarn = {
|
|
24
|
+
"label": "Yarn",
|
|
25
|
+
"checkCommand": ["yarn", "--version"],
|
|
26
|
+
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
27
|
+
"installUrl": "https://classic.yarnpkg.com/en/docs/install/#windows-stable"
|
|
28
|
+
};
|
|
29
|
+
var pnpm = {
|
|
30
|
+
"label": "pnpm",
|
|
31
|
+
"checkCommand": ["pnpm", "--version"],
|
|
32
|
+
"outputPattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
33
|
+
"installUrl": "https://pnpm.io/installation"
|
|
34
|
+
};
|
|
35
|
+
var pm_default = {
|
|
36
|
+
deno,
|
|
37
|
+
bun,
|
|
38
|
+
npm,
|
|
39
|
+
yarn,
|
|
40
|
+
pnpm
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { pm_default as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
//#region src/init/json/rt.json
|
|
5
|
+
var deno = {
|
|
6
|
+
"label": "Deno",
|
|
7
|
+
"checkCommand": ["deno", "--version"],
|
|
8
|
+
"outputPattern": "^deno\\s+\\d+\\.\\d+\\.\\d+\\b"
|
|
9
|
+
};
|
|
10
|
+
var bun = {
|
|
11
|
+
"label": "Bun",
|
|
12
|
+
"checkCommand": ["bun", "--version"],
|
|
13
|
+
"outputPattern": "^\\d+\\.\\d+\\.\\d+$"
|
|
14
|
+
};
|
|
15
|
+
var pnpm = {
|
|
16
|
+
"label": "Node.js",
|
|
17
|
+
"checkCommand": ["node", "--version"],
|
|
18
|
+
"outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
|
|
19
|
+
};
|
|
20
|
+
var yarn = {
|
|
21
|
+
"label": "Node.js",
|
|
22
|
+
"checkCommand": ["node", "--version"],
|
|
23
|
+
"outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
|
|
24
|
+
};
|
|
25
|
+
var npm = {
|
|
26
|
+
"label": "Node.js",
|
|
27
|
+
"checkCommand": ["node", "--version"],
|
|
28
|
+
"outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
|
|
29
|
+
};
|
|
30
|
+
var rt_default = {
|
|
31
|
+
deno,
|
|
32
|
+
bun,
|
|
33
|
+
pnpm,
|
|
34
|
+
yarn,
|
|
35
|
+
npm
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { rt_default as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
//#region src/init/json/vscode-settings-for-deno.json
|
|
5
|
+
var deno_enable = true;
|
|
6
|
+
var deno_unstable = true;
|
|
7
|
+
var editor_detectIndentation = false;
|
|
8
|
+
var editor_indentSize = 2;
|
|
9
|
+
var editor_insertSpaces = true;
|
|
10
|
+
var __javascript_ = {
|
|
11
|
+
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
12
|
+
"editor.formatOnSave": true,
|
|
13
|
+
"editor.codeActionsOnSave": { "source.sortImports": "always" }
|
|
14
|
+
};
|
|
15
|
+
var __javascriptreact_ = {
|
|
16
|
+
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
17
|
+
"editor.formatOnSave": true,
|
|
18
|
+
"editor.codeActionsOnSave": { "source.sortImports": "always" }
|
|
19
|
+
};
|
|
20
|
+
var __json_ = {
|
|
21
|
+
"editor.defaultFormatter": "vscode.json-language-features",
|
|
22
|
+
"editor.formatOnSave": true
|
|
23
|
+
};
|
|
24
|
+
var __jsonc_ = {
|
|
25
|
+
"editor.defaultFormatter": "vscode.json-language-features",
|
|
26
|
+
"editor.formatOnSave": true
|
|
27
|
+
};
|
|
28
|
+
var __typescript_ = {
|
|
29
|
+
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
30
|
+
"editor.formatOnSave": true,
|
|
31
|
+
"editor.codeActionsOnSave": { "source.sortImports": "always" }
|
|
32
|
+
};
|
|
33
|
+
var __typescriptreact_ = {
|
|
34
|
+
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
35
|
+
"editor.formatOnSave": true,
|
|
36
|
+
"editor.codeActionsOnSave": { "source.sortImports": "always" }
|
|
37
|
+
};
|
|
38
|
+
var vscode_settings_for_deno_default = {
|
|
39
|
+
"deno.enable": deno_enable,
|
|
40
|
+
"deno.unstable": deno_unstable,
|
|
41
|
+
"editor.detectIndentation": editor_detectIndentation,
|
|
42
|
+
"editor.indentSize": editor_indentSize,
|
|
43
|
+
"editor.insertSpaces": editor_insertSpaces,
|
|
44
|
+
"[javascript]": __javascript_,
|
|
45
|
+
"[javascriptreact]": __javascriptreact_,
|
|
46
|
+
"[json]": __json_,
|
|
47
|
+
"[jsonc]": __jsonc_,
|
|
48
|
+
"[typescript]": __typescript_,
|
|
49
|
+
"[typescriptreact]": __typescriptreact_
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { vscode_settings_for_deno_default as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
//#region src/init/json/vscode-settings.json
|
|
5
|
+
var editor_detectIndentation = false;
|
|
6
|
+
var editor_indentSize = 2;
|
|
7
|
+
var editor_insertSpaces = true;
|
|
8
|
+
var __javascript_ = {
|
|
9
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
10
|
+
"editor.formatOnSave": true,
|
|
11
|
+
"editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
|
|
12
|
+
};
|
|
13
|
+
var __javascriptreact_ = {
|
|
14
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
15
|
+
"editor.formatOnSave": true,
|
|
16
|
+
"editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
|
|
17
|
+
};
|
|
18
|
+
var __json_ = {
|
|
19
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
20
|
+
"editor.formatOnSave": true
|
|
21
|
+
};
|
|
22
|
+
var __jsonc_ = {
|
|
23
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
24
|
+
"editor.formatOnSave": true
|
|
25
|
+
};
|
|
26
|
+
var __typescript_ = {
|
|
27
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
28
|
+
"editor.formatOnSave": true,
|
|
29
|
+
"editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
|
|
30
|
+
};
|
|
31
|
+
var __typescriptreact_ = {
|
|
32
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
33
|
+
"editor.formatOnSave": true,
|
|
34
|
+
"editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
|
|
35
|
+
};
|
|
36
|
+
var vscode_settings_default = {
|
|
37
|
+
"editor.detectIndentation": editor_detectIndentation,
|
|
38
|
+
"editor.indentSize": editor_indentSize,
|
|
39
|
+
"editor.insertSpaces": editor_insertSpaces,
|
|
40
|
+
"[javascript]": __javascript_,
|
|
41
|
+
"[javascriptreact]": __javascriptreact_,
|
|
42
|
+
"[json]": __json_,
|
|
43
|
+
"[jsonc]": __jsonc_,
|
|
44
|
+
"[typescript]": __typescript_,
|
|
45
|
+
"[typescriptreact]": __typescriptreact_
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { vscode_settings_default as default };
|
package/dist/init/lib.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
import deno_default from "../deno.js";
|
|
5
|
+
import { colors, isNotFoundError, runSubCommand } from "../utils.js";
|
|
6
|
+
import kv_default from "./json/kv.js";
|
|
7
|
+
import mq_default from "./json/mq.js";
|
|
8
|
+
import pm_default from "./json/pm.js";
|
|
9
|
+
import rt_default from "./json/rt.js";
|
|
10
|
+
import webframeworks_default from "./webframeworks.js";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
13
|
+
import { getLogger } from "@logtape/logtape";
|
|
14
|
+
import process from "node:process";
|
|
15
|
+
import { entries, evolve, fromEntries, isObject, map, negate, pipe, throwIf, when } from "@fxts/core";
|
|
16
|
+
import { toMerged } from "es-toolkit";
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
|
|
19
|
+
//#region src/init/lib.ts
|
|
20
|
+
const PACKAGE_VERSION = deno_default.version;
|
|
21
|
+
const logger = getLogger([
|
|
22
|
+
"fedify",
|
|
23
|
+
"cli",
|
|
24
|
+
"init"
|
|
25
|
+
]);
|
|
26
|
+
const addFedifyDeps = (json) => Object.fromEntries(Object.entries(json).map(([key, value]) => [key, toMerged(value, { dependencies: { [`@fedify/${key}`]: PACKAGE_VERSION } })]));
|
|
27
|
+
const kvStores = addFedifyDeps(kv_default);
|
|
28
|
+
const messageQueues = addFedifyDeps(mq_default);
|
|
29
|
+
const toRegExp = (str) => new RegExp(str);
|
|
30
|
+
const convertPattern = (obj) => pipe(obj, entries, map(([key, value]) => [key, evolve({ outputPattern: toRegExp })(value)]), fromEntries);
|
|
31
|
+
const packageManagers = convertPattern(pm_default);
|
|
32
|
+
const runtimes = convertPattern(rt_default);
|
|
33
|
+
const getLabel = (name) => pipe(name, whenHasLabel(webframeworks_default), whenHasLabel(packageManagers), whenHasLabel(messageQueues), whenHasLabel(kvStores), whenHasLabel(runtimes));
|
|
34
|
+
const whenHasLabel = (desc) => when((name) => name in desc, (name) => desc[name].label);
|
|
35
|
+
const getInstallUrl = (pm) => packageManagers[pm].installUrl;
|
|
36
|
+
async function isPackageManagerAvailable(pm) {
|
|
37
|
+
if (await isCommandAvailable(packageManagers[pm])) return true;
|
|
38
|
+
if (process.platform !== "win32") return false;
|
|
39
|
+
const cmd = [packageManagers[pm].checkCommand[0] + ".cmd", ...packageManagers[pm].checkCommand.slice(1)];
|
|
40
|
+
if (await isCommandAvailable({
|
|
41
|
+
...packageManagers[pm],
|
|
42
|
+
checkCommand: cmd
|
|
43
|
+
})) return true;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const readTemplate = (templatePath) => readFileSync(join(import.meta.dirname, "templates", ...(templatePath + ".tpl").split("/")), "utf8");
|
|
47
|
+
const getInstruction = (pm) => `
|
|
48
|
+
To start the server, run the following command:
|
|
49
|
+
|
|
50
|
+
${getDevCommand(pm)}
|
|
51
|
+
|
|
52
|
+
Then, try look up an actor from your server:
|
|
53
|
+
|
|
54
|
+
${colors.bold(colors.green("fedify lookup http://localhost:8000/users/john"))}
|
|
55
|
+
|
|
56
|
+
`;
|
|
57
|
+
const getDevCommand = (pm) => colors.bold(colors.green(pm === "deno" ? "deno task dev" : pm === "bun" ? "bun dev" : `${pm} run dev`));
|
|
58
|
+
async function isCommandAvailable({ checkCommand, outputPattern }) {
|
|
59
|
+
try {
|
|
60
|
+
const { stdout } = await runSubCommand(checkCommand, { stdio: [
|
|
61
|
+
null,
|
|
62
|
+
"pipe",
|
|
63
|
+
null
|
|
64
|
+
] });
|
|
65
|
+
logger.debug("The stdout of the command {command} is: {stdout}", {
|
|
66
|
+
command: checkCommand,
|
|
67
|
+
stdout
|
|
68
|
+
});
|
|
69
|
+
return outputPattern.exec(stdout.trim()) ? true : false;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (isNotFoundError(error)) return false;
|
|
72
|
+
logger.debug("The command {command} failed with the error: {error}", {
|
|
73
|
+
command: checkCommand,
|
|
74
|
+
error
|
|
75
|
+
});
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function createFile(path$1, content) {
|
|
80
|
+
await mkdir(dirname(path$1), { recursive: true });
|
|
81
|
+
await writeFile(path$1, content);
|
|
82
|
+
}
|
|
83
|
+
const isNotExistsError = (e) => isObject(e) && "code" in e && e.code === "ENOENT";
|
|
84
|
+
const throwUnlessNotExists = throwIf(negate(isNotExistsError));
|
|
85
|
+
const isDirectoryEmpty = async (path$1) => {
|
|
86
|
+
try {
|
|
87
|
+
const files = await readdir(path$1);
|
|
88
|
+
return files.length === 0;
|
|
89
|
+
} catch (e) {
|
|
90
|
+
throwUnlessNotExists(e);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const getNextInitCommand = (pm) => [
|
|
95
|
+
...createNextAppCommand(pm),
|
|
96
|
+
".",
|
|
97
|
+
"--ts",
|
|
98
|
+
"--app",
|
|
99
|
+
"--biome",
|
|
100
|
+
"--skip-install"
|
|
101
|
+
];
|
|
102
|
+
const createNextAppCommand = (pm) => pm === "deno" ? [
|
|
103
|
+
"deno",
|
|
104
|
+
"run",
|
|
105
|
+
"-A",
|
|
106
|
+
"npm:create-next-app@latest"
|
|
107
|
+
] : pm === "bun" ? [
|
|
108
|
+
"bun",
|
|
109
|
+
"create",
|
|
110
|
+
"next-app"
|
|
111
|
+
] : pm === "npm" ? ["npx", "create-next-app"] : [
|
|
112
|
+
pm,
|
|
113
|
+
"dlx",
|
|
114
|
+
"create-next-app"
|
|
115
|
+
];
|
|
116
|
+
const getNitroInitCommand = (pm) => [
|
|
117
|
+
...createNitroAppCommand(pm),
|
|
118
|
+
pm === "deno" ? "npm:giget@latest" : "giget@latest",
|
|
119
|
+
"nitro",
|
|
120
|
+
"."
|
|
121
|
+
];
|
|
122
|
+
const createNitroAppCommand = (pm) => pm === "deno" ? [
|
|
123
|
+
"deno",
|
|
124
|
+
"run",
|
|
125
|
+
"-A"
|
|
126
|
+
] : pm === "bun" ? ["bunx"] : pm === "npm" ? ["npx"] : [pm, "dlx"];
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
export { PACKAGE_VERSION, createFile, getInstallUrl, getInstruction, getLabel, getNextInitCommand, getNitroInitCommand, isDirectoryEmpty, isPackageManagerAvailable, kvStores, logger, messageQueues, readTemplate, throwUnlessNotExists };
|
package/dist/init/mod.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
import { replace } from "../utils.js";
|
|
5
|
+
import { PACKAGE_MANAGER } from "./const.js";
|
|
6
|
+
import { PACKAGE_VERSION, getInstruction, getNextInitCommand, getNitroInitCommand, readTemplate } from "./lib.js";
|
|
7
|
+
import { pipe } from "@fxts/core";
|
|
8
|
+
|
|
9
|
+
//#region src/init/webframeworks.ts
|
|
10
|
+
const webFrameworks = {
|
|
11
|
+
hono: {
|
|
12
|
+
label: "Hono",
|
|
13
|
+
packageManagers: PACKAGE_MANAGER,
|
|
14
|
+
init: (projectName, pm) => ({
|
|
15
|
+
dependencies: pm === "deno" ? {
|
|
16
|
+
"@std/dotenv": "^0.225.2",
|
|
17
|
+
"@hono/hono": "^4.5.0",
|
|
18
|
+
"@hongminhee/x-forwarded-fetch": "^0.2.0"
|
|
19
|
+
} : pm === "bun" ? {
|
|
20
|
+
hono: "^4.5.0",
|
|
21
|
+
"x-forwarded-fetch": "^0.2.0"
|
|
22
|
+
} : {
|
|
23
|
+
"@dotenvx/dotenvx": "^1.14.1",
|
|
24
|
+
hono: "^4.5.0",
|
|
25
|
+
"@hono/node-server": "^1.12.0",
|
|
26
|
+
tsx: "^4.17.0",
|
|
27
|
+
"x-forwarded-fetch": "^0.2.0"
|
|
28
|
+
},
|
|
29
|
+
devDependencies: pm === "bun" ? { "@types/bun": "^1.1.6" } : {},
|
|
30
|
+
federationFile: "src/federation.ts",
|
|
31
|
+
loggingFile: "src/logging.ts",
|
|
32
|
+
files: {
|
|
33
|
+
"src/app.tsx": pipe("hono/app.tsx", readTemplate, replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono")).replace(/\/\* logger \*\//, projectName),
|
|
34
|
+
"src/index.ts": readTemplate(`hono/index/${pm}.ts`)
|
|
35
|
+
},
|
|
36
|
+
compilerOptions: pm === "deno" ? void 0 : {
|
|
37
|
+
"lib": ["ESNext", "DOM"],
|
|
38
|
+
"target": "ESNext",
|
|
39
|
+
"module": "NodeNext",
|
|
40
|
+
"moduleResolution": "NodeNext",
|
|
41
|
+
"allowImportingTsExtensions": true,
|
|
42
|
+
"verbatimModuleSyntax": true,
|
|
43
|
+
"noEmit": true,
|
|
44
|
+
"strict": true,
|
|
45
|
+
"jsx": "react-jsx",
|
|
46
|
+
"jsxImportSource": "hono/jsx"
|
|
47
|
+
},
|
|
48
|
+
tasks: {
|
|
49
|
+
"dev": pm === "deno" ? "deno run -A --watch ./src/index.ts" : pm === "bun" ? "bun run --hot ./src/index.ts" : "dotenvx run -- tsx watch ./src/index.ts",
|
|
50
|
+
"prod": pm === "deno" ? "deno run -A ./src/index.ts" : pm === "bun" ? "bun run ./src/index.ts" : "dotenvx run -- node --import tsx ./src/index.ts"
|
|
51
|
+
},
|
|
52
|
+
instruction: getInstruction(pm)
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
express: {
|
|
56
|
+
label: "Express",
|
|
57
|
+
packageManagers: [
|
|
58
|
+
"bun",
|
|
59
|
+
"npm",
|
|
60
|
+
"yarn",
|
|
61
|
+
"pnpm"
|
|
62
|
+
],
|
|
63
|
+
init: (projectName, pm) => ({
|
|
64
|
+
dependencies: {
|
|
65
|
+
express: "^4.19.2",
|
|
66
|
+
"@fedify/express": PACKAGE_VERSION,
|
|
67
|
+
...pm !== "deno" && pm !== "bun" ? {
|
|
68
|
+
"@dotenvx/dotenvx": "^1.14.1",
|
|
69
|
+
tsx: "^4.17.0"
|
|
70
|
+
} : {}
|
|
71
|
+
},
|
|
72
|
+
devDependencies: {
|
|
73
|
+
"@types/express": "^4.17.21",
|
|
74
|
+
...pm === "bun" ? { "@types/bun": "^1.1.6" } : {}
|
|
75
|
+
},
|
|
76
|
+
federationFile: "src/federation.ts",
|
|
77
|
+
loggingFile: "src/logging.ts",
|
|
78
|
+
files: {
|
|
79
|
+
"src/app.ts": readTemplate("express/app.ts").replace(/\/\* logger \*\//, projectName),
|
|
80
|
+
"src/index.ts": readTemplate("express/index.ts")
|
|
81
|
+
},
|
|
82
|
+
compilerOptions: pm === "deno" ? void 0 : {
|
|
83
|
+
"lib": ["ESNext", "DOM"],
|
|
84
|
+
"target": "ESNext",
|
|
85
|
+
"module": "NodeNext",
|
|
86
|
+
"moduleResolution": "NodeNext",
|
|
87
|
+
"allowImportingTsExtensions": true,
|
|
88
|
+
"verbatimModuleSyntax": true,
|
|
89
|
+
"noEmit": true,
|
|
90
|
+
"strict": true
|
|
91
|
+
},
|
|
92
|
+
tasks: {
|
|
93
|
+
"dev": pm === "bun" ? "bun run --hot ./src/index.ts" : "dotenvx run -- tsx watch ./src/index.ts",
|
|
94
|
+
"prod": pm === "bun" ? "bun run ./src/index.ts" : "dotenvx run -- node --import tsx ./src/index.ts"
|
|
95
|
+
},
|
|
96
|
+
instruction: getInstruction(pm)
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
nitro: {
|
|
100
|
+
label: "Nitro",
|
|
101
|
+
packageManagers: PACKAGE_MANAGER,
|
|
102
|
+
init: (_, pm) => ({
|
|
103
|
+
command: getNitroInitCommand(pm),
|
|
104
|
+
dependencies: { "@fedify/h3": PACKAGE_VERSION },
|
|
105
|
+
federationFile: "server/federation.ts",
|
|
106
|
+
loggingFile: "server/logging.ts",
|
|
107
|
+
files: {
|
|
108
|
+
"server/middleware/federation.ts": readTemplate("nitro/server/middleware/federation.ts"),
|
|
109
|
+
"server/error.ts": readTemplate("nitro/server/error.ts"),
|
|
110
|
+
"nitro.config.ts": readTemplate("nitro/nitro.config.ts")
|
|
111
|
+
},
|
|
112
|
+
instruction: getInstruction(pm)
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
next: {
|
|
116
|
+
label: "Next.js",
|
|
117
|
+
packageManagers: PACKAGE_MANAGER,
|
|
118
|
+
init: (_, pm) => ({
|
|
119
|
+
label: "Next.js",
|
|
120
|
+
command: getNextInitCommand(pm),
|
|
121
|
+
dependencies: { "@fedify/next": PACKAGE_VERSION },
|
|
122
|
+
devDependencies: { "@types/node": "^20.11.2" },
|
|
123
|
+
federationFile: "federation/index.ts",
|
|
124
|
+
loggingFile: "logging.ts",
|
|
125
|
+
files: { "middleware.ts": readTemplate("next/middleware.ts") },
|
|
126
|
+
instruction: getInstruction(pm)
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var webframeworks_default = webFrameworks;
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { webframeworks_default as default };
|
package/dist/kv.bun.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
import { getCacheDir } from "./cache.js";
|
|
5
|
+
import { SqliteKvStore } from "@fedify/sqlite";
|
|
6
|
+
import { Database } from "bun:sqlite";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
|
|
9
|
+
//#region src/kv.bun.ts
|
|
10
|
+
async function getKvStore() {
|
|
11
|
+
const path$1 = join(await getCacheDir(), "sqlite");
|
|
12
|
+
const sqlite = new Database(path$1);
|
|
13
|
+
return new SqliteKvStore(sqlite);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getKvStore };
|
package/dist/kv.node.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
import { getCacheDir } from "./cache.js";
|
|
5
|
+
import { SqliteKvStore } from "@fedify/sqlite";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { DatabaseSync } from "node:sqlite";
|
|
8
|
+
|
|
9
|
+
//#region src/kv.node.ts
|
|
10
|
+
async function getKvStore() {
|
|
11
|
+
const path$1 = join(await getCacheDir(), "sqlite");
|
|
12
|
+
const sqlite = new DatabaseSync(path$1);
|
|
13
|
+
return new SqliteKvStore(sqlite);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getKvStore };
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import { mkdir } from "node:fs/promises";
|
|
6
|
+
import { configure, getConsoleSink } from "@logtape/logtape";
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { getFileSink } from "@logtape/file";
|
|
9
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
|
+
|
|
11
|
+
//#region src/log.ts
|
|
12
|
+
function getRecordingSink() {
|
|
13
|
+
let records = [];
|
|
14
|
+
let recording = false;
|
|
15
|
+
const sink = (record) => {
|
|
16
|
+
if (recording) records.push(record);
|
|
17
|
+
};
|
|
18
|
+
sink.startRecording = () => {
|
|
19
|
+
records = [];
|
|
20
|
+
recording = true;
|
|
21
|
+
};
|
|
22
|
+
sink.stopRecording = () => {
|
|
23
|
+
recording = false;
|
|
24
|
+
};
|
|
25
|
+
sink.getRecords = () => [...records];
|
|
26
|
+
return sink;
|
|
27
|
+
}
|
|
28
|
+
const recordingSink = getRecordingSink();
|
|
29
|
+
const logFile = process.env["FEDIFY_LOG_FILE"];
|
|
30
|
+
if (logFile != null) await mkdir(dirname(logFile), { recursive: true });
|
|
31
|
+
await configure({
|
|
32
|
+
sinks: {
|
|
33
|
+
console: getConsoleSink(),
|
|
34
|
+
recording: recordingSink,
|
|
35
|
+
file: logFile == null ? () => void 0 : getFileSink(logFile)
|
|
36
|
+
},
|
|
37
|
+
filters: {},
|
|
38
|
+
loggers: [{
|
|
39
|
+
category: "fedify",
|
|
40
|
+
lowestLevel: "debug",
|
|
41
|
+
sinks: ["recording", "file"]
|
|
42
|
+
}, {
|
|
43
|
+
category: ["logtape", "meta"],
|
|
44
|
+
lowestLevel: "warning",
|
|
45
|
+
sinks: ["console", "file"]
|
|
46
|
+
}],
|
|
47
|
+
contextLocalStorage: new AsyncLocalStorage(),
|
|
48
|
+
reset: true
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { recordingSink };
|