Skip to content

doooss/ps-gen

Repository files navigation

sample-cli

Personal CLI Template Tool Like @turbo/gen

This code was authored by ChatGPT.

How to use

  1. install package (Dev recommand)
    npm i -D ps-gen
  1. Please add ps-gen to the scripts in package.json as follows:
    "scripts":{
        "gen" : "ps-gen"
    }
  1. 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 }}\""
        }
    ]
}   

  1. In the folder where config.json is located, please create the desired template using the .hbs

About

cli lib like turbo/gen

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published