-
Notifications
You must be signed in to change notification settings - Fork 17
/
plopfile.js
70 lines (65 loc) · 1.54 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
const fs = require('fs');
const getReadmeData = require('./scripts/get-readme-template-data');
const packagesPath = 'packages';
const componentsPath = `${packagesPath}/components`;
const templatesPath = 'plop-templates';
module.exports = plop => {
// We declare a new generator
plop.setGenerator('component', {
// Describes what generator does.
description: 'Create a new component',
// Get inputs from the user.
// That's Inquirer.js doing the job behind the hood.
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?'
},
{
type: 'input',
name: 'version',
message: 'version?',
default() {
const lernaData = JSON.parse(fs.readFileSync('./lerna.json', 'utf8'));
return lernaData.version;
}
}
],
actions: [
{
type: 'addMany',
destination: `${componentsPath}`,
base: `${templatesPath}/components`,
templateFiles: `${templatesPath}/components/**`,
data() {
const lernaData = JSON.parse(fs.readFileSync('./lerna.json', 'utf8'));
return {
version: lernaData.version
};
}
}
]
});
plop.setGenerator('readme', {
description: 'Generate README.md files',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is the component name?'
}
],
actions: function(data) {
return [
{
type: 'add',
force: true,
path: `${componentsPath}/{{kebabCase name}}/README.md`,
templateFile: `${templatesPath}/readme/README.md`,
data: () => getReadmeData(data.name)
}
];
}
});
};