alfresco-ng2-components/lib/cli/scripts/plugins/process-service-check-plugin.ts
siva kumar 09b4df5af7
[ACA-4227] [APS] Create a script to check Process Services Management plugin status before running e2e tests (#6486)
* [ACA-4227] Create a generic script to check plugin status before running e2e tests by plugin name

* * Added governace env check

* * Added AAE plugin check

* * Updated script

* small improvements, add uiName parameter for the command

* * Fixed comments

* * Moved check-plugin script in the common place

* * Added table format to show plugin status

Co-authored-by: adomi <ardit.domi@alfresco.com>
2021-01-06 11:56:24 +00:00

55 lines
2.0 KiB
TypeScript

import { PluginInterface } from './plugin-model';
import { logger } from '../logger';
import { ProcessServiceHealth } from './process-services-health';
export class ProcessServiceCheckPlugin {
processServiceHealth: ProcessServiceHealth;
constructor(
private plugInInfo: PluginInterface,
private alfrescoJsApi: any
) {
this.processServiceHealth = new ProcessServiceHealth(
this.plugInInfo,
this.alfrescoJsApi
);
}
async checkProcessServicesPlugin() {
let pluginStatus;
try {
const isPluginEnabled = await this.processServiceHealth.isPluginEnabledFromAppConfiguration();
const isBackendActive = await this.processServiceHealth.checkBackendHealth();
if (isPluginEnabled && isBackendActive) {
logger.info(
`The plugin ${
this.plugInInfo.name
} has been correctly configured`
);
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: `${'Active'}`, BE: 'Enabled', FE: 'Enabled' }];
console.table(pluginStatus);
} else {
this.logConfigurationError();
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'Enabled' : 'Disabled', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }];
console.table(pluginStatus);
process.exit(1);
}
} catch (e) {
this.logConfigurationError(e);
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'Disabled', FE: 'Disabled' }];
console.table(pluginStatus);
process.exit(1);
}
}
private logConfigurationError(error?: any) {
logger.error(
`The plugin ${
this.plugInInfo.name
} has not been correctly configured`,
error
);
}
}