Skip to content

Commit

Permalink
Upgrade to new deviceInfo api from roku-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Nov 5, 2023
1 parent acc5c90 commit 56d8952
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 101 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"postman-request": "^2.88.1-postman.32",
"replace-in-file": "^6.3.2",
"replace-last": "^1.2.6",
"roku-deploy": "^3.10.3",
"roku-deploy": "^3.10.4",
"semver": "^7.5.4",
"serialize-error": "^8.1.0",
"smart-buffer": "^4.2.0",
Expand Down
72 changes: 0 additions & 72 deletions src/DeviceInfo.ts

This file was deleted.

16 changes: 8 additions & 8 deletions src/RendezvousTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import type { SourceLocation } from './managers/LocationManager';
import { logger } from './logging';
import { SceneGraphDebugCommandController } from './SceneGraphDebugCommandController';
import * as xml2js from 'xml2js';
import * as request from 'request';
import { util } from './util';
import * as semver from 'semver';

const telnetRendezvousString = 'on\n';
import type { DeviceInfo } from 'roku-deploy';
import type { LaunchConfiguration } from './LaunchConfiguration';

export class RendezvousTracker {
constructor(
private deviceInfo
private launchConfiguration: LaunchConfiguration,
private deviceInfo: DeviceInfo
) {
this.clientPathsMap = {};
this.emitter = new EventEmitter();
Expand All @@ -38,7 +38,7 @@ export class RendezvousTracker {
* Determine if the current Roku device supports the ECP rendezvous tracking feature
*/
public get doesHostSupportEcpRendezvousTracking() {
return semver.gte(this.deviceInfo['software-version'] as string, '11.5.0');
return semver.gte(this.deviceInfo.softwareVersion, '11.5.0');
}

public logger = logger.createLogger(`[${RendezvousTracker.name}]`);
Expand Down Expand Up @@ -140,7 +140,7 @@ export class RendezvousTracker {
* Run a SceneGraph logendezvous 8080 command and get the text output
*/
private async runSGLogrendezvousCommand(command: 'status' | 'on' | 'off'): Promise<string> {
let sgDebugCommandController = new SceneGraphDebugCommandController(this.deviceInfo.host as string);
let sgDebugCommandController = new SceneGraphDebugCommandController(this.launchConfiguration.host);
try {
this.logger.info(`port 8080 command: logrendezvous ${command}`);
return (await sgDebugCommandController.logrendezvous(command)).result.rawResponse;
Expand Down Expand Up @@ -197,7 +197,7 @@ export class RendezvousTracker {
* Get the response from an ECP sgrendezvous request from the Roku
*/
public async getEcpRendezvous(): Promise<EcpRendezvousData> {
const url = `http://${this.deviceInfo.host}:${this.deviceInfo.remotePort}/query/sgrendezvous`;
const url = `http://${this.launchConfiguration.host}:${this.launchConfiguration.remotePort}/query/sgrendezvous`;
this.logger.info(`Sending ECP rendezvous request:`, url);
// Send rendezvous query to ECP
const rendezvousQuery = await util.httpGet(url);
Expand Down Expand Up @@ -241,7 +241,7 @@ export class RendezvousTracker {
try {
this.logger.log(`Sending ecp sgrendezvous request: ${toggle}`);
const response = await util.httpPost(
`http://${this.deviceInfo.host}:${this.deviceInfo.remotePort}/sgrendezvous/${toggle}`,
`http://${this.launchConfiguration.host}:${this.launchConfiguration.remotePort}/sgrendezvous/${toggle}`,
//not sure if we need this, but it works...so probably better to just leave it here
{ body: '' }
);
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/DebugProtocolAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { DebugProtocolClient } from '../debugProtocol/client/DebugProtocolClient
import type { Variable } from '../debugProtocol/events/responses/VariablesResponse';
import { VariableType } from '../debugProtocol/events/responses/VariablesResponse';
import type { TelnetAdapter } from './TelnetAdapter';
import type { DeviceInfo } from '../DeviceInfo';
import type { DeviceInfo } from 'roku-deploy';

/**
* A class that connects to a Roku device over telnet debugger port and provides a standardized way of interacting with it.
Expand Down Expand Up @@ -335,7 +335,7 @@ export class DebugProtocolAdapter {
* Determines if the current version of the debug protocol supports emitting compile error updates.
*/
public get supportsCompileErrorReporting() {
return semver.satisfies(this.deviceInfo['brightscript-debugger-version'], '>=3.1.0');
return semver.satisfies(this.deviceInfo.brightscriptDebuggerVersion, '>=3.1.0');
}

public async watchCompileOutput() {
Expand Down
13 changes: 6 additions & 7 deletions src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fsExtra from 'fs-extra';
import { orderBy } from 'natural-orderby';
import * as path from 'path';
import { rokuDeploy, CompileError } from 'roku-deploy';
import type { RokuDeploy, RokuDeployOptions } from 'roku-deploy';
import type { DeviceInfo, RokuDeploy, RokuDeployOptions } from 'roku-deploy';
import {
BreakpointEvent,
DebugSession as BaseDebugSession,
Expand Down Expand Up @@ -49,7 +49,6 @@ import type { AugmentedSourceBreakpoint } from '../managers/BreakpointManager';
import { BreakpointManager } from '../managers/BreakpointManager';
import type { LogMessage } from '../logging';
import { logger, FileLoggingManager, debugServerLogOutputEventTransport, LogLevelPriority } from '../logging';
import type { DeviceInfo } from '../DeviceInfo';
import * as xml2js from 'xml2js';
import { VariableType } from '../debugProtocol/events/responses/VariablesResponse';
import { DiagnosticSeverity } from 'brighterscript';
Expand Down Expand Up @@ -277,12 +276,12 @@ export class BrightScriptDebugSession extends BaseDebugSession {

// fetches the device info and parses the xml data to JSON object
try {
this.deviceInfo = await this.fetchDeviceInfo(this.launchConfiguration.host, this.launchConfiguration.remotePort);
this.deviceInfo = await rokuDeploy.getDeviceInfo({ host: this.launchConfiguration.host, remotePort: this.launchConfiguration.remotePort, enhance: true });
} catch (e) {
return this.shutdown(`Unable to connect to roku at '${this.launchConfiguration.host}'. Verify the IP address is correct and that the device is powered on and connected to same network as this computer.`);
}

if (!this.deviceInfo['developer-enabled']) {
if (this.deviceInfo && !this.deviceInfo.developerEnabled) {
return this.shutdown(`Developer mode is not enabled for host '${this.launchConfiguration.host}'.`);
}

Expand All @@ -309,7 +308,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {

await this.initRendezvousTracking();

this.createRokuAdapter(this.launchConfiguration.host, this.rendezvousTracker);
this.createRokuAdapter(this.rendezvousTracker);
if (!this.enableDebugProtocol) {
//connect to the roku debug via telnet
if (!this.rokuAdapter.connected) {
Expand Down Expand Up @@ -446,7 +445,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
}

private async _initRendezvousTracking() {
this.rendezvousTracker = new RendezvousTracker(this.deviceInfo);
this.rendezvousTracker = new RendezvousTracker(this.launchConfiguration, this.deviceInfo);

//pass the debug functions used to locate the client files and lines thought the adapter to the RendezvousTracker
this.rendezvousTracker.registerSourceLocator(async (debuggerPath: string, lineNumber: number) => {
Expand Down Expand Up @@ -1216,7 +1215,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
await this.shutdown();
}

private createRokuAdapter(host: string, rendezvousTracker: RendezvousTracker) {
private createRokuAdapter(rendezvousTracker: RendezvousTracker) {
if (this.enableDebugProtocol) {
this.rokuAdapter = new DebugProtocolAdapter(this.launchConfiguration, this.projectManager, this.breakpointManager, rendezvousTracker, this.deviceInfo);
} else {
Expand Down

0 comments on commit 56d8952

Please sign in to comment.