289 lines · 9.7 KB
// Package config is the squint.yaml file: what application to run, how to
// reach it, and which screens to photograph.
//
// The shape is deliberately small. Everything an application needs to be
// started, seeded and reached is a shell command or a URL, so squint knows
// nothing about any particular framework, language or database -- and a
// project that cannot express itself in these four fields is telling you
// its test fixture is the problem, not the config format.
package config

import (
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"

	"gopkg.in/yaml.v3"
)

// Config is a whole squint.yaml.
type Config struct {
	// App is how to build, start and seed the application under test.
	App App `yaml:"app"`
	// Auth is how to log in, for scenarios that name a user.
	Auth *Auth `yaml:"auth"`
	// Viewports are the screen sizes to shoot at, by name. A scenario that
	// names none is shot at every one of them, which is how mobile stops
	// being an afterthought.
	Viewports map[string]Viewport `yaml:"viewports"`
	// Themes are variants of the same page, by name -- usually light and
	// dark. Each says how to ask for itself: a cookie, or nothing at all
	// for the default.
	Themes map[string]Theme `yaml:"themes"`
	// Rubric is the design guide review mode reads. A path, relative to
	// the project.
	Rubric string `yaml:"rubric"`
	// Scale is how many image pixels are captured per CSS pixel. Two is a
	// retina-class rendering: the file comes out twice the width of the
	// viewport, and a browser showing it at CSS size has two real pixels