Skip to content

Commit e885035

Browse files
Merge pull request #209 from pcoop/branch1
Reduce screen redrawing with scroll bars
2 parents 4b98ee3 + d8a9b60 commit e885035

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

src/api/BundlePush/BundlePusher.ts

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class BundlePusher {
4343
* @memberof BundlePusher
4444
*/
4545
constructor(params: IHandlerParameters, localDirectory: string) {
46+
4647
this.params = params;
4748
this.localDirectory = localDirectory;
4849
this.validateParameters();
@@ -130,11 +131,13 @@ export class BundlePusher {
130131
await this.runAllNpmInstalls(sshSession, packageJsonFiles);
131132

132133
// Run DFHDPLOY to install the bundle
133-
await this.deployBundle(zosMFSession, bd, cicsSession, bundle);
134+
const deployMessages = await this.deployBundle(zosMFSession, bd, cicsSession, bundle);
134135

135136
// Complete the progress bar
136137
this.progressBar.percentComplete = TaskProgress.ONE_HUNDRED_PERCENT;
137138
this.endProgressBar();
139+
140+
this.issueMessage(deployMessages);
138141
return "PUSH operation completed.";
139142
}
140143

@@ -341,7 +344,8 @@ export class BundlePusher {
341344
this.startProgressBar();
342345
}
343346

344-
private async deployBundle(zosMFSession: AbstractSession, bd: BundleDeployer, cicsSession: AbstractSession, bundle: Bundle) {
347+
private async deployBundle(zosMFSession: AbstractSession, bd: BundleDeployer,
348+
cicsSession: AbstractSession, bundle: Bundle): Promise<string> {
345349
// End the current progress bar so that DEPLOY can create its own
346350
this.updateStatus("Deploying bundle '" + this.params.arguments.name + "' to CICS");
347351
const subtask = new SubtaskWithStatus(this.progressBar, TaskProgress.THIRTY_PERCENT);
@@ -369,16 +373,20 @@ export class BundlePusher {
369373
this.startProgressBar();
370374

371375
// Collect general information about the regions in the CICSplex scope
372-
const diagnosticsWorking = await this.outputGeneralDiagnostics(cicsSession);
373-
if (diagnosticsWorking && bundle.containsDefinitionsOfType("http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP")) {
376+
let deployMessages = await this.generateGeneralDiagnostics(cicsSession);
377+
if (deployMessages !== "" && bundle.containsDefinitionsOfType("http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP")) {
374378
// Generate additional diagnostic output for Node.js
375-
await this.outputNodejsSpecificDiagnostics(cicsSession);
379+
deployMessages += await this.generateNodejsSpecificDiagnostics(cicsSession);
376380
}
377381

378382
// Now rethrow the original error, if there was one.
379383
if (deployError !== undefined) {
384+
// If we're going to throw an error then report any messages now
385+
this.issueMessage(deployMessages);
380386
throw deployError;
381387
}
388+
389+
return deployMessages;
382390
}
383391

384392
private sshOutput(data: string) {
@@ -615,13 +623,13 @@ export class BundlePusher {
615623
}
616624
}
617625

618-
private async outputGeneralDiagnostics(cicsSession: AbstractSession): Promise<boolean> {
619-
let scopeFound = false;
626+
private async generateGeneralDiagnostics(cicsSession: AbstractSession): Promise<string> {
627+
let msgBuffer = "";
620628
try {
621629
if (cicsSession !== undefined) {
622630
// Attempt to gather additional Node.js specific information from CICS
623631
this.updateStatus("Gathering Scope information");
624-
scopeFound = await this.gatherGeneralDiagnosticsFromCics(cicsSession);
632+
msgBuffer = await this.gatherGeneralDiagnosticsFromCics(cicsSession);
625633
}
626634
}
627635
catch (diagnosticsError) {
@@ -633,15 +641,15 @@ export class BundlePusher {
633641
logger.debug(diagnosticsError.message);
634642
}
635643
}
636-
return scopeFound;
644+
return msgBuffer;
637645
}
638646

639-
private async outputNodejsSpecificDiagnostics(cicsSession: AbstractSession) {
640-
let diagnosticsIssued = false;
647+
private async generateNodejsSpecificDiagnostics(cicsSession: AbstractSession): Promise<string> {
648+
let msgBuffer = "";
641649
try {
642650
// Attempt to gather additional Node.js specific information from CICS
643651
this.updateStatus("Gathering Node.js diagnostics");
644-
diagnosticsIssued = await this.gatherNodejsDiagnosticsFromCics(cicsSession);
652+
msgBuffer = await this.gatherNodejsDiagnosticsFromCics(cicsSession);
645653
}
646654
catch (diagnosticsError) {
647655
// Something went wrong generating diagnostic info. Don't trouble the user
@@ -654,15 +662,16 @@ export class BundlePusher {
654662
}
655663

656664
// We must have a cics profile in order to have got this far, so suggest a command that can be run to figure out more.
657-
if (diagnosticsIssued === false) {
658-
const msg = "For further information on the state of your NODEJSAPP resources, consider running the following command:\n\n" +
665+
if (msgBuffer === "") {
666+
msgBuffer += "For further information on the state of your NODEJSAPP resources, consider running the following command:\n\n" +
659667
"zowe cics get resource CICSNodejsapp --region-name " + this.params.arguments.scope +
660668
" --criteria \"BUNDLE=" + this.params.arguments.name + "\" --cics-plex " + this.params.arguments.cicsplex + "\n";
661-
this.issueMessage(msg);
662669
}
670+
671+
return msgBuffer;
663672
}
664673

665-
private async gatherGeneralDiagnosticsFromCics(cicsSession: AbstractSession): Promise<boolean> {
674+
private async gatherGeneralDiagnosticsFromCics(cicsSession: AbstractSession): Promise<string> {
666675
// Issue a CMCI get to the target CICSplex
667676
try {
668677
this.updateStatus("Querying Regions in Scope over CMCI");
@@ -677,27 +686,25 @@ export class BundlePusher {
677686
throw new Error("CICSRegion CMCI output record not found.");
678687
}
679688
const outputRegionRecords = cmciRegionResponse.response.records.cicsregion;
680-
const msg = "CICS Regions in Scope '" + this.params.arguments.scope + "' of CICSplex '" + this.params.arguments.cicsplex + "':\n";
681-
this.issueMessage(msg);
689+
let msgBuffer = "CICS Regions in Scope '" + this.params.arguments.scope + "' of CICSplex '" + this.params.arguments.cicsplex + "':\n";
682690

683691
// We may have an array of records if there was more than one Region in the scope
684692
if (Array.isArray(outputRegionRecords)) {
685693
for (const record of outputRegionRecords) {
686-
this.reportRegionData(record);
694+
msgBuffer = this.reportRegionData(record, msgBuffer);
687695
}
688696
}
689697
else {
690-
this.reportRegionData(outputRegionRecords);
698+
msgBuffer = this.reportRegionData(outputRegionRecords, msgBuffer);
691699
}
700+
return msgBuffer;
692701
}
693702
catch (error) {
694703
throw new Error("Failure collecting diagnostics for Bundle " + this.params.arguments.name + ": " + error.message);
695704
}
696-
697-
return true;
698705
}
699706

700-
private async gatherNodejsDiagnosticsFromCics(cicsSession: AbstractSession): Promise<boolean> {
707+
private async gatherNodejsDiagnosticsFromCics(cicsSession: AbstractSession): Promise<string> {
701708
try {
702709
// Process each NODEJSAPP in the Scope
703710
this.updateStatus("Querying NODEJSAPP resources over CMCI");
@@ -714,37 +721,34 @@ export class BundlePusher {
714721
}
715722
const outputNodejsRecords = cmciNodejsResponse.response.records.cicsnodejsapp;
716723

717-
const msg = "\nNODEJSAPP resources for Bundle '" + this.params.arguments.name + "' in Scope '" + this.params.arguments.scope + "':\n";
718-
this.issueMessage(msg);
724+
let msgBuffer = "\nNODEJSAPP resources for Bundle '" + this.params.arguments.name + "' in Scope '" + this.params.arguments.scope + "':\n";
719725

720726
// We may have an array of records if there was more than one NODEJSAPP in the bundle
721727
if (Array.isArray(outputNodejsRecords)) {
722728
for (const record of outputNodejsRecords) {
723-
this.reportNODEJSAPPData(record);
729+
msgBuffer = this.reportNODEJSAPPData(record, msgBuffer);
724730
}
725731
}
726732
else {
727-
this.reportNODEJSAPPData(outputNodejsRecords);
733+
msgBuffer = this.reportNODEJSAPPData(outputNodejsRecords, msgBuffer);
728734
}
735+
return msgBuffer;
729736
}
730737
catch (error) {
731738
throw new Error("Failure collecting diagnostics for Bundle " + this.params.arguments.name + ": " + error.message);
732739
}
733-
734-
return true;
735740
}
736741

737-
private reportRegionData(outputRecord: any) {
742+
private reportRegionData(outputRecord: any, msgBuffer: string): string {
738743
const MAX_LENGTH = 8;
739744
const applid = outputRecord.applid.padEnd(MAX_LENGTH, " ");
740745
const jobid = outputRecord.jobid.padEnd(MAX_LENGTH, " ");
741746
const jobname = outputRecord.jobname.padEnd(MAX_LENGTH, " ");
742747

743-
const msg = " Applid: " + applid + " jobname: " + jobname + " jobid: " + jobid + "\n";
744-
this.issueMessage(msg);
748+
return msgBuffer + " Applid: " + applid + " jobname: " + jobname + " jobid: " + jobid + "\n";
745749
}
746750

747-
private reportNODEJSAPPData(outputRecord: any) {
751+
private reportNODEJSAPPData(outputRecord: any, msgBuffer: string) {
748752
const name = outputRecord.name;
749753
const enablestatus = outputRecord.enablestatus;
750754
const pid = outputRecord.pid;
@@ -759,10 +763,9 @@ export class BundlePusher {
759763
stderr = "<not available>";
760764
}
761765

762-
const msg = "CICS NODEJSAPP resource '" + name + "' is in '" + enablestatus + "' state in region '" +
763-
region + "' with process id '" + pid + "'.\n" +
764-
" stdout: " + stdout + "\n" +
765-
" stderr: " + stderr + "\n";
766-
this.issueMessage(msg);
766+
return msgBuffer + "CICS NODEJSAPP resource '" + name + "' is in '" + enablestatus + "' state in region '" +
767+
region + "' with process id '" + pid + "'.\n" +
768+
" stdout: " + stdout + "\n" +
769+
" stderr: " + stderr + "\n";
767770
}
768771
}

0 commit comments

Comments
 (0)