Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

How to add your template to Stagehand

Kathy Walrath edited this page Jul 11, 2018 · 12 revisions

Here's the process for adding templates.

Check with us before you start

We try not to have too many templates. If we add one, we might want to delete one.

Get Stagehand

cd my_dir
git clone https://github.com/google/stagehand.git
cd stagehand

Create your generator and _data files

  • Choose a name for your template, following conventions set by existing generators (e.g. web-something)
  • Create a copy of the file that's closest to your template type in lib/src/generators (e.g. copy web_simple.dart to web_something.dart)
  • Update the info in the main generator file to match your template

Create a directory for your template in /templates, and add your files there

  • Remove all /packages entries

  • Replace all instances of your project’s name with {{projectName}}

  • Update pubspec.yaml with entries like:

    name: {{projectName}}
    version: 0.0.1
    description: A sample command-line application.
    author: {{author}} <email@example.com>
    homepage: https://www.example.com
    

Add your template to lib/stagehand.dart

Import its main generator file, and add an instance of its generator to the generators list.

Run the Grind.build() to compress your template into the generator

From within your stagehand directory:
pub run build_runner build

Test your template

See How to test a template.

Fork the code and make a pull request

See instructions here in the "As a contributor to open-source" section

When it works and your pull request is accepted, don't forget to reset stagehand

pub global deactivate stagehand
pub global activate stagehand
Clone this wiki locally