-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
87 lines (83 loc) · 2.47 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
module.exports = function(plop) {
plop.setGenerator("React Component", {
description: "Create a new React component",
prompts: [
{
type: "prompt",
name: "componentName",
message: "Name of your component:"
}
],
actions: () => {
const actions = [
{
type: "add",
path:
"./src/components/{{pascalCase componentName}}/{{pascalCase componentName}}.js",
templateFile: "./config/plop/component/component.js.plop"
}
];
return actions;
}
});
plop.setActionType("doTheThing", function(answers, config, plop) {
// do something
doSomething(config.configProp);
// if something went wrong
throw "error message";
// otherwise
return "success status message";
});
plop.setGenerator("Apollo Store", {
description: "Generate a new Apollo local store",
prompts: [
{
type: "prompt",
name: "storeName",
message: 'Name of your store (e.g. "Lang" or "Theme")'
}
],
actions: () => {
const actions = [
{
type: "add",
path: "./src/store/{{pascalCase storeName}}/index.js",
templateFile: "./config/plop/store/index.js.plop"
},
{
type: "add",
path: "./src/store/{{pascalCase storeName}}/defaults.js",
templateFile: "./config/plop/store/defaults.js.plop"
},
{
type: "add",
path: "./src/store/{{pascalCase storeName}}/queries.js",
templateFile: "./config/plop/store/queries.js.plop"
},
{
type: "add",
path: "./src/store/{{pascalCase storeName}}/mutations.js",
templateFile: "./config/plop/store/mutations.js.plop"
},
{
type: "add",
path: "./src/store/{{pascalCase storeName}}/resolvers.js",
templateFile: "./config/plop/store/resolvers.js.plop"
},
{
type: "modify",
path: "./src/lib/apolloLinkState.js",
pattern: /(import { withClientState } from "apollo-link-state";)/gi,
template: `import { {{camelCase storeName}}Store } from "../store/{{pascalCase storeName}}";\r\nimport { withClientState } from "apollo-link-state";`
},
{
type: "modify",
path: "./src/lib/apolloLinkState.js",
pattern: /(];)/gi,
template: ", {{camelCase storeName}}Store];"
}
];
return actions;
}
});
};