Sign in

    moonbitstack/moonctl/scaffold does not have a README file

    Regen

    pub(all) enum Regen {
    Always
    Once
    } derive(Eq)

    Whether a regeneration may replace a file that is already on disk. Always is for what moonctl owns — the routes and the types, which must follow the spec — and Once for what it only seeds: handlers, logic, configuration, manifests.

    Regen::equal

    fn Regen::equal(Regen, Regen) -> Bool

    Regen::not_equal

    fn Regen::not_equal(x : Regen, y : Regen) -> Bool

    TreeFile

    pub(all) struct TreeFile {
    path : String
    content : String
    regen : Regen
    }

    One file of a generated project tree: where it goes, what is in it, and whether regenerating the tree is allowed to overwrite it.

    generate_tree

    fn generate_tree(spec :
    Spec
    , style? :
    Style
    , dir? : String) -> Array[TreeFile]

    Generate the layered project tree goctl writes, in MoonBit: the service entry point and its moon.mod, etc/<service>.yaml, internal/config, internal/svc, internal/types, internal/handler (the generated routes plus a stub per handler, under internal/handler/<group>/ for a grouped route), internal/logic, internal/middleware for every middleware an @server block named, and a moon.pkg for each of those packages.

    style (default gozero) names the files and the handler, logic and middleware entry points inside them. Names the spec itself chose — the type blocks and their fields — are left as written, since a MoonBit type name has to keep its capital. dir puts the whole tree under a directory.

    Each file says whether a regeneration may overwrite it; hand the result to tree_plan to apply that.

    pins

    let pins : Map[String, String]

    The version of each library generated code imports.

    These are the versions this repository's CI scaffolds a project against and builds, so a generated project is promised to compile with them. A project that wants a later release edits its own moon.mod.

    port

    let port : Int

    The port a scaffolded service listens on.

    12000, the one every server in this family defaults to: HTTP, WebSocket and h2c share it because one listener tells them apart, so a generated manifest and a generated configuration name the same number without anyone saying which they meant.

    scaffold_api

    fn scaffold_api(name : String) -> Array[
    GenFile
    ]

    Scaffold a runnable moonapi service project under <name>/: a moon.mod (depending on the published moonapi + moonasgi), a sample <name>.api spec, its generated routes+handlers in src/app.mbt (through the same generate the gen api command uses, so it compiles), and a README. This is goctl's goctl api new.

    scaffold_docker

    fn scaffold_docker(name : String, port? : Int) -> Array[
    GenFile
    ]

    Scaffold container files for a native mctl-generated service: a Dockerfile (a MoonBit build stage that produces the native binary, then a slim runtime stage that runs it) and a .dockerignore. name is the binary/image name, port the port the service listens on. goctl's goctl docker.

    scaffold_kube

    fn scaffold_kube(name : String, port? : Int, replicas? : Int) -> Array[
    GenFile
    ]

    Scaffold a Kubernetes deployment for the service under deploy/: a Deployment (replicas pods of the <name> image, a container port, and a liveness probe on /ping) and a Service exposing it. goctl's goctl kube deploy.

    The manifests are built as values and written by moonyaml, not joined out of string fragments. A generator that joins fragments has the indentation in its string literals, where a missed space is invisible, and quotes nothing — so the first service name with a colon in it emits a file Kubernetes reads as something else.

    scaffold_model

    fn scaffold_model(name : String) -> Array[
    GenFile
    ]

    Scaffold a moonorm data-layer project under <name>/: a moon.mod (depending on the published moonorm + moondb), a sample schema.sql, its generated models + CRUD in src/model.mbt (through the same generate_crud_from_ddl as gen crud), and a README. goctl's goctl model … new.

    scaffold_rpc

    fn scaffold_rpc(name : String) -> Array[
    GenFile
    ]

    Scaffold a moonrpc service project under <name>/: a moon.mod (depending on the published moonrpc), a sample <name>.proto, its generated service stub in src/service.mbt (through the same generate_grpc as gen proto), and a README. goctl's goctl rpc new.

    tree_plan

    fn tree_plan(tree : Array[TreeFile], exists : (String) -> Bool) -> Array[
    GenFile
    ]

    The files of tree a run should actually write, given a way to ask whether a path is already on disk. A file moonctl owns (Always — the routes and the types) is always written; anything else is written only when it is not there yet, so a second run refreshes what follows the spec and leaves every handler and logic body the author has since filled in exactly as it is.