LogoCyanPrint
TemplatesReferenceSDK Reference

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

ExportPurpose
StartTemplateWithLambdaEntry point for templates
StartProcessorWithLambdaEntry point for processors
StartPluginWithLambdaEntry point for plugins
StartResolverWithLambdaEntry point for resolvers

Interfaces

InterfaceDescription
IInquirerAsk user questions
IDeterminismGet deterministic values via get(key, origin)

Types

TypeDescription
GlobTypeFile processing types (Template = 0, Copy = 1)
CyanGlobFile glob configuration
CyanTemplate 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 values
return {
processors: [{
name: 'cyan/default',
files: [{ glob: '**/*', exclude: [], type: GlobType.Template }],
config: { vars: {} }
}],
plugins: []
};
});

Using IInquirer

// Text input
const name = await i.text('Project name?', 'project.name', 'Enter name');
// Selection
const license = await i.select('License?', ['MIT', 'Apache-2.0'], 'project.license', 'Choose');
// Confirmation
const 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 cached
const projectId = d.get('project.id', () => crypto.randomUUID());
// Get deterministic timestamp
const createdAt = d.get('created.at', () => new Date().toISOString());
// Get sequential-style value for a category
const userId = d.get('user.id', () => `user-${Date.now()}`);

SDK Reference Sections

Version Compatibility

SDK VersionCyanPrint CLINode.js
1.x1.x18+
2.x2.x20+