2

I'm in the process of building some tools but find myself thinking I'm reinventing the wheel. I'm looking for a cli, preferably written in javascript, that has a config file and template engine. The config file would let you specify projects and features and have a path option that would point to the template(s) and create the files/folders at the path specified by the config, or current working directory. Ideally it would not overwrite folders or files that were pre-existing and would handle such cases gracefully.

I started building something like this using oclif for the cli framework. So the responses I get here will determine if I continue that work or save some time by using something that may be more polished. The example below is react, but I would want to use such a tool for Laravel, Vue, Vulcan, etc...

In the end it doesn't matter how it works but here is an example of a possible solution.

config.js

const commands = {
  react: {
    functionalComponent: {
      argName: 'fc',
      template: '/templates/react/fc.hbs'
    }
  }
}
// console
$ cd ./my-project/src/components
$ gen react -fc
rob.luton
  • 395
  • 1
  • 4
  • 7

1 Answers1

2

You could try the CLI version (https://www.telosys.org/cli.html) of Telosys (https://www.telosys.org/ ) an Open Source code generator.

This code generator is language agnostic, you can generate any kind of text files.

It uses a template engine (https://www.telosys.org/templates.html ) based on Velocity (http://velocity.apache.org/engine/1.7/ ) and each template file can be fed with variables defined for each project and/or entities defined in text files.

This tool is written in Java (not in JS) but it only requires a Java Runtime on your machine (Java 7 or +), that's it.

I use it very often for project bootstrapping and to generate all the boilerplate (and boring) code.

See also :

rlopez
  • 655
  • 7
  • 15