Skip to content

Templates

Template Structure

The OK CLI uses a template-based system to generate code. Templates are stored in the ok_cli/templates/ directory.

App Template

The app template creates a complete React Native application structure.

Location: ok_cli/templates/app-template/

Variables: - project_name: Display name of the project - project_slug: Slugified project name for directories

Component Template

The component template generates React components with TypeScript support.

Location: ok_cli/templates/component/

Variables: - name: Name of the component

Generated Files: - {name}.tsx: Main component file - {name}.types.tsx: TypeScript type definitions - {name}.story.tsx: Storybook story - {name}.test.tsx: Unit test file - index.tsx: Export file

Template Configuration

Each template contains a copier.yml file that defines:

  • Available variables and their types
  • Default values
  • Help text for variables
  • Template engine configuration

Customizing Templates

To customize templates:

  1. Edit the template files in ok_cli/templates/
  2. Modify the copier.yml configuration
  3. Test with ok-cli generate <type> <name>

Adding New Templates

To add a new template type:

  1. Create a new directory in ok_cli/templates/
  2. Add copier.yml configuration
  3. Create template files with {{variable}} syntax
  4. Update ok_cli/commands/generate.py to include the new template