/** * cli:derive-pwa-spec — validate.ts */ import { validatePwaMetaV1 } from '../../../lib/pwa-meta.js' import { DerivePwaSpecInputSchema, type ValidationResult } from './types.js' export function validate(raw: unknown): ValidationResult { const result = DerivePwaSpecInputSchema.safeParse(raw) if (!result.success) { return { valid: false, errors: result.error.issues.map((i) => `[${i.path.join('.')}] ${i.message}`), warnings: [], } } const errors: string[] = [] for (const update of result.data.updates) { if (update.pwa === null) continue const err = validatePwaMetaV1(update.pwa) if (err) errors.push(`[updates.${update.app}/${update.module}/${update.pagespec}] ${err}`) } if (result.data.updates.length > 0 && !result.data.write) { return { valid: errors.length === 0, errors, warnings: ['updates provided without write: true — running in report-only mode, nothing will be persisted.'], } } return { valid: errors.length === 0, errors, warnings: [] } }