|
1 |
| -module.exports = function(plop) { |
2 |
| - plop.addHelper("lowerCase", text => text.toLowerCase()); |
3 |
| - plop.addHelper("properCase", text => |
4 |
| - text.replace(/\w\S*/g, function(txt) { |
| 1 | +module.exports = function (plop) { |
| 2 | + plop.addHelper('lowerCase', (text) => text.toLowerCase()); |
| 3 | + plop.addHelper('properCase', (text) => |
| 4 | + text.replace(/\w\S*/g, function (txt) { |
5 | 5 | return txt.charAt(0).toUpperCase() + txt.substr(1);
|
6 |
| - }) |
| 6 | + }), |
7 | 7 | );
|
8 | 8 |
|
9 |
| - plop.setGenerator("component", { |
10 |
| - description: "Add a react component", |
| 9 | + plop.setGenerator('component', { |
| 10 | + description: 'Add a react component', |
11 | 11 | prompts: [
|
12 | 12 | {
|
13 |
| - type: "input", |
14 |
| - name: "name", |
15 |
| - message: "Component name please (ex: layout, breadcrumbs, menuItem)!" |
16 |
| - } |
| 13 | + type: 'input', |
| 14 | + name: 'name', |
| 15 | + message: 'Component name please (ex: layout, breadcrumbs, menuItem)!', |
| 16 | + }, |
17 | 17 | ],
|
18 | 18 | actions: [
|
19 | 19 | {
|
20 |
| - type: "add", |
| 20 | + type: 'add', |
21 | 21 | path:
|
22 |
| - "src/lib/components/{{lowerCase name}}/{{properCase name}}.component.js", |
23 |
| - templateFile: "plop-templates/component.hbs" |
| 22 | + 'src/lib/components/{{lowerCase name}}/{{properCase name}}.component.js', |
| 23 | + templateFile: 'plop-templates/component.hbs', |
24 | 24 | },
|
25 | 25 | {
|
26 |
| - type: "add", |
| 26 | + type: 'add', |
27 | 27 | path:
|
28 |
| - "src/lib/components/{{lowerCase name}}/{{properCase name}}.component.test.js", |
29 |
| - templateFile: "plop-templates/component.test.hbs" |
30 |
| - }, |
31 |
| - { |
32 |
| - type: "add", |
33 |
| - path: "src/lib/components/{{lowerCase name}}/__snapshots__/config.js", |
34 |
| - templateFile: "plop-templates/component.config.hbs" |
| 28 | + 'src/lib/components/{{lowerCase name}}/{{properCase name}}.component.test.js', |
| 29 | + templateFile: 'plop-templates/component.test.hbs', |
35 | 30 | },
|
36 | 31 | {
|
37 |
| - type: "add", |
38 |
| - path: "stories/{{lowerCase name}}.js", |
39 |
| - templateFile: "plop-templates/stories.hbs" |
| 32 | + type: 'add', |
| 33 | + path: 'stories/{{lowerCase name}}.stories.js', |
| 34 | + templateFile: 'plop-templates/stories.hbs', |
40 | 35 | },
|
41 |
| - { |
42 |
| - type: "append", |
43 |
| - path: "stories/index.js", |
44 |
| - template: 'import "./{{lowerCase name}}";', |
45 |
| - separator: "" |
46 |
| - } |
47 |
| - ] |
| 36 | + ], |
48 | 37 | });
|
49 | 38 | };
|
0 commit comments