Fastree config
This file is your blueprint for generating project structures automatically. Let's break it down step by step. š
fastree.config.json
is the configuration file that defines the folder and file structure of your project. It allows you to automate the creation of directories, files, and templates by running a single command.
šÆ Example Configuration
Here's a sample .fastree.config.json
file:
{
"structure": [
{
"path": "src/components",
"folders": [
{
"name": "<feature-name>",
"files": [],
"folders": []
}
],
"files": [
{
"name": "<feature-name>-component.tsx",
"template": "ReactComponent"
}
]
}
]
}
š Breaking It Down
-
structure (Array) : This is the main section that defines the folders and files Fastree will generate.
-
path (String) : Specifies the base directory where new components or features will be created. In the example above, everything will be created inside src/components.
-
folders (Array) : Defines nested folders within the base path. The
{ "name": "<feature-name>" }
section means that when you generate a feature,<feature-name>
will be replaced dynamically. -
files (Array) : Defines files that should be created inside the specified directory. The
{ "name": "<feature-name>-component.tsx", "template": "ReactComponent" }
means: The file name will be replaced dynamically with the feature name. It will use the "ReactComponent" template.
š Using Fastree Now that you have set up your configuration, you can generate features using:
npx fastree generate auth
What Happens?
A new folder named Auth will be created inside src/components/. A file Auth-component.tsx will be generated using the ReactComponent template. Final Output Structure:
src/
āāā components/
ā āāā auth/
ā ā āāā auth-component.tsx (Generated using template)
Now you're all set to automate your project structure like a pro! š Happy coding! š