this repo has no description
at design-docs 235 lines 5.5 kB view raw view rendered
1# @sitebase/cli 2 3The sitebase CLI is a tool for managing your standard.site data from the command line. 4 5## Installation 6 7```bash 8# From the monorepo 9bun install 10bun run --filter @sitebase/cli build 11 12# Link globally (optional) 13bun link 14``` 15 16## Setting the target publication 17 18All commands except `auth *` and `pub list` require a target publication. 19 20The target is determined from these sources, in order of precedence: 21 221. `--pub-id <rkey>` argument passed to the command 232. `.sitebase.json` file in the current directory with a `publicationId` property 243. `SITEBASE_PUB_ID` environment variable 25 26The value is the **rkey** of the publication record (the last segment of the AT URI). 27 28## Commands 29 30### Auth 31 32#### `auth login <handle>` 33 34Logs in to an ATProto account via OAuth. 35 36- Launches a temporary local HTTP server to handle the OAuth callback 37- Opens your browser to the authorization page 38- Requests the [standard.site auth bundle](https://pdsls.dev/at://did:plc:re3ebnp5v7ffagz6rb6xfei4/com.atproto.lexicon.schema/site.standard.authFull) 39- Stores session data in `$HOME/.sitebase/session.json` 40 41```bash 42sitebase auth login <atproto-handle> 43``` 44 45#### `auth logout` 46 47Clears the stored session data. 48 49```bash 50sitebase auth logout 51``` 52 53### Publication 54 55#### `pub list` 56 57Lists all publications in the authenticated account's PDS. 58 59Does not require a target publication. 60 61```bash 62sitebase pub list 63``` 64 65#### `pub set` 66 67Interactively select a publication from your account to set as the target. 68 69Writes the selection to `.sitebase.json` in the current directory. 70 71```bash 72sitebase pub set 73``` 74 75#### `pub view` 76 77Displays information about the target publication (name, URL, description, AT URI). 78 79```bash 80sitebase pub view # reads from SITEBASE_PUB_ID or .sitebase.json 81sitebase pub view --pub-id my-blog 82``` 83 84#### `pub edit` 85 86Opens the publication metadata in `$EDITOR` for editing. 87 88The publication data is presented as YAML. Save and close the editor to write changes back to the PDS. 89 90```bash 91sitebase pub edit 92``` 93 94#### `pub export` 95 96Exports all documents from the target publication to local files. 97 98Uses a `sitebase.config.ts` configuration file. See [export.md](./export.md) for config format. 99 100```bash 101# Auto-discover sitebase.config.ts in current directory 102sitebase pub export 103 104# Specify config file 105sitebase pub export --config ./my-config.ts 106``` 107 108**Options:** 109 110| Option | Description | 111|--------|-------------| 112| `-c, --config <file>` | Path to config file (auto-discovers `sitebase.config.ts` if not specified) | 113| `--init` | Create a starter `sitebase.config.ts` and `templates/post.hbs` in the current directory | 114 115```bash 116# Initialize export config 117sitebase pub export --init 118``` 119 120### Documents 121 122#### `doc list` 123 124Lists all documents in the target publication. 125 126```bash 127sitebase doc list 128sitebase doc list --tag post # Filter by tag 129sitebase doc list --tag draft # Show drafts 130``` 131 132#### `doc view <rkey>` 133 134Displays a document's metadata and content preview. 135 136```bash 137sitebase doc view abc123 138``` 139 140#### `doc edit <rkey>` 141 142Opens a document in `$EDITOR` for editing. 143 144The document is presented as a markdown file with YAML frontmatter (metadata in frontmatter, content in body). Save and close the editor to write changes back to the PDS. 145 146**Content type restriction:** Only documents with `pub.sitebase.content.*` types can be edited. Documents with other content types (e.g., pckt.blog blocks) will show an error. Use `doc view` to inspect these documents instead. 147 148```bash 149sitebase doc edit abc123 150``` 151 152#### `doc import <file>` 153 154Creates a new document in the target publication from a local file. 155 156The file should be markdown with YAML frontmatter containing at least a `title` field. 157 158```bash 159sitebase doc import ./my-post.md 160sitebase doc import ./my-post.md --tag post --tag featured 161``` 162 163#### `doc export <rkey>` 164 165Exports a single document to a local file or stdout. 166 167Unlike `pub export`, this command does NOT use the config file. Instead, options are provided via command line arguments. 168 169```bash 170# Output raw markdown to stdout 171sitebase doc export abc123 172 173# Output to file (filename supports handlebars) 174sitebase doc export abc123 -o "{{publishedAt}}_{{slug title}}.md" 175 176# With content template 177sitebase doc export abc123 -t ./templates/post.hbs -o ./content/my-post.md 178``` 179 180**Options:** 181 182| Option | Description | 183|--------|-------------| 184| `-o, --output <file>` | Output filename (supports handlebars: `{{title}}`, `{{slug title}}`, `{{publishedAt}}`, etc.) | 185| `-t, --template <file>` | Handlebars template file for content | 186| `--stdout` | Output to stdout (default if no `-o`) | 187 188### Drafts 189 190Drafts are stored in a separate `pub.sitebase.draft` collection, not as `site.standard.document` records. This keeps unpublished work separate from your public documents. 191 192See [lexicons.md](./lexicons.md) for the draft schema. 193 194#### `draft list` 195 196Lists all drafts for the target publication. 197 198```bash 199sitebase draft list 200``` 201 202#### `draft new` 203 204Creates a new draft and opens it in `$EDITOR`. 205 206```bash 207sitebase draft new 208``` 209 210#### `draft edit <rkey>` 211 212Opens a draft in `$EDITOR` for editing. 213 214```bash 215sitebase draft edit abc123 216``` 217 218#### `draft publish <rkey>` 219 220Publishes a draft as a `site.standard.document`. 221 222- Creates a new document record with `publishedAt` set to current time 223- Deletes the draft record 224 225```bash 226sitebase draft publish abc123 227``` 228 229#### `draft delete <rkey>` 230 231Deletes a draft without publishing. 232 233```bash 234sitebase draft delete abc123 235```