SDK Overview
CyanPrint SDK for template development
SDK Overview
The CyanPrint SDK (@atomicloud/cyan-sdk) provides the APIs for creating templates, processors, and plugins.
Installation
npm install @atomicloud/cyan-sdk
yarn add @atomicloud/cyan-sdk
pnpm add @atomicloud/cyan-sdk
Core Exports
Entry Points
| Export | Purpose |
|---|---|
StartTemplateWithLambda | Entry point for templates |
StartProcessorWithLambda | Entry point for processors |
StartPluginWithLambda | Entry point for plugins |
StartResolverWithLambda | Entry point for resolvers |
Interfaces
| Interface | Description |
|---|---|
IInquirer | Ask user questions |
IDeterminism | Get deterministic values via get(key, origin) |
Types
| Type | Description |
|---|---|
GlobType | File processing types (Template = 0, Copy = 1) |
CyanGlob | File glob configuration |
Cyan | Template configuration structure (processors and plugins) |
Quick Start
Template Entry Point
cyan.ts
import { StartTemplateWithLambda, GlobType } from '@atomicloud/cyan-sdk';StartTemplateWithLambda(async (i, d) => {// i: IInquirer - ask questions// d: IDeterminism - get deterministic valuesreturn {processors: [{name: 'cyan/default',files: [{ glob: '**/*', exclude: [], type: GlobType.Template }],config: { vars: {} }}],plugins: []};});
Using IInquirer
// Text inputconst name = await i.text('Project name?', 'project.name', 'Enter name');// Selectionconst license = await i.select('License?', ['MIT', 'Apache-2.0'], 'project.license', 'Choose');// Confirmationconst typescript = await i.confirm('Use TypeScript?', 'project.typescript', 'Add TS config');// Checkbox (multi-select)const features = await i.checkbox('Features?', ['ESLint', 'Prettier'], 'project.features', 'Select');// Date selection (returns string in ISO format)const startDate = await i.dateSelect('Start date?', 'project.startDate', 'Select date');
Using IDeterminism
// Get deterministic value with key and origin function// The key identifies the value, origin provides a default if not cachedconst projectId = d.get('project.id', () => crypto.randomUUID());// Get deterministic timestampconst createdAt = d.get('created.at', () => new Date().toISOString());// Get sequential-style value for a categoryconst userId = d.get('user.id', () => `user-${Date.now()}`);
SDK Reference Sections
IInquirer
Question asking API for interactive prompts
Cyan Config
Configuration structure for templates
Globbing
File pattern matching configuration
Types
TypeScript type definitions
Version Compatibility
| SDK Version | CyanPrint CLI | Node.js |
|---|---|---|
| 1.x | 1.x | 18+ |
| 2.x | 2.x | 20+ |