const path = require('path');
const jscodeshift = require('jscodeshift/src/Runner');

const codemodScript = path.resolve(__dirname, 'transform.js');

const transform = () => {
  const workingDir = path.resolve(process.cwd());

  jscodeshift
    .run(codemodScript, [workingDir], {
      verbose: 0,
      dry: false,
      print: false,
      extensions: 'js',
      ignorePattern: '**/node_modules/**',
      filter: '**/tailwind.config.js'
    })
    .then(
      (stats) => {
        console.log(`Codemod completed. Stats:`, stats);
      },
      (error) => {
        console.error(`Error executing codemod: ${error.message}`);
      }
    );
};

module.exports = {
  transform
};
