-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
47 lines (46 loc) · 1.03 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
const LABEL_RE = /^[\w ]+$/
const TAGS_RE = /^[\w-]+(,\s*[\w-]+)*$/
export default function (
/** @type {import('plop').NodePlopAPI} */
plop,
) {
plop.setHelper('splitCommaList', (input) => {
return input.split(',').map((i) => i.trim())
})
plop.setGenerator('kit', {
description: 'Generate a new kit product',
prompts: [
{
type: 'input',
name: 'label',
message: 'Product label',
validate: (input) => {
return LABEL_RE.test(input)
},
},
{
type: 'input',
name: 'description',
message: 'Product description',
default: '',
},
{
type: 'input',
name: 'tags',
message: 'Product tags',
default: '',
validate: (input) => {
return TAGS_RE.test(input)
},
},
],
actions: [
{
type: 'addMany',
destination: './products/{{ dashCase label }}',
base: './templates/kit',
templateFiles: './templates/kit/*',
},
],
})
}