Documentation
¶
Overview ¶
Package scaffold generates a new Puzzle application from an embedded template tree (see templates/). It backs `puzzle init`: it validates the requested app name (it becomes an npm package name) and template, refuses to write into a non-empty directory, and copies the template's files with the __APP_NAME__ placeholder substituted.
Templates are real files under templates/<name>/ embedded with go:embed (all: so dotfiles like .gitignore are included). Adding a template is a matter of dropping a new subtree in; no Go changes are needed beyond registering its name in Templates.
Index ¶
Constants ¶
const DefaultTemplate = "default"
DefaultTemplate is used when --template is not given.
Variables ¶
var Templates = []string{"default", "todos"}
Templates lists the template names `puzzle init` accepts, in menu order. The first entry is the default.
Functions ¶
func ValidTemplate ¶
ValidTemplate reports whether name is a known template.
func ValidateName ¶
ValidateName reports whether name is an acceptable app / npm package name.
func WriteJSConfig ¶
WriteJSConfig writes the editor-only jsconfig.json into an already scaffolded app directory, wiring the '@' alias for JS apps (SPEC §40, D75). Like WriteTypeScriptConfig it only drops a config file — no user JS is rewritten (D3) — and it refuses to overwrite an existing jsconfig.json.
func WriteTypeScriptConfig ¶
WriteTypeScriptConfig writes a strict/noEmit tsconfig.json into an already scaffolded app directory (v1.22, D54), backing `puzzle init --typescript`. It returns the created files as slash paths relative to dir, and is a no-op-safe add-on: it never rewrites user JS, only drops the config. It refuses to overwrite an existing tsconfig.json.
Types ¶
type Result ¶
type Result struct {
// Dir is the absolute path of the created app directory.
Dir string
// Files are the created files, as slash paths relative to Dir, sorted.
Files []string
}
Result reports what Create produced.