-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathplopfile.js
52 lines (49 loc) · 1.44 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
const commonPrompts = [
{
type: 'input',
name: 'name',
message: 'Widget name',
},
{
type: 'input',
name: 'author',
message: 'Widget author',
default: 'Eko Eryanto <[email protected]>',
},
];
const addFile = (type, path, tpl) => {
const template = (tpl || path).replace(/\.hbs$/, '');
return {
type: 'add',
path: `${type}/{{kebabCase name}}/${path}`,
templateFile: `plop-templates/${type}/${template}.hbs`,
};
};
module.exports = function generate(plop) {
plop.setGenerator('widget', {
description: 'Generate basic files for new widget',
prompts: commonPrompts,
actions: () => [
addFile('widgets', 'package.json'),
addFile('widgets', '/src/index.js', 'index.js'),
addFile('widgets', 'src/Control.js', 'control.js'),
addFile('widgets', 'src/Preview.js', 'preview.js'),
addFile('widgets', 'README.md'),
addFile('widgets', '.babelrc'),
addFile('widgets', 'rollup.config.js'),
addFile('widgets', 'public/index.html', 'index.html'),
addFile('widgets', 'public/config.yml', 'config.yml'),
],
});
plop.setGenerator('core', {
description: 'Generate basic files for new widget',
prompts: commonPrompts,
actions: () => [
addFile('core', '.babelrc'),
addFile('core', 'src/index.js', 'index.js'),
addFile('core', 'package.json'),
addFile('core', 'README.md'),
addFile('core', 'rollup.config.js'),
],
});
};