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:
- Edit the template files in
ok_cli/templates/ - Modify the
copier.ymlconfiguration - Test with
ok-cli generate <type> <name>
Adding New Templates¶
To add a new template type:
- Create a new directory in
ok_cli/templates/ - Add
copier.ymlconfiguration - Create template files with
{{variable}}syntax - Update
ok_cli/commands/generate.pyto include the new template