-
Notifications
You must be signed in to change notification settings - Fork 9
/
plopfile.mjs
215 lines (182 loc) · 5.56 KB
/
plopfile.mjs
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**
* Plop JS
* https://plopjs.com/documentation/
*/
export default function (plop) {
/* App
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setGenerator("app", {
description: "create new app",
prompts: [
{ // Name your app
type: "input",
name: "name",
message: "What is the name of your app?"
}
],
actions: [
{ // Create the app and add to @apps workspace
type: "addMany",
destination: "./apps/{{name}}",
base: `.templates/app`,
templateFiles: `.templates/app/**/*`
},
{ // Create the app $alias for svelte.config.js
type: "append",
path: "./packages/config/dist/svelte.config.js",
pattern: /\(plop added\)/g,
templateFile: ".templates/svelte.config.js.hbs"
},
{ // Add app to symlink function
type: "append",
path: "./.sh/symlinks.sh",
pattern: /# create symlinks/g,
templateFile: ".templates/symlinks.sh.hbs"
}
]
})
/* Component
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setGenerator("component", {
description: "create new component",
prompts: [
{ // Name
type: "input",
name: "name",
message: "What's the name of your component?"
},
{ // Type
type: 'list',
name: 'component',
message: 'What type of component?',
choices: ['Atom', 'Molecule', 'Organism', 'Template', 'Page', 'Particle' ]
}
],
actions: [
{ // create component
type: "addMany",
destination: "./packages/components/src/components/{{name}}",
base: `.templates/component/template`,
templateFiles: `.templates/component/template/**/*`
},
{ // export component
type: "append",
path: "./packages/components/index.js",
pattern: /\/\* components \*\//i,
templateFile: ".templates/component/index.js.hbs"
},
{ // create story
type: "addMany",
destination: "./apps/+stories/src/{{name}}",
base: `.templates/story/`,
templateFiles: `.templates/story/**/*.hbs`
}
],
});
/* Store
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setGenerator("store", {
description: "create new store",
prompts: [
{ // Name
type: "input",
name: "name",
message: "What's the name of your store?"
},
],
actions: [
{ // create store
type: "addMany",
destination: "./packages/components/src/stores",
base: `.templates/store/template`,
templateFiles: `.templates/store/template/**/*`
},
{ // export store
type: "append",
path: "./packages/components/index.js",
pattern: /\/\* stores \*\//i,
templateFile: ".templates/store/index.js.hbs"
}
],
});
/* Action
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setGenerator("action", {
description: "create new action",
prompts: [
{ // Name
type: "input",
name: "name",
message: "What's the name of your action?"
},
],
actions: [
{ // create action
type: "addMany",
destination: "./packages/components/src/actions",
base: `.templates/action/template`,
templateFiles: `.templates/action/template/**/*`
},
{ // export action
type: "append",
path: "./packages/components/index.js",
pattern: /\/\* actions \*\//i,
templateFile: ".templates/action/index.js.hbs"
}
],
});
/* Story
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setGenerator("story", {
description: "create new story",
prompts: [
{ // Name story
type: "input",
name: "name",
message: "What is the name of your story?"
}
],
actions: [
{ // Create story
type: "addMany",
destination: "./apps/+stories/src/{{name}}",
base: `.templates/story/`,
templateFiles: `.templates/story/**/*.hbs`
}
],
});
/* CI
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setGenerator("ci", {
description: "create new CI",
prompts: [
{ // Name your CI
type: "input",
name: "name",
message: "What is the name of the app?"
}
],
actions: [
{ // Add CI templates
type: "addMany",
destination: "./apps/{{name}}/",
base: `.templates/ci/`,
templateFiles: `.templates/ci/**/*.hbs`
},
{ // Add to the "include" inside the root .gitlab-ci.yml file
type: "append",
path: "./.gitlab-ci.yml",
pattern: /include\:/g,
templateFile: ".templates/.gitlab-ci.yml.hbs"
}
],
});
/* Helpers
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setHelper("lowerCaseNoSpace", function (str) {
return str.toLowerCase().replace(/\s/g, '');
});
plop.setHelper("createPortNumber", function () {
return Math.floor(Math.random() * 1000) + 3000;
});
}