Zumen is a command line tool.
A development tool that can create a group of files at once based on the design described in json (or yaml)
Install the design set with the init command.
npx zumen@latest init
Next, customize the design set and run basic commands.
npx zumen@latest
Add the -o option to overwrite the output file.
Be careful, as the finished file that you manually customized will be reverted.
npx zumen@latest -o
preview of final structure "-p" option preview the final system-interpreted structure.
npx zumen@latest -p
- Create a drawing file (zumen.json) directly under the project.
- Create a template file (**..ejs) in ./zumen/
- run command 'npx zumen@latest'
Place the drawing file (zumen.json or zumen.yml, zumen.yaml) that describes the files to be created directly under the project.
Describe the file structure in the drawing file. For folders, add / at the end of the item name, and for files, the item name will be "template name"="file name". See the example for details. (The right hand side of "=" is a string that will later be used in templates and to replace {name} in filenames.)
{
"src/": {
"components/": {
"template01=dialogComponent": {
"comment": "the comment"
}
}
}
}
- Item names and values in the file are basically arbitrary and can be expanded as ejs in the template. (However, the name and path are added implicitly, so even if you specify them, they will be overwritten by the system.)
- For other detailed explanations, please refer to "Special function".
- how to use ejs https://ejs.co/#docs
Create the template described in the drawing file. The template name is arbitrary, but must match the field name with equals. In the example above, you need to create a template called "template01".
filename: ./zumen/template01={name}.tsx.ejs
// <%= comment %>
const <%= name %> = () => {
return (
<div>
I'm <%= name %>
</div>
);
}
- Make sure the file extension is ".ejs"
- {name} replaces the right side of equals specified in the drawing file.
- The template is finally compiled with ejs.
src/components/dialogComponent.tsx
// the comment
const dialogComponent = () => {
return (
<div>
I'm dialogComponent
</div>
);
}
If you specify "@{template name}" as the value of the item to expand, it will return a list of target file names in the specified hierarchy and will be replaced with a complete array in the template.
{
"src/": {
"components/": {
"component=DialogOpen": {
"comment": "Dialog open button."
},
"component=DialogClose": {
"comment": "Dialog close button."
},
"index=": {
"brings": "@component"
}
}
}
}
- Can also be set like "../@component" with hierarchy specified.
<%_ for (var i = 0; i < brings.length; i++) { _%>
export * from './<%= brings[i].name %>';
<%_ } _%>
#### File completed with the above set
export * from './DialogOpen';
export * from './DialogClose';
You can use the file name "name" and the file path string "path" in the template.