text: /* eslint-disable no-undef */
  /* eslint-disable @typescript-eslint/no-var-requires */
  require('colors');
  const fs = require('fs');
  const templates = require('./templates');
  
  const componentName = process.argv[2];
  
  if (!componentName) {
    console.error('⚠️  Please supply a valid component name  ⚠️ '.red);
    process.exit(1);
  }
  
  console.log(`🛠  Creating component templates with the name: ${componentName}`);
  
  const componentDirectory = `./src/${componentName}`;
  
  if (fs.existsSync(componentDirectory)) {
    console.error(`⚠️   Component ${componentName} already exists.  ⚠️ `.red);
    process.exit(1);
  }
  
  fs.mkdirSync(componentDirectory);
  
  const generatedTemplates = templates.map((template) => template(componentName));
  
  generatedTemplates.forEach((template) => {
    if (template.index) {
      fs.writeFileSync(`${componentDirectory}/index${template.extension}`, template.content);
    } else if (template.declaration) {
      fs.writeFileSync(`${componentDirectory}/declaration${template.extension}`, template.content);
    } else {
      fs.writeFileSync(`${componentDirectory}/${componentName}${template.extension}`, template.content);
    }
  });
  
  console.log('🎉  Successfully created component under: ' + componentDirectory.green);
  