LogoCyanPrint
TemplatesReferenceSDK Reference

Globbing Reference

File pattern matching for templates

Globbing Reference

Glob patterns control which files are included, excluded, and how they're processed. These patterns are configured within CyanGlob objects as part of the Cyan configuration structure's files array.

Basic Patterns

Match All

glob: '**/*'
  • ** - Match any number of directories
  • * - Match any number of characters (except /)

Match by Extension

glob: '**/*.md' // All markdown files
glob: '**/*.ts' // All TypeScript files
glob: '**/*.json' // All JSON files

Match Specific Directory

glob: 'src/**/*' // Everything under src/
glob: 'docs/**/*.md' // Markdown files under docs/

Pattern Syntax

PatternDescriptionExample Match
*Any characters (no /)file.ts, component.tsx
**Any directoriessrc/, src/lib/, src/lib/utils/
**/*Any file in any directorysrc/index.ts, lib/utils.ts
*.extFiles with extensionfile.md, readme.md
**/*.extAll files with extension in any directorysrc/file.ts, lib/utils.ts
?Single characterfile1.ts, file2.ts
[abc]Character setfile-a.ts, file-b.ts
[!abc]Negated setfile-x.ts (not a, b, or c)
{a,b,c}Brace expansion*.{ts,tsx} matches TypeScript files

Multiple Patterns

Import

import { GlobType } from '@atomicloud/cyan-sdk';

Multiple File Groups

Use multiple file groups for different processing:

files: [
{ root: 'templates', glob: '**/*.md', exclude: [], type: GlobType.Template },
{ root: 'templates', glob: '**/*.json', exclude: [], type: GlobType.Template },
{ root: 'templates', glob: '**/*.png', exclude: [], type: GlobType.Copy },
{ root: 'templates', glob: '**/*.jpg', exclude: [], type: GlobType.Copy }
]

Multiple Extensions in One Pattern

// Match .ts and .tsx files
glob: '**/*.ts?(x)'
// Match .js, .jsx, .ts, .tsx
glob: '**/*.@(js|ts)?(x)'

Extglob patterns like ?(x) and @(a|b) use bash extended glob syntax. The Node SDK uses minimatch which supports these by default. Test your patterns if using other SDKs.

Exclude Patterns

Exclude files from processing:

files: [{
root: 'templates', // Defaults to '.' (current directory) if omitted
glob: '**/*',
exclude: [
'**/node_modules/**', // Exclude node_modules
'**/test/**', // Exclude test directories
'**/*.test.*', // Exclude test files
'**/*.spec.*', // Exclude spec files
'**/.DS_Store', // Exclude macOS files
'**/dist/**', // Exclude build output
'**/.git/**' // Exclude git directory
],
type: GlobType.Template
}]

Common Patterns

Source Code Only

glob: 'src/**/*.{ts,tsx,js,jsx}'

Documentation

glob: 'docs/**/*.md'

Configuration Files

glob: '*.{json,yaml,yml,toml}'

Assets

glob: 'assets/**/*.{png,jpg,svg,ico}'

Ignore Hidden Files

exclude: ['**/.*'] // Files starting with dot

GlobType Reference

The GlobType enum controls how files are processed:

TypeUse Case
GlobType.TemplateText files needing variable substitution
GlobType.CopyBinary files and files without variables

Python SDK Note: The Python SDK uses different enum values: GlobType.Template = 1 and GlobType.Copy = 2 (instead of 0 and 1 in Node/.NET). Always use the symbolic names rather than numeric values for cross-SDK compatibility.

Best Practices

1. Be Explicit

// Good: Explicit file types
glob: '**/*.{md,json,ts,tsx}'
// Bad: Too broad, might catch unwanted files
glob: '**/*'

2. Separate by Processing Type

files: [
// Template files
{ root: 'templates', glob: '**/*.md', exclude: [], type: GlobType.Template },
{ root: 'templates', glob: '**/*.json', exclude: [], type: GlobType.Template },
// Binary files (never template!)
{ root: 'templates', glob: '**/*.png', exclude: [], type: GlobType.Copy },
{ root: 'templates', glob: '**/*.woff2', exclude: [], type: GlobType.Copy }
]

3. Use Meaningful Excludes

exclude: [
'**/node_modules/**', // Dependencies
'**/dist/**', // Build output
'**/.cache/**', // Cache directories
'**/*.log', // Log files
'**/.env*' // Environment files
]

Testing Patterns

Test your glob patterns to ensure they match expected files:

# Using find (note: use single * for -name, not **)
find templates -name "*.md"
# Using shell globbing (zsh/bash with globstar enabled)
ls templates/**/*.md
# Using the glob CLI tool
glob "**/*.md" templates/