forked from LekoArts/gatsby-themes
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
126 lines (121 loc) · 3.5 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
119
120
121
122
123
124
125
126
const prompt = [
{
type: `input`,
name: `name`,
message: `Name of the theme`,
},
{
type: `input`,
name: `readme-name`,
message: `Name for the README title, alt tags of images and siteMetadata`,
},
{
type: `input`,
name: `starter-name`,
message: `Name of the respective starter project (if already existing use the name after "LekoArts/" so "gatsby-starter-x")`,
},
]
const themeActions = [
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/.npmignore`,
templateFile: `plop-templates/theme/.npmignore.hbs`,
},
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/gatsby-config.js`,
templateFile: `plop-templates/theme/gatsby-config.js.hbs`,
},
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/index.js`,
templateFile: `plop-templates/theme/index.js.hbs`,
},
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/package.json`,
templateFile: `plop-templates/theme/package.json.hbs`,
},
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/README.md`,
templateFile: `plop-templates/theme/README.md.hbs`,
},
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/src/components/seo.tsx`,
templateFile: `plop-templates/theme/seo.tsx.hbs`,
},
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/src/gatsby-plugin-theme-ui/index.js`,
templateFile: `plop-templates/theme/theme-ui.js.hbs`,
},
{
type: `add`,
path: `themes/gatsby-theme-{{kebabCase name}}/src/hooks/use-site-metadata.tsx`,
templateFile: `plop-templates/theme/use-site-metadata.tsx.hbs`,
},
]
const exampleActions = [
{
type: `add`,
path: `examples/{{kebabCase name}}/gatsby-config.js`,
templateFile: `plop-templates/example/gatsby-config.js.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/src/pages/index.js`,
templateFile: `plop-templates/example/index-page.js.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/LICENSE`,
templateFile: `plop-templates/example/LICENSE.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/.gitignore`,
templateFile: `plop-templates/example/.gitignore.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/.github/FUNDING.yml`,
templateFile: `plop-templates/example/FUNDING.yml.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/package.json`,
templateFile: `plop-templates/example/package.json.hbs`,
},
{
type: `add`,
path: `examples/{{kebabCase name}}/README.md`,
templateFile: `plop-templates/example/README.md.hbs`,
},
{
type: `add`,
path: `cypress/e2e/{{kebabCase name}}.ts`,
templateFile: `plop-templates/cypress-test.ts.hbs`,
},
]
module.exports = function(plop) {
// Add a new theme + example to get going with theme development
plop.setGenerator(`theme & example`, {
description: `Use this template to get started with the next theme! It sets up a theme inside /themes, an example inside /examples and a Cypress test.`,
prompts: [...prompt],
actions: [...themeActions, ...exampleActions].filter(Boolean),
})
// Add a new theme
plop.setGenerator(`theme`, {
description: `Sets up a new theme`,
prompts: [...prompt],
actions: [...themeActions].filter(Boolean),
})
// Add a new example
plop.setGenerator(`example`, {
description: `Sets up a new example`,
prompts: [...prompt],
actions: [...exampleActions].filter(Boolean),
})
}