-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplopfile.cjs
80 lines (80 loc) · 2.41 KB
/
plopfile.cjs
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
/* eslint-disable max-lines-per-function */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable func-names */
module.exports = function (plop) {
plop.setGenerator('dynamicStructure', {
actions(data) {
const upperCaseComponentName =
String(data?.componentName)[0].toUpperCase() + String(data?.componentName).slice(1);
const lowerCaseComponentName =
String(data?.componentName)[0].toLowerCase() + String(data?.componentName).slice(1);
const modelClassName = `${upperCaseComponentName}Model`;
const viewClassName = `${upperCaseComponentName}View`;
const stylesName = `${lowerCaseComponentName}View.module.scss`;
return [
{
data: {
modelClassName,
viewClassName,
},
path: `src/${data?.folderName}/${upperCaseComponentName}/model/${upperCaseComponentName}Model.ts`,
templateFile: 'src/templates/NewComponent/model/TemplateModel.ts',
type: 'add',
},
{
data: {
stylesName,
viewClassName,
},
path: `src/${data?.folderName}/${upperCaseComponentName}/view/${upperCaseComponentName}View.ts`,
templateFile: 'src/templates/NewComponent/view/TemplateView.ts',
type: 'add',
},
{
path: `src/${data?.folderName}/${upperCaseComponentName}/view/${lowerCaseComponentName}View.module.scss`,
templateFile: 'src/templates/NewComponent/view/templateView.module.scss',
type: 'add',
},
];
},
description: 'Generator for new component',
prompts: [
{
choices: [
{
name: 'app',
value: 'app',
},
{
name: 'entities',
value: 'entities',
},
{
name: 'features',
value: 'features',
},
{
name: 'pages',
value: 'pages',
},
{
name: 'shared',
value: 'shared',
},
{
name: 'widgets',
value: 'widgets',
},
],
message: 'Choose the folder where you want to create new component:',
name: 'folderName',
type: 'rawlist',
},
{
message: 'Enter the new component name:',
name: 'componentName',
type: 'input',
},
],
});
};