1// Command prep packs the e2e registry: every corpus volume, written out as a2// real .atlas file under dist/e2e/bundles.3//4// `make test-e2e` runs this before Playwright starts the application, so the5// browser walks a library that was built from committed bytes moments6// earlier. There is nothing to fetch and nothing that can be missing: if the7// corpus does not pack, this command fails and the e2e run goes red rather8// than quietly walking an empty library.9package main1011import (12 "fmt"13 "os"14 "path/filepath"1516 "github.com/FelineStateMachine/atlas/format/vnext"17 "github.com/FelineStateMachine/atlas/tests/corpus"18)1920func main() {21 if err := run(); err != nil {22 fmt.Fprintln(os.Stderr, "prep:", err)23 os.Exit(1)24 }25}2627func run() error {28 root := corpus.Root(".")29 slugs, err := corpus.Slugs(root)30 if err != nil {31 return fmt.Errorf("reading the corpus (run from the repository root): %w", err)32 }33 if len(slugs) == 0 {34 return fmt.Errorf("the corpus at %s holds no volumes", root)35 }3637 dir := filepath.Join("dist", "e2e", "bundles")38 if err := os.RemoveAll(dir); err != nil {39 return err40 }41 if err := os.MkdirAll(dir, 0o755); err != nil {42 return err43 }44 for _, slug := range slugs {45 path, err := corpus.Pack(filepath.Join(root, slug), dir)46 if err != nil {47 return fmt.Errorf("packing %s: %w", slug, err)48 }49 fmt.Println(path)50 }5152 // The included Earth volume beside the corpus: the committed bundle the53 // desktop embeds, installed whole through the format's own path. It is the54 // one registry entry with real rasters, which is what lets a spec ask for55 // a tile and get an image back.56 included, err := filepath.Glob(filepath.Join("included", "*.atlas"))57 if err != nil {58 return err59 }60 if len(included) != 1 {61 return fmt.Errorf("included/ holds %d bundles, want exactly the one Earth", len(included))62 }63 installed, err := vnext.Install(dir, included[0], vnext.StandardSchema())64 if err != nil {65 return fmt.Errorf("installing %s: %w", included[0], err)66 }67 fmt.Println(installed.Locator)68 return nil69}