( destDir: string, name: string, templateId: string, localVideoName: string | undefined, durationSeconds?: number, tailwind = false, resolution?: CanvasResolution, )
| 516 | // --------------------------------------------------------------------------- |
| 517 | |
| 518 | async function scaffoldProject( |
| 519 | destDir: string, |
| 520 | name: string, |
| 521 | templateId: string, |
| 522 | localVideoName: string | undefined, |
| 523 | durationSeconds?: number, |
| 524 | tailwind = false, |
| 525 | resolution?: CanvasResolution, |
| 526 | ): Promise<void> { |
| 527 | mkdirSync(destDir, { recursive: true }); |
| 528 | |
| 529 | // Use bundled template if available, otherwise fetch from GitHub. |
| 530 | // Check for index.html inside the dir — an empty directory left by the |
| 531 | // build toolchain should not prevent the remote fetch fallback. |
| 532 | const templateDir = getStaticTemplateDir(templateId); |
| 533 | if (existsSync(join(templateDir, "index.html"))) { |
| 534 | cpSync(templateDir, destDir, { recursive: true }); |
| 535 | } else { |
| 536 | await fetchRemoteTemplate(templateId, destDir); |
| 537 | } |
| 538 | patchVideoSrc(destDir, localVideoName, durationSeconds); |
| 539 | if (tailwind) writeTailwindSupport(destDir); |
| 540 | if (resolution) applyResolutionPreset(destDir, resolution); |
| 541 | |
| 542 | writeFileSync( |
| 543 | resolve(destDir, "meta.json"), |
| 544 | JSON.stringify( |
| 545 | { |
| 546 | id: name, |
| 547 | name, |
| 548 | createdAt: new Date().toISOString(), |
| 549 | }, |
| 550 | null, |
| 551 | 2, |
| 552 | ), |
| 553 | "utf-8", |
| 554 | ); |
| 555 | |
| 556 | // Write hyperframes.json so `hyperframes add` knows which registry to use |
| 557 | // and where to drop block/component files. Overwritten only if absent. |
| 558 | if (!existsSync(resolve(destDir, "hyperframes.json"))) { |
| 559 | const { writeProjectConfig, DEFAULT_PROJECT_CONFIG } = |
| 560 | await import("../utils/projectConfig.js"); |
| 561 | writeProjectConfig(destDir, DEFAULT_PROJECT_CONFIG); |
| 562 | } |
| 563 | |
| 564 | writeDefaultPackageJson(destDir, name); |
| 565 | |
| 566 | // Copy shared files (CLAUDE.md, AGENTS.md) for AI agent context |
| 567 | const sharedDir = getSharedTemplateDir(); |
| 568 | if (existsSync(sharedDir)) { |
| 569 | for (const entry of readdirSync(sharedDir, { withFileTypes: true })) { |
| 570 | const src = join(sharedDir, entry.name); |
| 571 | const dest = resolve(destDir, entry.name); |
| 572 | if (entry.isFile() || entry.isSymbolicLink()) { |
| 573 | copyFileSync(src, dest); |
| 574 | } |
| 575 | } |
no test coverage detected