All files / src/lib/project/migration migrateProjectResources.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  8x       8x   8x           8x   8x 8x   8x     3x 6x      
import { CompressedProjectResources } from "shared/lib/resources/types";
import {
  ProjectResourcesMigration,
  applyProjectResourcesMigration,
} from "./helpers";
import { migrate410r1To420r1, migrate420r1To420r2 } from "./versions/410to420";
 
const migrations: ProjectResourcesMigration[] = [
  // 4.1.0 to 4.2.0
  migrate410r1To420r1,
  migrate420r1To420r2,
];
 
const lastMigration = migrations[migrations.length - 1];
 
export const LATEST_PROJECT_VERSION = lastMigration.to.version;
export const LATEST_PROJECT_MINOR_VERSION = lastMigration.to.release;
 
export const migrateProjectResources = async (
  resources: CompressedProjectResources
): Promise<CompressedProjectResources> => {
  return migrations.reduce((migratedResources, migration) => {
    return applyProjectResourcesMigration(migratedResources, migration);
  }, resources);
};