-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
47 lines (45 loc) · 1.56 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 frameworks = ['D3', 'Vega', 'Vega-Lite', 'AntV', 'Echarts', 'RoughViz'];
const InsertPoints = {};
frameworks.forEach(framework => {
InsertPoints[framework] = `<!-- ${framework} Insert Point -->`
});
module.exports = function (plop) {
plop.setGenerator('demo', {
description: 'Add new demo',
prompts: [{
type: 'input',
name: 'name',
message: 'Demo name please'
}, {
type: 'list',
name: 'framework',
message: 'Framework please',
choices: frameworks,
default: frameworks[0]
// choices: frameworks.map(framework => ({
// name: framework
// })),
// default: frameworks[0]
},
{
type: 'input',
name: 'source',
message: 'Demo source url please'
}],
actions: (answers) => [{
type: 'add',
path: 'src/demos/{{kebabCase framework}}/{{kebabCase name}}/index.js',
templateFile: 'templates/index.js'
},{
type: 'add',
path: 'src/demos/{{kebabCase framework}}/{{kebabCase name}}/index.html',
templateFile: 'templates/demo-template.hbs'
},{
type: 'modify',
path: 'src/index.html',
pattern: `<!-- ${answers.framework} Insert Point -->`,
template: `<li><a href="./demos/{{kebabCase framework}}/{{kebabCase name}}/index.html">{{titleCase name}}</a></li>
<!-- ${answers.framework} Insert Point -->`
}]
})
}