diff --git a/common/constants.ts b/common/constants.ts index c226ab5f..fca8f8af 100644 --- a/common/constants.ts +++ b/common/constants.ts @@ -1,3 +1,6 @@ +import packageJson from '../package.json'; + +export const VERSION = packageJson.version; export const DEFAULT_STYLE = { font: 'Pretendard JP Variable', fontWeight: '400', @@ -105,6 +108,9 @@ export const DEFAULT_CONFIG = { config: {}, }, + __internal__: { + version: VERSION, + }, }; export const PRESET_PREFIX = '__preset__'; diff --git a/src/config/index.ts b/src/config/index.ts index 476eff69..e75021f0 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -9,10 +9,9 @@ import { createMigrator, migrateTable } from './migration'; import { State } from './state'; +import { VERSION } from '../../common/constants'; import { ConfigSchema, GameListSchema, LyricMapperSchema, ThemeListSchema } from '../../common/schema'; -import packageJson from '../../package.json'; - let resolver: () => void = () => null; const init = { config: 0, @@ -52,7 +51,7 @@ const tryMigration = () => { if (isLoaded) { const internalConfig = config.get()['__internal__']; const prevVersion = typeof internalConfig?.version === 'string' ? internalConfig.version : '0.0.0'; - const nowVersion = packageJson.version; + const nowVersion = VERSION; console.log('[Alspotron] prepare for migration', prevVersion, '->', nowVersion); const migrator = createMigrator(migrateTable, prevVersion); diff --git a/src/config/migration/runner.ts b/src/config/migration/runner.ts index 6c679e4f..54d5c909 100644 --- a/src/config/migration/runner.ts +++ b/src/config/migration/runner.ts @@ -19,7 +19,7 @@ export const createMigrator = (table: MigrateTable, prevVersion: string) => { const bMin = minVersion(b); if (!aMin || !bMin) return 0; - return lt(aMin, bMin) ? 1 : -1; + return lt(aMin, bMin) ? -1 : 1; }) .map(([matcher, migrator]) => { if (clean(matcher) !== null) { @@ -31,8 +31,7 @@ export const createMigrator = (table: MigrateTable, prevVersion: string) => { return migrator; } }) - .filter(Boolean) - .reverse(); + .filter(Boolean); return (initData: MigratorData) => { const result = { ...initData };