forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
103 lines (103 loc) · 2.98 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
module.exports = function(plop) {
// Add new package
plop.setGenerator(`package`, {
description: `This is sets up the basic files for a new package.`,
prompts: [
{
type: `input`,
name: `name`,
message: `name of new package`,
},
{
type: `input`,
name: `author`,
message: `Your name/email for putting in the package.json of the new package`,
},
{
type: `confirm`,
name: `isBrowser`,
message: `Will this package contain code that runs in a browser, e.g. have a gatsby-browser.js or gatsby-ssr.js file?`,
},
],
actions: (data) =>
[
{
type: `add`,
path: `packages/{{kebabCase name}}/package.json`,
templateFile: `plop-templates/package/package.json.hbs`,
},
{
type: `add`,
path: `packages/{{kebabCase name}}/index.js`,
templateFile: `plop-templates/package/index.js.hbs`,
},
{
type: `add`,
path: `packages/{{kebabCase name}}/README.md`,
templateFile: `plop-templates/package/README.md.hbs`,
},
data.isBrowser && {
type: `add`,
path: `packages/{{kebabCase name}}/.babelrc`,
templateFile: `plop-templates/package/.babelrc.hbs`,
},
{
type: `add`,
path: `packages/{{kebabCase name}}/.gitignore`,
templateFile: `plop-templates/package/.gitignore.hbs`,
},
{
type: `add`,
path: `packages/{{kebabCase name}}/.npmignore`,
templateFile: `plop-templates/package/.npmignore.hbs`,
},
{
type: `add`,
path: `packages/{{kebabCase name}}/src/.gitkeep`,
},
].filter(Boolean),
})
// Add new example site
plop.setGenerator(`example`, {
description: `This is sets up the basic files for a new example site.`,
prompts: [
{
type: `input`,
name: `name`,
message: `name of new example site`,
},
{
type: `input`,
name: `author`,
message: `Your name/email for putting in the package.json of the new example site`,
},
],
actions: [
{
type: `add`,
path: `examples/{{kebabCase name}}/package.json`,
templateFile: `plop-templates/example/package.json.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/src/pages/index.js`,
templateFile: `plop-templates/example/index.js.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/README.md`,
templateFile: `plop-templates/example/README.md.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/.gitignore`,
templateFile: `plop-templates/example/.gitignore.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/.eslintrc`,
templateFile: `plop-templates/example/.eslintrc.hbs`,
},
],
})
}