auto: PR for feat/export-options-overrides #42

Merged
jaybe merged 8 commits from feat/export-options-overrides into main 2025-11-14 23:13:59 +00:00
2 changed files with 55 additions and 0 deletions
Showing only changes of commit e6c897a863 - Show all commits
+18
View File
@@ -6,6 +6,24 @@ export function buildExtrasForPage(page: Page): Record<string, Uint8Array> {
const extras: Record<string, Uint8Array> = {} const extras: Record<string, Uint8Array> = {}
const te = new TextEncoder() const te = new TextEncoder()
// Always provide a baseline robots.txt
const robots = `User-agent: *\nDisallow:`
extras['robots.txt'] = te.encode(robots)
// Provide a minimal site.webmanifest derived from Page
try {
const name = page.title || 'App'
const short = name.length > 12 ? name.slice(0, 12) : name
const manifest = {
name,
short_name: short,
start_url: '/',
display: 'standalone',
theme_color: page.theme?.primaryColor ?? '#000000',
}
extras['site.webmanifest'] = te.encode(JSON.stringify(manifest))
} catch {}
const hasAction = !!(page.form?.actionUrl && page.form.actionUrl.trim().length > 0) const hasAction = !!(page.form?.actionUrl && page.form.actionUrl.trim().length > 0)
if (!hasAction) { if (!hasAction) {
const code = `// Google Apps Script (Code.gs) const code = `// Google Apps Script (Code.gs)
+37
View File
@@ -0,0 +1,37 @@
import { describe, it, expect } from 'vitest'
import { pageSchema, type Page } from '@/lib/schema/page'
import { buildExtrasForPage } from '@/lib/exporter/extras'
function makePage(overrides: Partial<Page> = {}): Page {
const base: Page = pageSchema.parse({
title: 'My Landing',
locale: 'en',
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
sections: [],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
seo: { title: 'SEO Title', description: 'desc' },
})
return { ...base, ...overrides }
}
describe('extras 자동 생성: site.webmanifest / robots.txt', () => {
it('Page에서 파생된 site.webmanifest JSON과 robots.txt를 extras에 포함한다', async () => {
const page = makePage({ title: 'Awesome App', theme: { primaryColor: '#123456', fontFamily: 'Inter' } })
const extras = buildExtrasForPage(page)
// robots.txt 존재 및 베이스라인 확인
expect(Object.keys(extras)).toContain('robots.txt')
const robots = new TextDecoder().decode(extras['robots.txt'])
expect(robots).toMatch(/User-agent: \*/)
// manifest 존재 및 필수 키 확인
expect(Object.keys(extras)).toContain('site.webmanifest')
const manifestStr = new TextDecoder().decode(extras['site.webmanifest'])
const manifest = JSON.parse(manifestStr)
expect(manifest.name).toBe('Awesome App')
expect(manifest.short_name.length).toBeGreaterThan(0)
expect(manifest.start_url).toBe('/')
expect(manifest.display).toBe('standalone')
expect(manifest.theme_color).toBe('#123456')
})
})