export default function (plop) {
  // lit generator
  plop.setGenerator('lit', {
    description: 'create lit-element',
    prompts: [
      {
        type: 'input',
        name: 'name',
        message: 'name of the element eg: `button` for `nile-button`',
      },
    ],
    actions: [
      {
        type: 'append',
        path: 'src/index.ts',
        templateFile: 'plop-templates/lit/litindex.ts.hbs',
      },
      {
        type: 'add',
        path: 'src/nile-{{name}}/index.ts',
        templateFile: 'plop-templates/lit/litindex.ts.hbs',
      },
      {
        type: 'add',
        path: 'src/nile-{{name}}/nile-{{name}}.ts',
        templateFile: 'plop-templates/lit/lit.ts.hbs',
      },
      {
        type: 'add',
        path: 'src/nile-{{name}}/nile-{{name}}.css.ts',
        templateFile: 'plop-templates/lit/lit.css.ts.hbs',
      },
      {
        type: 'modify',
        path: 'package.json',
        transform: (content, data) => {
          const packageJson = JSON.parse(content);
          const newName = `./nile-${data.name}`;
          packageJson.exports[newName] = `./dist/src/nile-${data.name}/index.js`;

          return JSON.stringify(packageJson, null, 2);
        },
      },
    ],
  });
}
