diff --git a/deno.json b/deno.json index 047a04ad..5ae189c9 100644 --- a/deno.json +++ b/deno.json @@ -41,9 +41,9 @@ "@opentelemetry/core": "npm:@opentelemetry/core@^2.5.0", "@opentelemetry/sdk-trace-base": "npm:@opentelemetry/sdk-trace-base@^2.5.0", "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.39.0", - "@optique/config": "jsr:@optique/config@^0.10.0", - "@optique/core": "jsr:@optique/core@^0.10.0", - "@optique/run": "jsr:@optique/run@^0.10.0", + "@optique/config": "jsr:@optique/config@^0.10.1", + "@optique/core": "jsr:@optique/core@^0.10.1", + "@optique/run": "jsr:@optique/run@^0.10.1", "@std/assert": "jsr:@std/assert@^1.0.13", "@std/async": "jsr:@std/async@^1.0.13", "@std/encoding": "jsr:@std/encoding@^1.0.10", diff --git a/deno.lock b/deno.lock index 7393f5b4..84106218 100644 --- a/deno.lock +++ b/deno.lock @@ -21,9 +21,9 @@ "jsr:@logtape/logtape@2": "2.0.2", "jsr:@logtape/logtape@^1.0.4": "1.3.7", "jsr:@logtape/logtape@^2.0.2": "2.0.2", - "jsr:@optique/config@0.10": "0.10.0", - "jsr:@optique/core@0.10": "0.10.0", - "jsr:@optique/run@0.10": "0.10.0", + "jsr:@optique/config@~0.10.1": "0.10.1", + "jsr:@optique/core@~0.10.1": "0.10.1", + "jsr:@optique/run@~0.10.1": "0.10.1", "jsr:@std/assert@0.224": "0.224.0", "jsr:@std/assert@0.226": "0.226.0", "jsr:@std/assert@^1.0.13": "1.0.18", @@ -277,8 +277,8 @@ "@logtape/logtape@2.0.2": { "integrity": "546fcd514e66f2b841c6f261fa3a3d905b52d876dc1bba8ffe1a087d9275c4c9" }, - "@optique/config@0.10.0": { - "integrity": "5dde8d9fa9f247b0a0f7184dadcb75bb7a48444c53b60a0f0786230351026192", + "@optique/config@0.10.1": { + "integrity": "e3ac94f205d8f7282bdd099a571f7934cb397eb9bb8ad7f03c5f6092f07ba543", "dependencies": [ "jsr:@optique/core", "npm:@standard-schema/spec" @@ -287,11 +287,11 @@ "@optique/core@0.10.0-dev.333+076fceae": { "integrity": "1ebe1782740f08d568ae0c5258786933a8502d1e137feb49b2d8ab06d204b11a" }, - "@optique/core@0.10.0": { - "integrity": "52e7bef19b7157d99aa7d376dfbcec4b59ef8233ef8963de057c8ea0898b6028" + "@optique/core@0.10.1": { + "integrity": "d448268934d45c01e7b7dee359572b9a7b00d3965c6fb745afe4384956f2aa59" }, - "@optique/run@0.10.0": { - "integrity": "7bf5335e660879c62427d6f7d7fd92264d9260bff8f6c7700f479ab0d3779b0b", + "@optique/run@0.10.1": { + "integrity": "910daf228e62c96f119a3dd13e376cea462e31912f7f8de7df9cee7319ff2f94", "dependencies": [ "jsr:@optique/core" ] @@ -5874,9 +5874,9 @@ "jsr:@hono/hono@^4.8.3", "jsr:@logtape/file@2", "jsr:@logtape/logtape@2", - "jsr:@optique/config@0.10", - "jsr:@optique/core@0.10", - "jsr:@optique/run@0.10", + "jsr:@optique/config@~0.10.1", + "jsr:@optique/core@~0.10.1", + "jsr:@optique/run@~0.10.1", "jsr:@std/assert@^1.0.13", "jsr:@std/async@^1.0.13", "jsr:@std/encoding@^1.0.10", diff --git a/packages/cli/package.json b/packages/cli/package.json index 16ff7ad3..045ddaca 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -19,8 +19,8 @@ "test-init": "deno task test-init", "pretest:bun": "pnpm build", "test:bun": "bun test", - "run": "pnpm build && node dist/mod.js", - "runi": "tsdown && node dist/mod.js", + "run": "pnpm build && node --disable-warning=ExperimentalWarning dist/mod.js", + "runi": "tsdown && node --disable-warning=ExperimentalWarning dist/mod.js", "run:bun": "pnpm build && bun dist/mod.js", "runi:bun": "tsdown && bun dist/mod.js" }, @@ -73,6 +73,7 @@ }, "dependencies": { "@fedify/fedify": "workspace:*", + "@fedify/init": "workspace:*", "@fedify/relay": "workspace:*", "@fedify/sqlite": "workspace:*", "@fedify/vocab": "workspace:*", diff --git a/packages/cli/src/mod.ts b/packages/cli/src/mod.ts index 8100d5b0..d4c7b21c 100644 --- a/packages/cli/src/mod.ts +++ b/packages/cli/src/mod.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin/env node --disable-warning=ExperimentalWarning import { runWithConfig } from "@optique/config/run"; import { merge, message, or } from "@optique/core"; import { printError } from "@optique/run"; @@ -21,6 +21,7 @@ import { globalOptions } from "./options.ts"; import { relayCommand, runRelay } from "./relay.ts"; import { runTunnel, tunnelCommand } from "./tunnel.ts"; import { runWebFinger, webFingerCommand } from "./webfinger/mod.ts"; +import metadata from "../deno.json" with { type: "json" }; /** * Returns the system-wide configuration file paths. @@ -107,31 +108,40 @@ async function main() { mode: "both", onShow: () => process.exit(0), }, + version: { + mode: "both", + value: metadata.version, + }, + completion: { + mode: "command", + name: "both", + }, onError: () => process.exit(1), + colors: process.stdout.isTTY && + (process.env.NO_COLOR == null || process.env.NO_COLOR === ""), + maxWidth: process.stdout.columns, + showDefault: true, + showChoices: true, }); if (result.command === "init") { await runInit(result); - } - if (result.command === "lookup") { + } else if (result.command === "lookup") { await runLookup(result); - } - if (result.command === "webfinger") { + } else if (result.command === "webfinger") { await runWebFinger(result); - } - if (result.command === "inbox") { + } else if (result.command === "inbox") { runInbox(result); - } - if (result.command === "nodeinfo") { + } else if (result.command === "nodeinfo") { runNodeInfo(result); - } - if (result.command === "tunnel") { + } else if (result.command === "tunnel") { await runTunnel(result); - } - if (result.command === "generate-vocab") { + } else if (result.command === "generate-vocab") { await runGenerateVocab(result); - } - if (result.command === "relay") { + } else if (result.command === "relay") { await runRelay(result); + } else { + // Make this branch exhaustive for type safety, even though it should never happen: + const _exhaustiveCheck: never = result; } } diff --git a/packages/cli/src/options.ts b/packages/cli/src/options.ts index 96dc8dde..42ba0e59 100644 --- a/packages/cli/src/options.ts +++ b/packages/cli/src/options.ts @@ -87,7 +87,7 @@ export function createTunnelOption(section: S) { }); } -export const debugOption = object("Global options", { +export const debugOption = object({ debug: bindConfig( option("-d", "--debug", { description: message`Enable debug mode.`, diff --git a/packages/init/src/command.ts b/packages/init/src/command.ts index 020b2552..93569a53 100644 --- a/packages/init/src/command.ts +++ b/packages/init/src/command.ts @@ -56,12 +56,6 @@ const messageQueue = optional(option( }, )); -const debugOption = object("Global options", { - debug: option("-d", "--debug", { - description: message`Enable debug mode.`, - }), -}); - export const initOptions = object("Initialization options", { dir: optional(argument(path({ metavar: "DIR" }), { description: @@ -74,7 +68,6 @@ export const initOptions = object("Initialization options", { dryRun: option("--dry-run", { description: message`Perform a trial run with no changes made.`, }), - debugOption, }); export const initCommand = command( @@ -117,7 +110,6 @@ export const testInitCommand = command( packageManager: multiple(packageManager), kvStore: multiple(kvStore), messageQueue: multiple(messageQueue), - debugOption, }), optional(or(noHydRun, noDryRun)), ), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b378c7ff..16f4caa0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,14 +49,14 @@ catalogs: specifier: ^1.39.0 version: 1.39.0 '@optique/config': - specifier: ^0.10.0 - version: 0.10.0 + specifier: ^0.10.1 + version: 0.10.1 '@optique/core': - specifier: ^0.10.0 - version: 0.10.0 + specifier: ^0.10.1 + version: 0.10.1 '@optique/run': - specifier: ^0.10.0 - version: 0.10.0 + specifier: ^0.10.1 + version: 0.10.1 '@std/assert': specifier: jsr:^1.0.13 version: 1.0.13 @@ -750,6 +750,9 @@ importers: '@fedify/fedify': specifier: workspace:* version: link:../fedify + '@fedify/init': + specifier: workspace:* + version: link:../init '@fedify/relay': specifier: workspace:* version: link:../relay @@ -794,13 +797,13 @@ importers: version: 2.0.0 '@optique/config': specifier: 'catalog:' - version: 0.10.0(@standard-schema/spec@1.0.0) + version: 0.10.1(@standard-schema/spec@1.0.0) '@optique/core': specifier: 'catalog:' - version: 0.10.0 + version: 0.10.1 '@optique/run': specifier: 'catalog:' - version: 0.10.0 + version: 0.10.1 '@poppanator/http-constants': specifier: ^1.1.1 version: 1.1.1 @@ -876,10 +879,10 @@ importers: version: link:../init '@optique/core': specifier: 'catalog:' - version: 0.10.0 + version: 0.10.1 '@optique/run': specifier: 'catalog:' - version: 0.10.0 + version: 0.10.1 es-toolkit: specifier: 'catalog:' version: 1.43.0 @@ -1155,10 +1158,10 @@ importers: version: 2.0.0 '@optique/core': specifier: 'catalog:' - version: 0.10.0 + version: 0.10.1 '@optique/run': specifier: 'catalog:' - version: 0.10.0 + version: 0.10.1 chalk: specifier: 'catalog:' version: 5.6.2 @@ -3665,18 +3668,18 @@ packages: peerDependencies: '@opentelemetry/api': ^1.1.0 - '@optique/config@0.10.0': - resolution: {integrity: sha512-3lGlNrZjouFyLbhDL0Q6cEVrsDhaKDNG74Ti5JSRHMoK7xJgtWiSFwY+ArfdSfpHptPQGTbpNW7oTH2dItM/rg==} + '@optique/config@0.10.1': + resolution: {integrity: sha512-ncbIqlI4vbtYkMOKKF8NJSL7ZhrJTxAhp22Q7rJ/dI3pwPP13s03gIszVdgIecnVV4JuHuiayPAW3Ii+kREvwg==} engines: {bun: '>=1.2.0', deno: '>=2.3.0', node: '>=20.0.0'} peerDependencies: '@standard-schema/spec': ^1.1.0 - '@optique/core@0.10.0': - resolution: {integrity: sha512-PdQUfZdMCUa3mD8DWeGCV3JrD7CAvdiUP9P7JyIbgCEtQznhJ6gBWff0WGq/LRv7QDvyYbIjIvAY159GLHZ4IQ==} + '@optique/core@0.10.1': + resolution: {integrity: sha512-AGe6Si5saE9x9z6Po13+9ZAZEymIU5Wv3ImOJ9Lz0SSnlRTIwc3q/62U1lb08Kk2vblDJiX7Of6n09OYRQNLNw==} engines: {bun: '>=1.2.0', deno: '>=2.3.0', node: '>=20.0.0'} - '@optique/run@0.10.0': - resolution: {integrity: sha512-9/mB6qb8D1Gdut5xpC3AfLHqzS7Zq4B0bh/WpjU1R0RQPPBqS8vCGxt+hbuXYlmEQXAH8BMZSAGTXX/WqmRxtw==} + '@optique/run@0.10.1': + resolution: {integrity: sha512-3KhxiFiYQz5Jf4g50vliEdViMBaXx6JdV3ujtzpy6P69Y0O70b5pcBpXOh4uOxbfEKKnUt2kRVn56SS3wberog==} engines: {bun: '>=1.2.0', deno: '>=2.3.0', node: '>=20.0.0'} '@oxc-project/runtime@0.75.0': @@ -11213,16 +11216,16 @@ snapshots: '@opentelemetry/api': 1.9.0 '@opentelemetry/core': 1.30.1(@opentelemetry/api@1.9.0) - '@optique/config@0.10.0(@standard-schema/spec@1.0.0)': + '@optique/config@0.10.1(@standard-schema/spec@1.0.0)': dependencies: - '@optique/core': 0.10.0 + '@optique/core': 0.10.1 '@standard-schema/spec': 1.0.0 - '@optique/core@0.10.0': {} + '@optique/core@0.10.1': {} - '@optique/run@0.10.0': + '@optique/run@0.10.1': dependencies: - '@optique/core': 0.10.0 + '@optique/core': 0.10.1 '@oxc-project/runtime@0.75.0': {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 09118c22..7f8335b5 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -51,9 +51,9 @@ catalog: "@opentelemetry/sdk-node": ^0.211.0 "@opentelemetry/sdk-trace-base": ^2.5.0 "@opentelemetry/semantic-conventions": ^1.39.0 - "@optique/config": ^0.10.0 - "@optique/core": ^0.10.0 - "@optique/run": ^0.10.0 + "@optique/config": ^0.10.1 + "@optique/core": ^0.10.1 + "@optique/run": ^0.10.1 "@std/assert": "jsr:^1.0.13" "@std/async": "jsr:^1.0.13" "@std/path": "jsr:^1.0.6"