-
Notifications
You must be signed in to change notification settings - Fork 2
/
plopfile.ts
61 lines (61 loc) · 1.97 KB
/
plopfile.ts
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
export const plop = (plop: any) => {
plop.setGenerator('component', {
description: 'Create a component',
// User input prompts provided as arguments to the template
prompts: [
{
// Raw text input
type: 'input',
// Variable name for this input
name: 'name',
// Prompt to display on command line
message: 'What is your component name?',
},
],
actions: [
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Component/Component.tsx.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.test.tsx',
templateFile: 'plop-templates/Component/Component.test.tsx.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.style.ts',
templateFile: 'plop-templates/Component/Component.style.ts.hbs',
},
{
type: 'add',
path:
'src/components/{{pascalCase name}}/{{pascalCase name}}.stories.tsx',
templateFile: 'plop-templates/Component/Component.stories.tsx.hbs',
},
{
type: 'add',
path:
'src/components/{{pascalCase name}}/{{pascalCase name}}.stories.mdx',
templateFile: 'plop-templates/Component/Component.stories.mdx.hbs',
},
{
// Adds an index.js file if it does not already exist
type: 'add',
path: 'src/components/index.ts',
templateFile: 'plop-templates/index.ts.hbs',
// If index.js already exists in this location, skip this action
skipIfExists: true,
},
{
type: 'append',
path: 'src/components/index.ts',
template: `export * from './{{pascalCase name}}/{{pascalCase name}}';`,
},
],
});
};