Skip to content

dworak-dev/cli

Repository files navigation

@dworac/cli

npm npm GitHub issues GitHub

This is dworac's CLI tool. It is used to create new projects from several templates and more....

Usage

This is a command-line tool that generates a new project from a template. You can use it with npx or install it globally.

npx @dworac/cli

Help

In order to get help, you can use the --help flag.

npx @dworac/cli --help

Project generator

In order to obtain a list of available templates, you can use the list command.

npx @dworac/cli templates

To create a new project, run the following command:

npx @dworac/cli create <name> <template>

Options

  • -d, --description : The description of the new project.
  • -r, --repository : The git repository of the new project.
  • -k, --keywords : The keywords of the new project.
  • -a, --author : The author of the new project.

Examples

Generate a new project without options:

npx @dworac/cli create my-project typescript-lib-node

Generate a new project with a description, git repository, keywords, and author:

npx @dworac/cli create my-project typescript-lib-node -d "My project description" -r "https://github.com/dworac/cli" -k "cli template generator" -a "dworac <mail@dworac.com>"

Developping

In order to develop this project, you can use the following commands:

Install dependencies:

yarn

Run

yarn start:dev

In order to test the project locally you must build it and link it globally, the following command does both things:

yarn publish:local

To test it run the following command:

npx @dworac/cli

To unlink the project, you can use the following command:

yarn publish:local:unlink

Contributing

If you have any suggestions or improvements, please feel free to create a pull request or submit an issue.

Add a template

Adding a new template is very simple:

  • Create a new folder with the name of the template in the templates folder.
  • Add a template.json file to your template folder
  • If you have any .gitignore files rename them to gitignore

template.json

template.json file should be in each one of the templates folder and it should look something like this.

{
  "name": "typescript-api",
  "description": "This template is used to create an express server with typescript, grahpql, typeorm, and postgres.",
  "commands": [
    {
      "name": "yarn",
      "description": "Install dependencies"
    }
  ],
  "secrets": [
    {
      "name": "DIGITALOCEAN_APP_NAME",
      "description": "Name of the digital ocean app the project will be deployed to."
    }
  ]
}

This file helps document the template for the cli's output. All of the properties are optional but recommended:

interface TemplateInfo {
    name: string;
    description?: string;
    commands?: {
        name: string;
        description: string;
    }[]; // Recommended commands, starter commands.
    secrets?: {
        name: string;
        description: string;
    }[]; // Secrets needed for github workflows to work.
}

License

This project is licensed under the MIT license. Please see the LICENSE file for more information.