feat(setup): skip redundant operator-pack prompts and add strict-mode docs/tests
This commit is contained in:
@@ -21,6 +21,13 @@ describe('CLI program', () => {
|
||||
expect(commandNames).toContain('zai-auth');
|
||||
});
|
||||
|
||||
it('registers doctor strict flag on doctor command', () => {
|
||||
const program = createProgram();
|
||||
const doctor = program.commands.find((c) => c.name() === 'doctor');
|
||||
const strictOption = doctor?.options.find((o) => o.long === '--strict');
|
||||
expect(strictOption).toBeDefined();
|
||||
});
|
||||
|
||||
it('has version info', () => {
|
||||
const program = createProgram();
|
||||
expect(program.version()).toBeDefined();
|
||||
|
||||
@@ -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 * * *');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user