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
- func All() []string
- func Enforce(w io.Writer, template string, plugins []string, src Source) error
- func HasFlutter(name string) bool
- func IsCloneTemplate(name string) bool
- func Scaffold(name string, opts ScaffoldOptions) ([]string, error)
- type Entitled
- type Lookup
- type Manifest
- type Missing
- type PluginInfo
- type Report
- type ScaffoldOptions
- type Source
Constants ¶
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 Enforce ¶ added in v1.4.15
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
HasFlutter reports whether the embedded template ships a flutter/ starter.
func IsCloneTemplate ¶
IsCloneTemplate reports whether name is one of the bundled clone templates.
Types ¶
type Entitled ¶ added in v1.4.15
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 ¶
GetManifest reads the manifest.json for the named template.
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
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.
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.