forked from oneezy/monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.multiselect.mjs
111 lines (102 loc) · 3.35 KB
/
plopfile.multiselect.mjs
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
/* Component
▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ */
plop.setGenerator("component", {
description: "Create a new component",
prompts: [
{ // Name
type: "input",
name: "name",
message: "What's the name of your component?"
},
{ // Type
type: 'list',
name: 'component',
message: 'What type of component?',
choices: ['Component', 'Action', 'Store']
}
],
actions: function(data) {
let actions = [];
/* Component Type */
switch (data.component) {
case 'Component':
// create component
actions.push({
type: "addMany",
destination: "./packages/components/src/{{name}}",
base: `.templates/component/template`,
templateFiles: `.templates/component/template/**/*`
});
// export component
actions.push({
type: "append",
path: "./packages/components/index.js",
pattern: /\/\* components \*\//i,
templateFile: ".templates/component/index.js.hbs"
});
// create story
actions.push({
type: "addMany",
destination: "./apps/+stories/src/{{name}}",
base: `.templates/story/`,
templateFiles: `.templates/story/**/*.hbs`
});
break;
case 'Store':
// create store
actions.push({
type: "addMany",
destination: "./packages/components/src/stores",
base: `.templates/store/template`,
templateFiles: `.templates/store/template/**/*`
});
// export store
actions.push({
type: "append",
path: "./packages/components/index.js",
pattern: /\/\* stores \*\//i,
templateFile: ".templates/store/index.js.hbs"
});
break;
case 'Action':
// create action
actions.push({
type: "addMany",
destination: "./packages/components/src/actions",
base: `.templates/action/template`,
templateFiles: `.templates/action/template/**/*`
});
// export action
actions.push({
type: "append",
path: "./packages/components/index.js",
pattern: /\/\* actions \*\//i,
templateFile: ".templates/action/index.js.hbs"
});
break;
default:
// create component
actions.push({
type: "addMany",
destination: "./packages/components/src/{{name}}",
base: `.templates/component/template`,
templateFiles: `.templates/component/template/**/*`
});
// export component
actions.push({
type: "append",
path: "./packages/components/index.js",
pattern: /\/\* components \*\//i,
templateFile: ".templates/component/index.js.hbs"
});
// create story
actions.push({
type: "addMany",
destination: "./apps/+stories/src/{{name}}",
base: `.templates/story/`,
templateFiles: `.templates/story/**/*.hbs`
});
}
return actions;
},
});