Templetor CLI

A command-line tool to bootstrap Flutter projects from a bundled template, handling dynamic name and organization replacement.

Installation

Activate the CLI from pub.dev:

dart pub global activate templetor_cli

Troubleshooting

If you encounter errors like command not found or 'templetor_cli' is not recognized as an internal or external command, it means your system environment needs to be updated.

On Windows, you can resolve this by following these steps:

  1. Open PowerShell as an administrator.
  2. Run the following command to add the Dart Pub cache to your user's PATH:
    [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$env:LOCALAPPDATA\Pub\Cache\bin", "User")
    
  3. Close all open terminal or PowerShell windows.
  4. Open a new terminal and try using the CLI again.

Usage

List Available Templates

To see which templates are available, run the list-templates command:

templetor_cli list-templates

Create a New Project

Run the create command to generate a new project. You only need to provide a project name.

templetor_cli create <project_name>

Options

  • --org: Specify the organization. Defaults to com.example.
  • --description: The description for the new project. Defaults to "A new Flutter project.".
  • --template, -t: The template to use. Defaults to redux.

Example:

templetor_cli create my_app --org com.mycompany --description "My amazing new app." --template redux

How it Works

The CLI now uses a template that is bundled with the tool itself.

  1. Creates a fresh Flutter project using flutter create with your specified project name, organization, and description.
  2. Deletes the default lib and test directories from the new project.
  3. Locates the chosen template and reads its configuration from a templetor.json file to determine the placeholder name.
  4. Recursively copies files from the bundled template directory to the new project.
  5. During the copy process, it dynamically replaces placeholders based on the template's configured name. It handles snake_case, camelCase, and PascalCase conversions.

Libraries