scaffold

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package scaffold renders the embedded template tree into a new site CLI repository. Every file under templates/ is a Go text/template using the delimiters << and >> (chosen so GitHub Actions ${{ ... }} and GoReleaser {{ ... }} expressions in the templates pass through untouched), and its path carries two replaceable tokens: BINARY for the command name and LIBPKG for the library package name.

Index

Constants

View Source
const ThemeSubmodule = "https://github.com/tamnd/tago-doks"

ThemeSubmodule is the docs theme every site shares, added as a git submodule at docs/themes/tago-doks so the docs workflow can build the tago site.

Variables

This section is empty.

Functions

func CreateRemote

func CreateRemote(w io.Writer, destDir, owner, repo string, private bool) error

CreateRemote creates the GitHub repository with gh and pushes the current branch, wiring origin in the process.

func InitGit

func InitGit(w io.Writer, destDir, message string) error

InitGit turns destDir into a git repo on main, adds the docs theme submodule, and makes the first commit. The submodule and commit are best-effort so a machine without network still gets a valid local repo.

func Render

func Render(destDir string, site Site) ([]string, error)

Render writes every template into destDir and returns the relative paths it wrote, in walk order. It never overwrites an existing file; a collision is an error so a half-finished scaffold is never silently clobbered.

func Tidy

func Tidy(w io.Writer, destDir string) error

Tidy runs go mod tidy so the new repo has a go.sum. It is best-effort: it needs network the first time and the repo's CI tidy job catches any drift.

Types

type Options

type Options struct {
	Owner       string
	Binary      string
	Host        string
	Short       string
	Description string
	License     string
	Author      string
	Email       string
	Year        int
}

Options carries the parts of a Site a caller may override; zero values fall back to the house defaults in NewSite.

type Site

type Site struct {
	Name        string // bare site name, e.g. "reddit"
	Repo        string // repository name, e.g. "reddit-cli"
	Binary      string // command/binary name, e.g. "reddit"
	LibPkg      string // library package name, e.g. "reddit"
	Scheme      string // resource-URI scheme the kit domain owns, e.g. "reddit"
	Host        string // the site host the client and domain target, e.g. "reddit.com"
	EnvPrefix   string // env var prefix, the upper-cased binary, e.g. "REDDIT"
	Owner       string // GitHub owner, e.g. "tamnd"
	Module      string // Go module path, e.g. "github.com/tamnd/reddit-cli"
	Image       string // container image, e.g. "ghcr.io/tamnd/reddit"
	Domain      string // docs domain, e.g. "reddit-cli.tamnd.com"
	PagesURL    string // GitHub Pages URL, e.g. "https://tamnd.github.io/reddit-cli/"
	GitHubURL   string // repo URL, e.g. "https://github.com/tamnd/reddit-cli"
	Short       string // one-line description
	Description string // longer description
	License     string // SPDX id, e.g. "Apache-2.0"
	Author      string // copyright holder
	Email       string // maintainer email
	Year        int    // copyright year
}

Site is the data a single template render is given.

func NewSite

func NewSite(name string, opt Options) Site

NewSite fills a Site from a bare name and the chosen options, deriving every path-shaped field so a caller only sets what actually varies.

Jump to

Keyboard shortcuts

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