🛠️ CLI Reference
Firetype provides a powerful CLI tool for generating type definitions from your schema files.Generate Command
Generate TypeScript types from your Firestore schema definitions.Options
| Option | Description | Required | Default |
|---|---|---|---|
--input=<path> | Directory containing your schema definitions (output will be written here) | Yes | - |
--mode=<mode> | SDK mode: admin, client, or omit for both | No | both |
Examples
Help Command
Display help information for all available commands.Generated Files
The CLI generates anindex.ts file in your input directory containing:
- Schema definitions: Zod schemas compiled from your directory structure
- Converters: Type-safe Firestore converters with optional validation
- API functions:
createFireTypeAdmin()and/orcreateFireTypeClient()functions
File Structure Example
📝 Note: Always regenerate types after modifying your schemas. The generated file includes
import statements for the required Firestore SDKs based on your
--mode selection.CLI Usage Patterns
Development Workflow
Monorepo Setup
CI/CD Integration
Troubleshooting CLI Issues
Common Issues
”Cannot find module” errors
Problem: TypeScript can’t find the generated types. Solution: Make sure you’ve generated types before importing them:Schema validation errors
Problem: Your schema files aren’t being recognized. Solutions:- Ensure schema files export a
schemaconstant:export const schema = z.object({...}) - Check that schema files are named exactly
schema.ts - Verify the directory structure matches your Firestore collections
CLI not found
Problem:firetype command not recognized.
Solutions:
- Use
npx @anonymous-dev/firetypeinstead offiretype - Check that the package is installed:
npm list @anonymous-dev/firetype - For local installation, ensure your
PATHincludes node_modules/.bin
Type errors in generated code
Problem: TypeScript errors in the generated index.ts file. Solutions:- Update to the latest version:
npm update @anonymous-dev/firetype - Regenerate types after schema changes
- Check that your Zod schemas are valid