A simple approach to PlopJS with first class TypeScript support and a one-line plopfile
npm install dot-plopdot-plopA simple approach to PlopJS with first class TypeScript support and a one-line
plopfile.
``sh`
$ npm i plop dot-plop -D
Put plopfile.js in your project directory:
`javascript`
module.exports = require('dot-plop')
1. Create a new folder in your project directory called .plop..plop/generators
2. Write your generators in TypeScript and put them in ..plop/templates/
3. We put our templates in , but you can put them anywhere you.plop/helpers
like, just so your generators know where they are.
4. Write your helpers in TypeScript and put them in ..plop/prompts
5. Write your Inquirer prompts in TypeScript and put them in .plop
6. Run from the command line.
dot-plop will auto discover your generators and helpers. They will have the
same name as their export name.
`typescript
import { PlopGenerator } from 'plop'
export const units: PlopGenerator = {
description: 'Feature logic and API integrations',
prompts: [
{
type: 'input',
name: 'fileName',
message: 'unit name please',
},
],
actions: [
{
type: 'add',
path: 'src/units/{{dashCase fileName}}.ts',
templateFile: '.plop/templates/units/unit.ts.hbs',
},
{
type: 'add',
path: 'src/units/{{dashCase fileName}}.test.ts',
templateFile: '.plop/templates/units/unit.test.ts.hbs',
},
],
}
``