Add configuration version checking
This commit is contained in:
parent
b98f37729d
commit
e082502f88
@ -147,8 +147,11 @@
|
||||
playersSearch: true,
|
||||
|
||||
// Use more compact pre-2.0 player marker style
|
||||
compactPlayerMarkers: true,
|
||||
}
|
||||
compactPlayerMarkers: false,
|
||||
},
|
||||
|
||||
// Config version. Do not modify.
|
||||
version: 1
|
||||
};
|
||||
</script>
|
||||
|
||||
|
1
src/index.d.ts
vendored
1
src/index.d.ts
vendored
@ -67,6 +67,7 @@ interface LiveAtlasGlobalConfig {
|
||||
servers: Map<string, LiveAtlasServerDefinition>;
|
||||
messages: LiveAtlasGlobalMessageConfig;
|
||||
ui: LiveAtlasUIConfig;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
interface LiveAtlasServerDefinition {
|
||||
|
@ -17,6 +17,9 @@
|
||||
import {LiveAtlasGlobalConfig, LiveAtlasServerDefinition} from "@/index";
|
||||
import ConfigurationError from "@/errors/ConfigurationError";
|
||||
import {DynmapUrlConfig} from "@/dynmap";
|
||||
import {useStore} from "@/store";
|
||||
|
||||
const expectedConfigVersion = 1;
|
||||
|
||||
const validateLiveAtlasConfiguration = (config: any): Map<string, LiveAtlasServerDefinition> => {
|
||||
const check = '\nCheck your server configuration in index.html is correct.',
|
||||
@ -125,6 +128,10 @@ export const getServerDefinitions = (config: LiveAtlasGlobalConfig): Map<string,
|
||||
throw new ConfigurationError(`No configuration found.\nCheck for any syntax errors in your configuration in index.html. Your browser console may contain additional information.`);
|
||||
}
|
||||
|
||||
if (config.version !== expectedConfigVersion) {
|
||||
throw new ConfigurationError(`Configuration version mismatch.\nUse a fresh copy of index.html from your current LiveAtlas version (${useStore().state.version}) and reapply any customisations.`);
|
||||
}
|
||||
|
||||
if (typeof config.servers !== 'undefined') {
|
||||
return validateLiveAtlasConfiguration(config.servers);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user