Skip to content
standards-labPublic

About

The web client template of Standards Lab's web client stack: builds embedded (served by go-web-sdk's NewClient) or external.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

webappgen

The web client CLI of the standards-lab web client stack. webappgen new <kind> writes a client project for one kind of app, and webappgen inject <kind> installs a client into an existing project, from files embedded in its binary, so one version names both the CLI and every file it writes. The written project depends on the stack's layers, web-foundation, web-icons, web-components, web-app-sdk, and web-tooling, each by its exact release tag, and pins its toolchain with mise.

Install

With mise, from the GitHub release's binaries for linux and macOS on amd64 and arm64:

mise use github:standards-lab/webappgen

Or with Go:

go install github.com/standards-lab/webappgen/cmd/webappgen@latest

webappgen version prints the release the binary was built from.

On Windows, run webappgen and the project it writes in WSL: there is no Windows build yet, and the written project's toolchain and browser tier are pinned for linux and macOS.

Write a standalone app

webappgen new standalone my-app
cd my-app
mise install
mise run install
mise run check

new standalone <dir> writes a static web client, served on its own, into a new or empty directory, and prints the steps left to run. Its flags:

Flag Default What it sets
--name name the directory's name the project's package name
--title title the name the page's title
--base path / the absolute path the app is served under, written as its <base href>
--api-base URL /api/ the URL of the API the app calls, written to its public/config.json
--install off run mise install and mise run install in the project, leaving mise run check

--install reads the network, naming each step and its output on stderr. A missing mise or a step that fails exits nonzero naming the step and the steps left, and the written project stays.

The written project's tasks:

  • install installs the pinned tools and the packages.
  • check runs the step scripts in scripts/check/ in order: lint, format, type-check, the unit tier, the build into dist/, its size, and the browser tier in the pinned chrome-headless-shell, isolated by a network namespace on Linux, not macOS.
  • build builds the app into dist/.
  • dev serves the source with Vite's dev server, and preview serves the build with vite preview.
  • currency reports any tool, package, or layer pin behind its latest, holding typescript to typescript-eslint's range and rolldown to vite's.

MISE_ENV=agent, which the project's .claude/settings.json sets, adds for each step a check:<step> task that runs it alone.

The written page is web-foundation's application page: a header with the app's title and its actions over a main column where the router mounts each view. The header holds two buttons, drawn with web-icons' glyphs:

  • Help, on the ? key, opens a dialog listing the page's keyboard shortcuts (web-components' sl-shortcuts).
  • Settings, on the S key, opens a dialog to choose the color, space, and type profiles (web-components' sl-settings). A choice applies and is stored at once, and the stored choice applies before first paint on every later visit.

Each dialog closes on its Close button or Escape. The page ignores ? and S inside a text field. The written project's own README.md documents its tasks, its config, deploying it, and how it is built.

Deploy a standalone build

mise run build writes the app to dist/, for any static host:

  • Serve dist/ under the --base path the project was written with; the build's <base href> and its asset URLs name that path.
  • Replace the built config.json with the deployment's own: it names the API the app calls, as {"apiBase": "<URL>"}, and the app reads it at runtime, so one build serves every deployment.
  • The host must answer index.html for any unknown path under the base, so a deep link or a reload reaches the app's router.

Write a service app

webappgen new service-app example.com/my-service my-service
cd my-service
git init
mise install
go mod download
mise -C client install
mise -C client run install
mise run check

new service-app <module> <dir> copies go-web-sdk-template, at its pinned version, into a new or empty directory as <module>, with gonew, then writes a web client into it. inject service-app <service-dir> writes the client into an existing copy of the template. Each prints the steps left, inject's from mise -C client install. Both take these flags:

Flag Default What it sets
--name name the directory's name the client's package name
--title title the name the page's title
--base path / the absolute path the service serves the client under
--api-base URL /api/ the URL of the API the client calls, written into the page's #app-config
--client-dir path client the client's directory in the service
--install off run the install steps, leaving mise run check

Each writes the client, its Go package, internal/app/client.go, two scripts, and .air.toml, and edits the service's wiring, tasks, and CI to serve and build the client. A service that differs from the template where any edit goes is left unedited: inject writes nothing, prints every edit, and exits 1, running no install step. docs/service-app.md details each file and the printed edits.

In the service, mise run check builds and checks the client, then checks the service; mise run serve builds the client, then runs the service; and mise run dev runs air, which rebuilds the client and the service, then restarts the service, whenever the client's sources or the service's Go change. Under MISE_ENV=agent, which the service's .claude/settings.json sets, check:client runs the client's step alone.

Deploy a service app

Build the client, then the service: the client's mise run build writes dist/, which the service's build embeds, so a deployment ships the binary alone. The service serves the client's shell, with its config, for any path under --base that isn't a built file.

Capabilities

  • CLI: version, new with one leaf per kind of app, and inject with one leaf per kind that installs into an existing project; usage errors name the fix.
  • Standalone kind: new standalone <dir>, with the flags above.
  • Service-app kind: new service-app <module> <dir> and inject service-app <service-dir>, with the flags above.
  • Written project: the application page with Help and Settings, a home and a not-found view, its config read from config.json or #app-config, its own README.md, a check of step scripts with unit and browser tiers, and a check:<step> task per step under MISE_ENV=agent.

Contributing

The repository is the Go module github.com/standards-lab/webappgen on go-cli-sdk. Every tool is pinned in mise.toml:

mise run install      # the pins, the module's requirements, and the caches below; reads the network
mise run check        # Go, shell, workflow, and context checks, then integration; reads no network
mise run build        # the CLI into bin/
mise run integration  # the integration tier alone
mise run fmt          # gofmt every Go file
mise run currency     # each Go, tool, package, layer, and action pin trailing; reads the network

check runs the step scripts in scripts/check/ in order. MISE_ENV=agent adds a check:<step> task for each, and vet, test, and lint for the Go step's gates. Only install installs a missing tool; every other task names mise run install when one is missing. mise run install fills two caches the offline integration tier reads: scripts/fetch-store.sh writes a project and fetches its packages into .cache/pnpm-store, and scripts/fetch-service.sh puts the service-app kind's pins and the template's requirements in the module cache and installs the template's tools. The module builds with GOWORK=off. Tests are black-box _test packages in each package's test/, with fixtures in test/testdata/. golangci-lint's testpackage allows only an export_test.go, and only to export a clock or probe hook the API can't reach deterministically.

The root mise.toml pins every tool the starter's internal/starter/files/mise.toml.tmpl pins, each entry as the starter writes it, and air as the service-app kind's mise.toml edit pins it; a unit test holds them equal. Bump a shared tool in both files at once; bumping chrome-headless-shell also takes each platform's sha256 and size from its download, by hand, in both. A changed starter package regenerates internal/starter/files/pnpm-lock.yaml with the pinned pnpm.

A release is a vX.Y.Z tag pushed on main's merge commit, with its CHANGELOG.md section; the release workflow tags nothing. It refuses a tag whose commit isn't on main, checks, and builds and packs the four binaries with scripts/pack.sh, which a clone at the tag also runs (scripts/pack.sh vX.Y.Z <outdir>) and which refuses any binary whose version isn't the tag. It creates the release as a draft from the tag's CHANGELOG.md section, attaches every archive and SHA256SUMS, and only then publishes it, so a release appears only whole: a failed upload leaves a draft.

License

Apache License 2.0.

About

The web client template of Standards Lab's web client stack: builds embedded (served by go-web-sdk's NewClient) or external.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages