-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
46 lines (44 loc) · 1.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
const frameworks = ['D3', 'Vega', 'Vega-Lite', 'AntV', 'Echarts', 'RoughViz'];
const InsertPoints = {};
frameworks.forEach(framework => {
InsertPoints[framework] = `<!-- ${framework} Insert Point -->`
});
module.exports = function (plop) {
plop.setGenerator('new', {
description: 'Add new demo',
prompts: [{
type: 'input',
name: 'name',
message: 'Demo name please'
}, {
type: 'input',
name: 'tags',
message: 'Tags please, seperated by commas',
}],
actions: (answers) => {
const {_name, _tags} = answers;
const name = _name.trim().split(" ").map(subName => subName.trim()).join("-")
let tagsArr = _tags.trim().split(",").map(tag =>tag.trim());//JSON.parse(tags);
if(!Array.isArray(tagsArr)) tagsArr = [];
else tagsArr = tagsArr.map(item => "" + item)
return [{
type: 'add',
path: 'src/app/gallery/(demos)/{{kebabCase name}}/page.tsx',
templateFile: 'templates/page.hbs'
},{
type: 'add',
path: 'src/app/gallery/(demos)/{{kebabCase name}}/render.ts',
templateFile: 'templates/render.hbs'
},{
type: 'modify',
path: 'src/app/gallery/config.ts',
pattern: `// __plop_insert_point__`,
template: `, {
name: "${name}",
width: "w-40",
tags: ${JSON.stringify(tagsArr)}
}// __plop_insert_point__`
}]
}
})
}