deployServer

tcmts.dev.deployServer · #2kkqgv7r · term · runs on the server

uses node:path

Deploy tcm's server, tcm.codes: tcm serve of tcm's codebase, and its site, on Railway. What's uploaded is the server's files (tcmts.deploy.server, with the site's home page), the known-good tcm's package and the docs site built from the codebase, under /docs, to the tcm-server service of the Railway project the repository is linked to (railway link). pnpm server:deploy.

import { buildSite, deployStage, knownGood, railwayProject, railwayUp } from "#codebase/tcmts/dev";
import fs from "node:fs";
import path from "node:path";

export async function deployServer(): Promise<void> {
  const known = knownGood();
  const linked = railwayProject();
  const stage = deployStage("tcmts.deploy.server", known);
  const site = await buildSite(path.join(stage, "site", "docs"), { large: true, base: "/docs" });
  if (site.problems.length) throw new Error(`docs site:\n${site.problems.join("\n")}`);
  // and the tcm it runs, for anyone to get (a checkout's `pnpm tcm` gets it from there, the first time)
  fs.copyFileSync(path.join(known.good, known.tgz), path.join(stage, "site", "tcm-ts.tgz"));
  railwayUp(stage, "tcm-server", linked, known.good);
}

uses