4.0.0 • Published 10 months ago

@4o/engineer v4.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

🚀 Engineer: Automated Code Generation Toolkit

Overview

Engineer is a powerful, flexible code generation toolkit designed to streamline the process of creating boilerplate code, configuration files, and project structures using liquid templates and a declarative configuration approach.

🌟 Features

  • Dynamic Template Generation: Create code from liquid templates with context-aware rendering
  • Flexible Configuration: Define complex entity relationships and generation strategies
  • Multi-Template Support: Generate multiple file types in a single run
  • Extensible Actions: Easily add custom generation actions
  • Type-Safe Configuration: Built-in configuration validation with Superstruct

📦 Installation

Install Engineer using npm:

npm install @4o/engineer

🔧 Configuration

Create an engineer.config.js file in your project root:

const config = () => {
  const context = {
    // Define your project's context and entities
    entities: [
      // Entity definitions
    ]
  };

  return {
    context,
    templates: [
      // Template generation instructions
    ]
  };
};

export default config;

Configuration Options

  • context: An object containing your project's data model
  • templates: An array of template generation instructions
    • type: Generation type ("once" or "loop")
    • name: Template identifier
    • template: Path to the liquid template
    • path: Output file path (supports dynamic paths with liquid syntax)
    • iterator: (Optional) Used for loop-based generation

🚀 Usage

Create a simple script to run Engineer:

import engineer from "@4o/engineer";

const main = async () => {
  console.time('engineer');
  await engineer();
  console.timeEnd('engineer');
};

main();

📝 Liquid Template Example

{% for entity in entities %}
model {{entity.name}} {
  // Model definition using entity metadata
}
{% endfor %}

🔍 Generation Strategies

One-Time Generation

Use type: "once" to generate a single file:

{
  type: "once",
  name: "prisma-schema",
  template: "./prisma.liquid",
  path: "./out/prisma/schema.prisma"
}

Loop-Based Generation

Use type: "loop" to generate multiple files:

{
  type: "loop",
  name: "module",
  template: "./module.liquid",
  path: "./out/modules/{{name}}.js",
  iterator: "entities"
}

🛠️ Supported Actions

  • compile: Render liquid templates
  • writeTextToFile: Write generated content to files
  • readTextFromFile: Read template files
  • parseState: Extract nested object properties
  • log: Console logging

🚨 Error Handling

Engineer provides detailed configuration and runtime error messages to help diagnose issues quickly.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

📄 License

Add your project's license information

🔗 Dependencies

  • Liquid.js: Template rendering
  • Superstruct: Configuration validation
  • Node.js File System APIs

📧 Contact

Add contact information or project maintainer details

4.0.0

10 months ago

0.0.1

11 months ago

0.0.0

11 months ago