cmd-sync-servers - v1.0.0
    Preparing search index...

    Class SiteRegistry

    The master list of sites in sites.json, shared by the CLI and the VS Code extension. Every write takes the lock file, re-reads the file so another process's change is never lost, validates the result, keeps the previous version as sites.json.bak, and replaces the file atomically. A file that fails validation is never rewritten.

    Index
    • get lastSelectedSiteId(): string | undefined

      The site last chosen in either front end, when it still exists.

      Returns string | undefined

    • Adds a site and returns it as stored. Its first server becomes the Remote server unless remoteServerId says otherwise.

      Parameters

      Returns Promise<
          {
              cloaking: {
                  enabled: boolean;
                  paths: string[];
                  patterns: string[];
                  useGlobalPatterns?: boolean;
              };
              id: string;
              local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
              localRoot: string;
              name: string;
              remoteServerId?: string;
              servers: {
                  auth?: {
                      keyPath?: string;
                      method: "password" | "key" | "agent";
                      savePassword: boolean;
                  };
                  host?: string;
                  id: string;
                  name: string;
                  options: {
                      allowInsecure?: boolean;
                      allowRootDeletes?: boolean;
                      hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                      ipFamily?: 4 | 6;
                      legacyAlgorithms?: boolean;
                      passive: boolean;
                      remoteDirMode?: string;
                      remoteFileMode?: string;
                      timeoutSeconds: number;
                      tls?: {
                          caFile?: string;
                          minVersion: "TLSv1.2" | "TLSv1.3";
                          servername?: string;
                          trustedCertificate?: {
                              pinnedAt: string;
                              sha256: string;
                              validTo: string;
                          };
                      };
                      uploadOnSave: boolean;
                  };
                  port?: number;
                  protocol: "sftp"
                  | "ftps"
                  | "ftps-implicit"
                  | "ftp"
                  | "local";
                  remoteRoot: string;
                  username?: string;
                  webUrl?: string;
              }[];
              sync: {
                  compare: "metadata"
                  | "checksum";
                  concurrency: number;
                  guard: { enabled: boolean; patterns: string[] };
                  maintainInfo: boolean;
                  massDelete: { maxCount: number; maxPercent: number };
                  mtimeToleranceSeconds: number;
                  recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
                  symlinks: "skip" | "follow-inside-root" | "follow";
              };
              testingServerId?: string;
          },
      >

      SyncError E_CONFIG_INVALID when the site is not valid or its name is taken.

    • Adds a server to a site. The first server of a site becomes its Remote server.

      Parameters

      Returns Promise<
          {
              auth?: {
                  keyPath?: string;
                  method: "password"
                  | "key"
                  | "agent";
                  savePassword: boolean;
              };
              host?: string;
              id: string;
              name: string;
              options: {
                  allowInsecure?: boolean;
                  allowRootDeletes?: boolean;
                  hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                  ipFamily?: 4 | 6;
                  legacyAlgorithms?: boolean;
                  passive: boolean;
                  remoteDirMode?: string;
                  remoteFileMode?: string;
                  timeoutSeconds: number;
                  tls?: {
                      caFile?: string;
                      minVersion: "TLSv1.2" | "TLSv1.3";
                      servername?: string;
                      trustedCertificate?: {
                          pinnedAt: string;
                          sha256: string;
                          validTo: string;
                      };
                  };
                  uploadOnSave: boolean;
              };
              port?: number;
              protocol: "sftp"
              | "ftps"
              | "ftps-implicit"
              | "ftp"
              | "local";
              remoteRoot: string;
              username?: string;
              webUrl?: string;
          },
      >

    • The site with this id, as a copy that can be changed freely.

      Parameters

      • siteId: string

      Returns
          | {
              cloaking: {
                  enabled: boolean;
                  paths: string[];
                  patterns: string[];
                  useGlobalPatterns?: boolean;
              };
              id: string;
              local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
              localRoot: string;
              name: string;
              remoteServerId?: string;
              servers: {
                  auth?: {
                      keyPath?: string;
                      method: "password" | "key" | "agent";
                      savePassword: boolean;
                  };
                  host?: string;
                  id: string;
                  name: string;
                  options: {
                      allowInsecure?: boolean;
                      allowRootDeletes?: boolean;
                      hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                      ipFamily?: 4 | 6;
                      legacyAlgorithms?: boolean;
                      passive: boolean;
                      remoteDirMode?: string;
                      remoteFileMode?: string;
                      timeoutSeconds: number;
                      tls?: {
                          caFile?: string;
                          minVersion: "TLSv1.2" | "TLSv1.3";
                          servername?: string;
                          trustedCertificate?: {
                              pinnedAt: string;
                              sha256: string;
                              validTo: string;
                          };
                      };
                      uploadOnSave: boolean;
                  };
                  port?: number;
                  protocol: "sftp"
                  | "ftps"
                  | "ftps-implicit"
                  | "ftp"
                  | "local";
                  remoteRoot: string;
                  username?: string;
                  webUrl?: string;
              }[];
              sync: {
                  compare: "metadata"
                  | "checksum";
                  concurrency: number;
                  guard: { enabled: boolean; patterns: string[] };
                  maintainInfo: boolean;
                  massDelete: { maxCount: number; maxPercent: number };
                  mtimeToleranceSeconds: number;
                  recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
                  symlinks: "skip" | "follow-inside-root" | "follow";
              };
              testingServerId?: string;
          }
          | undefined

    • Every site, in the order they were added.

      Returns {
          cloaking: {
              enabled: boolean;
              paths: string[];
              patterns: string[];
              useGlobalPatterns?: boolean;
          };
          id: string;
          local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
          localRoot: string;
          name: string;
          remoteServerId?: string;
          servers: {
              auth?: {
                  keyPath?: string;
                  method: "password" | "key" | "agent";
                  savePassword: boolean;
              };
              host?: string;
              id: string;
              name: string;
              options: {
                  allowInsecure?: boolean;
                  allowRootDeletes?: boolean;
                  hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                  ipFamily?: 4 | 6;
                  legacyAlgorithms?: boolean;
                  passive: boolean;
                  remoteDirMode?: string;
                  remoteFileMode?: string;
                  timeoutSeconds: number;
                  tls?: {
                      caFile?: string;
                      minVersion: "TLSv1.2" | "TLSv1.3";
                      servername?: string;
                      trustedCertificate?: {
                          pinnedAt: string;
                          sha256: string;
                          validTo: string;
                      };
                  };
                  uploadOnSave: boolean;
              };
              port?: number;
              protocol: "sftp"
              | "ftps"
              | "ftps-implicit"
              | "ftp"
              | "local";
              remoteRoot: string;
              username?: string;
              webUrl?: string;
          }[];
          sync: {
              compare: "metadata"
              | "checksum";
              concurrency: number;
              guard: { enabled: boolean; patterns: string[] };
              maintainInfo: boolean;
              massDelete: { maxCount: number; maxPercent: number };
              mtimeToleranceSeconds: number;
              recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
              symlinks: "skip" | "follow-inside-root" | "follow";
          };
          testingServerId?: string;
      }[]

    • Reads sites.json again, for example after another process changed it.

      Returns Promise<void>

    • Removes a site from the list and returns it. Its local folder, its servers' files, its saved secrets and its sync records are not touched.

      Parameters

      • siteId: string

      Returns Promise<
          {
              cloaking: {
                  enabled: boolean;
                  paths: string[];
                  patterns: string[];
                  useGlobalPatterns?: boolean;
              };
              id: string;
              local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
              localRoot: string;
              name: string;
              remoteServerId?: string;
              servers: {
                  auth?: {
                      keyPath?: string;
                      method: "password" | "key" | "agent";
                      savePassword: boolean;
                  };
                  host?: string;
                  id: string;
                  name: string;
                  options: {
                      allowInsecure?: boolean;
                      allowRootDeletes?: boolean;
                      hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                      ipFamily?: 4 | 6;
                      legacyAlgorithms?: boolean;
                      passive: boolean;
                      remoteDirMode?: string;
                      remoteFileMode?: string;
                      timeoutSeconds: number;
                      tls?: {
                          caFile?: string;
                          minVersion: "TLSv1.2" | "TLSv1.3";
                          servername?: string;
                          trustedCertificate?: {
                              pinnedAt: string;
                              sha256: string;
                              validTo: string;
                          };
                      };
                      uploadOnSave: boolean;
                  };
                  port?: number;
                  protocol: "sftp"
                  | "ftps"
                  | "ftps-implicit"
                  | "ftp"
                  | "local";
                  remoteRoot: string;
                  username?: string;
                  webUrl?: string;
              }[];
              sync: {
                  compare: "metadata"
                  | "checksum";
                  concurrency: number;
                  guard: { enabled: boolean; patterns: string[] };
                  maintainInfo: boolean;
                  massDelete: { maxCount: number; maxPercent: number };
                  mtimeToleranceSeconds: number;
                  recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
                  symlinks: "skip" | "follow-inside-root" | "follow";
              };
              testingServerId?: string;
          },
      >

    • Removes a server and clears any role it held.

      Parameters

      • siteId: string
      • serverId: string

      Returns Promise<
          {
              auth?: {
                  keyPath?: string;
                  method: "password"
                  | "key"
                  | "agent";
                  savePassword: boolean;
              };
              host?: string;
              id: string;
              name: string;
              options: {
                  allowInsecure?: boolean;
                  allowRootDeletes?: boolean;
                  hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                  ipFamily?: 4 | 6;
                  legacyAlgorithms?: boolean;
                  passive: boolean;
                  remoteDirMode?: string;
                  remoteFileMode?: string;
                  timeoutSeconds: number;
                  tls?: {
                      caFile?: string;
                      minVersion: "TLSv1.2" | "TLSv1.3";
                      servername?: string;
                      trustedCertificate?: {
                          pinnedAt: string;
                          sha256: string;
                          validTo: string;
                      };
                  };
                  uploadOnSave: boolean;
              };
              port?: number;
              protocol: "sftp"
              | "ftps"
              | "ftps-implicit"
              | "ftp"
              | "local";
              remoteRoot: string;
              username?: string;
              webUrl?: string;
          },
      >

    • Replaces a site with next, as edited in an editor. The id cannot change.

      Parameters

      • siteId: string
      • next: unknown

      Returns Promise<
          {
              cloaking: {
                  enabled: boolean;
                  paths: string[];
                  patterns: string[];
                  useGlobalPatterns?: boolean;
              };
              id: string;
              local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
              localRoot: string;
              name: string;
              remoteServerId?: string;
              servers: {
                  auth?: {
                      keyPath?: string;
                      method: "password" | "key" | "agent";
                      savePassword: boolean;
                  };
                  host?: string;
                  id: string;
                  name: string;
                  options: {
                      allowInsecure?: boolean;
                      allowRootDeletes?: boolean;
                      hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                      ipFamily?: 4 | 6;
                      legacyAlgorithms?: boolean;
                      passive: boolean;
                      remoteDirMode?: string;
                      remoteFileMode?: string;
                      timeoutSeconds: number;
                      tls?: {
                          caFile?: string;
                          minVersion: "TLSv1.2" | "TLSv1.3";
                          servername?: string;
                          trustedCertificate?: {
                              pinnedAt: string;
                              sha256: string;
                              validTo: string;
                          };
                      };
                      uploadOnSave: boolean;
                  };
                  port?: number;
                  protocol: "sftp"
                  | "ftps"
                  | "ftps-implicit"
                  | "ftp"
                  | "local";
                  remoteRoot: string;
                  username?: string;
                  webUrl?: string;
              }[];
              sync: {
                  compare: "metadata"
                  | "checksum";
                  concurrency: number;
                  guard: { enabled: boolean; patterns: string[] };
                  maintainInfo: boolean;
                  massDelete: { maxCount: number; maxPercent: number };
                  mtimeToleranceSeconds: number;
                  recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
                  symlinks: "skip" | "follow-inside-root" | "follow";
              };
              testingServerId?: string;
          },
      >

    • Replaces a server with next, as edited in an editor. The id cannot change.

      Parameters

      • siteId: string
      • serverId: string
      • next: unknown

      Returns Promise<
          {
              auth?: {
                  keyPath?: string;
                  method: "password"
                  | "key"
                  | "agent";
                  savePassword: boolean;
              };
              host?: string;
              id: string;
              name: string;
              options: {
                  allowInsecure?: boolean;
                  allowRootDeletes?: boolean;
                  hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                  ipFamily?: 4 | 6;
                  legacyAlgorithms?: boolean;
                  passive: boolean;
                  remoteDirMode?: string;
                  remoteFileMode?: string;
                  timeoutSeconds: number;
                  tls?: {
                      caFile?: string;
                      minVersion: "TLSv1.2" | "TLSv1.3";
                      servername?: string;
                      trustedCertificate?: {
                          pinnedAt: string;
                          sha256: string;
                          validTo: string;
                      };
                  };
                  uploadOnSave: boolean;
              };
              port?: number;
              protocol: "sftp"
              | "ftps"
              | "ftps-implicit"
              | "ftp"
              | "local";
              remoteRoot: string;
              username?: string;
              webUrl?: string;
          },
      >

    • Finds a site by id, by name ignoring case, or by a path inside its local root, where the deepest local root wins.

      Parameters

      Returns
          | {
              cloaking: {
                  enabled: boolean;
                  paths: string[];
                  patterns: string[];
                  useGlobalPatterns?: boolean;
              };
              id: string;
              local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
              localRoot: string;
              name: string;
              remoteServerId?: string;
              servers: {
                  auth?: {
                      keyPath?: string;
                      method: "password" | "key" | "agent";
                      savePassword: boolean;
                  };
                  host?: string;
                  id: string;
                  name: string;
                  options: {
                      allowInsecure?: boolean;
                      allowRootDeletes?: boolean;
                      hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                      ipFamily?: 4 | 6;
                      legacyAlgorithms?: boolean;
                      passive: boolean;
                      remoteDirMode?: string;
                      remoteFileMode?: string;
                      timeoutSeconds: number;
                      tls?: {
                          caFile?: string;
                          minVersion: "TLSv1.2" | "TLSv1.3";
                          servername?: string;
                          trustedCertificate?: {
                              pinnedAt: string;
                              sha256: string;
                              validTo: string;
                          };
                      };
                      uploadOnSave: boolean;
                  };
                  port?: number;
                  protocol: "sftp"
                  | "ftps"
                  | "ftps-implicit"
                  | "ftp"
                  | "local";
                  remoteRoot: string;
                  username?: string;
                  webUrl?: string;
              }[];
              sync: {
                  compare: "metadata"
                  | "checksum";
                  concurrency: number;
                  guard: { enabled: boolean; patterns: string[] };
                  maintainInfo: boolean;
                  massDelete: { maxCount: number; maxPercent: number };
                  mtimeToleranceSeconds: number;
                  recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
                  symlinks: "skip" | "follow-inside-root" | "follow";
              };
              testingServerId?: string;
          }
          | undefined

    • Records the site last chosen, so either front end can open on it; undefined clears it.

      Parameters

      • siteId: string | undefined

      Returns Promise<void>

    • Changes a site in place. change may edit any field except id.

      Parameters

      • siteId: string
      • change: (
            site: {
                cloaking: {
                    enabled: boolean;
                    paths: string[];
                    patterns: string[];
                    useGlobalPatterns?: boolean;
                };
                id: string;
                local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
                localRoot: string;
                name: string;
                remoteServerId?: string;
                servers: {
                    auth?: {
                        keyPath?: string;
                        method: "password" | "key" | "agent";
                        savePassword: boolean;
                    };
                    host?: string;
                    id: string;
                    name: string;
                    options: {
                        allowInsecure?: boolean;
                        allowRootDeletes?: boolean;
                        hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                        ipFamily?: 4 | 6;
                        legacyAlgorithms?: boolean;
                        passive: boolean;
                        remoteDirMode?: string;
                        remoteFileMode?: string;
                        timeoutSeconds: number;
                        tls?: {
                            caFile?: string;
                            minVersion: "TLSv1.2" | "TLSv1.3";
                            servername?: string;
                            trustedCertificate?: {
                                pinnedAt: string;
                                sha256: string;
                                validTo: string;
                            };
                        };
                        uploadOnSave: boolean;
                    };
                    port?: number;
                    protocol: "sftp"
                    | "ftps"
                    | "ftps-implicit"
                    | "ftp"
                    | "local";
                    remoteRoot: string;
                    username?: string;
                    webUrl?: string;
                }[];
                sync: {
                    compare: "metadata"
                    | "checksum";
                    concurrency: number;
                    guard: { enabled: boolean; patterns: string[] };
                    maintainInfo: boolean;
                    massDelete: { maxCount: number; maxPercent: number };
                    mtimeToleranceSeconds: number;
                    recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
                    symlinks: "skip" | "follow-inside-root" | "follow";
                };
                testingServerId?: string;
            },
        ) => void

      Returns Promise<
          {
              cloaking: {
                  enabled: boolean;
                  paths: string[];
                  patterns: string[];
                  useGlobalPatterns?: boolean;
              };
              id: string;
              local: { cache: boolean; caseSensitive?: boolean; webUrl?: string };
              localRoot: string;
              name: string;
              remoteServerId?: string;
              servers: {
                  auth?: {
                      keyPath?: string;
                      method: "password" | "key" | "agent";
                      savePassword: boolean;
                  };
                  host?: string;
                  id: string;
                  name: string;
                  options: {
                      allowInsecure?: boolean;
                      allowRootDeletes?: boolean;
                      hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                      ipFamily?: 4 | 6;
                      legacyAlgorithms?: boolean;
                      passive: boolean;
                      remoteDirMode?: string;
                      remoteFileMode?: string;
                      timeoutSeconds: number;
                      tls?: {
                          caFile?: string;
                          minVersion: "TLSv1.2" | "TLSv1.3";
                          servername?: string;
                          trustedCertificate?: {
                              pinnedAt: string;
                              sha256: string;
                              validTo: string;
                          };
                      };
                      uploadOnSave: boolean;
                  };
                  port?: number;
                  protocol: "sftp"
                  | "ftps"
                  | "ftps-implicit"
                  | "ftp"
                  | "local";
                  remoteRoot: string;
                  username?: string;
                  webUrl?: string;
              }[];
              sync: {
                  compare: "metadata"
                  | "checksum";
                  concurrency: number;
                  guard: { enabled: boolean; patterns: string[] };
                  maintainInfo: boolean;
                  massDelete: { maxCount: number; maxPercent: number };
                  mtimeToleranceSeconds: number;
                  recovery: { enabled: boolean; keepDays: number; maxMegabytes: number };
                  symlinks: "skip" | "follow-inside-root" | "follow";
              };
              testingServerId?: string;
          },
      >

    • Changes a server in place. change may edit any field except id.

      Parameters

      • siteId: string
      • serverId: string
      • change: (
            server: {
                auth?: {
                    keyPath?: string;
                    method: "password" | "key" | "agent";
                    savePassword: boolean;
                };
                host?: string;
                id: string;
                name: string;
                options: {
                    allowInsecure?: boolean;
                    allowRootDeletes?: boolean;
                    hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                    ipFamily?: 4 | 6;
                    legacyAlgorithms?: boolean;
                    passive: boolean;
                    remoteDirMode?: string;
                    remoteFileMode?: string;
                    timeoutSeconds: number;
                    tls?: {
                        caFile?: string;
                        minVersion: "TLSv1.2" | "TLSv1.3";
                        servername?: string;
                        trustedCertificate?: {
                            pinnedAt: string;
                            sha256: string;
                            validTo: string;
                        };
                    };
                    uploadOnSave: boolean;
                };
                port?: number;
                protocol: "sftp"
                | "ftps"
                | "ftps-implicit"
                | "ftp"
                | "local";
                remoteRoot: string;
                username?: string;
                webUrl?: string;
            },
        ) => void

      Returns Promise<
          {
              auth?: {
                  keyPath?: string;
                  method: "password"
                  | "key"
                  | "agent";
                  savePassword: boolean;
              };
              host?: string;
              id: string;
              name: string;
              options: {
                  allowInsecure?: boolean;
                  allowRootDeletes?: boolean;
                  hostKey?: { algorithm: string; pinnedAt: string; sha256: string };
                  ipFamily?: 4 | 6;
                  legacyAlgorithms?: boolean;
                  passive: boolean;
                  remoteDirMode?: string;
                  remoteFileMode?: string;
                  timeoutSeconds: number;
                  tls?: {
                      caFile?: string;
                      minVersion: "TLSv1.2" | "TLSv1.3";
                      servername?: string;
                      trustedCertificate?: {
                          pinnedAt: string;
                          sha256: string;
                          validTo: string;
                      };
                  };
                  uploadOnSave: boolean;
              };
              port?: number;
              protocol: "sftp"
              | "ftps"
              | "ftps-implicit"
              | "ftp"
              | "local";
              remoteRoot: string;
              username?: string;
              webUrl?: string;
          },
      >