persona-test-cli
v0.1.7
Published
运维 CLI for persona-test — admin 和已审核通过的普通用户都能用;设备码浏览器授权登录,管理分享链接(campaigns)和画像(personas),普通用户只能看到/编辑自己创建的。
Readme
persona-test-cli
Ops CLI for a persona-test deployment. By default it points at
https://persona.mixlab.top; pass --base-url <url> (or set PERSONA_TEST_CLI_URL) to point
it at a different deployment instead. Admin and approved regular users can both use it — a
regular user only ever sees/edits campaigns and personas they created themselves; admin sees
and can edit everything.
Install
npm install -g persona-test-cliGetting started
# New account: register, then wait for an admin to approve it at /admin/users
persona-test-cli register
# Log in — opens a browser to approve the CLI (device-code flow), no password typed into the terminal
persona-test-cli login
# See everything at once
persona-test-cli exampleslogin works for both admin (approve with the admin password login) and regular users (approve
with their email/password login) — whichever session is active in the browser when the
authorize page loads decides the scope of the issued token.
Commands
| Command | Who | What |
|---|---|---|
| register | anyone | Self-register (pending admin approval) |
| login | anyone | Device-code browser login |
| logout | anyone | Clear the stored token |
| whoami | anyone | Show current identity + available commands |
| campaigns list/create/edit/link/stats | anyone | Share links — scoped to your own unless admin |
| campaigns create/edit --image <path> | anyone | Set the entry image from a local file — auto-resized/compressed to match the web dashboard's pipeline |
| personas list/create/edit | anyone | Ad-copy personas — scoped to your own unless admin |
| events tail | anyone | Poll new impression/click events (starts from now; --since <iso> to replay history first) |
| users list/approve/reject | admin only | Registration approval queue |
Run any command with --help for its full options and copy-pasteable examples.
Scripting / agent use
--json(orPERSONA_TEST_CLI_JSON=1): every command prints machine-readable JSON instead of a table — success to stdout,{"error": ..., "usage": ...}to stderr on failure.- Exit codes:
0ok ·1unclassified ·2not logged in / invalid token ·3bad arguments ·4not found ·5forbidden (not yours). PERSONA_TEST_CLI_TOKEN=<token>: skip login entirely — set once by a human via the normal device-code flow, then exported into an automated environment.register --email <e> --password <p>: non-interactive registration (fails fast instead of hanging on a prompt when stdin isn't a TTY).login --no-open: print the authorize URL instead of trying to launch a browser (headless/ sandboxed environments).- Update notice: once a day, checks npm for a newer version and prints a one-line reminder to
stderr if you're behind. Skipped automatically under
--json, in CI (CIenv set), or withNO_UPDATE_NOTIFIER=1.
License
MIT
