feat(setup): skip redundant operator-pack prompts and add strict-mode docs/tests

This commit is contained in:
William Valentin
2026-02-16 15:27:27 -08:00
parent 7ce58f5966
commit dc1c691ea5
6 changed files with 103 additions and 8 deletions
+30
View File
@@ -127,4 +127,34 @@ describe('setupAutomation', () => {
expect(automation?.heartbeat).toBeUndefined();
expect(automation?.minio_sync).toBeUndefined();
});
it('skips operator-pack reconfiguration prompts when already configured and not reconfigured', async () => {
const builder = new ConfigBuilder();
builder.applyOperatorPack({
outputChannel: 'telegram',
outputPeer: '123',
backupSchedule: '0 2 * * *',
dailyBriefingSchedule: '0 8 * * *',
enableMinioSync: true,
});
const p = makePrompter({
confirms: [
false, // reconfigure operator pack?
false, // enable cron scheduler
false, // enable webhook receiver
false, // configure google services
],
});
await setupAutomation(p, builder);
const config = builder.build() as Record<string, unknown>;
const backup = config.backup as Record<string, unknown>;
const automation = config.automation as Record<string, unknown>;
const briefing = automation.daily_briefing as Record<string, unknown>;
expect(backup.schedule).toBe('0 2 * * *');
expect(briefing.schedule).toBe('0 8 * * *');
});
});
+19 -5
View File
@@ -57,12 +57,26 @@ const GOOGLE_SERVICES: GoogleService[] = [
];
export async function setupAutomation(p: Prompter, builder: ConfigBuilder): Promise<void> {
const enableOperatorPack = await p.confirm(
'Enable operator automation pack (scheduled backups + heartbeat alerts + daily briefing + MinIO sync)?',
false,
const config = builder.build();
const automation = (config.automation ?? {}) as Record<string, unknown>;
const backup = (config.backup ?? {}) as Record<string, unknown>;
const operatorPackConfigured = Boolean(
backup.enabled === true
&& (automation.heartbeat as { enabled?: boolean } | undefined)?.enabled
&& (automation.daily_briefing as { enabled?: boolean } | undefined)?.enabled,
);
if (enableOperatorPack) {
const config = builder.build();
const configureOperatorPack = operatorPackConfigured
? await p.confirm(
'Operator automation pack appears enabled. Reconfigure operator pack settings now?',
false,
)
: await p.confirm(
'Enable operator automation pack (scheduled backups + heartbeat alerts + daily briefing + MinIO sync)?',
false,
);
if (configureOperatorPack) {
const telegramPeer = config.telegram?.allowed_chat_ids?.[0];
const defaultOutputChannel = telegramPeer ? 'telegram' : 'webchat';
const defaultOutputPeer = telegramPeer ? String(telegramPeer) : 'operator';