@fedify/cli 2.0.0-pr.474.1879 → 2.0.0-pr.478.1916

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/cli",
3
- "version": "2.0.0-pr.474.1879+be9e2989",
3
+ "version": "2.0.0-pr.478.1916+5db44d85",
4
4
  "license": "MIT",
5
5
  "exports": "./src/mod.ts",
6
6
  "imports": {
package/dist/deno.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  //#region deno.json
5
5
  var name = "@fedify/cli";
6
- var version = "2.0.0-pr.474.1879+be9e2989";
6
+ var version = "2.0.0-pr.478.1916+5db44d85";
7
7
  var license = "MIT";
8
8
  var exports = "./src/mod.ts";
9
9
  var imports = {
package/dist/inbox.js CHANGED
@@ -30,8 +30,7 @@ const inboxCommand = command("inbox", merge(object("Inbox options", {
30
30
  acceptFollow: optional(multiple(option("-a", "--accept-follow", string({ metavar: "URI" }), { description: message`Accept follow requests from the given actor. The argument can be either an actor URI or a handle, or a wildcard (${"*"}). Can be specified multiple times. If a wildcard is specified, all follow requests will be accepted.` }))),
31
31
  noTunnel: option("-T", "--no-tunnel", { description: message`Do not tunnel the ephemeral ActivityPub server to the public Internet.` }),
32
32
  actorName: withDefault(option("--actor-name", string({ metavar: "NAME" }), { description: message`Customize the actor display name.` }), "Fedify Ephemeral Inbox"),
33
- actorSummary: withDefault(option("--actor-summary", string({ metavar: "SUMMARY" }), { description: message`Customize the actor description.` }), "An ephemeral ActivityPub inbox for testing purposes."),
34
- authorizedFetch: option("-A", "--authorized-fetch", { description: message`Require HTTP Signatures for all incoming requests. Returns 401 for unsigned requests.` })
33
+ actorSummary: withDefault(option("--actor-summary", string({ metavar: "SUMMARY" }), { description: message`Customize the actor description.` }), "An ephemeral ActivityPub inbox for testing purposes.")
35
34
  }), debugOption), {
36
35
  brief: message`Run an ephemeral ActivityPub inbox server.`,
37
36
  description: message`Spins up an ephemeral server that serves the ActivityPub inbox with an one-time actor, through a short-lived public DNS with HTTPS. You can monitor the incoming activities in real-time.`
@@ -39,8 +38,7 @@ const inboxCommand = command("inbox", merge(object("Inbox options", {
39
38
  async function runInbox(command$1) {
40
39
  const fetch = createFetchHandler({
41
40
  actorName: command$1.actorName,
42
- actorSummary: command$1.actorSummary,
43
- requireHttpSignature: command$1.authorizedFetch
41
+ actorSummary: command$1.actorSummary
44
42
  });
45
43
  const sendDeleteToPeers = createSendDeleteToPeers({
46
44
  actorName: command$1.actorName,
@@ -302,7 +300,6 @@ function createFetchHandler(actorOptions) {
302
300
  actorName: actorOptions.actorName,
303
301
  actorSummary: actorOptions.actorSummary
304
302
  },
305
- requireHttpSignature: actorOptions.requireHttpSignature,
306
303
  onNotAcceptable: app.fetch.bind(app),
307
304
  onNotFound: app.fetch.bind(app),
308
305
  onUnauthorized: app.fetch.bind(app)
@@ -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]) => printMessage` ${key}=${value}`;
48
+ const noticeEnvKeyValue = ([key, value]) => {
49
+ printMessage`${text(` ${key}='${value}'`)}`;
50
+ };
49
51
  function noticeHowToRun({ initializer: { instruction, federationFile } }) {
50
- printMessage`${instruction}`;
51
- printMessage`Start by editing the ${federationFile} file to define your federation!
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 { colors, isNotFoundError, runSubCommand } from "../utils.js";
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
- ${colors.bold(colors.green("fedify lookup http://localhost:8000/users/john"))}
55
+ ${commandLine("fedify lookup http://localhost:8000/users/john")}
55
56
 
56
57
  `;
57
- const getDevCommand = (pm) => colors.bold(colors.green(pm === "deno" ? "deno task dev" : pm === "bun" ? "bun dev" : `${pm} run dev`));
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: "src/federation.ts",
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: "src/federation.ts",
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: "server/federation.ts",
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: "federation/index.ts",
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
- console.log(formatObject(nodeInfo$1, void 0, true));
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.474.1879+be9e2989",
3
+ "version": "2.0.0-pr.478.1916+5db44d85",
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.474.1879+be9e2989",
75
- "@fedify/vocab-runtime": "2.0.0-pr.474.1879+be9e2989",
76
- "@fedify/vocab-tools": "2.0.0-pr.474.1879+be9e2989",
77
- "@fedify/sqlite": "2.0.0-pr.474.1879+be9e2989"
74
+ "@fedify/sqlite": "2.0.0-pr.478.1916+5db44d85",
75
+ "@fedify/fedify": "2.0.0-pr.478.1916+5db44d85",
76
+ "@fedify/vocab-tools": "2.0.0-pr.478.1916+5db44d85",
77
+ "@fedify/vocab-runtime": "2.0.0-pr.478.1916+5db44d85"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/bun": "^1.2.23",
package/scripts/pack.ts CHANGED
@@ -26,7 +26,7 @@ async function compile(os: OS, arch: Arch, into: string): Promise<void> {
26
26
  }
27
27
  await $`deno compile --allow-all --include=${
28
28
  join("src", "init", "templates")
29
- } --target=${target} --output=${into} ${
29
+ } --node-modules-dir=none --target=${target} --output=${into} ${
30
30
  join(dirname(import.meta.dirname!), "src", "mod.ts")
31
31
  }`;
32
32
  }
package/src/inbox.tsx CHANGED
@@ -103,14 +103,6 @@ export const inboxCommand = command(
103
103
  }),
104
104
  "An ephemeral ActivityPub inbox for testing purposes.",
105
105
  ),
106
- authorizedFetch: option(
107
- "-A",
108
- "--authorized-fetch",
109
- {
110
- description:
111
- message`Require HTTP Signatures for all incoming requests. Returns 401 for unsigned requests.`,
112
- },
113
- ),
114
106
  }),
115
107
  debugOption,
116
108
  ),
@@ -127,7 +119,6 @@ export async function runInbox(
127
119
  const fetch = createFetchHandler({
128
120
  actorName: command.actorName,
129
121
  actorSummary: command.actorSummary,
130
- requireHttpSignature: command.authorizedFetch,
131
122
  });
132
123
  const sendDeleteToPeers = createSendDeleteToPeers({
133
124
  actorName: command.actorName,
@@ -508,11 +499,7 @@ app.get("/r/:idx{[0-9]+}", (c) => {
508
499
  });
509
500
 
510
501
  function createFetchHandler(
511
- actorOptions: {
512
- actorName: string;
513
- actorSummary: string;
514
- requireHttpSignature?: boolean;
515
- },
502
+ actorOptions: { actorName: string; actorSummary: string },
516
503
  ): (request: Request) => Promise<Response> {
517
504
  return async function fetch(request: Request): Promise<Response> {
518
505
  const timestamp = Temporal.Now.instant();
@@ -534,7 +521,6 @@ function createFetchHandler(
534
521
  actorName: actorOptions.actorName,
535
522
  actorSummary: actorOptions.actorSummary,
536
523
  },
537
- requireHttpSignature: actorOptions.requireHttpSignature,
538
524
  onNotAcceptable: app.fetch.bind(app),
539
525
  onNotFound: app.fetch.bind(app),
540
526
  onUnauthorized: app.fetch.bind(app),
@@ -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}=${value}`;
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
- printMessage`${instruction}`;
90
- printMessage`Start by editing the ${federationFile} file to define your federation!
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[]) {
@@ -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 { dirname, join as joinPath } from "node:path";
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 { colors, isNotFoundError, runSubCommand } from "../utils.ts";
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
- ) => string = (pm) => `
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
- colors.bold(
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: string;
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: string;
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: "src/federation.ts",
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: "src/federation.ts",
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: "server/federation.ts",
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: "federation/index.ts",
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
- console.log(formatObject(nodeInfo, undefined, true));
115
+ print(message`${text(formatObject(nodeInfo, undefined, true))}`);
115
116
  return;
116
117
  }
117
118
  const nodeInfo = await getNodeInfo(url, {