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
go get -u gitlab.com/kickr-dev/engine@latestInitialize (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"]
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
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 andpackage.json, and merge Helm values files.