scaffold

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package scaffold provides CS_N custom service scaffolding for nself projects. It handles slot assignment, template rendering, and .env.dev updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidLang

func IsValidLang(lang string) bool

IsValidLang reports whether lang is a supported template language.

func NextCSSlot

func NextCSSlot(projectRoot string) (int, error)

NextCSSlot returns the next CS_N slot number (1-10) not already set in .env.dev. Returns an error if all 10 slots are in use. This is the exported variant of the internal nextFreeSlot helper (G-006).

func SupportedLangs

func SupportedLangs() []string

SupportedLangs returns the list of supported language template names.

Types

type Options

type Options struct {
	// Name is the service name (e.g. "my-api"). Validated against customServiceNameRe.
	Name string
	// Lang is one of: go, node, python, rust, other. Default "go".
	Lang string
	// ProjectDir is the nSelf project root. Defaults to the current working directory.
	ProjectDir string
	// Force allows overwriting an existing service directory.
	Force bool
	// DryRun prints what would be done without writing any files.
	DryRun bool
}

Options configures a custom service scaffold run.

type Result

type Result struct {
	// Slot is the assigned CS_N slot number (1-10).
	Slot int
	// EnvKey is the env var name that was written (e.g. "CS_3").
	EnvKey string
	// EnvValue is the value that was written (e.g. "my-api:go:8003").
	EnvValue string
	// ServiceDir is the directory that was created.
	ServiceDir string
	// EnvFile is the .env file that was updated.
	EnvFile string
	// Files lists the relative (to ServiceDir) paths of emitted files.
	Files []string
}

Result describes what was emitted.

func Run

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

Run scaffolds a custom service into the nSelf project at opts.ProjectDir. It finds the next free CS_N slot (1-10), creates the service directory, and writes CS_N=<name>:<lang>:<port> into .env.dev.

Jump to

Keyboard shortcuts

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