engine

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: Apache-2.0

README

engine

GitLab Release GitLab Issues GitLab License GitLab CICD Go Version Plumber Score


A Go library to build projects scaffolding CLIs on three main features:

  • Initialization: interactive user configuration with huh (e.g. license choice, maintainers list, etc.)
  • Parsing: repository languages parsing
  • Generation: repository scaffolding with files generation based on Go template

How to use?

go get -u gitlab.com/kickr-dev/engine@latest

Initialize (pkg.go.dev)

Runs an interactive form with huh and alters the created configuration gradually with each huh.Group.

flowchart LR
    subgraph Groups["Form pages (each a set of related questions)"]
        direction TB
        G1["Page 1"] --> G2["Page 2"] --> Gn["Page N"]
    end

    Groups --> Form["Multi-step interactive form"]
    Form -->|"user answers each page"| Config["filled config"]

Generate (pkg.go.dev)

Parses a repository with all its configured parsers and then runs all generators to create the appropriate files regarding the repository configuration, technologies, languages, etc.

flowchart TB
    CFG["Repository config"] --> Parsing

    subgraph Parsing["Detect repository info (in order)"]
        direction LR
        P1["Parser 1"] --> P2["Parser 2"] --> Pn["Parser N"]
    end

    Parsing --> CHK{"Something failed?"}
    CHK -->|yes| ERR["Stop, nothing generated"]
    CHK -->|no| Generation

    subgraph Generation["Generate files (concurrently)"]
        direction LR
        G1["Generator 1"] ~~~ G2["Generator 2"] ~~~ Gn["Generator N"]
    end

    Generation --> CHK2{"Something failed?"}
    CHK2 -->|yes| ERRF["Report what failed"]
    CHK2 -->|no| OK["Repository generated"]
Templates

Each file has a policy. It can be rewritten every time, generated only once, removed or left alone, but by default it's rewritten only while nobody has edited it by hand.

flowchart TB
    File["File to generate"] --> Policy{"What does its policy say?"}

    Policy -->|remove| Remove["Delete the file"]
    Policy -->|skip| Untouched["Leave the file alone"]
    Policy -->|always| Write
    Policy -->|default| Owned{"Forced, or file<br/>never edited by hand?"}

    Owned -->|yes| Write["Write the file from its templates"]
    Owned -->|no| Keep["Keep the user's file,<br/>refresh only its marked sections"]

    Write --> Patch["Apply patches on top"]
    Keep --> Patch

Helpers

  • pkg/files: read, write, validate (JSON schema) and glob files.
  • pkg/generator: fetch .gitignore, code of conduct and pinned container images.
  • pkg/parser: detect Git, Go (go.mod, go.work, cmd), Hugo and package.json, and merge Helm values files.

Directories

Path Synopsis
pkg
Package engine provides functions to create and generate a project layout.
Package engine provides functions to create and generate a project layout.
files
Package files provides helpers to read, write and validate files, and to locate files across a directory tree.
Package files provides helpers to read, write and validate files, and to locate files across a directory tree.
generator
Package generator exposes a bunch of functions to be wrapped with engine.Generator function signature.
Package generator exposes a bunch of functions to be wrapped with engine.Generator function signature.
parser
Package parser provides a bunch of functions to be wrapped with engine.Parser function signature.
Package parser provides a bunch of functions to be wrapped with engine.Parser function signature.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL