Skip to content

A command line interface that generate files for your application

Notifications You must be signed in to change notification settings

guignol1981/file-gen-cli

Repository files navigation

Build Status CodeFactor npm version BCH compliance License: MIT

Speed up with

Logo

A CLI that generate files for your application

Getting started

  • install globaly with

    npm i file-gen-cli@latest -g

  • Add a folder to hold your templates and gencli.json files

    files templates examples here see bellow for gencli configuration here

  • Register your cli config with

    file-gen-cli register

  • Use your cli with

    file-gen-cli myCliName

  • List clis with

    `file-gen-cli list [tag1] [tag2] ...

  • Deduce templates from a folder

    file-gen-cli deduce <instanceName> [<prefix> <instanceNamePlural>]

You can rewrite the config the same way

When the register is done, and you use file-gen-cli with you cli name as parameter, it will then generate the files.

File gen cli use an heroku hosted server app to manage the configs, see how it works here https://github.com/guignol1981/file-gen-cli-server

Documentation (gencli.json)

General config

Param definition default required possible values
cliName name of your cli true a string with no spaces
description desc of your config (for public list) true
token a jwt to generate new config true contact me to get a token
fileNameCase the case of the files name kebab false kebab, camel, pascal, constant, snake
folderNameCase the case of the folders name kebab false kebab, camel, pascal, constant, snake
entityConfigs an array of entity configs true see Entity config bellow

Entity config

Param definition default required possible values
name the entity name true
prefix the entity prefix that can occur in different files template false
fileConfigs an array of file configs true
singularOnly if there is only singular name occurence in templates false false
flat determine if the cli should create a folder for the instance false false

File config

Param definition default required possible values
name the file name (the * symbole is replaced by the entity instance name) true
template the template name for the file (no template will generate an empty file) false
path path to create the file relative to the instance path ./ false

Templates

keywords (* = supported cases) replaced with
{{SINGULAR_*}} instance name with specified case
{{PLURAL_*}} instance plural name with specified case
{{PREFIXED_SINGULAR_*}} instance prefixed name with specified case
{{PREFIXED_PLURAL_*}} instance prefixed plural name with specified case

Supported Cases

CAMEL, CAPITAL, CONSTANT, DOT, HEADER, NO, KEBAB (deprecate, use PARAM) PARAM, PASCAL, PATH, SENTENCE, SNAKE,

TODO (feel free to help)

  • Convert to Typescript

Contributing

  • Feel free to suggest features, submit issues or update the documentation!

Contributors

  • Contribute and add your name here!

License

  • Copyright (c) 2019 Vincent Guillemette (github: guignol1981) Licensed under the MIT license.