@pb-admin/cli
v1.0.2
Published
CLI to manage PocketBase collections, rules, and schema across multiple instances
Readme
@pb-admin/cli
CLI tool for managing PocketBase collections, schema, and access rules. Keep your PocketBase configuration in version control and sync changes across environments.
Why?
- Version control - Track schema and rules changes in git
- Environment sync - Push same config to dev, staging, prod
- Team collaboration - Review PocketBase changes in PRs
- CI/CD ready - Automate deployments with diff checks
Installation
# npm
npm install -g @pb-admin/cli
# or run directly
npx @pb-admin/cli initQuick Start
# 1. Initialize in your project
pb-admin init
# 2. Pull current schema and rules from PocketBase
pb-admin pull
# 3. Edit files locally
# pb-admin/schema.json - collection fields
# pb-admin/rules.json - access permissions
# 4. Preview changes
pb-admin diff
# 5. Apply to PocketBase
pb-admin pushCommands
| Command | Description |
|---------|-------------|
| pb-admin init | Setup project, login, and pull initial config |
| pb-admin login | Login to PocketBase instance |
| pb-admin logout | Clear saved credentials |
| pb-admin pull | Download schema & rules from PocketBase |
| pb-admin push | Upload local schema & rules to PocketBase |
| pb-admin diff | Compare local files vs live PocketBase |
| pb-admin col | List and inspect collections |
| pb-admin status | Check login status |
Options
| Flag | Description |
|------|-------------|
| --schema, -s | Only operate on schema |
| --rules, -r | Only operate on rules |
| --dry-run, -n | Preview changes without applying |
| --debug | Show detailed error information |
Project Files
After pb-admin init:
your-project/
pb-admin.json # Config (PocketBase URL)
pb-admin/
schema.json # Collection fields definition
rules.json # Access rules (list/view/create/update/delete)Example: Updating Rules
// pb-admin/rules.json
{
"posts": {
"listRule": "", // public
"viewRule": "", // public
"createRule": "@request.auth.id != ''", // authenticated users
"updateRule": "@request.auth.id = owner", // owner only
"deleteRule": null // admin only
}
}pb-admin diff # see what changed
pb-admin push # apply to PocketBaseCI/CD Integration
# GitHub Actions example
- name: Check PocketBase config
env:
PB_URL: ${{ secrets.PB_URL }}
PB_EMAIL: ${{ secrets.PB_EMAIL }}
PB_PASSWORD: ${{ secrets.PB_PASSWORD }}
run: |
npx @pb-admin/cli diff# Shell script
export PB_URL=https://your-pocketbase.com
export [email protected]
export PB_PASSWORD=your-password
pb-admin diff || exit 1 # fail if config differs
pb-admin push # or apply changesCredentials
Credentials are stored per-project in ~/.config/pb-admin/projects/. Each project directory gets its own credentials file based on the project path.
License
MIT
