@cevek/tsgen
v1.0.2
Published
TypeScript file generator based on EJS templates
Maintainers
Readme
@cevek/tsgen
A TypeScript file generator based on EJS templates.
Installation
npm install -g @cevek/tsgenUsage
Global Installation
tsgen [templates-dir] [options]Local Installation
npx @cevek/tsgen [templates-dir] [options]Options
-w, --watch- Watch mode - regenerate files on template changes (default: false)-o, --output <dir>- Output directory for generated files (default: "output")[templates]- Directory containing templates (default: "./templates")
Examples
# Generate files from templates directory
tsgen ./templates
# Generate with custom output directory
tsgen ./templates -o ./generated
# Watch mode for automatic regeneration
tsgen ./templates -w -o ./generatedTemplate Structure
Each template should be in its own directory with the following structure:
templates/
├── component/
│ ├── component.ejs # Component template
│ └── config.ts # Template configuration
└── ...Template Example (component.ejs)
import React from 'react';
export const <%= componentName %>: React.FC = () => {
return (
<div>
<%= componentName %> Component
</div>
);
};Configuration Example (config.ts)
export default {
outputPath: 'MyComponent.tsx',
data: {
componentName: 'MyComponent'
}
};Features
- TypeScript support
- EJS templating
- Watch mode for automatic regeneration
- Custom output directory
- Prettier code formatting
- TypeScript configuration support
License
MIT
