-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
executable file
·34 lines (28 loc) · 1.01 KB
/
main.js
File metadata and controls
executable file
·34 lines (28 loc) · 1.01 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
#!/usr/bin/env node
const generateTemplateFile = require("./utils/index");
const fs = require("fs-extra");
const path = require("path");
const program = require("commander");
const chalker = require("chalker");
program
.name("create-react-component")
.version("0.0.1")
.description("A CLI tool to generate React components")
.arguments("<componentName>")
.action((componentName) => {
const componentPath = path.join("Components", componentName);
// Create the component directory
try {
fs.ensureDirSync(componentPath);
} catch (err) {
console.error(`Failed to create directory: ${err}`);
process.exit(1);
}
// Create the component files
const templateFiles = ["MyComponent.tsx", "text.ts", "useCustomHook.tsx"];
generateTemplateFile(templateFiles, componentName, componentPath);
console.log(
chalker`<blue> 🚀🚀🚀 React component '${componentName}' created successfully at ${componentPath} 🚀🚀🚀</blue>`
);
});
program.parse(process.argv);