forked from juliencrn/usehooks-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
53 lines (48 loc) · 1.38 KB
/
plopfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const format = require('date-fns/format')
module.exports = function (plop) {
plop.setGenerator('component', {
description: 'Create a post',
prompts: [
{
type: 'input',
name: 'name',
message: 'post name please (eg: "use test")',
},
],
actions: [
// Create the hook file itself
{
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.ts',
templateFile: 'templates/plop/hooks/hook/hook.ts.hbs',
},
// Create the test file
{
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.test.ts',
templateFile: 'templates/plop/hooks/hook/hook.test.ts.hbs',
},
// Create the markdown file to present the hook (doc)
{
data: {
date: format(new Date(), 'yyyy-MM-dd'),
},
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.mdx',
templateFile: 'templates/plop/hooks/hook/post.mdx.hbs',
},
// Create the demo react component file
{
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.demo.tsx',
templateFile: 'templates/plop/hooks/hook/demo.tsx.hbs',
},
// Update the global hooks index file
{
type: 'append',
path: 'src/index.ts',
templateFile: 'templates/plop/hooks/index.ts.hbs',
},
],
})
}