-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
61 lines (61 loc) · 1.6 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
module.exports = function(plop) {
plop.setGenerator("component", {
description: "Create a new component",
prompts: [
{
type: "input",
name: "name",
message: "Enter a PascalCase name for your component:"
}
],
actions: [
{
type: "add",
path: "src/components/{{name}}.js",
templateFile: "src/generator-templates/component.hbs"
},
function(data) {
return "Your component was created! 🚀";
}
]
});
plop.setGenerator("page", {
description: "Add a page to your application",
prompts: [
{
type: "input",
name: "title",
message: "Enter a PascalCase title for your new page, e.g NewPage"
} ,
{
type: "input",
name: "path",
message: "Enter a lowercase path, e.g new_page"
},
],
actions: [
{
type: "add",
name: "title",
path: "src/pages/{{title}}.js",
templateFile: "src/generator-templates/page.hbs"
},
{
type: "append",
path: "src/pages/index.js",
pattern: `{/* Add routes here */}`,
template: `<Route path="/{{path}}"><{{title}}/></Route>`
},
{
type: "append",
path: "src/pages/index.js",
pattern: `/* Import routes here */`,
template: `import { {{title}} } from "./{{title}}";`
},
function(data) {
console.log(data);
return `Your page called ${data.title} was created! Visit it at http://localhost:3000/${data.path}`;
}
]
});
};