const fs = require('fs');
const path = require('path');

const componentName = process.argv[2];

if (!componentName) {
  console.error('Please provide a component name.');
  process.exit(1);
}

const componentDir = path.join(__dirname, '../src/components', componentName);

if (fs.existsSync(componentDir)) {
  console.error(`Component '${componentName}' already exists.`);
  process.exit(1);
}

fs.mkdirSync(componentDir, { recursive: true });

const jsContent = `// ${componentName}.js
console.log('${componentName} component loaded');
`;

const scssContent = `// ${componentName}.scss
.${componentName} {
  /* Component styles */
}
`;

const twigContent = `{# ${componentName}.twig #}
<div class="${componentName}">
  <!-- Component markup -->
</div>
`;

fs.writeFileSync(path.join(componentDir, `${componentName}.js`), jsContent);
fs.writeFileSync(path.join(componentDir, `${componentName}.scss`), scssContent);
fs.writeFileSync(path.join(componentDir, `${componentName}.twig`), twigContent);

console.log(`Component '${componentName}' created successfully in src/components/${componentName}`);
