-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
148 lines (137 loc) · 5.36 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//TODO: Revisit paths. Will change since this is in framework folder now.
module.exports = function (plop) {
// plop.addHelper('NSToPath', function (ns) {
// return ns.replace(/\./gm,"/");
// });
plop.addHelper('FQNS_to_NS_and_Class', function (fqns) {
var parts = fqns.split(".");
var className = parts.pop();
var namespace = parts.join(".");
return {
namespace: ns,
className:className
}
});
plop.addHelper('FQNS_to_NS', function (fqns) {
var parts = fqns.split(".");
var className = parts.pop();
var namespace = parts.join(".");
return namespace
});
plop.addHelper('FQNS_to_NS_Path', function (fqns) {
var parts = fqns.split(".");
var className = parts.pop();
var namespace = parts.join("/");
return namespace
});
plop.addHelper('FQNS_to_Class', function (fqns) {
var parts = fqns.split(".");
var className = parts.pop();
return className
});
plop.addHelper('FQNS_to_TagName', function (fqns) {
var parts = fqns.split(".");
var className = parts.pop();
var tag = className.replace(/([a-zA-Z])(?=[A-Z0-9])/g, (f,m)=> `${m}-`).toLowerCase();
return tag
});
// create your generators here
plop.setGenerator('component', {
description: 'Generates a UI Component',
prompts: [
{
type: 'input',
name: 'namespace',
message: 'Fully-Qualified Namespace',
default: "core.ui.HelloWorld"
},
// {
// type: 'input',
// name: 'namespace',
// message: 'Component Namespace',
// default: "core.ui"
// },
// {
// type: 'input',
// name: 'class',
// message: 'Class Name',
// validate: function (value) {
// var tag = value.replace(/([a-zA-Z])(?=[A-Z0-9])/g, (f,m)=> `${m}-`).toLowerCase();
// if(tag.indexOf("-")<0){
// return 'Class names should be 2 words in CamelCase.\nEx: SlideShow\nEx: LoginBox\nEx: ToggleSwitch'
// }
// return true;
// }
// },
{
type: 'input',
name: 'parent',
message: 'Extends a parent class ? (a fully-qualified namespace to the parent, ex: w3c.ui.WebComponent)',
default: "w3c.ui.WebComponent"
}
], // array of inquirer prompts
actions: [
{
type: 'add',
path: 'src/{{FQNS_to_NS_Path namespace}}/{{FQNS_to_Class namespace}}/index.js',
templateFile: 'node_modules/od-plopgen-templates/generators/component/index.js.hbs'
},
{
type: 'add',
path: 'src/{{FQNS_to_NS_Path namespace}}/{{FQNS_to_Class namespace}}/index.css',
templateFile: 'node_modules/od-plopgen-templates/generators/component/index.css.hbs'
},
{
type: 'add',
path: 'src/{{FQNS_to_NS_Path namespace}}/{{FQNS_to_Class namespace}}/index.html',
templateFile: 'node_modules/od-plopgen-templates/generators/component/index.html.hbs'
}
] // array of actions
});
// create your generators here
plop.setGenerator('app', {
description: 'Generates an Application',
prompts: [
{
type: 'input',
name: 'namespace',
message: 'Application Namespace',
default:"applications.HelloWorld"
}
// {
// type: 'input',
// name: 'class',
// message: 'Application Class Name',
// validate: function (value) {
// var tag = value.replace(/([a-zA-Z])(?=[A-Z0-9])/g, (f,m)=> `${m}-`).toLowerCase();
// if(tag.indexOf("-")<0){
// return 'Class names should be 2 words in CamelCase.\nEx: UserDashboard\nEx: ShoppingCart\nEx: ReportsTool'
// }
// return true;
// }
// }
], // array of inquirer prompts
actions: [
{
type: 'add',
path: 'src/{{FQNS_to_NS_Path namespace}}/{{FQNS_to_Class namespace}}/index.js',
templateFile: 'node_modules/od-plopgen-templates/generators/application/index.js.hbs'
},
{
type: 'add',
path: 'src/{{FQNS_to_NS_Path namespace}}/{{FQNS_to_Class namespace}}/index.css',
templateFile: 'node_modules/od-plopgen-templates/generators/application/index.css.hbs'
},
{
type: 'add',
path: 'src/{{FQNS_to_NS_Path namespace}}/{{FQNS_to_Class namespace}}/index.html',
templateFile: 'node_modules/od-plopgen-templates/generators/application/index.html.hbs'
},
{
type: 'add',
path: '{{FQNS_to_TagName namespace}}.html',
templateFile: 'node_modules/od-plopgen-templates/generators/application/default.html.hbs'
}
] // array of actions
});
};