Cyan Config Reference
Configuration structure for templates
Cyan Config Reference
The configuration object returned by StartTemplateWithLambda defines how templates are processed.
Structure Overview
interface Cyan {processors: CyanProcessor[];plugins: CyanPlugin[];}
Processors
Processors handle file transformation. Most templates use the default processor.
Single Processor
return {processors: [{name: 'cyan/default',files: [{ root: 'templates', glob: '**/*', exclude: [], type: GlobType.Template }],config: {vars: {name: 'my-project',version: '1.0.0'}}}]};
Multiple Processors
return {processors: [{name: 'cyan/default',files: [{ root: 'templates', glob: '**/*.md', exclude: [], type: GlobType.Template }],config: { vars: { name } }},{name: 'myorg/custom-processor',files: [{ root: 'codegen', glob: '**/*.graphql', exclude: [], type: GlobType.Template }],config: { generateTypes: true }}]};
Processor Configuration
CyanProcessor Interface
Prop
Type
File Groups
Prop
Type
GlobType Options
| Value | Behavior |
|---|---|
GlobType.Template | Process with variable substitution |
GlobType.Copy | Copy without processing |
Default Processor Config
The cyan/default processor accepts:
Prop
Type
The cyan/default processor is the standard processor included with Cyan. The exact configuration options may vary based on the processor implementation. The vars type shown here is an example; the actual config type is unknown.
Plugins
Plugins run after file generation for post-processing.
The plugin names shown below (e.g., cyan/init-git, cyan/npm-install) are examples. Actual plugin names depend on your Cyan registry configuration.
Basic Plugin
return {processors: [/* ... */],plugins: [{name: 'cyan/init-git',config: {commitMessage: 'Initial commit'}}]};
Multiple Plugins
return {processors: [/* ... */],plugins: [{name: 'cyan/init-git',config: { commitMessage: 'Initial commit' }},{name: 'cyan/npm-install',config: { packageManager: 'pnpm' }}]};
Conditional Plugins
const plugins = [];if (initGit) {plugins.push({name: 'cyan/init-git',config: { commitMessage: 'Initial commit' }});}return {processors: [/* ... */],plugins};
Complete Example
index.ts
import { StartTemplateWithLambda, GlobType, QuestionType } from '@atomicloud/cyan-sdk';StartTemplateWithLambda(async (i, d) => {// Collect inputconst name = await i.text({type: QuestionType.Text,id: 'template.name',message: 'Project name?',default: 'my-project'});const typescript = await i.confirm({type: QuestionType.Confirm,id: 'template.typescript',message: 'TypeScript?',default: true});const docker = await i.confirm({type: QuestionType.Confirm,id: 'template.docker',message: 'Docker?',default: false});// Build file groupsconst files = [{ root: 'templates/base', glob: '**/*', exclude: [], type: GlobType.Template }];if (typescript) {files.push({ root: 'templates/typescript', glob: '**/*', exclude: [], type: GlobType.Template });}if (docker) {files.push({ root: 'templates/docker', glob: '**/*', exclude: [], type: GlobType.Template });}// Build pluginsconst plugins = [{name: 'cyan/init-git',config: { commitMessage: `Initial commit: ${name}` }}];// Return configreturn {processors: [{name: 'cyan/default',files,config: {vars: {name,typescript: typescript ? 'true' : 'false',docker: docker ? 'true' : 'false'}}}],plugins};});
Related
- IInquirer Reference - User input API
- Globbing Reference - File patterns
- Types Reference - Type definitions
- Default Processor - How cyan/default works