-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
65 lines (62 loc) · 1.82 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
const { camelCase, pascalCase, snakeCase, paramCase } = require('change-case');
const path = require('path');
module.exports = (plop) => {
plop.setHelper('camelCase', (text) => camelCase(text));
plop.setHelper('pascalCase', (text) => pascalCase(text));
plop.setHelper('snakeCase', (text) => snakeCase(text));
plop.setHelper('kebabCase', (text) => paramCase(text));
plop.setHelper(
'titleCase',
(text) => text.charAt(0).toUpperCase() + text.slice(1)
);
plop.setHelper('componentPath', (compName) => {
const pascalCaseName = plop.getHelper('pascalCase')(compName);
return path.join('src', 'components', 'core', pascalCaseName);
});
plop.setGenerator('feature', {
description: 'Generate common files and boilerplate code for a feature',
prompts: [
{
type: 'input',
name: 'featureName',
message: 'Enter the name of the feature (in singular form):',
},
{
type: 'input',
name: 'featureNameInPlural',
message: 'Enter the name of the feature (in plural form):',
},
],
actions: [
{
type: 'addMany',
destination: 'src/libs/features/{{ featureName }}',
base: 'templates/features',
templateFiles: 'templates/features/*',
},
],
});
plop.setGenerator('component', {
description: 'Generate files and boilerplate code for a core component',
prompts: [
{
type: 'input',
name: 'folderName',
message: 'Folder Name: ',
},
{
type: 'input',
name: 'compName',
message: 'Component Name: ',
},
],
actions: [
{
type: 'addMany',
destination: 'src/components/{{folderName}}/{{pascalCase compName}}',
base: 'templates/core',
templateFiles: 'templates/core/**',
},
],
});
};