1+ import type { PlopTypes } from '@turbo/gen'
2+ import { format } from 'date-fns'
3+ import path from 'path'
4+
5+ export default function generator ( plop : PlopTypes . NodePlopAPI ) : void {
6+ const usehooksSrcPath = path . resolve ( 'packages/usehooks-ts/src' )
7+ plop . setGenerator ( 'hook' , {
8+ description : 'Create a post' ,
9+ prompts : [
10+ {
11+ type : 'input' ,
12+ name : 'name' ,
13+ message : 'post name please (eg: "use test")' ,
14+ } ,
15+ ] ,
16+ actions : [
17+ {
18+ type : 'add' ,
19+ path : usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.ts' ,
20+ templateFile : 'templates/hook/hook.ts.hbs' ,
21+ } ,
22+ {
23+ type : 'add' ,
24+ path : usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.test.ts' ,
25+ templateFile : 'templates/hook/hook.test.ts.hbs' ,
26+ } ,
27+ {
28+ data : {
29+ date : format ( new Date ( ) , 'yyyy-MM-dd' ) ,
30+ } ,
31+ type : 'add' ,
32+ path : usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.md' ,
33+ templateFile : 'templates/hook/hook.mdx.hbs' ,
34+ } ,
35+ {
36+ type : 'add' ,
37+ path : usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.demo.tsx' ,
38+ templateFile : 'templates/hook/hook.demo.tsx.hbs' ,
39+ } ,
40+ {
41+ type : 'add' ,
42+ path : usehooksSrcPath + '/{{camelCase name}}/index.ts' ,
43+ templateFile : 'templates/hook/index.ts.hbs' ,
44+ } ,
45+ {
46+ type : 'append' ,
47+ path : usehooksSrcPath + '/index.ts' ,
48+ templateFile : 'templates/index.ts.hbs' ,
49+ } ,
50+ ] ,
51+ } )
52+ }
0 commit comments