-
Notifications
You must be signed in to change notification settings - Fork 4
/
plopfile.js
58 lines (55 loc) · 1.82 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
const { snakeCase } = require('lodash');
module.exports = (plop) => {
plop.setHelper('spacedUpperCase', (txt) =>
snakeCase(txt).split('_').join(' ').toUpperCase(),
);
// This helper allows us to place a variable inside curly braces without spaces
// between the text and the braces.
plop.setHelper('inBraces', (txt) => `{${txt}}`);
plop.setGenerator('component', {
description: 'Create a reusable component',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?',
},
],
actions: [
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'plop-templates/Component/Component.tsx.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.stories.ts',
templateFile: 'plop-templates/Component/Component.stories.ts.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.module.css',
templateFile: 'plop-templates/Component/Component.module.css.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.test.ts',
templateFile: 'plop-templates/Component/Component.test.ts.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/index.ts',
templateFile: 'plop-templates/Component/index.ts.hbs',
},
{
type: 'append',
pattern: /;\n$/,
separator: '',
path: 'src/index.ts',
template:
"export { default as {{pascalCase name}} } from './components/{{pascalCase name}}';",
},
// Removed sort to avoid removing per-version component ordering and documentation (see diff for old code)
],
});
};