forked from chakra-ui/chakra-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.ts
63 lines (51 loc) · 1.39 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
62
63
import nodePlop, { ActionType } from "node-plop"
import shell from "shelljs"
import _ from "lodash"
const plop = nodePlop("plop-templates/plopfile.hbs")
interface Answers {
componentName: string
description: string
destinationDirectory: "packages" | "tooling"
}
async function createPackage() {
plop.setHelper("capitalize", (text) => {
return _.capitalize(_.camelCase(text))
})
plop.setGenerator("component", {
description: "Generates a component package",
prompts: [
{
type: "input",
name: "componentName",
message: "Enter component name:",
},
{
type: "input",
name: "description",
message: "The description of this component:",
},
],
actions(answers: any) {
const actions: ActionType[] = []
if (!answers) return actions
const { componentName, description } = answers as Answers
actions.push({
type: "addMany",
templateFiles: "component-pkg/**",
destination: "../packages/{{dashCase componentName}}",
base: "component-pkg/",
data: { description, componentName },
abortOnFail: true,
})
return actions
},
})
const { runPrompts, runActions } = plop.getGenerator("component")
const answers = await runPrompts()
await runActions(answers)
}
async function run() {
await createPackage()
shell.exec("yarn")
}
run()