Help us shape the future of Go! Take the 2026 Go Developer Survey

clone

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package clone provides embedded app-clone templates for nself init --template. Each template bundles a Postgres schema and Hasura metadata; the app clones also carry seed data and a legacy Flutter starter. Templates are embedded in the binary via go:embed so no network access is required at scaffold time.

Index

Constants

View Source
const PricingURL = "https://nself.org/pricing"

PricingURL is where an operator buys the Bundles named in a report.

Variables

This section is empty.

Functions

func All

func All() []string

All returns the list of all bundled clone template names.

func Enforce added in v1.4.15

func Enforce(w io.Writer, template string, plugins []string, src Source) error

Enforce is the init gate. It runs before any file or directory is written; a template with no required plugins makes no catalog or licence call. From v1.5 an uncovered plugin (E110), a plugin in no registry (E137) or no catalog at all (E115) refuses. In v1.4 the E110/E137 report is printed to w as a warning and the scaffold proceeds; a catalog failure stays silent there, because the served catalog may not exist yet.

func HasFlutter added in v1.4.15

func HasFlutter(name string) bool

HasFlutter reports whether the embedded template ships a flutter/ starter.

func IsCloneTemplate

func IsCloneTemplate(name string) bool

IsCloneTemplate reports whether name is one of the bundled clone templates.

func Scaffold

func Scaffold(name string, opts ScaffoldOptions) ([]string, error)

Scaffold writes all template files for name into opts.TargetDir. Returns the list of files written (or that would be written on dry run).

Types

type Entitled added in v1.4.15

type Entitled func(ctx context.Context, bundle string) (bool, error)

Entitled reports whether the operator's licence covers one Bundle. It is the hardened license.BundleEntitled in production: signed, bound, fail closed.

type Lookup added in v1.4.15

type Lookup func(slug string) (PluginInfo, bool)

Lookup finds a plugin by slug in the catalog (both tiers).

type Manifest

type Manifest struct {
	Name            string   `json:"name"`
	Version         string   `json:"version"`
	Description     string   `json:"description"`
	RequiredPlugins []string `json:"required_plugins"`
	// NextSteps is optional: when set, init prints exactly these commands
	// after scaffolding instead of the generic clone hint.
	NextSteps []string `json:"next_steps,omitempty"`
}

Manifest describes a clone template.

func GetManifest

func GetManifest(name string) (Manifest, error)

GetManifest reads the manifest.json for the named template.

type Missing added in v1.4.15

type Missing struct {
	Plugin  string
	Bundles []string
}

Missing is one licensed plugin the licence does not cover.

type PluginInfo added in v1.4.15

type PluginInfo struct {
	Slug    string
	Tier    string   // "free" or "licensed"
	Bundles []string // Bundles that include the plugin
}

PluginInfo is the part of a catalog entry Check reads.

type Report added in v1.4.15

type Report struct {
	Template       string
	MissingLicence []Missing
	Unknown        []string
	// Unchecked are licensed plugins in no Bundle: not refused here.
	Unchecked []string
	// Reason is the first entitlement error seen, "" when every check answered.
	Reason string
}

Report is the outcome of Check.

func Check added in v1.4.15

func Check(ctx context.Context, template string, plugins []string, find Lookup, entitled Entitled) Report

Check resolves each plugin. It never returns an error for a missing licence: that is data in the Report.

func (Report) Err added in v1.4.15

func (r Report) Err() error

Err is the error that refuses the scaffold, nil when the Report is OK. A plugin in no registry (E137, exit 1) outranks a missing licence (E110, exit 3): buying a Bundle does not make the template work.

func (Report) Lines added in v1.4.15

func (r Report) Lines() string

Lines lists each uncovered plugin with the Bundles that include it.

func (Report) OK added in v1.4.15

func (r Report) OK() bool

OK reports whether the template may be scaffolded.

type ScaffoldOptions

type ScaffoldOptions struct {
	// TargetDir is the directory to write files into. It must exist.
	TargetDir string
	// NoSeed skips 002_seed.sql.
	NoSeed bool
	// DryRun prints files without writing.
	DryRun bool
}

ScaffoldOptions controls how a template is written to disk.

type Source added in v1.4.15

type Source func(ctx context.Context) (Lookup, Entitled, error)

Source supplies the catalog lookup and the entitlement check. Its error is the catalog's (E115 with no catalog and no cache, E116 for a broken one).

Jump to

Keyboard shortcuts

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