mirror of
https://github.com/logos-co/logos-web.git
synced 2026-08-27 12:11:14 +00:00
- apps/cms: auto-formatted prettier warnings in scripts and tests (schema-push-prompts.test.ts, dev.ts, schema-push-prompts.ts). - apps/web: auto-formatted prettier warnings in lib/press-engine.ts. - apps/web/lib/__tests__/link-policy.test.ts: drop docs.logos.co from the blocked-URL list — the live Get Started page now uses it as the canonical docs entry point via EXTERNAL_URLS.docs. - apps/cms/.../save-site-content-as-pr.test.ts: footerSchema now requires a newsletter object; add it to the test fixture so the builder passes Zod parsing. - apps/web/package.json: declare tsx as an explicit devDependency so test:perf / test:static find it under apps/web/node_modules/.bin after the pnpm 11 lockfile regeneration changed hoisting. - apps/web/test/performance/budgets.ts: bump maxHtmlBytes 325k -> 430k to cover homepage growth from recent motion polish and Get Started. - pnpm-lock.yaml: refresh after adding tsx to apps/web. Verified: pnpm test:release passes locally end-to-end.
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
const schemaConflictPromptPattern =
|
|
/Is [\s\S]* (?:table|column|schema) created or renamed from another (?:table|column|schema)\?/
|
|
|
|
const promptSubmittedPattern =
|
|
/(?:will be created|will be renamed|will be renamed\/moved|all .* conflicts resolved)/
|
|
|
|
export interface AutoSubmitState {
|
|
lastSubmissionAt: number
|
|
pendingPrompt: boolean
|
|
}
|
|
|
|
export interface SchemaPushAutomationEnv {
|
|
NODE_ENV?: string
|
|
VERCEL?: string
|
|
VERCEL_ENV?: string
|
|
}
|
|
|
|
export const createAutoSubmitState = (): AutoSubmitState => ({
|
|
lastSubmissionAt: 0,
|
|
pendingPrompt: false,
|
|
})
|
|
|
|
export const isLocalSchemaPushAutomationAllowed = (
|
|
env: SchemaPushAutomationEnv
|
|
): boolean => env.NODE_ENV !== 'production' && !env.VERCEL && !env.VERCEL_ENV
|
|
|
|
export const shouldSubmitDefaultSchemaChoice = (
|
|
output: string,
|
|
state: AutoSubmitState,
|
|
now = Date.now()
|
|
): boolean => {
|
|
if (promptSubmittedPattern.test(output)) {
|
|
state.pendingPrompt = false
|
|
}
|
|
|
|
if (!schemaConflictPromptPattern.test(output)) {
|
|
return false
|
|
}
|
|
|
|
if (state.pendingPrompt && now - state.lastSubmissionAt < 1000) {
|
|
return false
|
|
}
|
|
|
|
state.pendingPrompt = true
|
|
state.lastSubmissionAt = now
|
|
|
|
return true
|
|
}
|