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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43  10x       10x                       10x                         10x   10x 10x   10x     3x 27x      
import { CompressedProjectResources } from "shared/lib/resources/types";
import {
  ProjectResourcesMigration,
  applyProjectResourcesMigration,
} from "./helpers";
import {
  migrate410r1To420r1,
  migrate420r1To420r2,
  migrate420r2To420r3,
  migrate420r3To420r4,
  migrate420r4To420r5,
  migrate420r5To420r6,
  migrate420r6To420r7,
  migrate420r7To420r8,
  migrate420r8To420r9,
} from "./versions/410to420";
 
const migrations: ProjectResourcesMigration[] = [
  // 4.1.0 to 4.2.0
  migrate410r1To420r1,
  migrate420r1To420r2,
  migrate420r2To420r3,
  migrate420r3To420r4,
  migrate420r4To420r5,
  migrate420r5To420r6,
  migrate420r6To420r7,
  migrate420r7To420r8,
  migrate420r8To420r9,
];
 
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);
};