Get started
Six steps from a repo with no Lattice in it to a build that comes back from cache the second time you run it. You need a terminal and the tools your workspaces already use.
Install it into your repo
From the root of the repo you want to use Lattice in:
The script picks the archive for your platform, checks its SHA-256 against the release's published checksums, and refuses to install on a mismatch. The binary lands in
.lattice/bin/, and the script adds that path to your.gitignoreif the repo already has one. The only thing it writes outside the repo is aPATHline in your shell config. To skip that line, pass--no-modify-pathand call./.lattice/bin/latticedirectly.That script covers macOS, Linux, and Windows under Git Bash. In PowerShell, run the Windows installer instead:
irm https://latticeandcompany.github.io/lattice/install.ps1 | iexIt writes the same
.lattice\binand adds that directory to your userPATH, asking first. Every published build is listed on thereleases page. SeeInstallation for the switches both installers take.Check that it runs
lattice --versionlattice 1.1.1If your shell can't find
lattice, open a new terminal so thePATHline takes effect.Scaffold a config
lattice initOn a terminal,
initscans the repo first, then asks you to confirm the workspaces and the pinned tool versions it found. If the scan finds nothing, it walks you through adding them one at a time. To write what the scan finds without being asked, add-y.✓ wrote lattice.json ✓ wrote .lattice/schema.json ✓ updated .gitignore next: lattice run buildlattice.jsonis your config. Commit.lattice/schema.jsontoo, so your editor validates that config as you type.initgitignores the rest:.lattice/cache/,.lattice/toolchains/, and.lattice/bin/are all per-machine.Declare your workspaces
A workspace is a directory with its own manifest. It is the unit Lattice runs and caches tasks in. List each one by literal path, and say which ones depend on which:
{ "$schema": ".lattice/schema.json", "latticeVersion": "1.1.1", "workspaces": [ { "name": "ui", "path": "packages/ui" }, { "name": "web", "path": "apps/web", "dependsOn": ["ui"] } ], "tasks": { "build": { "dependsOn": ["^build"], "inputs": ["src/**/*"], "outputs": ["dist/**"] } } }Each workspace runs the tool already in its directory, identified from that directory's lockfile or manifest.
^buildmeans thebuildtask of every workspace this one depends on, run first.inputsare the files the cache watches for changes, andoutputsare the files it captures and restores. To write a command yourself instead, set"auto": falseon the workspace and give it ascriptsmap.Install dependencies
lattice setup❖ lattice setup ● ui npm install ● web npm install ❖ setup completesetupinstalls any tool versions you pinned, then installs each workspace's own dependencies. Run it as often as you like. Lattice skips a workspace whose lockfile hasn't changed.Run a task
lattice run build -vlattice: running `build` across 2 workspaces lattice: ui:build: hash 6ab2b4b8a24730ea lattice: ui:build: cache miss (nothing cached for this task yet) ui:build: running ui:build: done (0.25s) lattice: web:build: hash e7006757504cd76c lattice: web:build: cache miss (nothing cached for this task yet) web:build: running web:build: done (0.20s) lattice: 2 tasks, 0 cached, 0 failed, 0.46suibuilds beforewebbecausewebdepends on it. Workspaces with no dependency between them run at the same time.-vis short for--verbose, and it prints this plain log. Without it, on a terminal, you get a live display instead.Run it again without changing a file:
lattice: running `build` across 2 workspaces lattice: ui:build: hash 6ab2b4b8a24730ea ui:build: cache hit [6ab2b4b8] lattice: web:build: hash e7006757504cd76c web:build: cache hit [e7006757] lattice: 2 tasks, 2 cached, 0 failed, 0.00s, 0.45s saved lattice: full power, nothing to runSame hashes, so nothing re-ran.
dist/came back out of.lattice/cache/. Edit a file undersrc/and that workspace's hash changes. That workspace builds again, and so does anything that depends on it. Everything else still comes from cache.