matchabot v0.3.7
MatchaBot
Introduction
šµ MatchaBot is a code generator written in TypeScript.
You can use matchabot to create an entire project, or to generate code inside an existing project in a consistent way.
This tool has been created to offer a "Ruby on Rail" like programming experience with any projects: React / Vue / Angular, NextJS / Gatsby, etc ...
The complete documentation of the project is available at https://www.matchabot.site/
Features
- ā Easy to use in project generator
- ā You can create your own generator by project, or use a global templates repository
- ā Templating language support: HandleBars and EJS
- ā Powerfull command line support: automatic CLI arguments and automatic prompts for missing arguments
- ā Simplified workflow to create new generators for you own project
- ā Debug mode
- ā Add new file to your project
- ā Modify existing files
- ā You can generate any kind of files/projects (NodeJS, typescript, Javascript, SQL, C++, C, Go, ...)
Benefits
- ā Simple and Powerfull
- ā Save time and Boost your productivty
- ā Enforce a consistent project structure
- ā Easier team onboarding with a codified best practices stored inside each project
- ā Fun to use š¦
Key concepts
- š A code generator is identified by a name
- š A code generator offer one or more commands
- š A command takes a list of arguments as input and execute a list of actions āļø.
- š ļøļøA generator action is specified by one or multiple template written with a templating language such as HandleBars or EJS
- š The generators definition are stored inside your project inside the ./_machatbotdirectory as a subdirectory
- š commands are defined by a matchabot.cmd.jsonfile inside the./_machatbot/--generator-name--directory
How to start š
1 - Add matchabot to your project
Execute the following command at the root of your project.
yarn add matchabot --devor
npm install matchabot --save-dev2ļø - Initialise matchabot
Execute the following command at the root of your project.
matchabot initš This command create a local directory ./_matchabot inside your current project directory
Content of _matchabot
_matchabot
āāā license
āĀ Ā  āāā add
āĀ Ā  āĀ Ā  āāā apache2.md.hbs
āĀ Ā  āĀ Ā  āāā bsd.md.hbs
āĀ Ā  āĀ Ā  āāā gnu3.md.hbs
āĀ Ā  āĀ Ā  āāā matchabot.cmd.json
āĀ Ā  āĀ Ā  āāā mit.md.hbs
āĀ Ā  āāā matchabot.json
āāā react-app
    āāā create-app
    āĀ Ā  āāā matchabot.cmd.json
    āĀ Ā  āāā template
    āāā create-component
    āĀ Ā  āāā component.tsx.hbs
    āĀ Ā  āāā matchabot.cmd.json
    āĀ Ā  āāā stories.tsx.hbs
    āĀ Ā  āāā style.tsx.hbs
    āāā matchabot.jsonIn this example, the _matchabot is composed of 2 generators
- licence
- react-app
Each generator is defined by a matchabot.jsonfile
Example for license
{
  "name": "license",
  "description": "š Add licence to your project",
  "version": "1.0.0"
}Each subdirectory contains a definition of a command asociated with a generator
For the react-appgenerator we have 2 commands:
- create-app
- create-component
Each subdirectory contains a matchabot.cmd.json file that defines the *commands and list of actions to perform.
Example ./.matchabot/license/add/matchabot.cmd.json:
{
  "name": "add",
  "description": "add a licence file to your project",
  "version": "1.0.0",
  "args": [
    {
      "name": "CopyRightsHolder",
      "alias": "c",
      "type": "string",
      "default": "{{process.env.LOGNAME}}"
    },
    {
      "name": "ProgramDescription",
      "alias": "p",
      "type": "string"
    },
    {
      "name": "LicenceType",
      "type": "list",
      "choices": [
        { "name": "MIT License", "value": "mit" },
        { "name": "BSD License", "value": "bsd" },
        { "name": "Apache License, Version 2.0", "value": "apache2" },
        { "name": "GNU General Public License version 3", "value": "gnu3" }
      ],
      "default": "MIT"
    }
  ],
  "actions": [
    {
      "type": "template",
      "name": "Generate Licence",
      "source": "{{toLowerCase LicenceType}}.md.hbs",
      "target": "LICENCE.md"
    }
  ]
}command arguments
In this example, the args array contains a list of arguments (variables) that will be used in the templates.
Example of template
MIT License
{{ProgramDescription}}.
Copyright (c) {{formatDate currentDate "YYYY"}} - {{CopyRightsHolder}}
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.command actions
In this example with only have 1 action: select a template from "source": "{{toLowerCase LicenceType}}.md.hbs" and generates a file "target": "LICENCE.md"
3 - List all available generators
matchabot listš This command gives the list of defined generators
  __  __       _       _             ____        _
 |  \/  | __ _| |_ ___| |__   __ _  | __ )  ___ | |_
 | |\/| |/ _` | __/ __| '_ \ / _` | |  _ \ / _ \| __|
 | |  | | (_| | || (__| | | | (_| | | |_) | (_) | |_
 |_|  |_|\__,_|\__\___|_| |_|\__,_| |____/ \___/ \__|
Version: 0.3.0 šµ
Availables generators
---------------------
āāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā name               ā description                                                                                                            ā version  ā location                                                                       ā
āāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā generator          ā š¤ Built-in generator of generators: create your own generator                                                        ā 1.0.0    ā ./_matchabot/generator                                                         ā
āāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā license            ā š Add licence to your project                                                                                        ā 1.0.0    ā ./_matchabot/license                                                           ā
āāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā react-app          ā š react app generator                                                                                                 ā 1.0.0    ā ./_matchabot/react-app                                                         ā
āāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā4 - List available commands for a generator
Lists all the commands of the generator react-app
matchabot react-app listResult
  __  __       _       _             ____        _
 |  \/  | __ _| |_ ___| |__   __ _  | __ )  ___ | |_
 | |\/| |/ _` | __/ __| '_ \ / _` | |  _ \ / _ \| __|
 | |  | | (_| | || (__| | | | (_| | | |_) | (_) | |_
 |_|  |_|\__,_|\__\___|_| |_|\__,_| |____/ \___/ \__|
Version: 0.3.0 šµ
Availables command(s) for react-app
-----------------------------------
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā name                                   ā description                                                                                                            ā version  ā location                                                                       ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā create-app                             ā create a typescript react app                                                                                          ā 1.0.0    ā ./_matchabot/react-app/create-app                                              ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā create-component                       ā generate a Styled React Component, and an associated story                                                             ā 1.0.0    ā ./_matchabot/react-app/create-component                                        ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā5 - Use a generator to scaffold a project
Creation of a React Application using a template generator
matchabot react-app create-appResult
  __  __       _       _             ____        _
 |  \/  | __ _| |_ ___| |__   __ _  | __ )  ___ | |_
 | |\/| |/ _` | __/ __| '_ \ / _` | |  _ \ / _ \| __|
 | |  | | (_| | || (__| | | | (_| | | |_) | (_) | |_
 |_|  |_|\__,_|\__\___|_| |_|\__,_| |____/ \___/ \__|
Version: 0.3.0 šµ
? ApplicationName MyReactApp
šµ Generating files ...
š Created files5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago