migrateCopy

tcmts.cli.migrate.migrateCopy · #6ruownco · term · runs on the server

uses tcmts.cli.migrate.formatsOf, which uses node:sqlite

Make a codebase copied from elsewhere readable by this tcm (one a package ships, or suites packed: the tcm that made it may be older, as when a new layout's tcm is packed by the last one): in an older table layout or hash format, the copy is migrated in place. It's a copy, so nothing of it is kept as it was.

import { formatsOf, layoutOf, migrateFile } from "#codebase/tcmts/cli/migrate";
import { IR_VERSION } from "#codebase/tcmts/core/hash";
import { LAYOUT } from "#codebase/tcmts/store";

export function migrateCopy(file: string) {
  if (formatsOf(file).every((v) => v === IR_VERSION) && (layoutOf(file) ?? LAYOUT) === LAYOUT)
    return;
  migrateFile(file);
}

uses

used by