Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createPackage and publish to RokuDevice to avoid parallel testing… #129

Merged
merged 3 commits into from
Feb 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion client/src/OnDeviceComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
43 changes: 30 additions & 13 deletions client/src/RokuDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? [];
Expand All @@ -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');
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Utils {
/** Helper for setting up process.env from a config file */
public setupEnvironmentFromConfigFile(configFilePath = 'rta-config.json', deviceSelector: Record<string, any> | number | undefined = undefined) {
const config = this.getConfigFromConfigFile(configFilePath);
this.setupEnvironmentFromConfig(config);
this.setupEnvironmentFromConfig(config, deviceSelector);
}

/** Validates the ConfigOptions schema the current class is using
Expand Down
Loading