announceRelease

tcmts.studio.announceRelease · #hhaxyif3 · term · runs on the server

uses tcmts.studio.editableCodebase, which uses tcmts.share.servedCodebase, which uses process

Announce release version of name on the AT Protocol, as tcm release <name>@<version> --announce does (it's run: signed in in the browser the first time, which opens there, or kept from before), as as (a handle; else the account used last) and fetched from source (else what's kept, or origin): what it said.

import { HttpError } from "#codebase/tcmts/server";
import { editableCodebase, runTcm } from "#codebase/tcmts/studio";

export async function announceRelease(
  name: string,
  version: string,
  as: string,
  source: string,
): Promise<string> {
  const cb = editableCodebase();
  if (cb.store.branch().name !== "main")
    throw new HttpError(409, "Releases are announced from main.");
  if (!cb.store.releases(name).some((r) => r.version === version))
    throw new HttpError(404, `${name} ${version} isn't released.`);
  const out = await runTcm(cb.lay.root, [
    "release",
    `${name}@${version}`,
    "--announce",
    ...(as.trim() ? ["--as", as.trim()] : []),
    ...(source.trim() ? ["--source", source.trim()] : []),
  ]);
  if (out.code !== 0)
    throw new HttpError(400, out.text.split("\n").slice(0, 8).join("\n") || "the announce failed");
  return (
    out.text
      .split("\n")
      .filter((l) => /announced|doesn't have it/.test(l))
      .join("\n") || out.text.split("\n")[0]!
  );
}

uses

used by