announceAndTell
uses tcmts.cli.style.bold, which uses node:util
Announce a release of this codebase as the signed-in account, fetched from sources, and say so: where the
record is, and which sources don't have the release yet (it's announced anyway; a push sends it).
import type { OAuthSession } from "#codebase/tcmts/atproto"; import { announceRelease, releaseRecord } from "#codebase/tcmts/cli/announce"; import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { bold, dim, green } from "#codebase/tcmts/cli/style"; import { openRemote } from "#codebase/tcmts/cli/sync"; import type { Release } from "#codebase/tcmts/store"; export async function announceAndTell( cb: Codebase, rel: Release, o: { sources: string[]; session: OAuthSession }, ): Promise<void> { const record = await releaseRecord(cb, rel, o.sources); const { uri, was } = await announceRelease(o.session, record); const who = o.session.handle ? `@${o.session.handle}` : o.session.did; const what = bold(`${rel.package}@${rel.version}`); console.log( was === "same" ? `${what} is already announced as ${who}, as it is: ${uri}` : `${green(was === "new" ? "announced" : "announced again")} ${what} as ${who}${was === "updated" ? " (with its sources now)" : ""}: ${uri}`, ); console.log(dim(` fetched from ${o.sources.join(", ")}`)); for (const s of o.sources) { const why = await openRemote(cb, s) .remote.missingNamespaces([record.namespace]) .then((missing) => (missing.length ? "doesn't have it yet: `tcm push` sends it" : undefined)) .catch( (e: unknown) => `didn't answer (${(e as Error).message.split("\n")[0]}): people can't fetch it from there`, ); if (why) console.log(dim(` ${s} ${why}`)); } }
uses
- tcmts.atproto.OAuthSession
- tcmts.cli.announce.announceRelease
- tcmts.cli.announce.releaseRecord
- tcmts.cli.codebase.Codebase
- tcmts.cli.style.bold
- tcmts.cli.style.dim
- tcmts.cli.style.green
- tcmts.cli.sync.openRemote
- tcmts.store.Release