Skip to content

Usage Examples

Scenario 1: CLI workflow (developer)

bash
# Log in once (stored globally in ~/.config/packdog/config.json)
packdog login dev_<your-developer-token>
packdog whoami   # confirm it worked

# List the packages you have access to
packdog list
# → shooter-game    be027d3c-747d-4080-a854-d9f12aa32a2f

# Set up packdog.json
packdog init --id=be027d3c-747d-4080-a854-d9f12aa32a2f

# Build (project-specific)
npm run build

# Upload — auto-publishes to stage
packdog upload
# → Uploaded: abc-123-def (3 files, 45.2 KB)
# → Published to stage: abc-123-def

# Check versions and channels
packdog versions
packdog channels

# Publish to stable when ready
packdog publish

# Roll back if something goes wrong
packdog rollback --channel=stable

Scenario 2: CLI in a monorepo

bash
# Build sets the right packdog.json at the root
npm run build -- --pack=shooter

# Then use the standard CLI workflow
packdog upload
packdog publish

# Switch to another pack
npm run build -- --pack=quiz
packdog upload
packdog publish

Scenario 3: Stage → stable workflow

bash
# Upload auto-publishes to stage
packdog upload

# Test against the stage channel...

# When ready: promote to stable
packdog publish

Scenario 4: Client loads a package

javascript
const { index, baseUri } = await fetch(
  'https://api.packdog.dev/v1/packages/PACKAGE_ID/channels/stable',
  { headers: { 'Authorization': 'Bearer blk_yourcustomerkey' } }
).then(r => r.json());

// Load index.js (ES module / web component)
await import(index);

// Mount the component
const el = document.createElement('my-component');
el.baseUri = baseUri;  // the package uses this internally to load assets
document.body.appendChild(el);

Scenario 5: New version has a bug → rollback

bash
# Upload and publish a new version
packdog upload
packdog publish

# A critical bug — roll back immediately
packdog rollback --channel=stable
# → Rolled back to: <previous versionId>

# Fix the bug, rebuild, upload, publish
npm run build
packdog upload
packdog publish

Developer-side curl examples

These mirror what the CLI does — useful if you want to call the API directly from a CI script.

Upload a version

bash
curl -X POST https://api.packdog.dev/v1/packages/$PACKAGE_ID/upload \
  -H "Authorization: Bearer $DEVELOPER_TOKEN" \
  -F "index.js=@dist/index.js" \
  -F "assets/ship.png=@dist/assets/ship.png"
# → { "versionId": "uuid-1", ... }

Publish a version to a channel

bash
curl -X POST https://api.packdog.dev/v1/packages/$PACKAGE_ID/channels/stable \
  -H "Authorization: Bearer $DEVELOPER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"versionId": "uuid-1"}'

Requires can_publish permission on the developer token.

Roll back the current channel

bash
curl -X POST https://api.packdog.dev/v1/packages/$PACKAGE_ID/channels/stable/rollback \
  -H "Authorization: Bearer $DEVELOPER_TOKEN"

Returns 409 Conflict if another publish raced you — retry once.

Packdog runs on Cloudflare Workers, D1, and R2.