Documentation
¶
Overview ¶
Package scaffold writes the starter files for a website built on the cms module — main.go, page templates, .env, docker-compose.yml — into a directory. It is what "cms init" runs; importing it directly lets a host application build its own generator on top.
Nothing here imports the cms module itself, and nothing here imports anything outside the standard library. That is deliberate: the command wrapping this package is fetched with
go run github.com/tsawler/cms/cmd/cms@latest
which resolves the whole module graph. Keeping this package on the standard library alone keeps that a small download rather than one that drags in the database drivers, the AWS SDK, and testcontainers.
The embedded starter files are Go templates using [[ and ]] as delimiters, because most of what they contain is itself Go template source written in {{ and }}.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine string
Engine is a database engine the generated site can target.
The supported engines. All three are first-class — the same store tests run against each — so the choice is an operational one.
type Options ¶
type Options struct {
// SiteName is the human-readable name used in the page title, the
// brand in the header, and the generated README. Defaults to a
// title-cased form of the target directory's name.
SiteName string
// Engine is the database the generated main.go and docker-compose.yml
// target. Defaults to Postgres.
Engine Engine
// Blog adds the blog listing, news listing, and post templates, and
// sets Config.PostTemplate in the generated main.go. Without it, blog
// and news are disabled and the admin area does not offer them.
Blog bool
// Tailwind adds assets/input.css, assets/theme.css, gen.go, and
// tailwind-content.sh, and wires CMS_TAILWIND_COMMAND in .env so
// classes typed into content get compiled CSS without a redeploy.
// Both builds import theme.css, which is what keeps a customized theme
// from being reset by the content stylesheet. Without it the generated
// templates still carry their Tailwind classes — you supply
// static/site.css however you like.
Tailwind bool
// Captcha adds the Cap and Valkey services to docker-compose.yml for
// the login CAPTCHA. The CAP_* variables in .env stay commented out
// either way: the CMS runs without a CAPTCHA until they are set.
Captcha bool
// Force overwrites files that already exist. Without it they are left
// alone and reported as Skipped, which makes Write safe to re-run in a
// project that has already diverged.
Force bool
// DryRun reports what would be written without touching the disk.
DryRun bool
}
Options controls what Write generates. The zero value is valid and produces the smallest useful site: Postgres, no blog, no Tailwind, no CAPTCHA. The cms init command turns Blog and Tailwind on by default.
type Result ¶
Result records the disposition of a single file. Path is relative to the directory passed to Write.
func Write ¶
Write generates the starter files into dir, creating it if necessary, and returns what it did with each one in manifest order. Existing files are left alone unless Options.Force is set.
On error the results so far are still returned, so a caller can report the files that were written before the failure.