Skip to content

Commit

Permalink
fix migration
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-vorobiov committed Oct 1, 2024
1 parent 3f82615 commit 957cb87
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion evolve_analytics.meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Evolve Analytics
// @namespace http://tampermonkey.net/
// @version 0.6.1
// @version 0.6.2
// @description Track and see detailed information about your runs
// @author Sneed
// @match https://pmotschmann.github.io/Evolve/
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ export class ConfigManager extends Subscribable {
}

export function getConfig(game: Game) {
const config = loadConfig() ?? { version: 5, recordRuns: false, views: [] };
const config = loadConfig() ?? { version: 6, recordRuns: true, views: [] };
return new ConfigManager(game, config);
}
6 changes: 3 additions & 3 deletions src/migration/4.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { resets, universes, viewModes } from "../enums";
import type { Config as Config5 } from "../config";
import type { Config as Config6 } from "../config";

export type ViewConfig4 = {
resetType: keyof typeof resets,
Expand All @@ -16,9 +16,9 @@ export type Config4 = {
views: ViewConfig4[]
}

export function migrate4(config: Config4): Config5 {
export function migrate4(config: Config4): Config6 {
return {
version: 5,
version: 6,
recordRuns: config.recordRuns ?? true,
views: config.views.map(view => {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/migration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function migrate() {
migrated = true;
}

if (config.version < 5) {
if (config.version < 6) {
config = migrate4(config);
migrated = true;
}
Expand Down
4 changes: 2 additions & 2 deletions test/migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("Migration", () => {
migrate();

expect(loadConfig()).toEqual({
version: 5,
version: 6,
recordRuns: true,
views: [
{
Expand Down Expand Up @@ -171,7 +171,7 @@ describe("Migration", () => {
migrate();

expect(loadConfig()).toEqual({
version: 5,
version: 6,
recordRuns: true,
views: []
});
Expand Down
6 changes: 3 additions & 3 deletions test/migration4.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { describe, expect, it } from "@jest/globals";
import { migrate4 } from "../src/migration/4";

describe("Migration", () => {
describe("4 -> 5", () => {
describe("4 -> 6", () => {
it("should force the recordRuns field", () => {
const oldConfig = {
version: 4,
views: []
};

expect(migrate4(oldConfig as any)).toEqual({
version: 5,
version: 6,
recordRuns: true,
views: []
});
Expand All @@ -30,7 +30,7 @@ describe("Migration", () => {
};

expect(migrate4(oldConfig as any)).toEqual({
version: 5,
version: 6,
recordRuns: true,
views: [
{
Expand Down

0 comments on commit 957cb87

Please sign in to comment.