#!/usr/bin/env node
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
import prompts from 'prompts';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function init() {
console.log("🎬 Auto Director CLI");
const response = await prompts([
{
type: 'text',
name: 'projectName',
message: 'Project Name?',
initial: 'my-commercial'
},
{
type: 'select',
name: 'theme',
message: 'Select initial theme',
choices: [
{ title: 'Cyberpunk (Tech/Crypto)', value: 'cyberpunk' },
{ title: 'Minimal (SaaS/Modern)', value: 'minimal' },
{ title: 'Playful (Consumer/App)', value: 'playful' }
]
}
]);
if (!response.projectName) return;
const targetDir = path.join(process.cwd(), response.projectName);
// In a real published package, these would be in a specific template dir
// Since we are running from the repo itself for now, we copy from adjacent directories relative to bin/
const sourceRoot = path.join(__dirname, '..');
console.log(`\n🚀 Initializing ${response.projectName}...`);
try {
// 1. Create Directory
await fs.ensureDir(targetDir);
// 2. Copy Source Code (Engine)
const dirsToCopy = ['src', 'public', 'scripts'];
for (const dir of dirsToCopy) {
await fs.copy(path.join(sourceRoot, dir), path.join(targetDir, dir));
}
// 3. Copy Config Files
const filesToCopy = [
'package.json',
'tsconfig.json',
'remotion.config.ts',
'README.md',
'.gitignore'
];
for (const file of filesToCopy) {
if (fs.existsSync(path.join(sourceRoot, file))) {
await fs.copy(path.join(sourceRoot, file), path.join(targetDir, file));
}
}
// 4. Create initial director.json based on selection
const directorConfig = {
projectInfo: {
name: response.projectName,
description: "Generated by Auto Director"
},
style: {
theme: response.theme,
primaryColor: "#ffffff",
accentColor: "#3b82f6",
fontFamily: "Inter"
},
script: {
hook: "The future is here.",
solution: "Auto Director makes it easy.",
features: [
{ title: "Feature 1", subtitle: "It just works." },
{ title: "Feature 2", subtitle: "Fully automated." }
],
cta: "Get Started"
},
durationInFrames: 300,
fps: 60
};
await fs.writeJson(path.join(targetDir, 'director.json'), directorConfig, { spaces: 4 });
console.log(`\n✅ Done! To start making videos:\n`);
console.log(` cd ${response.projectName}`);
console.log(` npm install`);
console.log(` npm run start`);
} catch (err) {
console.error("Error initializing project:", err);
}
}
init();