Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions .eslintrc.js

This file was deleted.

30 changes: 14 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/[email protected]

- name: setup node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: cache node_modules
id: node-cache
uses: actions/cache@v2
- name: Setup node ${{ matrix.node-version }}
uses: actions/[email protected]
with:
path: node_modules
key: node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: install dependencies
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Install dependencies
run: pnpm install

- run: npm run test
- run: pnpm test

- run: npx codecov
- name: Codecov
uses: codecov/[email protected]
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

npx --no-install commitlint --edit $1
npx --no -- commitlint --edit $1
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"proseWrap": "always"
}
68 changes: 28 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Discover & control Roku devices from NodeJS.

**requirements:**

- node `10 or higher`
- node `18 or higher`
- a Roku device connected to your network
- a router/network that supports UPnP (for ssdp)

Expand All @@ -18,28 +18,19 @@ Discover & control Roku devices from NodeJS.
## Usage

```js
// es2015
import { RokuClient, Keys } from 'roku-client';
import { RokuClient, Keys } from 'roku-client'

// commonjs
const { RokuClient, Keys } = require('roku-client');
const client = await RokuClient.discover(/* timeout, defaults to 10 seconds */)
console.log(`roku device found at ${client.ip}`)

RokuClient.discover(/* timeout, defaults to 10 seconds */)
.then((client) => {
console.log(`roku device found at ${client.ip}`);
return client.apps();
})
.then((apps) => {
apps.forEach((app) => console.log(app));
// [{ id, name, type, version }, ...]
})
.catch((err) => {
console.error(err.stack);
});
const apps = await client.apps()

apps.forEach((app) => console.log(app))
// [{ id, name, type, version }, ...]

// Or, if the roku address is already known
const client = new RokuClient('http://192.168.1.17:8060');
client.keypress(Keys.VOLUME_UP);
const client = new RokuClient('http://192.168.1.17:8060')
client.keypress(Keys.VOLUME_UP)
```

## RokuClient.discover()
Expand All @@ -55,12 +46,12 @@ can be called which will wait the full timeout and return a promise that
resolves to an array of clients for all the addresses found.

```js
import { RokuClient } from 'roku-client';
import { RokuClient } from 'roku-client'

RokuClient.discoverAll().then((clients) => {
console.log(clients.map((c) => c.ip));
console.log(clients.map((c) => c.ip))
// ['http://192.168.1.17:8060', 'http://192.168.1.18:8060', ...]
});
})
```

## API Methods
Expand Down Expand Up @@ -90,10 +81,10 @@ RokuClient.discoverAll().then((clients) => {
accessed programmatically:

```js
import { Keys } from 'roku-client';
import { Keys } from 'roku-client'

Keys.HOME; // 'Home'
Keys.LEFT; // 'Left'
Keys.HOME // 'Home'
Keys.LEFT // 'Left'
```

### Commander
Expand Down Expand Up @@ -129,13 +120,13 @@ client
.then(/* commands succeeded */)
.catch((err) => {
/* commands failed */
});
})
```

##### Turn the volume up by 10

```js
client.command().volumeUp(10).send();
client.command().volumeUp(10).send()
```

##### Conditionally perform a command
Expand All @@ -146,7 +137,7 @@ client
.exec((cmd) => (goUp ? cmd.up(10) : cmd.down(10)))
.right()
.select()
.send();
.send()
```

##### Konami code
Expand All @@ -162,23 +153,23 @@ client
.right()
.text('ba')
.enter()
.send();
.send()
```

##### Wait before performing the next command

```js
client.command().enter().wait(1000).text('some text').send();
client.command().enter().wait(1000).text('some text').send()
```

##### Usage as a macro

```js
const volumeUp5 = client.command().volumeUp(5);
const volumeDown5 = client.command().volumeDown(5);
const volumeUp5 = client.command().volumeUp(5)
const volumeDown5 = client.command().volumeDown(5)

volumeUp5.send();
volumeUp5.send();
volumeUp5.send()
volumeUp5.send()
```

## Usage in the Browser
Expand All @@ -191,15 +182,14 @@ mechanism is out of the question. I was able to stub that part out with a
"browsers" field in package.json. The final nail in the coffin is that roku
devices don't set CORS headers, so even after getting the library to run,
browsers block the requests. At this point I've decided there isn't any point in
making this library isomorphic. In the future I might replace [fetch-ponyfill]
with something more light weight.
making this library isomorphic.

If you have a good reason for this library to work in browsers, let me know by
opening an issue!

## Testing

`$ npm run test`
`$ pnpm test`

This will run the linter, unit tests, and coverage.

Expand All @@ -221,7 +211,7 @@ Tested on OSX & raspberry pi w/ raspbian jessie, and with Roku TV.
[npm]: https://img.shields.io/npm/v/roku-client.svg?logo=npm
[npm-url]: https://npmjs.com/package/roku-client
[build]:
https://img.shields.io/github/workflow/status/bschlenk/node-roku-client/Node.js%20CI?logo=github
https://img.shields.io/github/actions/workflow/status/bschlenk/node-roku-client/main.yml?logo=github&branch=master
[build-url]:
https://github.com/bschlenk/node-roku-client/actions?query=workflow%3A%22Node.js+CI%22
[codecov]:
Expand All @@ -231,5 +221,3 @@ Tested on OSX & raspberry pi w/ raspbian jessie, and with Roku TV.
[device-info.ts]:
https://github.com/bschlenk/node-roku-client/blob/master/lib/device-info.ts
[skypack.dev]: https://www.skypack.dev
[node-fetch]: https://www.npmjs.com/package/node-fetch
[fetch-ponyfill]: https://www.npmjs.com/package/fetch-ponyfill
67 changes: 0 additions & 67 deletions __mocks__/node-ssdp.js

This file was deleted.

4 changes: 2 additions & 2 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
export default {
extends: ['@commitlint/config-conventional'],
};
}
22 changes: 22 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import bschlenk, { globals } from '@bschlenk/eslint-config';

export default [
{ ignores: ['**/dist/'] },
{ files: ['**/*.js', '**/*.ts'] },

{
languageOptions: {
parserOptions: { project: './tsconfig.json' },
globals: { ...globals.es2022 },
},
},

...bschlenk.configs.typescript,

{
rules: {
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
},
},
];
6 changes: 0 additions & 6 deletions index.mjs

This file was deleted.

Loading
Loading