mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-16 10:16:20 +01:00
Update default config
This commit is contained in:
@@ -9,10 +9,10 @@ export const getConfig = (name: string): BackendConfigType => {
|
||||
// Else if config exists but contains no "schema_version" property
|
||||
// then it is an old config file and we should try to migrate it
|
||||
// to the new format.
|
||||
let config = readConfig(name);
|
||||
if (!config.schemaVersion) {
|
||||
// TODO: Migrate config to new format
|
||||
config = migrateConfig(config);
|
||||
const config = readConfig(name);
|
||||
if (config.schemaVersion === undefined) {
|
||||
console.log('Migrating config file...', config);
|
||||
return migrateConfig(config, name);
|
||||
}
|
||||
return config;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BackendConfigType } from '../../types/config';
|
||||
|
||||
export const getFallbackConfig = (name?: string): BackendConfigType => ({
|
||||
schemaVersion: '1.0.0',
|
||||
schemaVersion: 1,
|
||||
configProperties: {
|
||||
name: name ?? 'default',
|
||||
},
|
||||
|
||||
@@ -9,13 +9,14 @@ export const getFrontendConfig = (name: string): ConfigType => {
|
||||
apps: config.apps.map((app) => ({
|
||||
...app,
|
||||
integration: {
|
||||
...app.integration ?? null,
|
||||
...(app.integration ?? null),
|
||||
type: app.integration?.type ?? null,
|
||||
properties: app.integration?.properties.map((property) => ({
|
||||
...property,
|
||||
value: property.type === 'private' ? undefined : property.value,
|
||||
isDefined: property.value != null,
|
||||
})) ?? [],
|
||||
properties:
|
||||
app.integration?.properties.map((property) => ({
|
||||
...property,
|
||||
value: property.type === 'private' ? undefined : property.value,
|
||||
isDefined: property.value != null,
|
||||
})) ?? [],
|
||||
},
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import fs from 'fs';
|
||||
import { ConfigType } from '../../types/config';
|
||||
import { Config } from '../types';
|
||||
|
||||
export function migrateConfig(config: Config): ConfigType {
|
||||
export function migrateConfig(config: Config, name: string): ConfigType {
|
||||
const newConfig: ConfigType = {
|
||||
schemaVersion: '1.0.0',
|
||||
schemaVersion: 1,
|
||||
configProperties: {
|
||||
name: config.name ?? 'default',
|
||||
},
|
||||
@@ -76,6 +77,9 @@ export function migrateConfig(config: Config): ConfigType {
|
||||
},
|
||||
},
|
||||
}));
|
||||
// Overrite the file ./data/configs/${name}.json
|
||||
// with the new config format
|
||||
fs.writeFileSync(`./data/configs/${name}.json`, JSON.stringify(newConfig, null, 2));
|
||||
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user