2024-07-08 14:40:45 +00:00
|
|
|
import {
|
|
|
|
createConfigValue,
|
|
|
|
FileConfig,
|
|
|
|
fileConfigAccessorFactory,
|
|
|
|
IWritableConfigValue
|
|
|
|
} from "./config";
|
2024-07-22 13:45:12 +00:00
|
|
|
import {convertToCoreFileContents, IGristCoreConfigFileLatest} from "./configCoreFileFormats";
|
|
|
|
import {isAffirmative} from 'app/common/gutil';
|
2024-07-08 14:40:45 +00:00
|
|
|
|
|
|
|
export type Edition = "core" | "enterprise";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Config options for Grist Core.
|
|
|
|
*/
|
|
|
|
export interface IGristCoreConfig {
|
|
|
|
edition: IWritableConfigValue<Edition>;
|
|
|
|
}
|
|
|
|
|
2024-07-17 21:46:28 +00:00
|
|
|
export function loadGristCoreConfigFile(configPath?: string): IGristCoreConfig {
|
|
|
|
const fileConfig = configPath ? FileConfig.create(configPath, convertToCoreFileContents) : undefined;
|
2024-07-08 14:40:45 +00:00
|
|
|
return loadGristCoreConfig(fileConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadGristCoreConfig(fileConfig?: FileConfig<IGristCoreConfigFileLatest>): IGristCoreConfig {
|
|
|
|
const fileConfigValue = fileConfigAccessorFactory(fileConfig);
|
|
|
|
return {
|
2024-07-22 13:45:12 +00:00
|
|
|
edition: createConfigValue<Edition>(
|
2024-08-14 17:06:52 +00:00
|
|
|
isAffirmative(process.env.GRIST_FORCE_ENABLE_ENTERPRISE) ? "enterprise" : "core",
|
2024-07-22 13:45:12 +00:00
|
|
|
fileConfigValue("edition")
|
|
|
|
)
|
2024-07-08 14:40:45 +00:00
|
|
|
};
|
|
|
|
}
|