mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
feat: include unconfigured secret paths in config settings snapshot
- Export SECRET_PATHS from registry for reuse
- Populate snapshot with `{ configured: true }` for non-empty secrets not already covered by registered fields
This commit is contained in:
@@ -15,7 +15,7 @@ import type {
|
||||
ConfigSettingsSnapshot,
|
||||
} from '../../types/settings';
|
||||
import { resolveConfig } from '../resolve';
|
||||
import { getConfigValueAtPath } from './registry';
|
||||
import { getConfigValueAtPath, SECRET_PATHS } from './registry';
|
||||
|
||||
const JSONC_FORMATTING_OPTIONS: FormattingOptions = {
|
||||
insertSpaces: true,
|
||||
@@ -337,6 +337,20 @@ export function buildConfigSettingsSnapshot(
|
||||
values[field.configPath] = structuredClone(rawValue != null ? rawValue : resolvedValue);
|
||||
}
|
||||
|
||||
for (const secretPath of SECRET_PATHS) {
|
||||
if (Object.hasOwn(values, secretPath)) {
|
||||
continue;
|
||||
}
|
||||
const rawValue = getConfigValueAtPath(options.rawConfig, secretPath);
|
||||
const resolvedValue = getConfigValueAtPath(options.resolvedConfig, secretPath);
|
||||
if (
|
||||
(typeof rawValue === 'string' && rawValue.length > 0) ||
|
||||
(typeof resolvedValue === 'string' && resolvedValue.length > 0)
|
||||
) {
|
||||
values[secretPath] = { configured: true };
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
configPath: options.configPath,
|
||||
fields: options.fields,
|
||||
|
||||
@@ -93,7 +93,7 @@ const JSON_OBJECT_FIELDS = new Set([
|
||||
'subtitleSidebar.css',
|
||||
]);
|
||||
|
||||
const SECRET_PATHS = new Set(['ai.apiKey', 'jimaku.apiKey', 'anilist.accessToken']);
|
||||
export const SECRET_PATHS = new Set(['ai.apiKey', 'jimaku.apiKey', 'anilist.accessToken']);
|
||||
|
||||
const COLOR_SUFFIXES = new Set(['Color', 'color', 'backgroundColor', 'singleColor']);
|
||||
const SUBTITLE_CSS_MANAGED_CONFIG_PATHS = new Set([
|
||||
|
||||
Reference in New Issue
Block a user