diff --git a/client/src/OnDeviceComponent.ts b/client/src/OnDeviceComponent.ts index a7bc149..3fc4b59 100644 --- a/client/src/OnDeviceComponent.ts +++ b/client/src/OnDeviceComponent.ts @@ -987,7 +987,7 @@ export class OnDeviceComponent { if (this.getConfig()?.clientDebugLogging) { const date = new Date; const formattedDate = `${utils.lpad(date.getMonth())}-${utils.lpad(date.getDate())} ${utils.lpad(date.getHours())}:${utils.lpad(date.getMinutes())}:${utils.lpad(date.getSeconds())}:${utils.lpad(date.getMilliseconds(), 3)}`; - console.log(`${formattedDate} [ODC] ${message}`, ...args); + console.log(`${formattedDate} [ODC][${this.device.getCurrentDeviceConfig().host}] ${message}`, ...args); } } } diff --git a/client/src/RokuDevice.ts b/client/src/RokuDevice.ts index 8fbf0ac..6ebf21b 100644 --- a/client/src/RokuDevice.ts +++ b/client/src/RokuDevice.ts @@ -44,22 +44,27 @@ export class RokuDevice { public async deploy(options?: rokuDeploy.RokuDeployOptions & { injectTestingFiles?: boolean; preventMultipleDeployments?: boolean; - deleteBeforeInstall?: boolean; + deleteBeforeInstall?: boolean; // Remove in v3 }, beforeZipCallback?: (info: rokuDeploy.BeforeZipCallbackInfo) => void) { - const injectTestingFiles = options?.injectTestingFiles !== false; - - const deviceConfig = this.getCurrentDeviceConfig(); options = rokuDeploy.getOptions(options); - options.host = deviceConfig.host; - options.password = deviceConfig.password; - - if (options.deleteBeforeInstall) { + if (options.deleteInstalledChannel || options.deleteBeforeInstall) { try { await rokuDeploy.deleteInstalledChannel(options); - } catch (e) {} - } else if (options?.preventMultipleDeployments !== false) { - if (this.deployed) return; + } catch (e) { + // note we don't report the error; as we don't actually care that we could not deploy - it's just useless noise to log it. + } } + await this.createPackage(options, beforeZipCallback); + const result = await this.publish(options); + this.deployed = true; + return result; + } + + public async createPackage(options?: rokuDeploy.RokuDeployOptions & { + injectTestingFiles?: boolean; + }, beforeZipCallback?: (info: rokuDeploy.BeforeZipCallbackInfo) => void) { + const injectTestingFiles = options?.injectTestingFiles !== false; + options = rokuDeploy.getOptions(options); if (injectTestingFiles) { const files = options.files ?? []; @@ -70,7 +75,7 @@ export class RokuDevice { options.files = files; } - await rokuDeploy.deploy(options, (info) => { + await rokuDeploy.createPackage(options, (info) => { // Manifest modification const manifestPath = `${info.stagingDir}/manifest`; const manifestContents = fsExtra.readFileSync(manifestPath, 'utf-8').replace('ENABLE_RTA=false', 'ENABLE_RTA=true'); @@ -90,7 +95,19 @@ export class RokuDevice { beforeZipCallback(info); } }); - this.deployed = true; + } + + public async publish(options?: rokuDeploy.RokuDeployOptions) { + const deviceConfig = this.getCurrentDeviceConfig(); + options = rokuDeploy.getOptions(options); + options.host = deviceConfig.host; + options.password = deviceConfig.password; + + return await rokuDeploy.publish(options); + } + + public getOutputZipFilePath(options: rokuDeploy.RokuDeployOptions) { + return rokuDeploy.getOutputZipFilePath(options); } private injectRtaHelpersIntoComponentContents(contents: string) { diff --git a/client/src/utils.ts b/client/src/utils.ts index 56709db..bef894a 100644 --- a/client/src/utils.ts +++ b/client/src/utils.ts @@ -122,7 +122,7 @@ class Utils { /** Helper for setting up process.env from a config file */ public setupEnvironmentFromConfigFile(configFilePath = 'rta-config.json', deviceSelector: Record | number | undefined = undefined) { const config = this.getConfigFromConfigFile(configFilePath); - this.setupEnvironmentFromConfig(config); + this.setupEnvironmentFromConfig(config, deviceSelector); } /** Validates the ConfigOptions schema the current class is using