forked from juliencrn/usehooks-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
76 lines (74 loc) · 2.14 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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: [
/**
* usehooks-ts packages side
*
* - Create the hook index file (for quick export)
* - Create the hook file itself
* - Create the test file
* - Update the global hooks index file
*/
{
type: 'add',
path: 'lib/src/{{camelCase name}}/index.ts',
templateFile: 'templates/plop/hooks/lib/index.ts.hbs',
},
{
type: 'add',
path: 'lib/src/{{camelCase name}}/{{camelCase name}}.ts',
templateFile: 'templates/plop/hooks/lib/hook.ts.hbs',
},
{
type: 'add',
path: 'lib/src/{{camelCase name}}/{{camelCase name}}.test.ts',
templateFile: 'templates/plop/hooks/lib/hook.test.ts.hbs',
},
{
type: 'append',
path: 'lib/src/index.ts',
templateFile: 'templates/plop/hooks/index.ts.hbs',
},
/**
* frontend side
*
* - Create the hook index file (for quick export)
* - Create the markdown file to present the hook
* - Create the demo react component file
* - Update the global hooks index file
*/
{
type: 'add',
path: 'site/src/hooks-doc/{{camelCase name}}/index.ts',
templateFile: 'templates/plop/hooks/site/index.ts.hbs',
},
{
data: {
date: format(new Date(), 'yyyy-MM-dd'),
},
type: 'add',
path: 'site/src/hooks-doc/{{camelCase name}}/{{camelCase name}}.mdx',
templateFile: 'templates/plop/hooks/site/post.mdx.hbs',
},
{
type: 'add',
path: 'site/src/hooks-doc/{{camelCase name}}/{{camelCase name}}.demo.tsx',
templateFile: 'templates/plop/hooks/site/demo.tsx.hbs',
},
{
type: 'append',
path: 'site/src/hooks-doc/index.ts',
templateFile: 'templates/plop/hooks/index.ts.hbs',
},
],
})
}