Skip to content

danecodes/roku-registry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@danecodes/roku-registry

CLI and library for managing Roku device registry state, built on @danecodes/roku-odc.

Define named registry configurations (presets) and activate them with one call — like database fixtures but for Roku app state.

Install

npm install @danecodes/roku-registry

Library Usage

import { RegistryManager } from '@danecodes/roku-registry';

const reg = new RegistryManager('192.168.0.30');

Read

const all = await reg.getAll();              // Record<string, Record<string, string>>
const section = await reg.getSection('auth'); // Record<string, string>
const value = await reg.get('auth', 'token'); // string | undefined

Snapshots

// Save current registry state
await reg.snapshot('./snapshots/logged-in.json');

// Restore from a snapshot (clears existing, then sets)
await reg.restore('./snapshots/logged-in.json');

Snapshot format is plain JSON:

{
  "auth": { "token": "abc123", "refreshToken": "xyz" },
  "settings": { "parentalControls": "true", "maxRating": "PG-13" },
  "onboarding": { "completed": "true" }
}

Diff

// Compare current device state to a snapshot
const diff = await reg.diff('./snapshots/expected.json');

// Compare two snapshots
const diff = await reg.diffSnapshots('./before.json', './after.json');

// Pretty-print
console.log(reg.formatDiff(diff));
// + auth.newKey = "value"
// - settings.removedKey = "old"
// ~ onboarding.step = "3" → "5"

Presets

const reg = new RegistryManager('192.168.0.30', {
  presets: {
    'fresh-install': {},
    'logged-in': {
      auth: { token: 'test-token-123', userId: 'user_abc' },
      onboarding: { completed: 'true' },
    },
    'premium-subscriber': {
      auth: { token: 'test-token-123', userId: 'user_abc' },
      subscription: { tier: 'premium', expires: '2099-01-01' },
      onboarding: { completed: 'true' },
    },
  },
});

// Activate a preset (clears registry first)
await reg.activate('logged-in');

// Activate with overrides (deep-merged into the preset)
await reg.activate('logged-in', {
  auth: { token: 'different-token' },
});

// List available presets
const names = await reg.listPresets(); // string[]

// Get preset data without activating
const data = await reg.getPreset('premium-subscriber');

CLI

Read

roku-registry get                           # full registry as JSON
roku-registry get auth                      # one section
roku-registry get auth.token                # one value

Write

roku-registry set auth.token abc123         # set a single key
roku-registry set auth '{"token":"abc","userId":"u1"}'  # set entire section

Clear

roku-registry clear                         # clear all sections
roku-registry clear auth                    # clear one section
roku-registry clear auth settings           # clear multiple sections

Snapshots

roku-registry snapshot ./state.json         # save current state
roku-registry restore ./state.json          # restore from file

Diff

roku-registry diff ./expected.json          # compare device to file
roku-registry diff ./before.json ./after.json  # compare two files

Presets

roku-registry presets                       # list available presets
roku-registry activate fresh-install        # activate a preset
roku-registry activate logged-in --override auth.token=xyz

Global Options

roku-registry --device 192.168.0.30         # specify device IP
roku-registry --config ./my-presets.json    # specify config file

Environment Variables

Variable Description
ROKU_DEVICE_IP Default device IP when --device is not specified

Preset Config File

Presets are loaded from the first source found:

  1. --config flag
  2. roku-registry.json in cwd
  3. .roku-registry.json in cwd
  4. roku-registry key in package.json
{
  "presets": {
    "fresh-install": {},
    "logged-in": {
      "auth": { "token": "test-token-123", "userId": "user_abc" },
      "onboarding": { "completed": "true" }
    }
  }
}

License

MIT

About

CLI and library for managing Roku device registry state

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages