sample-cli
Personal CLI Template Tool Like @turbo/gen
This code was authored by ChatGPT.
How to use
- install package (Dev recommand)
npm i -D ps-gen
- Please add ps-gen to the scripts in package.json as follows:
"scripts":{
"gen" : "ps-gen"
}
- Please write the following in <project-root>/cli/template/<template-name>/config.json:
ex. root/cli/template/hooks/config.json
{
"description": "keeping the naming convention (ex use + PascalCase)",
"prompts": [
{
"type": "input",
"name": "name",
"message": "What is the name of the hook?"
}
],
"baseUrl": "src/hooks",
"actions": [
{
"type": "add",
"path": "{{name}}/{{name}}.test.ts",
"templateFile": "test.hbs"
},
{
"type": "add",
"path": "{{name}}/index.ts",
"templateFile": "export.hbs"
},
{
"type": "add",
"path": "{{name}}/{{name}}.ts",
"templateFile": "hook.hbs"
},
{
"type": "append",
"path": "index.ts",
"template": "export { default as {{ name }} } from \"./{{ name }}\""
}
]
}
- In the folder where config.json is located, please create the desired template using the .hbs