feat(auth): backup settings file before auth modification

- Add backupSettingsFile() utility to create .orig backup before modifying settings
- Update success message to indicate backup was created
- Sync i18n translations for all supported languages
- Update documentation to reflect the change

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mingholy.lmh 2026-02-26 20:38:38 +08:00
parent 44b8ff729e
commit 0c53b19a74
11 changed files with 48 additions and 21 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import * as fs from 'node:fs';
import type {
Settings,
SettingScope,
@ -577,4 +578,25 @@ export function getEffectiveDisplayValue(
return getSettingValue(key, settings, mergedSettings);
}
/**
* Backup a settings file before modification.
* Creates a backup with `.orig` suffix if the file exists and backup doesn't already exist.
* @param filePath - Path to the settings file to backup
* @returns boolean indicating whether a backup was created
*/
export function backupSettingsFile(filePath: string): boolean {
try {
if (fs.existsSync(filePath)) {
const backupPath = `${filePath}.orig`;
if (!fs.existsSync(backupPath)) {
fs.renameSync(filePath, backupPath);
return true;
}
}
} catch (_e) {
// Ignore backup errors, proceed without backup
}
return false;
}
export const TEST_ONLY = { clearFlattenedSchema };