@poli-page/cli 0.1.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +495 -39
- package/dist/api-client.d.ts +162 -3
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +302 -28
- package/dist/api-client.js.map +1 -1
- package/dist/auth.d.ts +11 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +27 -0
- package/dist/auth.js.map +1 -0
- package/dist/cloud-context.d.ts +18 -0
- package/dist/cloud-context.d.ts.map +1 -0
- package/dist/cloud-context.js +51 -0
- package/dist/cloud-context.js.map +1 -0
- package/dist/commands/auth.d.ts +19 -15
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +68 -46
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/checkout.d.ts +13 -0
- package/dist/commands/checkout.d.ts.map +1 -0
- package/dist/commands/checkout.js +93 -0
- package/dist/commands/checkout.js.map +1 -0
- package/dist/commands/documents/delete.d.ts +14 -0
- package/dist/commands/documents/delete.d.ts.map +1 -0
- package/dist/commands/documents/delete.js +61 -0
- package/dist/commands/documents/delete.js.map +1 -0
- package/dist/commands/documents/get.d.ts +10 -0
- package/dist/commands/documents/get.d.ts.map +1 -0
- package/dist/commands/documents/get.js +81 -0
- package/dist/commands/documents/get.js.map +1 -0
- package/dist/commands/documents/index.d.ts +3 -0
- package/dist/commands/documents/index.d.ts.map +1 -0
- package/dist/commands/documents/index.js +14 -0
- package/dist/commands/documents/index.js.map +1 -0
- package/dist/commands/documents/preview.d.ts +19 -0
- package/dist/commands/documents/preview.d.ts.map +1 -0
- package/dist/commands/documents/preview.js +73 -0
- package/dist/commands/documents/preview.js.map +1 -0
- package/dist/commands/documents/thumbnails.d.ts +22 -0
- package/dist/commands/documents/thumbnails.d.ts.map +1 -0
- package/dist/commands/documents/thumbnails.js +108 -0
- package/dist/commands/documents/thumbnails.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +38 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link.d.ts.map +1 -1
- package/dist/commands/link.js +33 -33
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/new.d.ts +7 -2
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +47 -77
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/push.d.ts +14 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +73 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/render.d.ts +18 -0
- package/dist/commands/render.d.ts.map +1 -0
- package/dist/commands/render.js +83 -0
- package/dist/commands/render.js.map +1 -0
- package/dist/commands/thumbnail.d.ts +2 -22
- package/dist/commands/thumbnail.d.ts.map +1 -1
- package/dist/commands/thumbnail.js +39 -98
- package/dist/commands/thumbnail.js.map +1 -1
- package/dist/commands/version-state.d.ts +35 -0
- package/dist/commands/version-state.d.ts.map +1 -0
- package/dist/commands/version-state.js +153 -0
- package/dist/commands/version-state.js.map +1 -0
- package/dist/commands/versions.d.ts +1 -0
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js +26 -29
- package/dist/commands/versions.js.map +1 -1
- package/dist/commands/watch.d.ts +26 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +177 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/exit-codes.d.ts +32 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +77 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/file-watcher.d.ts +17 -0
- package/dist/file-watcher.d.ts.map +1 -0
- package/dist/file-watcher.js +74 -0
- package/dist/file-watcher.js.map +1 -0
- package/dist/format-resolver.d.ts.map +1 -1
- package/dist/format-resolver.js +4 -0
- package/dist/format-resolver.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/manifest.d.ts +3 -30
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +4 -1
- package/dist/manifest.js.map +1 -1
- package/dist/manifest.schema.d.ts +44 -0
- package/dist/manifest.schema.d.ts.map +1 -0
- package/dist/manifest.schema.js +88 -0
- package/dist/manifest.schema.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +11 -3
- package/dist/program.js.map +1 -1
- package/dist/sync-engine.d.ts +16 -0
- package/dist/sync-engine.d.ts.map +1 -0
- package/dist/sync-engine.js +65 -0
- package/dist/sync-engine.js.map +1 -0
- package/dist/template-importer.d.ts +69 -0
- package/dist/template-importer.d.ts.map +1 -0
- package/dist/template-importer.js +206 -0
- package/dist/template-importer.js.map +1 -0
- package/package.json +63 -63
- package/templates/blank/blank.html +0 -6
- package/templates/blank/blank.json +0 -6
- package/templates/header-main-footer/header-main-footer.html +0 -16
- package/templates/header-main-footer/header-main-footer.json +0 -6
- package/templates/header-main-footer-sidebar/header-main-footer-sidebar.html +0 -23
- package/templates/header-main-footer-sidebar/header-main-footer-sidebar.json +0 -6
- package/templates/header-main-sidebar-footer/header-main-sidebar-footer.html +0 -23
- package/templates/header-main-sidebar-footer/header-main-sidebar-footer.json +0 -6
- package/templates/header-sidebar-main-footer/header-sidebar-main-footer.html +0 -23
- package/templates/header-sidebar-main-footer/header-sidebar-main-footer.json +0 -6
- package/templates/sidebar-header-main-footer/sidebar-header-main-footer.html +0 -23
- package/templates/sidebar-header-main-footer/sidebar-header-main-footer.json +0 -6
package/README.md
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
# Poli Page CLI
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@poli-page/cli)
|
|
4
|
+
[](https://github.com/poli-page/cli/actions/workflows/ci.yml)
|
|
4
5
|
[](LICENSE)
|
|
5
6
|
|
|
6
|
-
Command-line tool for [Poli Page](https://poli.page) — scaffold projects,
|
|
7
|
+
Command-line tool for [Poli Page](https://poli.page) — scaffold projects, manage cloud-hosted templates, render PDFs, and operate document storage from your terminal or your CI pipeline.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Table of contents
|
|
12
|
+
|
|
13
|
+
- [Install](#install)
|
|
14
|
+
- [Quickstart](#quickstart)
|
|
15
|
+
- [Authentication](#authentication)
|
|
16
|
+
- [Commands](#commands)
|
|
17
|
+
- [Project lifecycle](#project-lifecycle)
|
|
18
|
+
- [Authentication commands](#authentication-commands)
|
|
19
|
+
- [Cloud sync](#cloud-sync)
|
|
20
|
+
- [Versioning](#versioning)
|
|
21
|
+
- [Render](#render)
|
|
22
|
+
- [Documents](#documents)
|
|
23
|
+
- [Manifest format](#manifest-format)
|
|
24
|
+
- [Configuration](#configuration)
|
|
25
|
+
- [Exit codes](#exit-codes)
|
|
26
|
+
- [CI / CD](#ci--cd)
|
|
27
|
+
- [Troubleshooting](#troubleshooting)
|
|
28
|
+
|
|
29
|
+
---
|
|
7
30
|
|
|
8
31
|
## Install
|
|
9
32
|
|
|
@@ -11,72 +34,505 @@ Command-line tool for [Poli Page](https://poli.page) — scaffold projects, crea
|
|
|
11
34
|
npm install -g @poli-page/cli
|
|
12
35
|
# or
|
|
13
36
|
pnpm add -g @poli-page/cli
|
|
37
|
+
# or
|
|
38
|
+
bun add -g @poli-page/cli
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Requirements**: Node.js 22.13 or later.
|
|
42
|
+
|
|
43
|
+
Verify the install:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
poli --version
|
|
47
|
+
poli --help
|
|
14
48
|
```
|
|
15
49
|
|
|
16
|
-
|
|
50
|
+
---
|
|
17
51
|
|
|
18
|
-
##
|
|
52
|
+
## Quickstart
|
|
19
53
|
|
|
20
54
|
```bash
|
|
21
|
-
# Authenticate (opens browser for device flow)
|
|
55
|
+
# 1. Authenticate (opens your browser for the device flow)
|
|
22
56
|
poli login
|
|
23
57
|
|
|
24
|
-
# Scaffold a new project
|
|
58
|
+
# 2. Scaffold a new project
|
|
25
59
|
poli init my-invoices
|
|
26
60
|
cd my-invoices
|
|
27
61
|
|
|
28
|
-
#
|
|
29
|
-
poli new invoice --
|
|
62
|
+
# 3. Add a template from the Poli Page starter collection
|
|
63
|
+
poli new invoice --from-template showcase/invoice
|
|
30
64
|
|
|
31
|
-
# Link the project to your
|
|
65
|
+
# 4. Link the project to your organization (writes the cloud manifest)
|
|
32
66
|
poli link
|
|
33
67
|
|
|
34
|
-
# Render a PDF
|
|
68
|
+
# 5. Render a PDF using the local template against the cloud engine
|
|
69
|
+
poli render invoice -o invoice.pdf
|
|
70
|
+
|
|
71
|
+
# 6. Push your work as a SANDBOX version
|
|
72
|
+
poli push --message "Initial draft"
|
|
73
|
+
|
|
74
|
+
# 7. Promote to LIVE when ready
|
|
75
|
+
poli versions list
|
|
76
|
+
poli promote 1.0.0
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
To iterate on a template with live feedback against the cloud:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
poli watch
|
|
83
|
+
# edit your template files; each save syncs to the cloud draft within 2 seconds
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Authentication
|
|
89
|
+
|
|
90
|
+
The CLI supports two authentication modes. Both flow through the same internal resolver.
|
|
91
|
+
|
|
92
|
+
### Interactive (developers)
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
poli login # device authorization flow — opens your browser
|
|
96
|
+
poli whoami # show the current session and active org
|
|
97
|
+
poli logout # clear ~/.polipage/credentials.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
After `poli login`, the session token is stored at `~/.polipage/credentials.json` and used automatically by every subsequent command.
|
|
101
|
+
|
|
102
|
+
### Programmatic (CI / CD / scripts)
|
|
103
|
+
|
|
104
|
+
Set the `POLI_PAGE_API_KEY` environment variable. The value must start with `pp_`:
|
|
105
|
+
|
|
106
|
+
| Prefix | Use case |
|
|
107
|
+
| ----------- | ----------------------------------------------------------------- |
|
|
108
|
+
| `pp_test_*` | Sandbox renders (unmetered, no quota) |
|
|
109
|
+
| `pp_live_*` | Live renders (counts in the monthly quota, billable) |
|
|
110
|
+
| `pp_sa_*` | Service account — recommended for CI; rotates without breaking dev|
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
export POLI_PAGE_API_KEY=pp_sa_live_xxx
|
|
35
114
|
poli render invoice -o invoice.pdf
|
|
115
|
+
poli push --message "Release v1.0.5"
|
|
36
116
|
```
|
|
37
117
|
|
|
118
|
+
### Precedence
|
|
119
|
+
|
|
120
|
+
When **both** `~/.polipage/credentials.json` (a session) and `POLI_PAGE_API_KEY` are set, **the session wins**. `poli login` does not refuse if the env var is set — it shows an info-message and proceeds, after which the new session takes precedence.
|
|
121
|
+
|
|
122
|
+
This means a developer can keep `POLI_PAGE_API_KEY` set in `.zshrc` for occasional CI-style commands without it interfering with their interactive workflow.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
38
126
|
## Commands
|
|
39
127
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
128
|
+
24 commands grouped by category.
|
|
129
|
+
|
|
130
|
+
### Project lifecycle
|
|
131
|
+
|
|
132
|
+
#### `poli init <name>`
|
|
133
|
+
|
|
134
|
+
Scaffold a new Poli Page project. Creates the directory, the `poli-page.json` manifest, `templates/`, `partials/`, `assets/{fonts,images}/`, `tailwind.css`, and `.gitignore`.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
poli init my-invoices
|
|
138
|
+
poli init . --with-template showcase/invoice # init in cwd + import a starter
|
|
139
|
+
poli init my-app --with-template showcase/quote --template-name custom-quote
|
|
140
|
+
poli init my-app --source github:my-org/my-templates --with-template internal/cover
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Flags:
|
|
144
|
+
|
|
145
|
+
- `--with-template <ref>` — pre-install a starter template, format `<collection>/<template>`
|
|
146
|
+
- `--template-name <name>` — override the imported template's destination name
|
|
147
|
+
- `--source <repo>` — source repo, format `github:<owner>/<repo>` (default: `github:poli-page/templates`)
|
|
148
|
+
- `--no-cache` — bypass the 24-hour template cache
|
|
149
|
+
|
|
150
|
+
#### `poli new <name>`
|
|
151
|
+
|
|
152
|
+
Create a new template inside an existing project from a remote starter.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
poli new invoice --from-template showcase/invoice
|
|
156
|
+
poli new quote --from-template structures/blank
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Flags:
|
|
160
|
+
|
|
161
|
+
- `--from-template <ref>` (required) — collection/template
|
|
162
|
+
- `--source <repo>` — override the source
|
|
163
|
+
- `--no-cache` — bypass cache
|
|
164
|
+
|
|
165
|
+
### Authentication commands
|
|
166
|
+
|
|
167
|
+
#### `poli login`
|
|
168
|
+
|
|
169
|
+
Opens your browser for the device authorization flow and stores the session token at `~/.polipage/credentials.json`.
|
|
170
|
+
|
|
171
|
+
#### `poli logout`
|
|
172
|
+
|
|
173
|
+
Clears the local credentials file.
|
|
174
|
+
|
|
175
|
+
#### `poli whoami`
|
|
176
|
+
|
|
177
|
+
Displays the active identity and organization. Calls `GET /v1/me` over hybrid auth (session or API key).
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
$ poli whoami
|
|
181
|
+
xavier@example.com @ acme (session)
|
|
182
|
+
|
|
183
|
+
$ POLI_PAGE_API_KEY=pp_live_xxx poli whoami
|
|
184
|
+
pp_live_xxx…abcd @ acme (api-key, environment=live)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Flag: `--json` to dump the raw `/v1/me` payload.
|
|
188
|
+
|
|
189
|
+
### Cloud sync
|
|
190
|
+
|
|
191
|
+
#### `poli link`
|
|
192
|
+
|
|
193
|
+
Interactively select an organization, create the cloud project, and write the `cloud:` section into `poli-page.json` with the four fields the API needs (`orgSlug`, `orgId`, `projectSlug`, `projectId`). No API key is stored in the manifest — the file is safe to commit.
|
|
194
|
+
|
|
195
|
+
#### `poli unlink`
|
|
196
|
+
|
|
197
|
+
Removes the `cloud:` section from `poli-page.json`. Local files are preserved.
|
|
198
|
+
|
|
199
|
+
#### `poli watch`
|
|
200
|
+
|
|
201
|
+
Auto-syncs the local project to the cloud draft on every save. Debounce 2s. Each batch sends only the SHA-256 delta via `PATCH /api/organizations/:orgId/projects/:projectId/files`.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
poli watch
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Resilience built in:
|
|
208
|
+
|
|
209
|
+
- Network errors → exponential backoff (1s, 2s, 4s, 8s, 16s, 30s capped, reset on success)
|
|
210
|
+
- `503 ORGANIZATION_MIGRATING` → 5-second retry
|
|
211
|
+
- `403 SYSTEM_PROJECT_LOCKED` (the `getting-started` system project) → friendly error + exit
|
|
212
|
+
- Other API errors → logged, watch continues, next save retries
|
|
213
|
+
|
|
214
|
+
Requires a TTY. Refused with exit `2` when run in a non-interactive context.
|
|
215
|
+
|
|
216
|
+
#### `poli checkout <version>`
|
|
217
|
+
|
|
218
|
+
Restore a specific published version locally. **Destructive** — overwrites any local file with the same path. Always commit your work before running.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
poli checkout 1.0.5 # exact semver only
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
`latest` and partial semver (`1.0`, `1`) are rejected with a friendly hint.
|
|
225
|
+
|
|
226
|
+
### Versioning
|
|
227
|
+
|
|
228
|
+
#### `poli push`
|
|
229
|
+
|
|
230
|
+
Sync the current local draft and create a new SANDBOX version.
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
poli push --message "Tweaked invoice header"
|
|
234
|
+
poli push --major --message "BREAKING: new schema"
|
|
235
|
+
poli push --minor
|
|
236
|
+
poli push --patch # default
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### `poli versions list` (alias `ls`)
|
|
240
|
+
|
|
241
|
+
Display all versions of the linked project with their state badges.
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
STATE VERSION PUSHED MESSAGE
|
|
245
|
+
LIVE 2.0.0 3 days ago Major redesign
|
|
246
|
+
LIVE 1.0.5 1 week ago Hotfix URSSAF
|
|
247
|
+
SANDBOX 1.1.0 2 hours ago
|
|
248
|
+
DEPRECATED 1.0.2 3 weeks ago
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
#### `poli promote <version>`
|
|
252
|
+
|
|
253
|
+
Move a SANDBOX version to LIVE. Confirmation prompt unless `--yes`.
|
|
254
|
+
|
|
255
|
+
#### `poli unpromote <version>`
|
|
256
|
+
|
|
257
|
+
Move a LIVE version back to SANDBOX. Shows a usage preview (calls in the last 24h, the next-latest LIVE) before confirming.
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
poli unpromote 1.0.5
|
|
261
|
+
poli unpromote 1.0.5 --force # allow unpromoting the last LIVE version
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### `poli versions deprecate <version>`
|
|
265
|
+
|
|
266
|
+
Mark a SANDBOX version as DEPRECATED.
|
|
267
|
+
|
|
268
|
+
#### `poli versions un-deprecate <version>`
|
|
269
|
+
|
|
270
|
+
Move a DEPRECATED version back to SANDBOX.
|
|
271
|
+
|
|
272
|
+
#### `poli versions download <version> [-o <dir>]`
|
|
273
|
+
|
|
274
|
+
Download a published version's content to a local directory (read-only inspection or hotfix base).
|
|
275
|
+
|
|
276
|
+
### Render
|
|
277
|
+
|
|
278
|
+
#### `poli render <name>`
|
|
279
|
+
|
|
280
|
+
Generate a PDF from a local template against the cloud engine.
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
poli render invoice # default: draft
|
|
284
|
+
poli render invoice --version 1.0.5 # exact semver pin
|
|
285
|
+
poli render invoice --version draft --data ./mock.json # custom data
|
|
286
|
+
poli render invoice -o ./out/invoice.pdf
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Flags:
|
|
290
|
+
|
|
291
|
+
- `--version <draft|X.Y.Z>` — exact semver only (`latest` is rejected)
|
|
292
|
+
- `--data <file>` — JSON data overrides the template's mock
|
|
293
|
+
- `-o <file>` — output path
|
|
294
|
+
|
|
295
|
+
The CLI surfaces the resolved environment in the success line:
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
✓ Rendered invoice v1.0.5 (live, billed)
|
|
299
|
+
✓ Rendered invoice (draft, sandbox)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Documents
|
|
303
|
+
|
|
304
|
+
Documents are the cloud-stored output of `render document` calls (made via the SDK or directly via the API). The CLI lets you inspect, delete, and re-derive thumbnails or preview HTML from them.
|
|
305
|
+
|
|
306
|
+
There is intentionally **no `poli documents list`** — your application is responsible for tracking the `documentId` values it cares about.
|
|
307
|
+
|
|
308
|
+
#### `poli documents get <id>`
|
|
309
|
+
|
|
310
|
+
Returns a JSON descriptor with metadata + a 15-minute presigned PDF URL. The CLI does not download the PDF — `curl` the URL or hand it to the browser yourself.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
poli documents get doc_abc123
|
|
314
|
+
poli documents get doc_abc123 --json
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
#### `poli documents delete <id>`
|
|
318
|
+
|
|
319
|
+
Soft-deletes a document. Idempotent: returns success if already deleted. Confirmation unless `--yes`.
|
|
320
|
+
|
|
321
|
+
#### `poli documents thumbnails <id>`
|
|
322
|
+
|
|
323
|
+
Regenerate page thumbnails from the document's stored canonical HTML. Counts as one billable render in the monthly quota when the auth env is `live`. Free tier returns `403 THUMBNAILS_NOT_AVAILABLE`.
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
poli documents thumbnails doc_abc123 --width 400
|
|
327
|
+
poli documents thumbnails doc_abc123 --pages 1,3 --format jpeg --quality 85
|
|
328
|
+
poli documents thumbnails doc_abc123 -o ./out
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Flags: `-w/--width`, `-f/--format png|jpeg`, `-q/--quality`, `--pages 1,3`, `-o/--output`, `--json`.
|
|
332
|
+
|
|
333
|
+
#### `poli documents preview <id>`
|
|
334
|
+
|
|
335
|
+
Fetch the stored canonical HTML re-wrapped as preview-mode (free, no quota cost). Default writes the file at `./output/documents/<id>.preview.html` and opens the browser.
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
poli documents preview doc_abc123
|
|
339
|
+
poli documents preview doc_abc123 --no-open
|
|
340
|
+
poli documents preview doc_abc123 -o ./preview.html
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
#### `poli thumbnail <documentId>` (alias)
|
|
344
|
+
|
|
345
|
+
Light alias for `poli documents thumbnails`. Accepts the same flags.
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
poli thumbnail doc_abc123 --width 200 --format png
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Without arguments, prints a friendly hint pointing at `poli render document` to produce a `documentId` first.
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Manifest format
|
|
356
|
+
|
|
357
|
+
`poli-page.json` is the per-project manifest. Committed to git (no secrets).
|
|
358
|
+
|
|
359
|
+
```jsonc
|
|
360
|
+
{
|
|
361
|
+
"project": {
|
|
362
|
+
"name": "my-invoices",
|
|
363
|
+
"version": "1.0.0"
|
|
364
|
+
},
|
|
365
|
+
"fonts": [
|
|
366
|
+
{
|
|
367
|
+
"family": "Inter",
|
|
368
|
+
"src": "assets/fonts/Inter.woff2",
|
|
369
|
+
"weight": 400
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
"templates": [
|
|
373
|
+
{
|
|
374
|
+
"name": "invoice",
|
|
375
|
+
"template": "templates/invoice/invoice.html",
|
|
376
|
+
"mock": "templates/invoice/invoice.json",
|
|
377
|
+
"format": "A4",
|
|
378
|
+
"orientation": "portrait"
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
"cloud": {
|
|
382
|
+
"orgSlug": "acme",
|
|
383
|
+
"orgId": "0e89d99e-1516-4b48-baa1-f49e660ad1c1",
|
|
384
|
+
"projectSlug": "invoices",
|
|
385
|
+
"projectId": "8274f64d-4ea2-4f96-b596-5727a7b17268"
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
The `cloud:` block is written by `poli link`, removed by `poli unlink`. **No API keys here** — the credentials file (or `POLI_PAGE_API_KEY`) carries the secret.
|
|
391
|
+
|
|
392
|
+
---
|
|
56
393
|
|
|
57
394
|
## Configuration
|
|
58
395
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
|
396
|
+
### Environment variables
|
|
397
|
+
|
|
398
|
+
| Variable | Effect |
|
|
399
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
400
|
+
| `POLI_PAGE_API_KEY` | Single env var for any API key in CI/CD. Accepts `pp_test_*`, `pp_live_*`, or `pp_sa_*`. Must start with `pp_`. **Precedence**: when a credentials file is also present, the session wins. |
|
|
401
|
+
| `POLI_API_URL` | Override the API base URL (precedence: `--api-url` flag → `POLI_API_URL` → `poli-page.json` `cloud.apiUrl` → `~/.polipage/credentials.json` `apiUrl` → default `https://api.poli.page`). |
|
|
402
|
+
| `POLI_PAGE_ENV` | Default render env (`sandbox` or `live`) when commands accept an env hint. |
|
|
403
|
+
| `NO_COLOR` | Disable ANSI colors (Unix standard). |
|
|
404
|
+
| `CI` | Auto-detected; equivalent to a global `--yes`. |
|
|
405
|
+
|
|
406
|
+
### Common flags
|
|
407
|
+
|
|
408
|
+
- `--api-url <url>` — override the API base URL for one invocation
|
|
409
|
+
- `--json` — structured JSON output (where supported)
|
|
410
|
+
- `-y` / `--yes` — skip confirmation prompts
|
|
411
|
+
- `-h` / `--help` — show help for any command or sub-command
|
|
412
|
+
- `-v` / `--version` — print the CLI version and exit
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Exit codes
|
|
417
|
+
|
|
418
|
+
| Code | Meaning |
|
|
419
|
+
| ---- | ------------------------------------------------------------------------------------------------------ |
|
|
420
|
+
| `0` | Success (or no-op, e.g. `promote` when nothing changes) |
|
|
421
|
+
| `1` | Recoverable inconsistency (already logged in, already linked, version already live) |
|
|
422
|
+
| `2` | Invalid usage (bad args, template not found, version not found, non-TTY context where TTY is required) |
|
|
423
|
+
| `3` | Network / API error (timeout, 5xx, unspecified 4xx) |
|
|
424
|
+
| `4` | Not authenticated — run `poli login` or set `POLI_PAGE_API_KEY` |
|
|
425
|
+
| `5` | Not authorized (insufficient role, `THUMBNAILS_NOT_AVAILABLE`, system project locked) |
|
|
426
|
+
| `6` | Invalid local state (no project, project not linked, empty folder where required) |
|
|
427
|
+
|
|
428
|
+
These map to the centralised `ExitCode` constants in `src/exit-codes.ts`. Every handler routes errors through `errorToExitCode(err)`.
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## CI / CD
|
|
433
|
+
|
|
434
|
+
### GitHub Actions
|
|
435
|
+
|
|
436
|
+
```yaml
|
|
437
|
+
# .github/workflows/render.yml
|
|
438
|
+
name: Render PDFs
|
|
439
|
+
|
|
440
|
+
on: workflow_dispatch
|
|
441
|
+
|
|
442
|
+
jobs:
|
|
443
|
+
render:
|
|
444
|
+
runs-on: ubuntu-latest
|
|
445
|
+
env:
|
|
446
|
+
POLI_PAGE_API_KEY: ${{ secrets.POLI_PAGE_API_KEY }}
|
|
447
|
+
steps:
|
|
448
|
+
- uses: actions/checkout@v4
|
|
449
|
+
- uses: actions/setup-node@v4
|
|
450
|
+
with:
|
|
451
|
+
node-version: '22'
|
|
452
|
+
- run: npm install -g @poli-page/cli
|
|
453
|
+
- run: poli render invoice -o ./artifacts/invoice.pdf --version 1.0.5
|
|
454
|
+
- uses: actions/upload-artifact@v4
|
|
455
|
+
with:
|
|
456
|
+
name: invoice-pdf
|
|
457
|
+
path: ./artifacts/invoice.pdf
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Recommended: use a **service account key** (`pp_sa_live_*`) so rotating it does not log out any developer.
|
|
461
|
+
|
|
462
|
+
### GitLab CI
|
|
63
463
|
|
|
64
|
-
|
|
464
|
+
```yaml
|
|
465
|
+
render:
|
|
466
|
+
image: node:22-alpine
|
|
467
|
+
variables:
|
|
468
|
+
POLI_PAGE_API_KEY: $POLI_PAGE_API_KEY
|
|
469
|
+
script:
|
|
470
|
+
- npm install -g @poli-page/cli
|
|
471
|
+
- poli render invoice -o invoice.pdf --version 1.0.5
|
|
472
|
+
artifacts:
|
|
473
|
+
paths:
|
|
474
|
+
- invoice.pdf
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### Vercel / Netlify build hook
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
# In a build script
|
|
481
|
+
npm install -g @poli-page/cli
|
|
482
|
+
POLI_PAGE_API_KEY=pp_sa_live_xxx poli render homepage-pdf -o ./public/welcome.pdf
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Service accounts have a **fixed role and environment** at creation. The CLI does not try to switch them — the API enforces the permissions.
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## Troubleshooting
|
|
490
|
+
|
|
491
|
+
### `Not logged in. Run \`poli login\` or set POLI_PAGE_API_KEY.`
|
|
492
|
+
|
|
493
|
+
Either run `poli login` interactively, or export `POLI_PAGE_API_KEY` for CI use. Exit code `4`.
|
|
494
|
+
|
|
495
|
+
### `POLI_PAGE_API_KEY must start with \`pp_\`...`
|
|
65
496
|
|
|
66
|
-
|
|
67
|
-
| --------------- | ------------------------ | -------------- |
|
|
68
|
-
| `POLI_API_URL` | `https://api.poli.page` | API base URL |
|
|
497
|
+
You set the variable but its value does not match the `pp_*` prefix. Rotate the key from the dashboard's API keys page. Exit code `4`.
|
|
69
498
|
|
|
70
|
-
|
|
499
|
+
### `This folder isn't linked to a cloud project. Run \`poli link\` first.`
|
|
71
500
|
|
|
72
|
-
|
|
501
|
+
You're in session mode and the local manifest has no `cloud:` block. Either run `poli link`, or switch to api-key mode with `POLI_PAGE_API_KEY=pp_*` (which carries the org context implicitly). Exit code `6`.
|
|
73
502
|
|
|
74
|
-
|
|
503
|
+
### `\`latest\` was retired. Run \`poli versions list\` and pin an exact semver...`
|
|
75
504
|
|
|
76
|
-
|
|
505
|
+
The CLI now requires an exact `X.Y.Z` semver when pinning a version. List the published versions with `poli versions list` and pick one. Exit code `2`.
|
|
77
506
|
|
|
78
|
-
|
|
507
|
+
### `403 THUMBNAILS_NOT_AVAILABLE`
|
|
508
|
+
|
|
509
|
+
Thumbnails (whether via `poli documents thumbnails` or `poli thumbnail`) are a paid-tier feature. Upgrade to Starter from the dashboard. Exit code `5`.
|
|
510
|
+
|
|
511
|
+
### `429 OVERAGE_CAP_EXCEEDED`
|
|
512
|
+
|
|
513
|
+
Your org has crossed the monthly cap on `live` PDF renders (counted across `render`, `render document`, and `documents thumbnails` calls). Wait until the next billing period or raise the cap from your dashboard. Exit code `3`.
|
|
514
|
+
|
|
515
|
+
### `503 ORGANIZATION_MIGRATING`
|
|
516
|
+
|
|
517
|
+
Your org is being migrated to a new tier. `poli watch` retries automatically after 5s. Other commands surface the error — retry by hand once the migration completes (typically under a minute).
|
|
518
|
+
|
|
519
|
+
### `poli watch` doesn't fire on save
|
|
520
|
+
|
|
521
|
+
Make sure you're not editing inside an ignored directory. Default ignores: `node_modules/`, `.git/`, `output/`, `dist/`, `*.log`, `.DS_Store`. The watcher uses `chokidar` v5; if your editor saves via "atomic write + rename" (some Vim setups), the rename event fires within the debounce window and triggers a sync.
|
|
522
|
+
|
|
523
|
+
### CI pipeline rejected with exit `5` on `poli promote`
|
|
524
|
+
|
|
525
|
+
Service-account `developer` keys cannot promote. Either use an `admin` SA, or run `poli promote` from a developer's interactive session. Service-account roles are fixed at creation.
|
|
526
|
+
|
|
527
|
+
---
|
|
79
528
|
|
|
80
529
|
## License
|
|
81
530
|
|
|
82
|
-
[
|
|
531
|
+
MIT — see [LICENSE](LICENSE).
|
|
532
|
+
|
|
533
|
+
## Links
|
|
534
|
+
|
|
535
|
+
- [Documentation](https://docs.poli.page)
|
|
536
|
+
- [Dashboard](https://app.poli.page)
|
|
537
|
+
- [Issue tracker](https://github.com/poli-page/cli/issues)
|
|
538
|
+
- [Changelog](CHANGELOG.md)
|