gristlabs_grist-core/app/server/lib/configCore.ts
Jordi Gutiérrez Hermoso a16d76d25d (core) config: rename TEST_ENABLE_ACTIVATION to GRIST_FORCE_ENABLE_ENTERPRISE
Summary:
The name of this env var has bothered me for a little while.
Let's rename it more meaningfully.

Test Plan: No need to test, cosmetic change only.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D4320
2024-08-14 14:33:06 -04:00

33 lines
1018 B
TypeScript

import {
createConfigValue,
FileConfig,
fileConfigAccessorFactory,
IWritableConfigValue
} from "./config";
import {convertToCoreFileContents, IGristCoreConfigFileLatest} from "./configCoreFileFormats";
import {isAffirmative} from 'app/common/gutil';
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>(
isAffirmative(process.env.GRIST_FORCE_ENABLE_ENTERPRISE) ? "enterprise" : "core",
fileConfigValue("edition")
)
};
}