|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "jinja" for Environment, DictLoader
|
|
|
|
System.print("=" * 60)
|
|
System.print("JINJA REAL-WORLD EXAMPLES")
|
|
System.print("=" * 60)
|
|
|
|
var templates = {
|
|
"invoice.html": "<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Invoice #{{ invoice.number }}</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 40px; }
|
|
.header { border-bottom: 2px solid #333; padding-bottom: 20px; }
|
|
.company-info { float: left; }
|
|
.invoice-info { float: right; text-align: right; }
|
|
.clear { clear: both; }
|
|
.addresses { margin: 30px 0; }
|
|
.from, .to { width: 45\%; display: inline-block; vertical-align: top; }
|
|
table { width: 100\%; border-collapse: collapse; margin: 20px 0; }
|
|
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; }
|
|
th { background: #f5f5f5; }
|
|
.amount { text-align: right; }
|
|
.totals { width: 300px; float: right; }
|
|
.totals td { border: none; padding: 5px 10px; }
|
|
.totals .total { font-weight: bold; font-size: 1.2em; border-top: 2px solid #333; }
|
|
.footer { margin-top: 50px; padding-top: 20px; border-top: 1px solid #ddd; font-size: 0.9em; color: #666; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class=\"header\">
|
|
<div class=\"company-info\">
|
|
<h1>{{ company.name }}</h1>
|
|
<p>{{ company.address }}<br>
|
|
{{ company.city }}, {{ company.country }}<br>
|
|
Tel: {{ company.phone }}<br>
|
|
Email: {{ company.email }}</p>
|
|
</div>
|
|
<div class=\"invoice-info\">
|
|
<h2>INVOICE</h2>
|
|
<p><strong>Invoice #:</strong> {{ invoice.number }}<br>
|
|
<strong>Date:</strong> {{ invoice.date }}<br>
|
|
<strong>Due Date:</strong> {{ invoice.due_date }}<br>
|
|
<strong>Status:</strong> {{ invoice.status|upper }}</p>
|
|
</div>
|
|
<div class=\"clear\"></div>
|
|
</div>
|
|
|
|
<div class=\"addresses\">
|
|
<div class=\"from\">
|
|
<h3>From:</h3>
|
|
<p>{{ company.name }}<br>
|
|
{{ company.address }}<br>
|
|
{{ company.city }}, {{ company.country }}</p>
|
|
</div>
|
|
<div class=\"to\">
|
|
<h3>Bill To:</h3>
|
|
<p><strong>{{ client.name }}</strong><br>
|
|
{{ client.address }}<br>
|
|
{{ client.city }}, {{ client.country }}<br>
|
|
{\% if client.vat \%}VAT: {{ client.vat }}{\% endif \%}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Description</th>
|
|
<th>Quantity</th>
|
|
<th class=\"amount\">Unit Price</th>
|
|
<th class=\"amount\">Amount</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{\% for item in invoice.items \%}
|
|
<tr>
|
|
<td>{{ loop.index }}</td>
|
|
<td>{{ item.description }}</td>
|
|
<td>{{ item.quantity }}</td>
|
|
<td class=\"amount\">${{ item.price|round(2) }}</td>
|
|
<td class=\"amount\">${{ (item.quantity * item.price)|round(2) }}</td>
|
|
</tr>
|
|
{\% endfor \%}
|
|
</tbody>
|
|
</table>
|
|
|
|
<table class=\"totals\">
|
|
<tr>
|
|
<td>Subtotal:</td>
|
|
<td class=\"amount\">${{ invoice.subtotal|round(2) }}</td>
|
|
</tr>
|
|
{\% if invoice.discount \%}
|
|
<tr>
|
|
<td>Discount ({{ invoice.discount_percent }}\%):</td>
|
|
<td class=\"amount\">-${{ invoice.discount|round(2) }}</td>
|
|
</tr>
|
|
{\% endif \%}
|
|
<tr>
|
|
<td>Tax ({{ invoice.tax_rate }}\%):</td>
|
|
<td class=\"amount\">${{ invoice.tax|round(2) }}</td>
|
|
</tr>
|
|
<tr class=\"total\">
|
|
<td>Total:</td>
|
|
<td class=\"amount\">${{ invoice.total|round(2) }}</td>
|
|
</tr>
|
|
</table>
|
|
<div class=\"clear\"></div>
|
|
|
|
{\% if invoice.notes \%}
|
|
<div class=\"notes\">
|
|
<h3>Notes:</h3>
|
|
<p>{{ invoice.notes }}</p>
|
|
</div>
|
|
{\% endif \%}
|
|
|
|
<div class=\"footer\">
|
|
<p>Payment Terms: {{ invoice.payment_terms|default(\"Net 30\") }}</p>
|
|
<p>Please make payment to: {{ company.bank_account }}</p>
|
|
<p>Thank you for your business!</p>
|
|
</div>
|
|
</body>
|
|
</html>",
|
|
|
|
"report.md": "# {{ report.title }}
|
|
|
|
**Generated:** {{ report.date }}
|
|
**Author:** {{ report.author }}
|
|
**Period:** {{ report.period_start }} to {{ report.period_end }}
|
|
|
|
---
|
|
|
|
## Executive Summary
|
|
|
|
{{ report.summary }}
|
|
|
|
## Key Metrics
|
|
|
|
| Metric | Value | Change |
|
|
|--------|-------|--------|
|
|
{\% for metric in report.metrics \%}
|
|
| {{ metric.name }} | {{ metric.value }} | {{ \"+\" if metric.change > 0 else \"\" }}{{ metric.change }}\% |
|
|
{\% endfor \%}
|
|
|
|
## Performance by Category
|
|
|
|
{\% for category in report.categories \%}
|
|
### {{ category.name }}
|
|
|
|
- **Revenue:** ${{ category.revenue|round(2) }}
|
|
- **Units Sold:** {{ category.units }}
|
|
- **Growth:** {{ category.growth }}\%
|
|
|
|
{\% if category.top_products \%}
|
|
Top products:
|
|
{\% for product in category.top_products \%}
|
|
{{ loop.index }}. {{ product.name }} (${{ product.revenue|round(2) }})
|
|
{\% endfor \%}
|
|
{\% endif \%}
|
|
|
|
{\% endfor \%}
|
|
|
|
## Recommendations
|
|
|
|
{\% for rec in report.recommendations \%}
|
|
{{ loop.index }}. **{{ rec.priority|upper }}**: {{ rec.text }}
|
|
{\% endfor \%}
|
|
|
|
---
|
|
|
|
*This report was automatically generated.*",
|
|
|
|
"api_response.json": "{
|
|
\"status\": \"{{ response.status }}\",
|
|
\"code\": {{ response.code }},
|
|
\"message\": \"{{ response.message }}\",
|
|
\"timestamp\": \"{{ response.timestamp }}\",
|
|
\"data\": {
|
|
{\% if response.data.user \%}
|
|
\"user\": {
|
|
\"id\": {{ response.data.user.id }},
|
|
\"name\": \"{{ response.data.user.name }}\",
|
|
\"email\": \"{{ response.data.user.email }}\",
|
|
\"role\": \"{{ response.data.user.role }}\",
|
|
\"created_at\": \"{{ response.data.user.created_at }}\"
|
|
},
|
|
{\% endif \%}
|
|
{\% if response.data.items \%}
|
|
\"items\": [
|
|
{\% for item in response.data.items \%}
|
|
{
|
|
\"id\": {{ item.id }},
|
|
\"name\": \"{{ item.name }}\",
|
|
\"price\": {{ item.price }},
|
|
\"available\": {{ \"true\" if item.available else \"false\" }}
|
|
}{{ \",\" if not loop.last else \"\" }}
|
|
{\% endfor \%}
|
|
],
|
|
\"total\": {{ response.data.items|length }},
|
|
{\% endif \%}
|
|
\"pagination\": {
|
|
\"page\": {{ response.pagination.page }},
|
|
\"per_page\": {{ response.pagination.per_page }},
|
|
\"total_pages\": {{ response.pagination.total_pages }},
|
|
\"total_items\": {{ response.pagination.total_items }}
|
|
}
|
|
}
|
|
}",
|
|
|
|
"config.yaml": "# Application Configuration
|
|
# Generated: {{ timestamp }}
|
|
|
|
app:
|
|
name: {{ config.app.name }}
|
|
version: {{ config.app.version }}
|
|
environment: {{ config.app.environment }}
|
|
debug: {{ \"true\" if config.app.debug else \"false\" }}
|
|
|
|
server:
|
|
host: {{ config.server.host }}
|
|
port: {{ config.server.port }}
|
|
workers: {{ config.server.workers }}
|
|
timeout: {{ config.server.timeout }}
|
|
|
|
database:
|
|
driver: {{ config.database.driver }}
|
|
host: {{ config.database.host }}
|
|
port: {{ config.database.port }}
|
|
name: {{ config.database.name }}
|
|
user: {{ config.database.user }}
|
|
pool_size: {{ config.database.pool_size }}
|
|
|
|
cache:
|
|
driver: {{ config.cache.driver }}
|
|
host: {{ config.cache.host }}
|
|
port: {{ config.cache.port }}
|
|
ttl: {{ config.cache.ttl }}
|
|
|
|
logging:
|
|
level: {{ config.logging.level }}
|
|
format: \"{{ config.logging.format }}\"
|
|
handlers:
|
|
{\% for handler in config.logging.handlers \%}
|
|
- type: {{ handler.type }}
|
|
{\% if handler.path \%}path: {{ handler.path }}{\% endif \%}
|
|
{\% if handler.max_size \%}max_size: {{ handler.max_size }}{\% endif \%}
|
|
{\% endfor \%}
|
|
|
|
features:
|
|
{\% for feature, enabled in config.features \%}
|
|
{{ feature }}: {{ \"true\" if enabled else \"false\" }}
|
|
{\% endfor \%}",
|
|
|
|
"sitemap.xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
|
|
{\% for page in pages \%}
|
|
<url>
|
|
<loc>{{ base_url }}{{ page.url }}</loc>
|
|
<lastmod>{{ page.last_modified }}</lastmod>
|
|
<changefreq>{{ page.change_freq|default(\"weekly\") }}</changefreq>
|
|
<priority>{{ page.priority|default(\"0.5\") }}</priority>
|
|
</url>
|
|
{\% endfor \%}
|
|
</urlset>",
|
|
|
|
"dockerfile": "# Dockerfile for {{ app.name }}
|
|
# Generated automatically - do not edit manually
|
|
|
|
FROM {{ app.base_image }}
|
|
|
|
LABEL maintainer=\"{{ app.maintainer }}\"
|
|
LABEL version=\"{{ app.version }}\"
|
|
|
|
# Set environment variables
|
|
{\% for key, value in app.env_vars \%}
|
|
ENV {{ key }}={{ value }}
|
|
{\% endfor \%}
|
|
|
|
# Set working directory
|
|
WORKDIR {{ app.workdir }}
|
|
|
|
# Install system dependencies
|
|
{\% if app.system_packages \%}
|
|
RUN apt-get update && apt-get install -y \\
|
|
{\% for pkg in app.system_packages \%}
|
|
{{ pkg }}{\% if not loop.last \%} \\{\% endif \%}
|
|
{\% endfor \%}
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
{\% endif \%}
|
|
|
|
# Copy dependency files
|
|
{\% for file in app.dependency_files \%}
|
|
COPY {{ file }} .
|
|
{\% endfor \%}
|
|
|
|
# Install application dependencies
|
|
{\% if app.install_cmd \%}
|
|
RUN {{ app.install_cmd }}
|
|
{\% endif \%}
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Expose port
|
|
EXPOSE {{ app.port }}
|
|
|
|
# Health check
|
|
{\% if app.healthcheck \%}
|
|
HEALTHCHECK --interval={{ app.healthcheck.interval }} --timeout={{ app.healthcheck.timeout }} \\
|
|
CMD {{ app.healthcheck.cmd }}
|
|
{\% endif \%}
|
|
|
|
# Run the application
|
|
CMD [\"{{ app.cmd }}\"]",
|
|
|
|
"readme.md": "# {{ project.name }}
|
|
|
|
{{ project.description }}
|
|
|
|
## Features
|
|
|
|
{\% for feature in project.features \%}
|
|
- {{ feature }}
|
|
{\% endfor \%}
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
{{ project.install_cmd }}
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
```{{ project.code_lang }}
|
|
{{ project.quick_start }}
|
|
```
|
|
|
|
## Configuration
|
|
|
|
| Option | Type | Default | Description |
|
|
|--------|------|---------|-------------|
|
|
{\% for opt in project.config_options \%}
|
|
| `{{ opt.name }}` | {{ opt.type }} | {{ opt.default|default(\"N/A\") }} | {{ opt.description }} |
|
|
{\% endfor \%}
|
|
|
|
## API Reference
|
|
|
|
{\% for endpoint in project.api_endpoints \%}
|
|
### {{ endpoint.method }} {{ endpoint.path }}
|
|
|
|
{{ endpoint.description }}
|
|
|
|
**Parameters:**
|
|
{\% for param in endpoint.params \%}
|
|
- `{{ param.name }}` ({{ param.type }}{\% if param.required \%}, required{\% endif \%}): {{ param.description }}
|
|
{\% endfor \%}
|
|
|
|
**Response:**
|
|
```json
|
|
{{ endpoint.response_example }}
|
|
```
|
|
|
|
{\% endfor \%}
|
|
|
|
## License
|
|
|
|
{{ project.license }}
|
|
|
|
## Author
|
|
|
|
{{ project.author }} - {{ project.author_email }}",
|
|
|
|
"changelog.md": "# Changelog
|
|
|
|
All notable changes to {{ project_name }} will be documented in this file.
|
|
|
|
{\% for release in releases \%}
|
|
## [{{ release.version }}] - {{ release.date }}
|
|
|
|
{\% if release.breaking \%}
|
|
### Breaking Changes
|
|
{\% for item in release.breaking \%}
|
|
- {{ item }}
|
|
{\% endfor \%}
|
|
|
|
{\% endif \%}
|
|
{\% if release.added \%}
|
|
### Added
|
|
{\% for item in release.added \%}
|
|
- {{ item }}
|
|
{\% endfor \%}
|
|
|
|
{\% endif \%}
|
|
{\% if release.changed \%}
|
|
### Changed
|
|
{\% for item in release.changed \%}
|
|
- {{ item }}
|
|
{\% endfor \%}
|
|
|
|
{\% endif \%}
|
|
{\% if release.deprecated \%}
|
|
### Deprecated
|
|
{\% for item in release.deprecated \%}
|
|
- {{ item }}
|
|
{\% endfor \%}
|
|
|
|
{\% endif \%}
|
|
{\% if release.removed \%}
|
|
### Removed
|
|
{\% for item in release.removed \%}
|
|
- {{ item }}
|
|
{\% endfor \%}
|
|
|
|
{\% endif \%}
|
|
{\% if release.fixed \%}
|
|
### Fixed
|
|
{\% for item in release.fixed \%}
|
|
- {{ item }}
|
|
{\% endfor \%}
|
|
|
|
{\% endif \%}
|
|
{\% if release.security \%}
|
|
### Security
|
|
{\% for item in release.security \%}
|
|
- {{ item }}
|
|
{\% endfor \%}
|
|
|
|
{\% endif \%}
|
|
{\% endfor \%}"
|
|
}
|
|
|
|
var env = Environment.new(DictLoader.new(templates))
|
|
|
|
System.print("\n" + "-" * 60)
|
|
System.print("1. INVOICE (HTML)")
|
|
System.print("-" * 60)
|
|
System.print(env.getTemplate("invoice.html").render({
|
|
"company": {
|
|
"name": "Acme Corporation",
|
|
"address": "123 Business Street",
|
|
"city": "New York, NY 10001",
|
|
"country": "USA",
|
|
"phone": "+1 (555) 123-4567",
|
|
"email": "billing@acme.com",
|
|
"bank_account": "Bank of America - 1234567890"
|
|
},
|
|
"client": {
|
|
"name": "TechStart Inc.",
|
|
"address": "456 Innovation Ave",
|
|
"city": "San Francisco, CA 94102",
|
|
"country": "USA",
|
|
"vat": "US123456789"
|
|
},
|
|
"invoice": {
|
|
"number": "INV-2024-001",
|
|
"date": "2024-01-15",
|
|
"due_date": "2024-02-14",
|
|
"status": "pending",
|
|
"items": [
|
|
{"description": "Web Development Services", "quantity": 40, "price": 150},
|
|
{"description": "UI/UX Design", "quantity": 20, "price": 125},
|
|
{"description": "Server Setup & Configuration", "quantity": 8, "price": 200},
|
|
{"description": "Monthly Maintenance (Jan)", "quantity": 1, "price": 500}
|
|
],
|
|
"subtotal": 9600,
|
|
"discount": 480,
|
|
"discount_percent": 5,
|
|
"tax_rate": 8.5,
|
|
"tax": 775.2,
|
|
"total": 9895.2,
|
|
"notes": "Thank you for choosing Acme Corporation. Payment is due within 30 days.",
|
|
"payment_terms": "Net 30"
|
|
}
|
|
}))
|
|
|
|
System.print("\n" + "-" * 60)
|
|
System.print("2. BUSINESS REPORT (Markdown)")
|
|
System.print("-" * 60)
|
|
System.print(env.getTemplate("report.md").render({
|
|
"report": {
|
|
"title": "Q4 2024 Sales Report",
|
|
"date": "2024-01-05",
|
|
"author": "Analytics Team",
|
|
"period_start": "2024-10-01",
|
|
"period_end": "2024-12-31",
|
|
"summary": "Q4 2024 showed strong performance with overall revenue growth of 15\% compared to Q3. The Electronics category led growth while we saw moderate decline in Accessories.",
|
|
"metrics": [
|
|
{"name": "Total Revenue", "value": "$1.2M", "change": 15},
|
|
{"name": "Orders", "value": "8,450", "change": 12},
|
|
{"name": "Avg Order Value", "value": "$142", "change": 3},
|
|
{"name": "Customer Retention", "value": "78\%", "change": -2}
|
|
],
|
|
"categories": [
|
|
{
|
|
"name": "Electronics",
|
|
"revenue": 650000,
|
|
"units": 4200,
|
|
"growth": 22,
|
|
"top_products": [
|
|
{"name": "Laptop Pro X", "revenue": 180000},
|
|
{"name": "Wireless Headphones", "revenue": 95000},
|
|
{"name": "Smart Watch V3", "revenue": 72000}
|
|
]
|
|
},
|
|
{
|
|
"name": "Clothing",
|
|
"revenue": 380000,
|
|
"units": 12500,
|
|
"growth": 8,
|
|
"top_products": [
|
|
{"name": "Winter Jacket", "revenue": 65000},
|
|
{"name": "Running Shoes", "revenue": 48000}
|
|
]
|
|
}
|
|
],
|
|
"recommendations": [
|
|
{"priority": "high", "text": "Increase inventory for Electronics category to meet Q1 demand"},
|
|
{"priority": "medium", "text": "Launch targeted campaign for Accessories to reverse decline"},
|
|
{"priority": "low", "text": "Consider expanding Clothing line with spring collection"}
|
|
]
|
|
}
|
|
}))
|
|
|
|
System.print("\n" + "-" * 60)
|
|
System.print("3. API RESPONSE (JSON)")
|
|
System.print("-" * 60)
|
|
System.print(env.getTemplate("api_response.json").render({
|
|
"response": {
|
|
"status": "success",
|
|
"code": 200,
|
|
"message": "Data retrieved successfully",
|
|
"timestamp": "2024-01-15T10:30:00Z",
|
|
"data": {
|
|
"user": {
|
|
"id": 12345,
|
|
"name": "John Doe",
|
|
"email": "john@example.com",
|
|
"role": "admin",
|
|
"created_at": "2023-06-15T08:00:00Z"
|
|
},
|
|
"items": [
|
|
{"id": 1, "name": "Widget A", "price": 29.99, "available": true},
|
|
{"id": 2, "name": "Widget B", "price": 49.99, "available": true},
|
|
{"id": 3, "name": "Widget C", "price": 19.99, "available": false}
|
|
]
|
|
},
|
|
"pagination": {
|
|
"page": 1,
|
|
"per_page": 10,
|
|
"total_pages": 5,
|
|
"total_items": 47
|
|
}
|
|
}
|
|
}))
|
|
|
|
System.print("\n" + "-" * 60)
|
|
System.print("4. CONFIG FILE (YAML)")
|
|
System.print("-" * 60)
|
|
System.print(env.getTemplate("config.yaml").render({
|
|
"timestamp": "2024-01-15 10:30:00",
|
|
"config": {
|
|
"app": {
|
|
"name": "MyApp",
|
|
"version": "2.1.0",
|
|
"environment": "production",
|
|
"debug": false
|
|
},
|
|
"server": {
|
|
"host": "0.0.0.0",
|
|
"port": 8080,
|
|
"workers": 4,
|
|
"timeout": 30
|
|
},
|
|
"database": {
|
|
"driver": "postgresql",
|
|
"host": "db.example.com",
|
|
"port": 5432,
|
|
"name": "myapp_prod",
|
|
"user": "app_user",
|
|
"pool_size": 20
|
|
},
|
|
"cache": {
|
|
"driver": "redis",
|
|
"host": "cache.example.com",
|
|
"port": 6379,
|
|
"ttl": 3600
|
|
},
|
|
"logging": {
|
|
"level": "INFO",
|
|
"format": "\%(asctime)s - \%(name)s - \%(levelname)s - \%(message)s",
|
|
"handlers": [
|
|
{"type": "console"},
|
|
{"type": "file", "path": "/var/log/myapp.log", "max_size": "100MB"}
|
|
]
|
|
},
|
|
"features": {
|
|
"new_dashboard": true,
|
|
"beta_api": false,
|
|
"analytics": true
|
|
}
|
|
}
|
|
}))
|
|
|
|
System.print("\n" + "-" * 60)
|
|
System.print("5. SITEMAP (XML)")
|
|
System.print("-" * 60)
|
|
System.print(env.getTemplate("sitemap.xml").render({
|
|
"base_url": "https://example.com",
|
|
"pages": [
|
|
{"url": "/", "last_modified": "2024-01-15", "change_freq": "daily", "priority": "1.0"},
|
|
{"url": "/about", "last_modified": "2024-01-10", "change_freq": "monthly", "priority": "0.8"},
|
|
{"url": "/products", "last_modified": "2024-01-14", "change_freq": "weekly", "priority": "0.9"},
|
|
{"url": "/blog", "last_modified": "2024-01-15", "change_freq": "daily", "priority": "0.7"},
|
|
{"url": "/contact", "last_modified": "2024-01-01", "change_freq": "yearly", "priority": "0.5"}
|
|
]
|
|
}))
|
|
|
|
System.print("\n" + "-" * 60)
|
|
System.print("6. DOCKERFILE")
|
|
System.print("-" * 60)
|
|
System.print(env.getTemplate("dockerfile").render({
|
|
"app": {
|
|
"name": "my-python-app",
|
|
"base_image": "python:3.11-slim",
|
|
"maintainer": "dev@example.com",
|
|
"version": "1.0.0",
|
|
"workdir": "/app",
|
|
"port": 8000,
|
|
"env_vars": {
|
|
"PYTHONUNBUFFERED": "1",
|
|
"PYTHONDONTWRITEBYTECODE": "1",
|
|
"APP_ENV": "production"
|
|
},
|
|
"system_packages": ["gcc", "libpq-dev", "curl"],
|
|
"dependency_files": ["requirements.txt", "setup.py"],
|
|
"install_cmd": "pip install --no-cache-dir -r requirements.txt",
|
|
"healthcheck": {
|
|
"interval": "30s",
|
|
"timeout": "10s",
|
|
"cmd": "curl -f http://localhost:8000/health || exit 1"
|
|
},
|
|
"cmd": "gunicorn -w 4 -b 0.0.0.0:8000 app:app"
|
|
}
|
|
}))
|
|
|
|
System.print("\n" + "-" * 60)
|
|
System.print("7. CHANGELOG")
|
|
System.print("-" * 60)
|
|
System.print(env.getTemplate("changelog.md").render({
|
|
"project_name": "MyAwesomeLib",
|
|
"releases": [
|
|
{
|
|
"version": "2.0.0",
|
|
"date": "2024-01-15",
|
|
"breaking": [
|
|
"Removed deprecated `oldMethod()` function",
|
|
"Changed default timeout from 30s to 60s"
|
|
],
|
|
"added": [
|
|
"New async API support",
|
|
"Plugin system for extensibility",
|
|
"TypeScript type definitions"
|
|
],
|
|
"changed": [
|
|
"Improved error messages",
|
|
"Updated dependencies to latest versions"
|
|
],
|
|
"fixed": [
|
|
"Memory leak in connection pool",
|
|
"Race condition in concurrent requests"
|
|
]
|
|
},
|
|
{
|
|
"version": "1.5.0",
|
|
"date": "2023-12-01",
|
|
"added": [
|
|
"Caching layer for improved performance",
|
|
"Retry mechanism with exponential backoff"
|
|
],
|
|
"deprecated": [
|
|
"`oldMethod()` - use `newMethod()` instead"
|
|
],
|
|
"fixed": [
|
|
"Timeout handling in slow networks",
|
|
"Unicode encoding issues"
|
|
],
|
|
"security": [
|
|
"Updated crypto library to patch CVE-2023-XXXXX"
|
|
]
|
|
}
|
|
]
|
|
}))
|
|
|
|
System.print("\n" + "=" * 60)
|
|
System.print("End of Real-World Examples")
|
|
System.print("=" * 60)
|