mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 14:22:07 +03:00
6ee94f66b4
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)
- There were two separate instances of the SettingsPathManager in route-settings and settings-loader causing the configured paths missmatching on test environment. Because of this missmatch, uploading and resetting the routes.yaml file didn't work!
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
const config = require('../../../shared/config');
|
|
const parseYaml = require('./yaml-parser');
|
|
const SettingsPathManager = require('@tryghost/settings-path-manager');
|
|
|
|
let settingsLoader;
|
|
let routeSettings;
|
|
|
|
module.exports = {
|
|
init: async () => {
|
|
const RouteSettings = require('./route-settings');
|
|
const SettingsLoader = require('./settings-loader');
|
|
const DefaultSettingsManager = require('./default-settings-manager');
|
|
|
|
const settingsPathManager = new SettingsPathManager({type: 'routes', paths: [config.getContentPath('settings')]});
|
|
settingsLoader = new SettingsLoader({parseYaml, settingFilePath: settingsPathManager.getDefaultFilePath()});
|
|
routeSettings = new RouteSettings({
|
|
settingsLoader,
|
|
settingsPath: settingsPathManager.getDefaultFilePath(),
|
|
backupPath: settingsPathManager.getBackupFilePath()
|
|
});
|
|
const defaultSettingsManager = new DefaultSettingsManager({
|
|
type: 'routes',
|
|
extension: '.yaml',
|
|
destinationFolderPath: config.getContentPath('settings'),
|
|
sourceFolderPath: config.get('paths').defaultSettings
|
|
});
|
|
|
|
return await defaultSettingsManager.ensureSettingsFileExists();
|
|
},
|
|
|
|
get loadRouteSettingsSync() {
|
|
return settingsLoader.loadSettingsSync.bind(settingsLoader);
|
|
},
|
|
get loadRouteSettings() {
|
|
return settingsLoader.loadSettings.bind(settingsLoader);
|
|
},
|
|
get getDefaultHash() {
|
|
return routeSettings.getDefaultHash.bind(routeSettings);
|
|
},
|
|
|
|
/**
|
|
* Methods used in the API
|
|
*/
|
|
api: {
|
|
get setFromFilePath() {
|
|
return routeSettings.setFromFilePath.bind(routeSettings);
|
|
},
|
|
get get() {
|
|
return routeSettings.get.bind(routeSettings);
|
|
},
|
|
get getCurrentHash() {
|
|
return routeSettings.getCurrentHash.bind(routeSettings);
|
|
}
|
|
}
|
|
};
|