openreels-deploy
OpenReels on Hugging Face Spaces: automation REST API, no-AI-assets mode, stock-clip cap and render timeout fixes
311fa35 Download docs/scripts/sync-archetypes.ts from abc1181/Whisper: direct link, hf CLI and curl.
- Browser
- Download file 2.5 kB
-
https://huggingface.co/spaces/abc1181/Whisper/resolve/main/docs/scripts/sync-archetypes.ts
- Command line
-
hf download hf://spaces/abc1181/Whisper/docs/scripts/sync-archetypes.ts
-
curl -L -o sync-archetypes.ts https://huggingface.co/spaces/abc1181/Whisper/resolve/main/docs/scripts/sync-archetypes.ts
2.5 kB
| import * as fs from "node:fs"; | |
| import * as path from "node:path"; | |
| const ARCHETYPES_SRC = path.resolve( | |
| import.meta.dirname, | |
| "../../src/config/archetypes", | |
| ); | |
| const ARCHETYPES_DEST = path.resolve(import.meta.dirname, "../src/data/archetypes"); | |
| // Ensure destination exists | |
| fs.mkdirSync(ARCHETYPES_DEST, { recursive: true }); | |
| // Required fields every archetype JSON must have | |
| const REQUIRED_FIELDS = [ | |
| "colorPalette", | |
| "artStyle", | |
| "lighting", | |
| "captionStyle", | |
| "defaultTransition", | |
| "transitionDurationFrames", | |
| "motionIntensity", | |
| "textCardFont", | |
| "compositionRules", | |
| "mood", | |
| "visualColorPalette", | |
| ]; | |
| const files = fs | |
| .readdirSync(ARCHETYPES_SRC) | |
| .filter((f) => f.endsWith(".json")); | |
| if (files.length === 0) { | |
| throw new Error(`No archetype JSON files found in ${ARCHETYPES_SRC}`); | |
| } | |
| const archetypes: { slug: string; name: string }[] = []; | |
| for (const file of files) { | |
| const src = path.join(ARCHETYPES_SRC, file); | |
| const dest = path.join(ARCHETYPES_DEST, file); | |
| const content = JSON.parse(fs.readFileSync(src, "utf-8")); | |
| // Validate required fields | |
| for (const field of REQUIRED_FIELDS) { | |
| if (!(field in content)) { | |
| throw new Error(`Archetype ${file} is missing required field: ${field}`); | |
| } | |
| } | |
| fs.copyFileSync(src, dest); | |
| const slug = file.replace(".json", ""); | |
| const name = slug | |
| .split("-") | |
| .map((w) => w.charAt(0).toUpperCase() + w.slice(1)) | |
| .join(" "); | |
| archetypes.push({ slug, name }); | |
| } | |
| // Generate barrel file | |
| const barrel = `// Auto-generated by sync-archetypes.ts — do not edit | |
| ${archetypes.map((a) => `import ${a.slug.replace(/-/g, "_")} from "./${a.slug}.json";`).join("\n")} | |
| export interface ArchetypeConfig { | |
| scenePacing: string; | |
| defaultTransition: string; | |
| transitionDurationFrames: number; | |
| captionStyle: string; | |
| colorPalette: { background: string; accent: string; text: string }; | |
| textCardFont: string; | |
| motionIntensity: number; | |
| artStyle: string; | |
| lighting: string; | |
| compositionRules: string; | |
| culturalMarkers: string; | |
| mood: string; | |
| antiArtifactGuidance: string; | |
| visualColorPalette: string[]; | |
| } | |
| export interface Archetype { | |
| slug: string; | |
| name: string; | |
| config: ArchetypeConfig; | |
| } | |
| export const archetypes: Archetype[] = [ | |
| ${archetypes.map((a) => ` { slug: "${a.slug}", name: "${a.name}", config: ${a.slug.replace(/-/g, "_")} as unknown as ArchetypeConfig },`).join("\n")} | |
| ]; | |
| `; | |
| fs.writeFileSync(path.join(ARCHETYPES_DEST, "index.ts"), barrel); | |
| console.log(`Synced ${files.length} archetypes to ${ARCHETYPES_DEST}`); | |