-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
118 lines (116 loc) · 2.83 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const newDate = new Date()
.toISOString()
.replace(/T/, " ")
.replace(/\..+/, "");
const newFileInfo = {
userName: require("os").userInfo().username,
created: newDate,
};
module.exports = plop => {
plop.setGenerator("ui", {
description: "Create a component",
prompts: [
{
type: "list",
name: "type",
message: "What kind of component?",
choices: [
{ name: "atom", value: "Atoms" },
{ name: "molecule", value: "Molecules" },
{ name: "organism", value: "Organisms" },
],
},
{
type: "input",
name: "name",
message: "What is your component's name?",
},
],
actions: [
{
type: "add",
path:
"./src/ui/{{pascalCase type}}/{{pascalCase name}}/{{pascalCase name}}.tsx",
templateFile: "./config/plop-templates/Component.tsx.hbs",
data: newFileInfo,
},
{
type: "add",
path:
"./src/ui/{{pascalCase type}}/{{pascalCase name}}/{{pascalCase name}}.stories.tsx",
templateFile: "./config/plop-templates/Component.stories.tsx.hbs",
data: newFileInfo,
},
{
type: "add",
path: "./src/ui/{{pascalCase type}}/{{pascalCase name}}/index.ts",
templateFile: "./config/plop-templates/index.ts.hbs",
},
{
type: "append",
path: "./src/ui/{{pascalCase type}}/index.ts",
template: 'export * from "./{{pascalCase name}}";',
},
],
});
plop.setGenerator("blogpost", {
description: "Generate a blog post",
prompts: [
{
type: "input",
name: "title",
message: "Entry title",
},
{
type: "input",
name: "summary",
message: "Article summary",
},
{
type: "input",
name: "photo",
message: "This article contains a header photo?",
}
],
actions: [
{
type: "add",
path: `./content/writings/${newDate.split(" ")[0]} - {{title}}/index.md`,
templateFile: "./config/plop-templates/article.md.hbs",
data: { pubdate: newDate.split(" ")[0] },
},
],
});
plop.setGenerator("workplace", {
description: "Generate work place in MD format",
prompts: [
{
type: "input",
name: "work",
message: "Company name",
},
{
type: "input",
name: "position",
message: "Position",
},
{
type: "input",
name: "from",
message: "Start date",
},
{
type: "input",
name: "to",
message: "End date",
}
],
actions: [
{
type: "add",
path: "./content/sections/experience/{{pascalCase work}}.md",
templateFile: "./config/plop-templates/workplace.md.hbs",
}
]
});
};