gristlabs_grist-core/app/server/lib/configCore.ts

29 lines
880 B
TypeScript
Raw Normal View History

import {
createConfigValue,
FileConfig,
fileConfigAccessorFactory,
IWritableConfigValue
} from "./config";
import { convertToCoreFileContents, IGristCoreConfigFileLatest } from "./configCoreFileFormats";
export type Edition = "core" | "enterprise";
/**
* Config options for Grist Core.
*/
export interface IGristCoreConfig {
edition: IWritableConfigValue<Edition>;
}
export function loadGristCoreConfigFile(configPath?: string): IGristCoreConfig {
const fileConfig = configPath ? FileConfig.create(configPath, convertToCoreFileContents) : undefined;
return loadGristCoreConfig(fileConfig);
}
export function loadGristCoreConfig(fileConfig?: FileConfig<IGristCoreConfigFileLatest>): IGristCoreConfig {
const fileConfigValue = fileConfigAccessorFactory(fileConfig);
return {
edition: createConfigValue<Edition>("core", fileConfigValue("edition"))
};
}