LogoCyanPrint

Template Development

Create reusable project templates with CyanPrint SDK

Template Development

Templates are the core building blocks of CyanPrint. They define how projects are scaffolded, from simple file copying to complex multi-step generators with user interactions.

What is a Template?

A CyanPrint template is a Docker container that:

  1. Asks questions to collect user preferences
  2. Processes files using variable substitution
  3. Generates output in the target directory

Templates can range from simple static file copiers to sophisticated generators with conditional logic, multiple processors, and plugin integrations.

Template Architecture

Components

ComponentPurposeExamples
index.tsTemplate logic entry pointQuestion handling, config generation
ProcessorsFile processing enginescyan/default, custom processors
PluginsPost-generation actionsGit initialization, dependency installation
Template FilesSource files to process.md, .ts, .json templates

Learning Path

Start Here: Tutorials

Follow the tutorials to learn template development step by step:

  1. Blank Template - Create your first template
  2. Adding Variables - Add variable substitution
  3. Changing Glob Patterns - Control file processing
  4. Asking Questions - Collect user input

New to CyanPrint? Start with the Introduction to understand the platform architecture.

How-To Guides

Task-oriented guides for common scenarios:

View all How-To Guides

Reference

Technical documentation for the SDK:

View all Reference Docs

Explanation

Deep dives into concepts and architecture:

View all Explanations

Quick Example

Here's a minimal template that asks for a project name and generates a README:

index.ts
import { StartTemplateWithLambda, GlobType, IInquirer, IDeterminism } from '@atomicloud/cyan-sdk';
StartTemplateWithLambda(async (i: IInquirer, d: IDeterminism) => {
// Ask user for project name
const name = await i.text('Project name?', 'project.name', 'Enter project name');
return {
processors: [{
name: 'cyan/default',
files: [{ root: 'template', glob: '**/*', exclude: [], type: GlobType.Template }],
config: { vars: { name } }
}]
};
});

Template file (template/README.md):

template/README.md
# var__name__
Welcome to your new project!

The var__name__ syntax is used by the default processor for variable substitution. Variables defined in config.vars are accessible using the var__<variableName>__ pattern. See the Default Processor explanation for more details.

Next Steps