Crates.io | kgen |
lib.rs | kgen |
version | 0.4.2 |
source | src |
created_at | 2022-08-21 18:00:59.434322 |
updated_at | 2022-08-29 17:45:38.911374 |
description | Codegen tool for typescript React projects |
homepage | |
repository | |
max_upload_size | |
id | 649878 |
size | 13,714 |
kgen is a code generation CLI tool for Typescript (Soon JS too) React projects built in Rust.
It speeds up your development and enforces standardization across your project.
Command example:
kgen component header --data
You could also do:
kgen c header -d
Generates a component in your /components directory (configurable too), and thanks to the --data flag adds basic fetching data logic to it. The generated component should look something like this:
import React from "react";
import { useState, useEffect } from "react";
interface HeaderProps {
}
interface DataType {
}
export const Header = ({ }: HeaderProps) => {
const [data, setData] = useState<DataType>({});
useEffect(() => {
fetch("").then(res => res.json().then(data => {
setData(data);
}))
}, [])
return (
<>
</>
)
}
To get this helper list with all the commands, flags, and aliases with short description whenever you need, just type on your terminal
kgen
orkgen --help
.
kgen [FILE_TYPE] [NAME] <EXTRA_OPTIONS>
component
| alias: c
| Generates a component file with boilerplate in the components directory.page
| alias: p
| Generates a page component file with boilerplate in the pages directory.--data
| alias: -d
| Adds data fetching logic to the component.--children
| alias: -c
| Adds children logic to the component.--local
| alias: -l
| Creates the component in the current directory.