@fedify/cli 2.0.0-pr.467.1877 → 2.0.0-pr.471.1909
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 +1 -1
- package/dist/deno.js +1 -1
- package/dist/init/action/notice.js +9 -5
- package/dist/init/action/patch.js +1 -1
- package/dist/init/lib.js +6 -5
- package/dist/init/webframeworks.js +5 -4
- package/dist/nodeinfo.js +6 -6
- package/package.json +5 -5
- package/src/init/action/notice.ts +9 -6
- package/src/init/action/patch.ts +1 -1
- package/src/init/lib.ts +9 -18
- package/src/init/types.ts +3 -2
- package/src/init/webframeworks.ts +5 -4
- package/src/nodeinfo.ts +2 -1
package/deno.json
CHANGED
package/dist/deno.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
|
|
4
4
|
import { colors } from "../../utils.js";
|
|
5
|
-
import { message } from "@optique/core";
|
|
5
|
+
import { message, text } from "@optique/core";
|
|
6
6
|
import { print, printError } from "@optique/run";
|
|
7
7
|
import { flow } from "es-toolkit";
|
|
8
8
|
|
|
@@ -45,11 +45,15 @@ function displayFile(path$1, content, emoji = "📄") {
|
|
|
45
45
|
}
|
|
46
46
|
const noticeConfigEnv = () => printMessage`Note that you probably want to edit the ${".env"} file.
|
|
47
47
|
It currently contains the following values:\n`;
|
|
48
|
-
const noticeEnvKeyValue = ([key, value]) =>
|
|
48
|
+
const noticeEnvKeyValue = ([key, value]) => {
|
|
49
|
+
printMessage`${text(` ${key}='${value}'`)}`;
|
|
50
|
+
};
|
|
49
51
|
function noticeHowToRun({ initializer: { instruction, federationFile } }) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
print(message`
|
|
53
|
+
${instruction}
|
|
54
|
+
|
|
55
|
+
Start by editing the ${federationFile} file to define your federation!
|
|
56
|
+
`);
|
|
53
57
|
}
|
|
54
58
|
function noticeErrorWhileAddDeps(command$1) {
|
|
55
59
|
return (error) => {
|
|
@@ -31,7 +31,7 @@ const recommendPatchFiles = (data) => pipe(data, set("files", getFiles), set("js
|
|
|
31
31
|
* @returns A record of file paths to their string content
|
|
32
32
|
*/
|
|
33
33
|
const getFiles = (data) => ({
|
|
34
|
-
[data.initializer.federationFile]: loadFederation({
|
|
34
|
+
[data.initializer.federationFile.toString()]: loadFederation({
|
|
35
35
|
imports: getImports(data),
|
|
36
36
|
...data
|
|
37
37
|
}),
|
package/dist/init/lib.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
|
|
4
4
|
import deno_default from "../deno.js";
|
|
5
|
-
import {
|
|
5
|
+
import { isNotFoundError, runSubCommand } from "../utils.js";
|
|
6
6
|
import kv_default from "./json/kv.js";
|
|
7
7
|
import mq_default from "./json/mq.js";
|
|
8
8
|
import pm_default from "./json/pm.js";
|
|
@@ -10,6 +10,7 @@ import rt_default from "./json/rt.js";
|
|
|
10
10
|
import webframeworks_default from "./webframeworks.js";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
13
|
+
import { commandLine, message } from "@optique/core/message";
|
|
13
14
|
import process from "node:process";
|
|
14
15
|
import { getLogger } from "@logtape/logtape";
|
|
15
16
|
import { entries, evolve, fromEntries, isObject, map, negate, pipe, throwIf, when } from "@fxts/core";
|
|
@@ -44,17 +45,17 @@ async function isPackageManagerAvailable(pm) {
|
|
|
44
45
|
return false;
|
|
45
46
|
}
|
|
46
47
|
const readTemplate = (templatePath) => readFileSync(join(import.meta.dirname, "templates", ...(templatePath + ".tpl").split("/")), "utf8");
|
|
47
|
-
const getInstruction = (pm) => `
|
|
48
|
+
const getInstruction = (pm) => message`
|
|
48
49
|
To start the server, run the following command:
|
|
49
50
|
|
|
50
|
-
${getDevCommand(pm)}
|
|
51
|
+
${commandLine(getDevCommand(pm))}
|
|
51
52
|
|
|
52
53
|
Then, try look up an actor from your server:
|
|
53
54
|
|
|
54
|
-
${
|
|
55
|
+
${commandLine("fedify lookup http://localhost:8000/users/john")}
|
|
55
56
|
|
|
56
57
|
`;
|
|
57
|
-
const getDevCommand = (pm) =>
|
|
58
|
+
const getDevCommand = (pm) => pm === "deno" ? "deno task dev" : pm === "bun" ? "bun dev" : `${pm} run dev`;
|
|
58
59
|
async function isCommandAvailable({ checkCommand, outputPattern }) {
|
|
59
60
|
try {
|
|
60
61
|
const { stdout } = await runSubCommand(checkCommand, { stdio: [
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { replace } from "../utils.js";
|
|
5
5
|
import { PACKAGE_MANAGER } from "./const.js";
|
|
6
6
|
import { PACKAGE_VERSION, getInstruction, getNextInitCommand, getNitroInitCommand, readTemplate } from "./lib.js";
|
|
7
|
+
import { message } from "@optique/core";
|
|
7
8
|
import { pipe } from "@fxts/core";
|
|
8
9
|
|
|
9
10
|
//#region src/init/webframeworks.ts
|
|
@@ -27,7 +28,7 @@ const webFrameworks = {
|
|
|
27
28
|
"x-forwarded-fetch": "^0.2.0"
|
|
28
29
|
},
|
|
29
30
|
devDependencies: pm === "bun" ? { "@types/bun": "^1.1.6" } : {},
|
|
30
|
-
federationFile:
|
|
31
|
+
federationFile: message`src/federation.ts`,
|
|
31
32
|
loggingFile: "src/logging.ts",
|
|
32
33
|
files: {
|
|
33
34
|
"src/app.tsx": pipe("hono/app.tsx", readTemplate, replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono")).replace(/\/\* logger \*\//, projectName),
|
|
@@ -73,7 +74,7 @@ const webFrameworks = {
|
|
|
73
74
|
"@types/express": "^4.17.21",
|
|
74
75
|
...pm === "bun" ? { "@types/bun": "^1.1.6" } : {}
|
|
75
76
|
},
|
|
76
|
-
federationFile:
|
|
77
|
+
federationFile: message`src/federation.ts`,
|
|
77
78
|
loggingFile: "src/logging.ts",
|
|
78
79
|
files: {
|
|
79
80
|
"src/app.ts": readTemplate("express/app.ts").replace(/\/\* logger \*\//, projectName),
|
|
@@ -102,7 +103,7 @@ const webFrameworks = {
|
|
|
102
103
|
init: (_, pm) => ({
|
|
103
104
|
command: getNitroInitCommand(pm),
|
|
104
105
|
dependencies: { "@fedify/h3": PACKAGE_VERSION },
|
|
105
|
-
federationFile:
|
|
106
|
+
federationFile: message`server/federation.ts`,
|
|
106
107
|
loggingFile: "server/logging.ts",
|
|
107
108
|
files: {
|
|
108
109
|
"server/middleware/federation.ts": readTemplate("nitro/server/middleware/federation.ts"),
|
|
@@ -120,7 +121,7 @@ const webFrameworks = {
|
|
|
120
121
|
command: getNextInitCommand(pm),
|
|
121
122
|
dependencies: { "@fedify/next": PACKAGE_VERSION },
|
|
122
123
|
devDependencies: { "@types/node": "^20.11.2" },
|
|
123
|
-
federationFile:
|
|
124
|
+
federationFile: message`federation/index.ts`,
|
|
124
125
|
loggingFile: "logging.ts",
|
|
125
126
|
files: { "middleware.ts": readTemplate("next/middleware.ts") },
|
|
126
127
|
instruction: getInstruction(pm)
|
package/dist/nodeinfo.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { debugOption } from "./globals.js";
|
|
5
5
|
import { colors, formatObject } from "./utils.js";
|
|
6
|
-
import { argument, command, constant, flag, merge, message, object, option, optional, or, string } from "@optique/core";
|
|
6
|
+
import { argument, command, constant, flag, merge, message, object, option, optional, or, string, text } from "@optique/core";
|
|
7
7
|
import { print, printError } from "@optique/run";
|
|
8
8
|
import process from "node:process";
|
|
9
9
|
import { getNodeInfo } from "@fedify/fedify";
|
|
@@ -58,7 +58,7 @@ async function runNodeInfo(command$1) {
|
|
|
58
58
|
process.exit(1);
|
|
59
59
|
}
|
|
60
60
|
spinner.succeed("NodeInfo document fetched.");
|
|
61
|
-
|
|
61
|
+
print(message`${text(formatObject(nodeInfo$1, void 0, true))}`);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const nodeInfo = await getNodeInfo(url, {
|
|
@@ -153,15 +153,15 @@ async function runNodeInfo(command$1) {
|
|
|
153
153
|
}
|
|
154
154
|
console.log(layout.join("\n"));
|
|
155
155
|
}
|
|
156
|
-
function indent(text, depth) {
|
|
157
|
-
return text.replace(/\n/g, "\n" + " ".repeat(depth));
|
|
156
|
+
function indent(text$1, depth) {
|
|
157
|
+
return text$1.replace(/\n/g, "\n" + " ".repeat(depth));
|
|
158
158
|
}
|
|
159
159
|
const LINK_REGEXP = /<link((?:\s+(?:[-a-z]+)=(?:"[^"]*"|'[^']*'|[^\s]+))*)\s*\/?>/gi;
|
|
160
160
|
const LINK_ATTRS_REGEXP = /(?:\s+([-a-z]+)=("[^"]*"|'[^']*'|[^\s]+))/gi;
|
|
161
161
|
async function getFaviconUrl(url, userAgent) {
|
|
162
162
|
const response = await fetch(url, { headers: { "User-Agent": userAgent == null ? getUserAgent() : userAgent } });
|
|
163
|
-
const text = await response.text();
|
|
164
|
-
for (const match of text.matchAll(LINK_REGEXP)) {
|
|
163
|
+
const text$1 = await response.text();
|
|
164
|
+
for (const match of text$1.matchAll(LINK_REGEXP)) {
|
|
165
165
|
const attrs = {};
|
|
166
166
|
for (const attrMatch of match[1].matchAll(LINK_ATTRS_REGEXP)) {
|
|
167
167
|
const [, key, value] = attrMatch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/cli",
|
|
3
|
-
"version": "2.0.0-pr.
|
|
3
|
+
"version": "2.0.0-pr.471.1909+976b008d",
|
|
4
4
|
"description": "CLI toolchain for Fedify and debugging ActivityPub",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"ora": "^8.2.0",
|
|
72
72
|
"shiki": "^1.6.4",
|
|
73
73
|
"srvx": "^0.8.7",
|
|
74
|
-
"@fedify/fedify": "2.0.0-pr.
|
|
75
|
-
"@fedify/sqlite": "2.0.0-pr.
|
|
76
|
-
"@fedify/vocab-runtime": "2.0.0-pr.
|
|
77
|
-
"@fedify/vocab-tools": "2.0.0-pr.
|
|
74
|
+
"@fedify/fedify": "2.0.0-pr.471.1909+976b008d",
|
|
75
|
+
"@fedify/sqlite": "2.0.0-pr.471.1909+976b008d",
|
|
76
|
+
"@fedify/vocab-runtime": "2.0.0-pr.471.1909+976b008d",
|
|
77
|
+
"@fedify/vocab-tools": "2.0.0-pr.471.1909+976b008d"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/bun": "^1.2.23",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { message } from "@optique/core";
|
|
1
|
+
import { message, text } from "@optique/core";
|
|
2
2
|
import { print, printError } from "@optique/run";
|
|
3
3
|
import { flow } from "es-toolkit";
|
|
4
4
|
import { colors, type RequiredNotNull } from "../../utils.ts";
|
|
@@ -80,15 +80,18 @@ export const noticeConfigEnv = () =>
|
|
|
80
80
|
printMessage`Note that you probably want to edit the ${".env"} file.
|
|
81
81
|
It currently contains the following values:\n`;
|
|
82
82
|
|
|
83
|
-
export const noticeEnvKeyValue = ([key, value]: [string, string]) =>
|
|
84
|
-
printMessage` ${key}
|
|
83
|
+
export const noticeEnvKeyValue = ([key, value]: [string, string]) => {
|
|
84
|
+
printMessage`${text(` ${key}='${value}'`)}`;
|
|
85
|
+
};
|
|
85
86
|
|
|
86
87
|
export function noticeHowToRun(
|
|
87
88
|
{ initializer: { instruction, federationFile } }: InitCommandData,
|
|
88
89
|
) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
print(message`
|
|
91
|
+
${instruction}
|
|
92
|
+
|
|
93
|
+
Start by editing the ${federationFile} file to define your federation!
|
|
94
|
+
`);
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
export function noticeErrorWhileAddDeps(command: string[]) {
|
package/src/init/action/patch.ts
CHANGED
|
@@ -53,7 +53,7 @@ export const recommendPatchFiles = (data: InitCommandData) =>
|
|
|
53
53
|
const getFiles = <
|
|
54
54
|
T extends InitCommandData,
|
|
55
55
|
>(data: T) => ({
|
|
56
|
-
[data.initializer.federationFile]: loadFederation({
|
|
56
|
+
[data.initializer.federationFile.toString()]: loadFederation({
|
|
57
57
|
imports: getImports(data),
|
|
58
58
|
...data,
|
|
59
59
|
}),
|
package/src/init/lib.ts
CHANGED
|
@@ -10,13 +10,15 @@ import {
|
|
|
10
10
|
when,
|
|
11
11
|
} from "@fxts/core";
|
|
12
12
|
import { getLogger } from "@logtape/logtape";
|
|
13
|
-
import {
|
|
13
|
+
import type { Message } from "@optique/core";
|
|
14
|
+
import { commandLine, message } from "@optique/core/message";
|
|
14
15
|
import { toMerged } from "es-toolkit";
|
|
15
16
|
import { readFileSync } from "node:fs";
|
|
16
17
|
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
18
|
+
import { dirname, join as joinPath } from "node:path";
|
|
17
19
|
import process from "node:process";
|
|
18
20
|
import metadata from "../../deno.json" with { type: "json" };
|
|
19
|
-
import {
|
|
21
|
+
import { isNotFoundError, runSubCommand } from "../utils.ts";
|
|
20
22
|
import kv from "./json/kv.json" with { type: "json" };
|
|
21
23
|
import mq from "./json/mq.json" with { type: "json" };
|
|
22
24
|
import pm from "./json/pm.json" with { type: "json" };
|
|
@@ -108,31 +110,20 @@ export const readTemplate: (templatePath: string) => string = (
|
|
|
108
110
|
|
|
109
111
|
export const getInstruction: (
|
|
110
112
|
packageManager: PackageManager,
|
|
111
|
-
) =>
|
|
113
|
+
) => Message = (pm) =>
|
|
114
|
+
message`
|
|
112
115
|
To start the server, run the following command:
|
|
113
116
|
|
|
114
|
-
${getDevCommand(pm)}
|
|
117
|
+
${commandLine(getDevCommand(pm))}
|
|
115
118
|
|
|
116
119
|
Then, try look up an actor from your server:
|
|
117
120
|
|
|
118
|
-
${
|
|
119
|
-
colors.bold(colors.green(
|
|
120
|
-
"fedify lookup http://localhost:8000/users/john",
|
|
121
|
-
))
|
|
122
|
-
}
|
|
121
|
+
${commandLine("fedify lookup http://localhost:8000/users/john")}
|
|
123
122
|
|
|
124
123
|
`;
|
|
125
124
|
|
|
126
125
|
const getDevCommand = (pm: PackageManager) =>
|
|
127
|
-
|
|
128
|
-
colors.green(
|
|
129
|
-
pm === "deno"
|
|
130
|
-
? "deno task dev"
|
|
131
|
-
: pm === "bun"
|
|
132
|
-
? "bun dev"
|
|
133
|
-
: `${pm} run dev`,
|
|
134
|
-
),
|
|
135
|
-
);
|
|
126
|
+
pm === "deno" ? "deno task dev" : pm === "bun" ? "bun dev" : `${pm} run dev`;
|
|
136
127
|
|
|
137
128
|
async function isCommandAvailable(
|
|
138
129
|
{ checkCommand, outputPattern }: {
|
package/src/init/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Message } from "@optique/core";
|
|
1
2
|
import type { RequiredNotNull } from "../utils.ts";
|
|
2
3
|
import type { InitCommand } from "./command.ts";
|
|
3
4
|
import type {
|
|
@@ -35,12 +36,12 @@ export interface WebFrameworkInitializer {
|
|
|
35
36
|
command?: string[];
|
|
36
37
|
dependencies?: object;
|
|
37
38
|
devDependencies?: object;
|
|
38
|
-
federationFile:
|
|
39
|
+
federationFile: Message;
|
|
39
40
|
loggingFile: string;
|
|
40
41
|
files?: Record<string, string>;
|
|
41
42
|
compilerOptions?: Record<string, string | boolean | number | string[] | null>;
|
|
42
43
|
tasks?: Record<string, string>;
|
|
43
|
-
instruction:
|
|
44
|
+
instruction: Message;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export interface WebFrameworkDescription {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pipe } from "@fxts/core";
|
|
2
|
+
import { message } from "@optique/core";
|
|
2
3
|
import { replace } from "../utils.ts";
|
|
3
4
|
import { PACKAGE_MANAGER } from "./const.ts";
|
|
4
5
|
import {
|
|
@@ -31,7 +32,7 @@ const webFrameworks: WebFrameworks = {
|
|
|
31
32
|
"x-forwarded-fetch": "^0.2.0",
|
|
32
33
|
},
|
|
33
34
|
devDependencies: pm === "bun" ? { "@types/bun": "^1.1.6" } : {},
|
|
34
|
-
federationFile:
|
|
35
|
+
federationFile: message`src/federation.ts`,
|
|
35
36
|
loggingFile: "src/logging.ts",
|
|
36
37
|
files: {
|
|
37
38
|
"src/app.tsx": pipe(
|
|
@@ -87,7 +88,7 @@ const webFrameworks: WebFrameworks = {
|
|
|
87
88
|
"@types/express": "^4.17.21",
|
|
88
89
|
...(pm === "bun" ? { "@types/bun": "^1.1.6" } : {}),
|
|
89
90
|
},
|
|
90
|
-
federationFile:
|
|
91
|
+
federationFile: message`src/federation.ts`,
|
|
91
92
|
loggingFile: "src/logging.ts",
|
|
92
93
|
files: {
|
|
93
94
|
"src/app.ts": readTemplate("express/app.ts")
|
|
@@ -121,7 +122,7 @@ const webFrameworks: WebFrameworks = {
|
|
|
121
122
|
init: (_, pm) => ({
|
|
122
123
|
command: getNitroInitCommand(pm),
|
|
123
124
|
dependencies: { "@fedify/h3": PACKAGE_VERSION },
|
|
124
|
-
federationFile:
|
|
125
|
+
federationFile: message`server/federation.ts`,
|
|
125
126
|
loggingFile: "server/logging.ts",
|
|
126
127
|
files: {
|
|
127
128
|
"server/middleware/federation.ts": readTemplate(
|
|
@@ -141,7 +142,7 @@ const webFrameworks: WebFrameworks = {
|
|
|
141
142
|
command: getNextInitCommand(pm),
|
|
142
143
|
dependencies: { "@fedify/next": PACKAGE_VERSION },
|
|
143
144
|
devDependencies: { "@types/node": "^20.11.2" },
|
|
144
|
-
federationFile:
|
|
145
|
+
federationFile: message`federation/index.ts`,
|
|
145
146
|
loggingFile: "logging.ts",
|
|
146
147
|
files: { "middleware.ts": readTemplate("next/middleware.ts") },
|
|
147
148
|
instruction: getInstruction(pm),
|
package/src/nodeinfo.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
optional,
|
|
17
17
|
or,
|
|
18
18
|
string,
|
|
19
|
+
text,
|
|
19
20
|
} from "@optique/core";
|
|
20
21
|
import { print, printError } from "@optique/run";
|
|
21
22
|
import type { ChalkInstance } from "chalk";
|
|
@@ -111,7 +112,7 @@ export async function runNodeInfo(
|
|
|
111
112
|
}
|
|
112
113
|
spinner.succeed("NodeInfo document fetched.");
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
print(message`${text(formatObject(nodeInfo, undefined, true))}`);
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
117
118
|
const nodeInfo = await getNodeInfo(url, {
|