DirectoryRemote

tcmts.cli.sync.DirectoryRemote · #e7qh63yv · class

Another codebase directory on this machine.

import { Codebase } from "#codebase/tcmts/cli/codebase";
import type { LockEntry } from "#codebase/tcmts/cli/codebase";
import type { ConflictRecord } from "#codebase/tcmts/cli/merge";
import { Peer } from "#codebase/tcmts/cli/sync";
import type {
  Caller, NamespaceNode, NewContribution, Output, Remote, SharedLint, SharedResult,
} from "#codebase/tcmts/cli/sync";
import type { DefRecord } from "#codebase/tcmts/core/types";
import type { Causal, Release } from "#codebase/tcmts/store";
import path_1 from "node:path";

export class DirectoryRemote implements Remote {
  readonly label: string;
  private peer: Peer;

  constructor(dir: string) {
    this.label = dir;
    this.peer = new Peer(Codebase.find(path_1.resolve(dir)));
  }

  async missing(c: string[]) {
    return this.peer.missing(c);
  }
  async get(h: string[]) {
    return this.peer.get(h);
  }
  async put(r: DefRecord[]) {
    return this.peer.put(r);
  }
  async packages() {
    return this.peer.packages();
  }
  async putPackages(e: LockEntry[]) {
    this.peer.putPackages(e);
  }
  async branch(n: string) {
    return this.peer.branch(n);
  }
  async setBranch(
    n: string,
    head: string,
    expect: string | null,
    command: string,
    conflicts?: Record<string, ConflictRecord>,
  ) {
    this.peer.setBranch(n, head, expect, command, conflicts);
  }
  async ancestors(h: string) {
    return this.peer.ancestors(h);
  }
  async missingCausals(h: string[]) {
    return this.peer.missingCausals(h);
  }
  async getCausals(h: string[]) {
    return this.peer.getCausals(h);
  }
  async putCausals(c: Causal[]) {
    this.peer.putCausals(c);
  }
  async missingNamespaces(h: string[]) {
    return this.peer.missingNamespaces(h);
  }
  async getNamespaces(h: string[]) {
    return this.peer.getNamespaces(h);
  }
  async putNamespaces(n: NamespaceNode[]) {
    this.peer.putNamespaces(n);
  }
  async releases() {
    return this.peer.releases();
  }
  async putReleases(r: Release[]) {
    this.peer.putReleases(r);
  }
  async contributions(all: boolean) {
    return this.peer.contributions(all);
  }
  async contribution(id: number) {
    return this.peer.contribution(id);
  }
  async openContribution(c: NewContribution) {
    return this.peer.openContribution(c);
  }
  async comment(id: number, c: { author: string; body: string; about?: string | null }) {
    this.peer.comment(id, c);
  }
  async mergeContribution(id: number, author: string) {
    return this.peer.mergeContribution(id, author);
  }
  async closeContribution(id: number, author: string, reopen = false) {
    this.peer.closeContribution(id, author, reopen);
  }
  async resultKeys(h: string[]) {
    return this.peer.resultKeys(h);
  }
  async results(p: [string, string][]) {
    return this.peer.results(p);
  }
  async putResults(r: SharedResult[]) {
    this.peer.putResults(r);
  }
  async lintKeys(h: string[]) {
    return this.peer.lintKeys(h);
  }
  async lints(p: [string, string][]) {
    return this.peer.lints(p);
  }
  async putLints(l: SharedLint[]) {
    this.peer.putLints(l);
  }
  run(h: string, args: string[], out: Output) {
    return this.peer.run(h, args, out);
  }
  async whoami(): Promise<Caller> {
    return { role: "maintainer" };
  }
  async users() {
    return this.peer.users();
  }
  async addUser(handle: string) {
    return this.peer.addUser(handle);
  }
  async removeUser(handle: string) {
    return this.peer.removeUser(handle);
  }
}

uses

used by