配置改为数据库存储
将运行时 JSON 配置迁入 app_config_entries,启动时从文件导入并删除源文件。
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import path from 'node:path'
|
||||
|
||||
import { APP_CONFIG_KEYS } from '../../config/app-config-keys.js'
|
||||
import { PROJECT_ROOT } from '../../config/runtime.js'
|
||||
import { readJsonFile, writeJsonFile } from '../../utils/json-file-store.js'
|
||||
import {
|
||||
readAppConfigEntry,
|
||||
saveAppConfigEntry,
|
||||
} from '../config/app-config-store.js'
|
||||
import { normalizeCloudtentaclesMatchName } from './cloudtentacles-match-utils.js'
|
||||
|
||||
const CLOUDTENTACLES_OVERRIDE_RULE_FILE_PATH = path.join(
|
||||
@@ -38,19 +42,21 @@ export function getCloudtentaclesOverrideRuleFilePath() {
|
||||
}
|
||||
|
||||
export function getCloudtentaclesOverrideRuleConfig(): CloudtentaclesOverrideRuleConfig {
|
||||
return readJsonFile(
|
||||
CLOUDTENTACLES_OVERRIDE_RULE_FILE_PATH,
|
||||
createDefaultCloudtentaclesOverrideRuleConfig,
|
||||
normalizeCloudtentaclesOverrideRuleConfig,
|
||||
)
|
||||
return readAppConfigEntry({
|
||||
configKey: APP_CONFIG_KEYS.cloudtentaclesOverrideRules,
|
||||
legacyFilePath: CLOUDTENTACLES_OVERRIDE_RULE_FILE_PATH,
|
||||
fallback: createDefaultCloudtentaclesOverrideRuleConfig,
|
||||
normalize: normalizeCloudtentaclesOverrideRuleConfig,
|
||||
})
|
||||
}
|
||||
|
||||
export function saveCloudtentaclesOverrideRuleConfig(rawValue: unknown): CloudtentaclesOverrideRuleConfig {
|
||||
return writeJsonFile(
|
||||
CLOUDTENTACLES_OVERRIDE_RULE_FILE_PATH,
|
||||
rawValue,
|
||||
normalizeCloudtentaclesOverrideRuleConfig,
|
||||
)
|
||||
export function saveCloudtentaclesOverrideRuleConfig(rawValue: unknown): Promise<CloudtentaclesOverrideRuleConfig> {
|
||||
return saveAppConfigEntry({
|
||||
configKey: APP_CONFIG_KEYS.cloudtentaclesOverrideRules,
|
||||
legacyFilePath: CLOUDTENTACLES_OVERRIDE_RULE_FILE_PATH,
|
||||
value: rawValue,
|
||||
normalize: normalizeCloudtentaclesOverrideRuleConfig,
|
||||
})
|
||||
}
|
||||
|
||||
export function resolveCloudtentaclesOverrideRule(productName: unknown) {
|
||||
|
||||
Reference in New Issue
Block a user