-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplopfile.js
More file actions
82 lines (81 loc) · 3.25 KB
/
plopfile.js
File metadata and controls
82 lines (81 loc) · 3.25 KB
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
module.exports = function (plop) {
plop.setGenerator('experiment', {
description: 'Create a new isolated experiment',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is the name of your experiment?',
validate: (value) => {
if (/.+/.test(value)) {
return true;
}
return 'name is required';
},
},
{
type: 'input',
name: 'description',
message: 'Short description (optional):',
},
],
actions: function () {
const actions = [
// 1. Create Route Group Layout (Isolated Environment)
{
type: 'add',
path: 'src/app/experiments/({{dashCase name}})/layout.tsx',
templateFile: 'plop-templates/experiment/route-layout.tsx.hbs',
},
// 2. Create Route Page
{
type: 'add',
path: 'src/app/experiments/({{dashCase name}})/{{dashCase name}}/page.tsx',
templateFile: 'plop-templates/experiment/route-page.tsx.hbs',
},
// 3. Create Route Error Boundary
{
type: 'add',
path: 'src/app/experiments/({{dashCase name}})/{{dashCase name}}/error.tsx',
templateFile: 'plop-templates/experiment/route-error.tsx.hbs',
},
// 4. Create Metadata File
{
type: 'add',
path: 'src/app/experiments/({{dashCase name}})/experiment.json',
template: JSON.stringify({
title: '{{titleCase name}}',
description: '{{description}}',
slug: '{{dashCase name}}',
created: new Date().toISOString(),
}, null, 2),
},
// 5. Create Public Assets Folder
{
type: 'add',
path: 'public/experiments/{{dashCase name}}/.gitkeep',
template: '',
},
// 6. Create Main Component
{
type: 'add',
path: 'src/components/experiments/{{dashCase name}}/{{pascalCase name}}.tsx',
templateFile: 'plop-templates/experiment/component.tsx.hbs',
},
// 7. Create Component Story
{
type: 'add',
path: 'src/components/experiments/{{dashCase name}}/{{pascalCase name}}.stories.tsx',
templateFile: 'plop-templates/experiment/component.stories.tsx.hbs',
},
// 8. Create Component Test
{
type: 'add',
path: 'src/components/experiments/{{dashCase name}}/{{pascalCase name}}.test.tsx',
templateFile: 'plop-templates/experiment/component.test.tsx.hbs',
}
];
return actions;
},
});
};