scaffold

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package scaffold provides the canonical plugin scaffolding logic shared between the nself CLI (plugin new command) and the standalone new-plugin binary in plugin-sdk-go/devkit.

Both entry points call scaffold.Run with a Params struct; the output is identical so that plugin authors get the same result regardless of whether they have nself installed or use the SDK devkit directly.

Index

Constants

This section is empty.

Variables

View Source
var SlugRE = regexp.MustCompile(`^[a-z][a-z0-9-]{0,39}[a-z0-9]$`)

SlugRE is the valid plugin name regexp. A slug must start with a lowercase letter, be at least 2 chars, at most 41 chars total, contain only lowercase letters, digits, and internal hyphens, and must NOT end with a hyphen.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Name is required. Must match SlugRE.
	Name string
	// Tier is "free" or "pro". Default "free".
	Tier string
	// Bundle is the bundle display name (optional for free plugins).
	Bundle string
	// Description defaults to "nSelf <name> plugin."
	Description string
	// Author is optional.
	Author string
	// Category defaults to "custom".
	Category string
	// Language is the plugin language: go, rust, node, static. Default "go".
	Language string
	// MinCLI is the minimum nSelf CLI version required. Default "1.0.9".
	MinCLI string
	// MinSDK is the minimum plugin-sdk-go version required. Default "0.1.0".
	MinSDK string
	// Port is the default listen port. Default 8080.
	Port int
	// OutDir overrides the output directory. Default: ./<name>.
	OutDir string
	// Force allows overwriting an existing directory.
	Force bool
}

Options configures a scaffold run.

type Params

type Params struct {
	Name        string // plugin slug, e.g. "mywidget"
	PascalName  string // e.g. "Mywidget"
	EnvPrefix   string // e.g. "MYWIDGET" (upper-cased, dashes to underscores)
	RepoBucket  string // "paid" or "free"
	Tier        string // "free" or "pro"
	Bundle      string // bundle display name, e.g. "nClaw" (empty allowed for free)
	Description string
	Author      string
	License     string
	Language    string // "go" (default), "rust", "node", "static"
	MinCLI      string
	MinSDK      string
	Category    string
	Port        int
	Year        int
}

Params carries all values available inside scaffold templates.

type Result

type Result struct {
	Dir   string
	Files []string
}

Result describes what was emitted.

func Run

func Run(opts Options) (*Result, error)

Run executes the scaffold and returns the result.

Jump to

Keyboard shortcuts

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