-
Notifications
You must be signed in to change notification settings - Fork 3
/
plopfile.js
83 lines (78 loc) · 2.21 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
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
const path = require('path');
const types = ['Package'];
const checkTypedName = (plop, type) => text => {
const properName = plop.getHelper('properCase');
const rv = properName(text);
if (!type || text.toLowerCase().indexOf(type.toLowerCase()) > -1) {
return rv;
}
return `${rv}${type}`;
};
const entry = plop => {
types.forEach(t => {
plop.setHelper(`check${t}Name`, checkTypedName(plop, t));
});
plop.setGenerator('package', {
description: 'create a new package',
prompts: [
{
type: 'input',
name: 'name',
message: "what's the name for the package?"
},
{
type: 'input',
name: 'description',
message: 'description to provide for the package.json'
},
{
type: 'input',
name: 'author',
message: 'author to provide for the package.json'
}
],
actions: [
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/package.json',
templateFile: '.plops/templates/package/package.json.hbs'
},
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/.gitignore',
templateFile: '.plops/templates/package/.gitignore.hbs'
},
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/.npmignore',
templateFile: '.plops/templates/package/.npmignore.hbs'
},
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/src/index.js',
templateFile: '.plops/templates/package/index.js.hbs'
},
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/.babelrc',
templateFile: '.plops/templates/package/.babelrc.hbs'
},
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/README.md',
templateFile: '.plops/templates/package/README.md.hbs'
},
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/rollup.config.js',
templateFile: '.plops/templates/package/rollup.config.js.hbs'
},
{
type: 'add',
path: 'packages/tao-{{kebabCase name}}/test/index.spec.js',
templateFile: '.plops/templates/package/index.spec.js.hbs'
}
]
});
};
module.exports = entry;