a73x

cmd/eitri-shape/main.go

Ref:   Size: 929 B   History

// eitri-shape regenerates the explorable architecture-shape diagram from the
// real package graph (`go list`). It writes two committed artifacts at the repo
// root: docs/shape.json (the authoritative, diff-reviewable model) and
// docs/shape.html (a self-contained viewer with the JSON inlined verbatim).
//
//	go run ./cmd/eitri-shape   // or: make shape
//
// `make shape-check` regenerates and fails CI if either artifact is stale.
package main

import (
	"log"
	"os"

	"github.com/a73x/eitri/internal/shape"
)

func main() {
	jsonBytes, err := shape.Generate()
	if err != nil {
		log.Fatalf("eitri-shape: %v", err)
	}
	if err := os.WriteFile("docs/shape.json", jsonBytes, 0o644); err != nil {
		log.Fatalf("eitri-shape: write docs/shape.json: %v", err)
	}
	if err := os.WriteFile("docs/shape.html", []byte(shape.RenderHTML(jsonBytes)), 0o644); err != nil {
		log.Fatalf("eitri-shape: write docs/shape.html: %v", err)
	}
}