@intentsolutionsio/orm-code-generator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "orm-code-generator",
3
+ "version": "1.0.0",
4
+ "description": "Generate ORM models from database schemas or create database schemas from models for TypeORM, Prisma, Sequelize, SQLAlchemy, and more",
5
+ "author": {
6
+ "name": "Claude Code Plugins",
7
+ "email": "[email protected]"
8
+ },
9
+ "repository": "https://github.com/jeremylongshore/claude-code-plugins",
10
+ "license": "MIT",
11
+ "keywords": [
12
+ "orm",
13
+ "models",
14
+ "code-generation",
15
+ "database",
16
+ "backend",
17
+ "agent-skills"
18
+ ]
19
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Jeremy Longshore & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # ORM Code Generator Plugin
2
+
3
+ Generate ORM models from database schemas or create database schemas from models.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ /plugin install orm-code-generator@claude-code-plugins-plus
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ The ORM agent activates automatically when you discuss ORM models, database schemas, or model generation.
14
+
15
+ ## Supported ORMs
16
+
17
+ - **TypeORM** (TypeScript/JavaScript)
18
+ - **Prisma** (TypeScript/JavaScript)
19
+ - **Sequelize** (JavaScript)
20
+ - **SQLAlchemy** (Python)
21
+ - **Django ORM** (Python)
22
+ - **Entity Framework** (C#)
23
+ - **Hibernate** (Java)
24
+ - And more...
25
+
26
+ ## Features
27
+
28
+ - Database-to-code generation
29
+ - Code-to-database schema generation
30
+ - Relationship mapping
31
+ - Migration file creation
32
+ - Validation rules
33
+ - Best practices enforcement
34
+
35
+ ## Example
36
+
37
+ "Generate TypeORM entities for a blog with users, posts, and comments"
38
+
39
+ ## License
40
+
41
+ MIT
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: orm-agent
3
+ description: Generate ORM models and schemas
4
+ ---
5
+ # ORM Code Generator Agent
6
+
7
+ You are an ORM code generation specialist supporting multiple ORM frameworks across different programming languages.
8
+
9
+ ## Supported ORMs
10
+
11
+ ### JavaScript/TypeScript
12
+ - **TypeORM**: Decorators, entities, migrations
13
+ - **Prisma**: Schema definition language
14
+ - **Sequelize**: Model definitions, associations
15
+ - **Mongoose**: MongoDB schemas
16
+
17
+ ### Python
18
+ - **SQLAlchemy**: Declarative models, relationships
19
+ - **Django ORM**: Models, managers, migrations
20
+ - **Peewee**: Simple ORM models
21
+ - **Tortoise ORM**: Async ORM
22
+
23
+ ### Other Languages
24
+ - **Entity Framework** (C#)
25
+ - **Hibernate** (Java)
26
+ - **ActiveRecord** (Ruby)
27
+ - **Eloquent** (PHP/Laravel)
28
+
29
+ ## Code Generation Capabilities
30
+
31
+ 1. **From Database Schema**
32
+ - Introspect existing database
33
+ - Generate model classes
34
+ - Create relationships
35
+ - Add validation rules
36
+
37
+ 2. **From Model Definitions**
38
+ - Create migration files
39
+ - Generate SQL schemas
40
+ - Build indexes
41
+ - Set up constraints
42
+
43
+ 3. **Relationship Handling**
44
+ - One-to-One
45
+ - One-to-Many
46
+ - Many-to-Many
47
+ - Self-referential
48
+ - Polymorphic
49
+
50
+ ## Example Outputs
51
+
52
+ ### TypeORM Entity
53
+ ```typescript
54
+ import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
55
+ import { User } from './User';
56
+
57
+ @Entity()
58
+ export class Post {
59
+ @PrimaryGeneratedColumn()
60
+ id: number;
61
+
62
+ @Column()
63
+ title: string;
64
+
65
+ @Column('text')
66
+ content: string;
67
+
68
+ @ManyToOne(() => User, user => user.posts)
69
+ author: User;
70
+
71
+ @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
72
+ createdAt: Date;
73
+ }
74
+ ```
75
+
76
+ ### Prisma Schema
77
+ ```prisma
78
+ model Post {
79
+ id Int @id @default(autoincrement())
80
+ title String
81
+ content String @db.Text
82
+ authorId Int
83
+ author User @relation(fields: [authorId], references: [id])
84
+ createdAt DateTime @default(now())
85
+ }
86
+ ```
87
+
88
+ ### SQLAlchemy Model
89
+ ```python
90
+ from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
91
+ from sqlalchemy.orm import relationship
92
+ from datetime import datetime
93
+
94
+ class Post(Base):
95
+ __tablename__ = 'posts'
96
+
97
+ id = Column(Integer, primary_key=True)
98
+ title = Column(String(255), nullable=False)
99
+ content = Column(Text)
100
+ author_id = Column(Integer, ForeignKey('users.id'))
101
+ author = relationship('User', back_populates='posts')
102
+ created_at = Column(DateTime, default=datetime.utcnow)
103
+ ```
104
+
105
+ ## When to Activate
106
+
107
+ - User requests ORM model generation
108
+ - Database schema needs code representation
109
+ - Migration from one ORM to another
110
+ - API development requiring data models
111
+ - Database-first or code-first development
112
+
113
+ ## Approach
114
+
115
+ 1. Identify target ORM framework
116
+ 2. Analyze database schema or requirements
117
+ 3. Generate appropriate model code
118
+ 4. Include relationships and constraints
119
+ 5. Add validation and business logic hooks
120
+ 6. Provide usage examples
121
+ 7. Suggest best practices
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@intentsolutionsio/orm-code-generator",
3
+ "version": "1.0.0",
4
+ "description": "Generate ORM models from database schemas or create database schemas from models for TypeORM, Prisma, Sequelize, SQLAlchemy, and more",
5
+ "keywords": [
6
+ "orm",
7
+ "models",
8
+ "code-generation",
9
+ "database",
10
+ "backend",
11
+ "agent-skills",
12
+ "claude-code",
13
+ "claude-plugin",
14
+ "tonsofskills"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/jeremylongshore/claude-code-plugins-plus-skills.git",
19
+ "directory": "plugins/database/orm-code-generator"
20
+ },
21
+ "homepage": "https://tonsofskills.com/plugins/orm-code-generator",
22
+ "bugs": "https://github.com/jeremylongshore/claude-code-plugins-plus-skills/issues",
23
+ "license": "MIT",
24
+ "author": {
25
+ "name": "Claude Code Plugins",
26
+ "email": "[email protected]"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "README.md",
33
+ ".claude-plugin",
34
+ "skills",
35
+ "agents"
36
+ ],
37
+ "scripts": {
38
+ "postinstall": "node -e \"console.log(\\\"\\\\n→ This npm package is a tracking/proof artifact. Install the plugin via:\\\\n ccpi install orm-code-generator\\\\n or /plugin install orm-code-generator@claude-code-plugins-plus in Claude Code\\\\n\\\")\""
39
+ }
40
+ }
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: generating-orm-code
3
+ description: |
4
+ Execute use when you need to work with ORM code generation.
5
+ This skill provides ORM model and code generation with comprehensive guidance and automation.
6
+ Trigger with phrases like "generate ORM models", "create entity classes",
7
+ or "scaffold database models".
8
+
9
+ allowed-tools: Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(mongosh:*)
10
+ version: 1.0.0
11
+ author: Jeremy Longshore <jeremy@intentsolutions.io>
12
+ license: MIT
13
+ compatible-with: claude-code, codex, openclaw
14
+ tags: [database, orm-code]
15
+ ---
16
+ # ORM Code Generator
17
+
18
+ ## Overview
19
+
20
+ Generate type-safe ORM model classes, migration files, and repository patterns from existing database schemas or domain specifications. Supports Prisma, TypeORM, Sequelize, SQLAlchemy, Django ORM, and Drizzle ORM.
21
+
22
+ ## Prerequisites
23
+
24
+ - Database connection string or credentials for schema introspection
25
+ - `psql` or `mysql` CLI for querying `information_schema`
26
+ - Target ORM framework already installed in the project (`prisma`, `typeorm`, `sqlalchemy`, etc.)
27
+ - Node.js/Python/Go runtime matching the target ORM
28
+ - Existing project structure to place generated models in the correct directory
29
+
30
+ ## Instructions
31
+
32
+ 1. Introspect the database schema by querying `information_schema.COLUMNS`, `information_schema.TABLE_CONSTRAINTS`, and `information_schema.KEY_COLUMN_USAGE` to extract all tables, columns, data types, nullable flags, defaults, primary keys, foreign keys, and unique constraints.
33
+
34
+ 2. For PostgreSQL, additionally query `pg_catalog.pg_type` for custom enum types and `pg_catalog.pg_index` for index definitions. For MySQL, query `information_schema.STATISTICS` for index details.
35
+
36
+ 3. Map database column types to ORM field types:
37
+ - `varchar/text` -> `String` / `@Column('text')`
38
+ - `integer/bigint` -> `Int` / `@Column('int')`
39
+ - `boolean` -> `Boolean` / `@Column('boolean')`
40
+ - `timestamp/datetime` -> `DateTime` / `@Column('timestamp')`
41
+ - `jsonb/json` -> `Json` / `@Column('jsonb')`
42
+ - `uuid` -> `String` with `@default(uuid())` or `uuid.uuid4`
43
+ - Custom enums -> Generate enum type definitions
44
+
45
+ 4. Generate model classes with proper decorators/attributes:
46
+ - For **Prisma**: Generate `schema.prisma` with `model` blocks, `@id`, `@unique`, `@relation`, and `@default` directives.
47
+ - For **TypeORM**: Generate entity classes with `@Entity()`, `@Column()`, `@PrimaryGeneratedColumn()`, `@ManyToOne()`, `@OneToMany()` decorators.
48
+ - For **SQLAlchemy**: Generate model classes extending `Base` with `Column()`, `ForeignKey()`, `relationship()`, and `__tablename__`.
49
+ - For **Drizzle**: Generate table definitions with `pgTable()`, `serial()`, `varchar()`, `timestamp()`, and `relations()`.
50
+
51
+ 5. Generate relationship mappings from foreign key constraints. Detect one-to-one (unique FK), one-to-many, and many-to-many (junction table with two FKs) patterns automatically. Add both sides of each relationship with proper cascade options.
52
+
53
+ 6. Create migration files that capture the current schema state. For Prisma: `npx prisma migrate dev --name init`. For TypeORM: generate migration with `typeorm migration:generate`. For Alembic: `alembic revision --autogenerate`.
54
+
55
+ 7. Generate repository/service layer with common CRUD operations: `findById`, `findAll` with pagination, `create`, `update`, `delete`, and relationship-aware queries (`findWithRelations`).
56
+
57
+ 8. Add validation decorators or constraints matching database CHECK constraints and NOT NULL columns. Use `class-validator` for TypeORM, Pydantic validators for SQLAlchemy, or Zod schemas for Prisma.
58
+
59
+ 9. Generate TypeScript/Python type definitions or interfaces for API layer consumption, ensuring the ORM models and API types stay synchronized.
60
+
61
+ 10. Validate generated models by running a test migration against a temporary database or by comparing the generated schema against the live database schema with a diff tool.
62
+
63
+ ## Output
64
+
65
+ - **Model/entity files** with full type annotations, decorators, and relationship mappings
66
+ - **Migration files** capturing the initial schema state
67
+ - **Enum type definitions** for database enum columns
68
+ - **Repository/service classes** with typed CRUD operations
69
+ - **Validation schemas** (Zod, class-validator, Pydantic) matching database constraints
70
+ - **Type definition files** for API layer consumption
71
+
72
+ ## Error Handling
73
+
74
+ | Error | Cause | Solution |
75
+ |-------|-------|---------|
76
+ | Circular relationship dependency | Two entities reference each other, causing import cycles | Use lazy loading (`() => RelatedEntity`) in TypeORM; use `ForwardRef` in SQLAlchemy; split into separate files with deferred imports |
77
+ | Unknown column type mapping | Database uses custom types, extensions, or domain types not in the standard mapping | Add custom type mapping in generator config; use `@Column({ type: 'text' })` as fallback; register custom transformers |
78
+ | Migration conflicts with existing data | Generated migration adds NOT NULL columns without defaults | Add default values to new columns; create a two-phase migration (add nullable, backfill, set NOT NULL) |
79
+ | Junction table not detected as many-to-many | Junction table has extra columns beyond the two foreign keys | Model as an explicit entity with two ManyToOne relationships instead of an implicit ManyToMany |
80
+ | Schema drift between ORM models and database | Manual database changes not reflected in ORM code | Run introspection again; use `prisma db pull` or `sqlacodegen` to regenerate; diff against existing models |
81
+
82
+ ## Examples
83
+
84
+ **Prisma schema from PostgreSQL e-commerce database**: Introspect 15 tables including users, orders, products, and categories. Generate `schema.prisma` with proper `@relation` directives, enum types for order status, and `@default(autoincrement())` for serial columns. Output includes Zod validation schemas for each model.
85
+
86
+ **TypeORM entities from MySQL SaaS application**: Generate entity classes for a multi-tenant application with tenant isolation. Each entity includes a `tenantId` column with a custom `@TenantAware` decorator. Repository layer includes tenant-scoped query methods.
87
+
88
+ **SQLAlchemy models from legacy database with naming conventions**: Introspect a database with inconsistent naming (mix of camelCase and snake_case). Generate models with `__tablename__` preserving original names while using Pythonic property names. Alembic migration captures the full schema.
89
+
90
+ ## Resources
91
+
92
+ - Prisma introspection: https://www.prisma.io/docs/orm/prisma-schema/introspection
93
+ - TypeORM entity documentation: https://typeorm.io/entities
94
+ - SQLAlchemy ORM tutorial: https://docs.sqlalchemy.org/en/20/orm/
95
+ - Drizzle ORM schema: https://orm.drizzle.team/docs/sql-schema-declaration
96
+ - Django inspectdb command: https://docs.djangoproject.com/en/5.0/howto/legacy-databases/
@@ -0,0 +1,6 @@
1
+ # Assets
2
+
3
+ Bundled resources for orm-code-generator skill
4
+
5
+ - [ ] examples/ecommerce_database_schema.sql: Example SQL schema for an e-commerce database.
6
+ - [ ] examples/blog_typeorm_model.ts: Example TypeORM model for a blog application.
@@ -0,0 +1,4 @@
1
+ # References
2
+
3
+ Bundled resources for orm-code-generator skill
4
+
@@ -0,0 +1,8 @@
1
+ # Scripts
2
+
3
+ Bundled resources for orm-code-generator skill
4
+
5
+ - [ ] generate_model.py: Generates ORM model code based on a database schema or user-defined model definition.
6
+ - [ ] generate_schema.py: Generates database schema based on an ORM model definition.
7
+ - [ ] validate_model.py: Validates the ORM model definition against best practices and common pitfalls.
8
+ - [ ] migration_generator.py: Generates migration files for different ORMs based on model changes.
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ orm-code-generator - Generator Script
4
+ Generates ORM model code based on a database schema or user-defined model definition.
5
+ Generated: 2025-12-10 03:48:17
6
+ """
7
+
8
+ import os
9
+ import json
10
+ import argparse
11
+ from pathlib import Path
12
+ from datetime import datetime
13
+
14
+ class Generator:
15
+ def __init__(self, config: Dict):
16
+ self.config = config
17
+ self.output_dir = Path(config.get('output', './output'))
18
+ self.output_dir.mkdir(parents=True, exist_ok=True)
19
+
20
+ def generate_markdown(self, title: str, content: str) -> Path:
21
+ """Generate markdown document."""
22
+ filename = f"{title.lower().replace(' ', '_')}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md"
23
+ file_path = self.output_dir / filename
24
+
25
+ md_content = f"""# {title}
26
+
27
+ Generated by orm-code-generator
28
+ Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
29
+
30
+ ## Overview
31
+ {content}
32
+
33
+ ## Configuration
34
+ ```json
35
+ {json.dumps(self.config, indent=2)}
36
+ ```
37
+
38
+ ## Category
39
+ database
40
+
41
+ ## Plugin
42
+ orm-code-generator
43
+ """
44
+
45
+ file_path.write_text(md_content)
46
+ return file_path
47
+
48
+ def generate_json(self, data: Dict) -> Path:
49
+ """Generate JSON output."""
50
+ filename = f"output_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
51
+ file_path = self.output_dir / filename
52
+
53
+ output_data = {
54
+ "generated_by": "orm-code-generator",
55
+ "timestamp": datetime.now().isoformat(),
56
+ "category": "database",
57
+ "plugin": "orm-code-generator",
58
+ "data": data,
59
+ "config": self.config
60
+ }
61
+
62
+ with open(file_path, 'w') as f:
63
+ json.dump(output_data, f, indent=2)
64
+
65
+ return file_path
66
+
67
+ def generate_script(self, name: str, template: str) -> Path:
68
+ """Generate executable script."""
69
+ filename = f"{name}.sh"
70
+ file_path = self.output_dir / filename
71
+
72
+ script_content = f"""#!/bin/bash
73
+ # Generated by orm-code-generator
74
+ # Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
75
+
76
+ set -e # Exit on error
77
+
78
+ echo "🚀 Running {name}..."
79
+
80
+ # Template content
81
+ {template}
82
+
83
+ echo "✅ Completed successfully"
84
+ """
85
+
86
+ file_path.write_text(script_content)
87
+ file_path.chmod(0o755) # Make executable
88
+ return file_path
89
+
90
+ def main():
91
+ parser = argparse.ArgumentParser(description="Generates ORM model code based on a database schema or user-defined model definition.")
92
+ parser.add_argument('--type', choices=['markdown', 'json', 'script'], default='markdown')
93
+ parser.add_argument('--output', '-o', default='./output', help='Output directory')
94
+ parser.add_argument('--config', '-c', help='Configuration file')
95
+ parser.add_argument('--title', default='orm-code-generator Output')
96
+ parser.add_argument('--content', help='Content to include')
97
+
98
+ args = parser.parse_args()
99
+
100
+ config = {'output': args.output}
101
+ if args.config and Path(args.config).exists():
102
+ with open(args.config) as f:
103
+ config.update(json.load(f))
104
+
105
+ generator = Generator(config)
106
+
107
+ print(f"🔧 Generating {args.type} output...")
108
+
109
+ if args.type == 'markdown':
110
+ output_file = generator.generate_markdown(
111
+ args.title,
112
+ args.content or "Generated content"
113
+ )
114
+ elif args.type == 'json':
115
+ output_file = generator.generate_json(
116
+ {"title": args.title, "content": args.content}
117
+ )
118
+ else: # script
119
+ output_file = generator.generate_script(
120
+ args.title.lower().replace(' ', '_'),
121
+ args.content or "# Add your script content here"
122
+ )
123
+
124
+ print(f"✅ Generated: {output_file}")
125
+ return 0
126
+
127
+ if __name__ == "__main__":
128
+ import sys
129
+ sys.exit(main())
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ orm-code-generator - Generator Script
4
+ Generates database schema based on an ORM model definition.
5
+ Generated: 2025-12-10 03:48:17
6
+ """
7
+
8
+ import os
9
+ import json
10
+ import argparse
11
+ from pathlib import Path
12
+ from datetime import datetime
13
+
14
+ class Generator:
15
+ def __init__(self, config: Dict):
16
+ self.config = config
17
+ self.output_dir = Path(config.get('output', './output'))
18
+ self.output_dir.mkdir(parents=True, exist_ok=True)
19
+
20
+ def generate_markdown(self, title: str, content: str) -> Path:
21
+ """Generate markdown document."""
22
+ filename = f"{title.lower().replace(' ', '_')}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md"
23
+ file_path = self.output_dir / filename
24
+
25
+ md_content = f"""# {title}
26
+
27
+ Generated by orm-code-generator
28
+ Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
29
+
30
+ ## Overview
31
+ {content}
32
+
33
+ ## Configuration
34
+ ```json
35
+ {json.dumps(self.config, indent=2)}
36
+ ```
37
+
38
+ ## Category
39
+ database
40
+
41
+ ## Plugin
42
+ orm-code-generator
43
+ """
44
+
45
+ file_path.write_text(md_content)
46
+ return file_path
47
+
48
+ def generate_json(self, data: Dict) -> Path:
49
+ """Generate JSON output."""
50
+ filename = f"output_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
51
+ file_path = self.output_dir / filename
52
+
53
+ output_data = {
54
+ "generated_by": "orm-code-generator",
55
+ "timestamp": datetime.now().isoformat(),
56
+ "category": "database",
57
+ "plugin": "orm-code-generator",
58
+ "data": data,
59
+ "config": self.config
60
+ }
61
+
62
+ with open(file_path, 'w') as f:
63
+ json.dump(output_data, f, indent=2)
64
+
65
+ return file_path
66
+
67
+ def generate_script(self, name: str, template: str) -> Path:
68
+ """Generate executable script."""
69
+ filename = f"{name}.sh"
70
+ file_path = self.output_dir / filename
71
+
72
+ script_content = f"""#!/bin/bash
73
+ # Generated by orm-code-generator
74
+ # Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
75
+
76
+ set -e # Exit on error
77
+
78
+ echo "🚀 Running {name}..."
79
+
80
+ # Template content
81
+ {template}
82
+
83
+ echo "✅ Completed successfully"
84
+ """
85
+
86
+ file_path.write_text(script_content)
87
+ file_path.chmod(0o755) # Make executable
88
+ return file_path
89
+
90
+ def main():
91
+ parser = argparse.ArgumentParser(description="Generates database schema based on an ORM model definition.")
92
+ parser.add_argument('--type', choices=['markdown', 'json', 'script'], default='markdown')
93
+ parser.add_argument('--output', '-o', default='./output', help='Output directory')
94
+ parser.add_argument('--config', '-c', help='Configuration file')
95
+ parser.add_argument('--title', default='orm-code-generator Output')
96
+ parser.add_argument('--content', help='Content to include')
97
+
98
+ args = parser.parse_args()
99
+
100
+ config = {'output': args.output}
101
+ if args.config and Path(args.config).exists():
102
+ with open(args.config) as f:
103
+ config.update(json.load(f))
104
+
105
+ generator = Generator(config)
106
+
107
+ print(f"🔧 Generating {args.type} output...")
108
+
109
+ if args.type == 'markdown':
110
+ output_file = generator.generate_markdown(
111
+ args.title,
112
+ args.content or "Generated content"
113
+ )
114
+ elif args.type == 'json':
115
+ output_file = generator.generate_json(
116
+ {"title": args.title, "content": args.content}
117
+ )
118
+ else: # script
119
+ output_file = generator.generate_script(
120
+ args.title.lower().replace(' ', '_'),
121
+ args.content or "# Add your script content here"
122
+ )
123
+
124
+ print(f"✅ Generated: {output_file}")
125
+ return 0
126
+
127
+ if __name__ == "__main__":
128
+ import sys
129
+ sys.exit(main())