A CLI utility library for scaffolding code templates and boilerplates
Sometimes you can find yourself copypasting a whole folder of files which represents some component (f.e. React component) and then renaming filenames, variables, etc. to satisfy your needs. Bystro helps you to automate this process.
$ npm install -D bystro
$ bystro <template_name> <path>
Note: You can alternatively run
npx bystro <template_name> <path>
without install step.
<template_name>
- Name of the template you want to scaffold.
<path>
- Path to scaffold template in.
List of available templates can be found here
To create a local template start by making a .bystro
directory in the current working directory:
$ mkdir .bystro
After that you can add templates:
$ mkdir .bystro/my_template
$ mkdir .bystro/my_template/__Name__
$ echo 'import "./__Name__.css";' > .bystro/my_template/__Name__.js
$ echo '// hello from __Name__' > .bystro/my_template/__Name__.css
$ touch .bystro/my_template/.templaterc
.templaterc
is required to tell bystro
how to process it. To make the above template to work add the following to its .templaterc
:
{
"variablePrefix": "__",
"variableSuffix": "__",
"variables": [
{
"name": "Name",
"description": "Component name"
}
]
}
To scaffold the above template run npx bystro my_template <path>
and you'll be prompted to fill the variable values:
? Enter Name (Component name): MyComponent
And that's it. Goto <path>
to view the scaffolded template tree:
|____MyComponent
| |____MyComponent.js
| | import "./MyComponent.css";
| |____MyComponent.css
| // hello from MyComponent
To make your template globally available just create a PR including your template in the templates
folder.