Files
descrybe/scripts/seed/build-category-ui-examples.mjs
T

26 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-10-14 20:02:42 +02:00
import { readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
const root = resolve(import.meta.dirname, '../..');
const source = resolve(root, 'apps/api/internal/aiprompts/defaults/prompt-rules-25.json');
const target = resolve(root, 'apps/web/src/lib/categories/prompt-examples.ts');
const rules = JSON.parse(readFileSync(source, 'utf8'));
const output = `/**
* GENERATED from apps/api/internal/aiprompts/defaults/prompt-rules-25.json.
* Run: node scripts/seed/build-category-ui-examples.mjs
* Read-only preview data; never writes category prompts automatically.
*/
import { DEFAULT_CONTENT_LANGUAGE, parseContentLanguage } from '../content-languages.ts';
import type { EnhancePromptSectionId } from './prompt-sections';
export const CATEGORY_FORMULA_RULES: Record<string, Record<EnhancePromptSectionId, string>> = ${JSON.stringify(rules, null, 2)};
export const CATEGORY_PROMPT_EXAMPLES = CATEGORY_FORMULA_RULES;
export function localizedCategoryPromptExample(language: string, section: EnhancePromptSectionId): string {
const code = parseContentLanguage(language, DEFAULT_CONTENT_LANGUAGE);
return (CATEGORY_FORMULA_RULES[code] ?? CATEGORY_FORMULA_RULES.en)[section];
}
`;
writeFileSync(target, output);
console.log(`Generated ${Object.keys(rules).length} synchronized language examples.`);