AppView in a box as a Vite plugin thing hatk.dev
at main 69 lines 1.7 kB view raw view rendered
1--- 2title: Scaffolding 3description: Generate code with the Hatk CLI. 4--- 5 6## Creating a project 7 8Create a new hatk project using the Vite+ template: 9 10```bash 11vp create github:hatk-dev/hatk-template-starter 12``` 13 14You'll be prompted for the target directory name. 15 16See the [Quickstart](/getting-started/quickstart) for prerequisites and setup. 17 18## `hatk generate` 19 20Generate lexicons, handlers, and other project files. 21 22### Lexicons 23 24```bash 25hatk generate record <nsid> # Record schema (e.g. fm.teal.alpha.feed.play) 26hatk generate query <nsid> # Query endpoint (GET) 27hatk generate procedure <nsid> # Procedure endpoint (POST) 28``` 29 30Creates a JSON lexicon file at `lexicons/<nsid-as-path>.json` with the appropriate schema template and automatically regenerates TypeScript types. 31 32### Handlers 33 34```bash 35hatk generate feed <name> # Feed generator in feeds/ 36hatk generate xrpc <nsid> # XRPC handler in xrpc/ 37hatk generate label <name> # Label definition in labels/ 38hatk generate og <name> # OpenGraph image route in og/ 39``` 40 41Each generator creates the handler file and a corresponding test file in the `test/` directory. 42 43### Types 44 45```bash 46hatk generate types 47``` 48 49Regenerate `hatk.generated.ts` from your current lexicon schemas. This runs automatically when generating new lexicons. 50 51## `hatk destroy` 52 53Remove a previously generated file and its test. 54 55```bash 56hatk destroy <type> <name> 57``` 58 59Where `<type>` is one of: `feed`, `xrpc`, `label`, `og`. 60 61## `hatk resolve` 62 63Fetch a lexicon schema from the AT Protocol network by its NSID. 64 65```bash 66hatk resolve <nsid> 67``` 68 69Downloads the lexicon JSON and any referenced definitions, saving them to your `lexicons/` directory.