-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
108 lines (106 loc) · 2.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
const { spawn } = require("child_process");
const installPackageInStorybook = (answers) => {
const kebabize = (str) =>
str
.replace(/([a-z])([A-Z])/g, "$1-$2")
.replace(/[\s_]+/g, "-")
.toLowerCase();
const packageName = `@fiscozen/${kebabize(answers.component)}`;
return new Promise((resolve, reject) => {
const process = spawn("pnpm", [
"--filter",
"@fiscozen/storybook",
"install",
packageName,
"--workspace",
]);
process.on("close", (code) => {
if (code === 0) resolve();
else reject(`exited with ${code}`);
});
});
};
module.exports = function (plop) {
basePath = "./packages/{{kebabCase component}}/";
plop.setActionType("installPackageInStorybook", installPackageInStorybook);
plop.setGenerator("component", {
description: "create a new component for the Design System",
prompts: [
{
type: "input",
name: "component",
message: "Insert component name",
},
{
type: "input",
name: "author",
message: "Insert author name",
},
],
actions: [
{
type: "add",
path: basePath + "package.json",
templateFile: "templates/component/package.json",
},
{
type: "add",
path: basePath + "tsconfig.json",
templateFile: "templates/component/tsconfig.json",
},
{
type: "add",
path: basePath + "vite.config.ts",
templateFile: "templates/component/vite.config.ts",
},
{
type: "add",
path: basePath + "vitest.config.ts",
templateFile: "templates/component/vitest.config.ts",
},
{
type: "add",
path: basePath + "prettierrc.js",
templateFile: "templates/component/.prettierrc.js",
},
{
type: "add",
path: basePath + "eslintrc.cjs",
templateFile: "templates/component/.eslintrc.cjs",
},
{
type: "add",
path: basePath + "README.md",
templateFile: "templates/component/README.md",
},
{
type: "add",
path: basePath + "src/index.ts",
templateFile: "templates/component/src/index.ts",
},
{
type: "add",
path: basePath + "src/types.ts",
templateFile: "templates/component/src/types.ts",
},
{
type: "add",
path: basePath + "src/Fz{{pascalCase component}}.vue",
templateFile: "templates/component/src/FzComponent.vue",
},
{
type: "add",
path: basePath + "src/__tests__/Fz{{pascalCase component}}.spec.ts",
templateFile: "templates/component/src/__tests__/FzComponent.spec.ts",
},
{
type: "add",
path: "./apps/storybook/src/stories/{{pascalCase component}}.stories.ts",
templateFile: "templates/component/src/story.ts",
},
{
type: "installPackageInStorybook",
},
],
});
};