Documentation
¶
Overview ¶
Package cli holds the commands of the avero binary, S14. The command in cmd/avero is a thin wrapper, so a test drives the commands with no process.
Index ¶
- Constants
- Variables
- func BasecoatURL(version string) string
- func BuildAssets(ctx context.Context, dir string, project *Project, minify bool, s Streams) error
- func CheckDescription(ctx context.Context, dir string, project *Project) error
- func Describe(ctx context.Context, dir string, project *Project, s Streams) error
- func Drel(ctx context.Context, dir string) error
- func Environment(dir string) ([]string, error)
- func FirstMigration(ctx context.Context, dir, shape string, _ Streams) error
- func GenerateCheck(dir string) error
- func Install(ctx context.Context, dir string, project *Project, s Streams) error
- func Run(ctx context.Context, s Streams, args []string) int
- func Slice(ctx context.Context, dir, name string) (written []string, registered bool, err error)
- func SliceMigration(ctx context.Context, dir, pkg string) error
- func Templ(ctx context.Context, dir string) error
- func Vendor(ctx context.Context, dir, shape string, s Streams) error
- func Version() string
- type Module
- type NodeTool
- type Project
- type ProjectAssets
- type ProjectTailwind
- type Streams
Constants ¶
const ( // OpenAPIFile is the description that `avero build` writes. OpenAPIFile = "openapi.json" // OpenAPIConfig is the configuration of the generator of the front end. OpenAPIConfig = "openapi-ts.config.ts" )
The names that the description of the API carries.
const ( // NPM is the package manager of Node.js. NPM = "npm" // Bun is the package manager and the runtime of Bun. Bun = "bun" // PNPM is the package manager pnpm. PNPM = "pnpm" // Yarn is the package manager Yarn. Yarn = "yarn" )
The package managers that a front end can use. Each one reads the dependencies and runs the scripts of package.json.
const ( // ScriptBuild builds the front end for a release. ScriptBuild = "build" // ScriptDev runs the development server of the front end. ScriptDev = "dev" // ScriptAPI writes the client of the front end from openapi.json. ScriptAPI = "api" )
The scripts of package.json that Avero runs.
const DrelConfig = "drel.yaml"
DrelConfig is the file that states the models and the migrations of each feature slice.
const EnvFile = ".env"
EnvFile is the file that a person writes beside the application. `avero dev` and `avero migrate` read it, so a command needs no export in the shell.
const ProjectFile = "avero.json"
ProjectFile is the file that states the shape of an application and the entry points of its assets. `avero new` writes it.
Variables ¶
var BasecoatStyles = []string{"vega", "nova", "maia", "lyra", "mira", "luma", "sera", "rhea"}
BasecoatStyles names the eight styles that Basecoat publishes. The first one is the default. dist/basecoat.css imports the default style.
var FrontEnd = map[string][]Module{ scaffold.ShapeSSR: { {"datastar", "https://cdn.jsdelivr.net/gh/starfederation/datastar@v1.0.3/bundles/datastar.js"}, }, }
FrontEnd holds the modules that each shape vendors. `avero js pin` fetches each one as a bundled ES module and records its address and its hash in avero.lock, so a later build needs no network and no Node.js. See DX-9.
The spa shape vendors nothing, because Vite and npm own its front end.
PackageManagers names every package manager that Avero drives.
Functions ¶
func BasecoatURL ¶
BasecoatURL returns the address of one release of Basecoat.
func BuildAssets ¶
BuildAssets builds the front end of the application.
A project with an external bundler reads its dependencies first, so one command builds an application that a person just wrote.
func CheckDescription ¶
CheckDescription reports a description of the API that is not current.
The client of the front end follows openapi.json, so a description that drifts is the whole fault: the generated types of the front end state a route or a field that the service does not hold. The check writes nothing.
func Describe ¶
Describe writes the description of the API and the client of the front end.
The Go handlers state the routes, the input types and the answers. The description states the same, and the generator of the front end reads it, so one change of a handler reaches the types of the front end.
func Drel ¶
Drel runs the drel generator when the application states its models.
The application carries the generator as a tool of its go.mod, so `go tool drel` needs no second installation. drel writes the columns, the repository and the migration set of each model.
func Environment ¶ added in v0.6.0
Environment returns the environment of a command that the CLI runs in the directory of an application: the variables of .env, and the variables of this process after them.
The variable of the shell wins, because a person who exports a value states it for this one run. The file states the value that the application keeps. os/exec reads the last value of a name, so the order of the list is the order of the rule.
GITHUB_APP_PRIVATE_KEY="$(cat key.pem)" avero dev
func FirstMigration ¶
FirstMigration writes the migration of the feature slice that the shape carries.
drel reads the model and writes the difference, so the SQL and the model can never disagree. The scaffolder writes no SQL of its own.
func GenerateCheck ¶
GenerateCheck proves that every generated file of the application is current. It runs in this process, so the application needs no dependency on the avero binary. The MCP server calls the same function. See S16.
func Install ¶
Install reads the dependencies of an external bundler.
It runs one time: a directory that already holds node_modules needs no second read. The package manager is the one that the application names, so an application of Bun never calls npm. See NodeToolOf.
func Slice ¶
Slice writes one feature slice, registers it and writes the generated files. The MCP tool scaffold_slice calls it, so an agent and a person write the same files. See the SDD, S16.
func SliceMigration ¶
SliceMigration writes the first migration of one slice, then runs the drel generator again, so the binary carries the new migration set.
func Templ ¶
Templ runs the templ generator when the application holds a .templ file.
The application carries the generator as a tool of its go.mod, so `go tool templ` needs no second installation. See the SDD, S15.
func Version ¶
func Version() string
Version returns the version of the binary.
The binary reads its own build, so `go install github.com/alternayte/avero/cli/cmd/avero@v0.5.0` states v0.5.0 and a build of a working copy states dev. No release step writes the value, so the version can never disagree with the binary.
Types ¶
type Module ¶
type Module struct {
// Name is the specifier that the source imports.
Name string
// URL is the address of the bundled ES module.
URL string
}
Module is one front end module that a shape vendors.
type NodeTool ¶
type NodeTool struct {
// Name is npm, bun, pnpm or yarn.
Name string
// Dir is the directory of the front end.
Dir string
// contains filtered or unexported fields
}
NodeTool runs the package manager of one front end.
Avero states no package manager of its own. The application names the tool in avero.json, or the front end states it in the packageManager member of its package.json, or its lock file names it. An application of Bun therefore never calls npm.
func NodeToolOf ¶
NodeToolOf returns the package manager of the front end of one project.
front is the directory of the front end. The order of the sources is the order of the intent: avero.json states the tool of this application, the packageManager member of package.json states the tool of the front end, and the lock file states the tool that wrote it. npm is the last answer, because every machine that holds Node.js holds npm.
func (NodeTool) Command ¶
Command builds the command of one script in the directory of the front end. It reports the absent tool before it runs anything, so the message names the program and the repair and not an error of the operating system.
func (NodeTool) HasScript ¶
HasScript reports a script that package.json states. A front end that states no script for the client of the API runs none.
type Project ¶
type Project struct {
// Name is the name of the application.
Name string `json:"name"`
// Shape is ssr, spa or api.
Shape string `json:"shape"`
// Hypermedia is datastar or htmx. An api holds none.
Hypermedia string `json:"hypermedia,omitempty"`
// Assets states the asset pipeline.
Assets ProjectAssets `json:"assets"`
// Migrations is the directory that holds the migration files.
Migrations string `json:"migrations"`
}
Project is the content of avero.json.
func LoadProject ¶
LoadProject reads avero.json from dir.
An absent file gives the defaults, so a command works in a directory that a person wrote by hand. A file that exists states the whole asset pipeline: a member that it does not name is empty, so a project that names no Tailwind input runs no Tailwind.
type ProjectAssets ¶
type ProjectAssets struct {
// Entries names each entry point, relative to the assets directory.
Entries []string `json:"entries"`
// Tier is bundled, node or external.
Tier string `json:"tier,omitempty"`
// Command runs the external bundler of tier 2. An empty value runs the
// build script of the package manager.
Command []string `json:"command,omitempty"`
// PackageManager names the tool that reads the dependencies and runs the
// scripts of the front end: npm, bun, pnpm or yarn. An empty value reads
// the packageManager member of package.json, then the lock file, then
// npm.
PackageManager string `json:"packageManager,omitempty"`
// Install reads the dependencies of the front end. An empty value runs
// the install command of the package manager.
Install []string `json:"install,omitempty"`
// Dev runs the development server of the front end. An empty value runs
// its dev script.
Dev []string `json:"dev,omitempty"`
// API writes the client of the front end from openapi.json. An empty
// value runs its api script.
API []string `json:"api,omitempty"`
// Dir is the directory of the external bundler, relative to the
// application. An empty value runs it in the application directory.
Dir string `json:"dir,omitempty"`
// Manifest states whether the bundler writes the manifest of Avero. A
// bundler that writes its own index document, such as Vite, writes none,
// and the application serves the build with assets.SPA.
Manifest *bool `json:"manifest,omitempty"`
// Tailwind states the stylesheet and the pinned version. An empty input
// runs no Tailwind.
Tailwind ProjectTailwind `json:"tailwind"`
}
ProjectAssets states the asset pipeline of one application.
type ProjectTailwind ¶
type ProjectTailwind struct {
// Input is the stylesheet that Tailwind reads.
Input string `json:"input,omitempty"`
// Version is the pinned release of the standalone binary.
Version string `json:"version,omitempty"`
// Asset is the name that the manifest records.
Asset string `json:"asset,omitempty"`
}
ProjectTailwind states the Tailwind build.
type Streams ¶
type Streams struct {
// Out receives the result of a command.
Out io.Writer
// Err receives a fault.
Err io.Writer
// In carries the requests of `avero mcp`. A nil value reads the standard
// input.
In io.Reader
// Dir is the working directory. An empty value is the process
// directory.
Dir string
// Fetch reads the package of a library. A nil value reads over HTTP. A
// test sets it, so the gate needs no network.
Fetch pipeline.Fetcher
}
Streams holds the input and the output of one run.