-
Notifications
You must be signed in to change notification settings - Fork 116
/
plopfile.js
118 lines (117 loc) · 3.92 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const camelCase = require("lodash/camelCase");
const startCase = require("lodash/startCase");
module.exports = function (plop) {
plop.setHelper("export", (txt) => `export {${startCase(camelCase(txt)).replace(/ /g, "")}}`);
plop.setHelper("import", (txt) => `import {${startCase(camelCase(txt)).replace(/ /g, "")}}`);
plop.setGenerator("create-package", {
description: "Creates a new component package",
prompts: [
{
type: "list",
name: "component-type",
message: "What type of component package?",
choices: ["components", "layout", "primitives"],
},
{
type: "input",
name: "component-name",
message: "What is the component package name?",
},
{
type: "list",
name: "component-category",
message: "What is the component package category?",
choices: [
"data display",
"feedback",
"interaction",
"layout",
"navigation",
"overlays",
"typography",
"user input",
],
},
{
type: "list",
name: "component-status",
message: "What is the component package status?",
choices: ["alpha", "beta", "production"],
},
{
type: "input",
name: "component-description",
message: "What is the component package description?",
},
],
actions: [
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/src/index.tsx",
templateFile: "tools/plop-templates/component-index.hbs",
},
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/src/{{pascalCase component-name}}.tsx",
templateFile: "tools/plop-templates/component-component.hbs",
},
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/__tests__/index.spec.tsx",
templateFile: "tools/plop-templates/component-tests.hbs",
},
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/stories/index.stories.tsx",
templateFile: "tools/plop-templates/component-stories.hbs",
},
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/build.js",
templateFile: "tools/plop-templates/build.hbs",
},
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/package.json",
templateFile: "tools/plop-templates/package.hbs",
},
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/tsconfig.json",
templateFile: "tools/plop-templates/tsconfig.hbs",
},
{
type: "add",
path: "packages/paste-core/{{component-type}}/{{kebabCase component-name}}/CHANGELOG.md",
templateFile: "tools/plop-templates/CHANGELOG.hbs",
},
],
});
plop.setGenerator("create-component-docs", {
description: "Creates a new directory for documentation of a component package on the website",
prompts: [
{
type: "input",
name: "component-name",
message: "What is the component package name?",
},
],
actions: [
{
type: "add",
path: "packages/paste-website/src/pages/components/{{kebabCase component-name}}/index.mdx",
templateFile: "tools/plop-templates/docs-index.hbs",
},
{
type: "add",
path: "packages/paste-website/src/pages/components/{{kebabCase component-name}}/api.mdx",
templateFile: "tools/plop-templates/docs-api.hbs",
},
{
type: "add",
path: "packages/paste-website/src/pages/components/{{kebabCase component-name}}/changelog.mdx",
templateFile: "tools/plop-templates/docs-changelog.hbs",
},
],
});
};